Entity name error

El Boss

New Member
I'm working on a Java desktop which is distributed via a JAR file and that JAR contains everything the application needs. The application that generates an HTML report for various things by first generating an XML file, and then using an XSL file to convert the XML to HTML. Once the report is generated it needs to be one file, so any script I want to use I have to include in the file, and I want to use jQuery. I have a jQuery file in a resources folder and I can parse through it and add it to the XML file just fine, but when it is time to transform the XML into HTML via the XSL I get the following error:\[code\]ERROR: 'The entity name must immediately follow the '&' in the entity reference.'javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: The entity name must immediately follow the '&' in the entity reference.ERROR: 'com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: The entity name must immediately follow the '&' in the entity reference.'\[/code\]Reading up on the error I can see that I need to encode special characters, but I'm not prepared to manually encode the entire jQuery file.So my end goal is this:1.) Need to have the following in my HTML report:\[code\]<script>// the entire jQuery library</script>\[/code\]2.) My main application must be completely contained in one JAR file3.) I would like to NOT copy/paste the jQuery library into the XSL file. This works, but it seems sloppy.UPDATE #1:I was wrong on point 3 above. I cannot copy/paste the jQuery library into the XSL file without getting the error:\[code\]java.io.UTFDataFormatException: encoded string too long: 239677 bytes\[/code\]which is immediately followed by the more comical error:\[code\]javax.xml.transform.TransformerConfigurationException: This Templates does not contain a class with the name 'GregorSamsa'.\[/code\]GregorSamsa in The MetamorphosisUPDATE #2:The start of my XSL stylesheet reads like this:\[code\]<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" <xsl:output method="html"/>\[/code\]I changed the version number from a \[code\]1.0\[/code\] to a \[code\]2.0\[/code\] but I get an error that reads:\[code\]ERROR: 'Unsupported XSL element 'http://www.w3.org/1999/XSL/Transform:sequence''javax.xml.transform.TransformerException: java.lang.RuntimeException: Unsupported XSL element 'http://www.w3.org/1999/XSL/Transform:sequence'\[/code\]Additionally, my jQuery file is in the same location as my XSL stylesheet, so I think the following should work (but it doesn't):\[code\]<xsl:sequence select="unparsed-text('jquery-1.8.3.min.js')" />\[/code\]UPDATE #3:Downloaded Saxon for Java here and added the JAR file to my application. Change my call to transformer factory to this:\[code\]TransformerFactory f = new net.sf.saxon.TransformerFactoryImpl(); // was TransformerFactory.newInstance();Transformer t = f.newTransformer( new StreamSource( Example.class.getResourceAsStream( "resource/report_style.xsl" ) ) );Source s = new StreamSource( XMLFile );Result r = new StreamResult( HTMLFile );t.transform( s, r );\[/code\]Using the suggested \[code\]<xsl:sequence select="unparsed-text('jquery-1.8.3.min.js')" />\[/code\] I still get the equivalent of my original error, though now with Saxon parser:\[code\]net.sf.saxon.trans.XPathException: org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.SXXP0003: Error reported by XML parser: The entity name must immediately follow the '&' in the entity reference.\[/code\]
 
Back
Top