[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.5

The entity name must immediately follow the '&' in the entity reference.

Asked by presynct in Extensible Stylesheet Language Transformation (XSLT), Hypertext Markup Language (HTML), Java Programming Language

Tags: HTML, PDF, XML, JAVA

Hi Friends,
I am trying to convert the HTML to PDF using Java and XSLT. In the converson process, if I have the & in the text field, the conversion works fine. But if I have the & in the text area, then it gives the error " The entity name must immediately follow the '&' in the entity reference.". Everything works fine if I dont have any & in the html page. I dont understand why it works for text field and not for textarea field. The error log is:
13:43:17,520 ERROR [STDERR] SystemId Unknown; Line #654; Column #117; The entity name must immediately follow the '&' in the entity reference.
13:43:18,505 ERROR [STDERR] FATAL ERROR: Premature end of file.
13:43:18,505 ERROR [PdfBuilder] PdfBuilder.generatePdf() HTML processing exception
org.xml.sax.SAXParseException: Premature end of file.
      at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
      at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
      at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
      at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
      at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
      at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
      at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
      at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
      at org.faceless.report.ReportParser2.parse(ReportParser2.java:82)
      at com.cmt.tower.document.Html2PdfTransformer.toPdf(Html2PdfTransformer.java:115)
      at com.cmt.tower.document.PdfBuilder.generatePdf(PdfBuilder.java:106)
      at com.cmt.tower.servlet.officer.PrintReportServlet.doPost(PrintReportServlet.java:190)
      at com.cmt.tower.servlet.TowerServlet.doGet(TowerServlet.java:306)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at com.cmt.tower.servlet.UserFilter.doFilter(UserFilter.java:263)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
      at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      at java.lang.Thread.run(Thread.java:619)

Thanks a lot in advance for your help and co operation.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
This is the code where exactly I am getting this error:
public byte[] transform(InputStream htmlStream) throws TransformerException {
	
		try {
			
			if(htmlStream == null)
				throw new IllegalArgumentException("Unable to transform: NULL html input stream specifed");
			
			TransformerFactory tFactory = TransformerFactory.newInstance();
			
			// ready xsl
			if(xslFile == null) {
				String contextPath = ResourceBundle.getBundle("presynct").getString("deploy.dir");
		        if (contextPath == null) {
		            throw new Exception("Unable to obtain presynct context path.");
		        }
				String xslFilename = contextPath + File.separator + "xsl" + File.separator + "html2pdf.xsl";
				xslFile = new File(xslFilename);
			}
			if(xslFile == null || !xslFile.exists())
				throw new Exception("Unable to find html2pdf.xsl file");
 
			StreamSource xslSrc = new StreamSource(xslFile);
			xslSrc.setSystemId(xslFile);
			
			Transformer transformer = tFactory.newTransformer(xslSrc);
			
			if(basePath == null) {
				basePath = 
					ResourceBundle.getBundle("presynct").getString("server.url")
					+ "/"
					+ ResourceBundle.getBundle("presynct").getString("context.root")
					+ "/";
			}
			if(basePath != null && basePath.length() > 0)
				transformer.setParameter("basePath", basePath);
			
			// ready input
			StreamSource ssrc = new StreamSource(htmlStream);
			
			// ready output
			ByteArrayOutputStream baos = new ByteArrayOutputStream();
			StreamResult sresult = new StreamResult(baos);
			
			// transform
			//log.debug("Html2PdfTransformer.transform() transforming to bigfaceless-compliant XML input...");
			transformer.transform(ssrc, sresult);
			
			byte[] rval = baos.toByteArray();
			
			baos.close();
			
			return rval;
		}
		catch(TransformerException te) {
			te.printStackTrace();
			throw te;
		}
		catch(Exception e) {
			throw new TransformerException("Html2PdfTransformer.transform() EXCEPTION",e);
		}
	}
[+][-]10/16/09 02:29 PM, ID: 25593510Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/16/09 02:44 PM, ID: 25593622Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/16/09 03:11 PM, ID: 25593748Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Extensible Stylesheet Language Transformation (XSLT), Hypertext Markup Language (HTML), Java Programming Language
Tags: HTML, PDF, XML, JAVA
Sign Up Now!
Solution Provided By: kmartin7
Participating Experts: 1
Solution Grade: A
 
[+][-]10/20/09 02:35 PM, ID: 25618904Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81 - Hierarchy / EE_QW_3_20080625