[code="java"]<%@ page contentType="text/html; charset=UTF-8" language="java" errorPage="" %>
<%@ page import="javax.xml.transform.*,javax.xml.transform.stream.*" %>
<%
//创建一个转换器工厂
TransformerFactory tFactory = TransformerFactory.newInstance();
//以指定的XSLT样式单文件创建一个转换器
Transformer transformer = tFactory.newTransformer(new StreamSource(application.getRealPath("WEB-INF/") + "/book.xslt"));
//执行实际转换,并将转换得到的目标文档作为响应输出
transformer.transform(new StreamSource(application.getRealPath("WEB-INF/") + "/book.xml"), new StreamResult(response.getOutputStream()));
%>[/code]
[color=red]<%@ page contentType="text/html; charset=UTF-8" language="java" errorPage="" %>
<%@ page import="javax.xml.transform.*,javax.xml.transform.stream.*" %>
<%
//创建一个转换器工厂
TransformerFactory tFactory = TransformerFactory.newInstance();
//以指定的XSLT样式单文件创建一个转换器
Transformer transformer = tFactory.newTransformer(new StreamSource(application.getRealPath("WEB-INF/") + "/book.xslt"));
//执行实际转换,并将转换得到的目标文档作为响应输出
transformer.transform(new StreamSource(application.getRealPath("WEB-INF/") + "/book.xml"), new StreamResult(response.getOutputStream()));
%>[/color]
我在测试jsp中写xalan,用XSLT把XML转换成HTML
前台测试功能可行,但MyEclipse却报了这个错误