8,906
社区成员
发帖
与我相关
我的任务
分享
[/quote]
可以告诉我一下怎么改吗?[/quote]
----------------------------------------------------------------------
@mbz007
部分代码如下:其中变量xmlContent为返回的要解析的xml报文。
StrDocument stringDocument = new StrDocument();
Document xmlDocument = stringDocument.stringToDoc(xmlContent);
TransformerFactory tFactory = TransformerFactory.newInstance();
//make the input sources for the xml and xslt documents
org.jdom.output.DOMOutputter outputter = new org.jdom.output.DOMOutputter();
//org.w3c.dom.Document与org.jdom.document的互转
org.w3c.dom.Document domDocument = outputter.output((org.jdom.Document) xmlDocument);
javax.xml.transform.Source xmlSource = new javax.xml.transform.dom.DOMSource(domDocument);
String personPath = getServletContext().getRealPath("/xmlXsl/person.xsl");
StreamSource xmltSource = new StreamSource(new FileInputStream(personPath));
/*
* 保证联合样式表中的其他xsl文件也能读取得到 或者xmltSource.setSystemId(personPath.toURL().toString());
*/
xmltSource.setSystemId(personPath);
//make the output result for the finished document using the httpResponse OutputStream
StreamResult xmlResult = new StreamResult(response.getOutputStream());
//get a xslt transformer
Transformer transformer = tFactory.newTransformer(xmltSource);
//do the transform
transformer.transform(xmlSource,xmlResult);
[/quote]
可以告诉我一下怎么改吗?