public String styleDocument(Document document, String stylesheet) throws Exception {
// load the transformer using JAXP
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(new StreamSource( stylesheet ));
// now lets style the given document
DocumentSource source = new DocumentSource( document );
DocumentResult result = new DocumentResult();
transformer.transform( source, result );
// return the transformed document
Document transformedDoc = result.getDocument();
return transformedDoc.asXML();
}
使用上面的方法出现错误
错误:“no protocol: <?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <h1> <xsl:value-of select="//title"/> </h1> <h2> <xsl:value-of select="//author"/> </h2> </xsl:template></xsl:stylesheet>”
致命错误:“无法编译样式表”
请高手指教!!!
// load the transformer using JAXP
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(new StreamSource( stylesheet ));
// now lets style the given document
DocumentSource source = new DocumentSource( document );
DocumentResult result = new DocumentResult();
transformer.transform( source, result );
// return the transformed document
Document transformedDoc = result.getDocument();
return transformedDoc.asXML();
}
使用上面的方法出现错误
错误:“no protocol: <?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <h1> <xsl:value-of select="//title"/> </h1> <h2> <xsl:value-of select="//author"/> </h2> </xsl:template></xsl:stylesheet>”
致命错误:“无法编译样式表”
请高手指教!!!
本文介绍了一个关于使用Java进行XML文档的XSLT转换过程中遇到的问题,具体表现为加载样式表时出现‘无协议’错误及后续的致命错误:无法编译样式表。文章详细描述了错误现象并寻求解决方案。
1572

被折叠的 条评论
为什么被折叠?



