出于某种原因,我的以下代码给出了异常:javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet
public String removePrettyPrint(String xml) throws TransformerException, TransformerFactoryConfigurationError {
String result = "";
TransformerFactory factory = TransformerFactory.newInstance();
String source = "<?xml version=\"1.0\"?><xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"> <xsl:output indent=\"no\" /> <xsl:template match=\"@*|node()\"> <xsl:copy> <xsl:apply-templates select=\"@*|node()\"/> </xsl:copy> </xsl:template></xsl:stylesheet>";
Source xslt = new StreamSource(source);
Transformer transformer = factory.newTransformer(xslt);
Source text = new StreamSource(xml);
transformer.transform(text, new StreamResult(result));
return result;
}
它有什么问题?