XHTML element with attribute "id" throws an error
See original GitHub issueHi, it sounds that since an element in the XHTML template has an “id” attribute, the PDF generation fails:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
</head>
<body>
<div id="wrapper">
<p>Hello world</p>
</div>
</body>
</html>
Console log:
InputStream: Doctype given is "-//W3C//DTD XHTML 1.0 Transitional//EN"
InputStream: Document content looks like XHTML 1.0 Strict
no warnings or errors were found
ERREUR : 'NOT_FOUND_ERR: An attempt is made to reference a node in a context where it does not exist.'
[error] application - Creating document from template
org.xhtmlrenderer.util.XRRuntimeException: Can't load the XML resource (using TRaX transformer). org.w3c.dom.DOMException: NOT_FOUND_ERR: An attempt is made to reference a node in a context where it does not exist.
at org.xhtmlrenderer.resource.XMLResource$XMLResourceBuilder.createXMLResource(XMLResource.java:191) ~[core-renderer-R8.jar:na]
at org.xhtmlrenderer.resource.XMLResource.load(XMLResource.java:79) ~[core-renderer-R8.jar:na]
at util.pdf.PDF.toStream(PDF.java:186) [pdf_2.10-0.5.jar:0.5]
at util.pdf.PDF.toBytes(PDF.java:168) [pdf_2.10-0.5.jar:0.5]
at util.pdf.PDF.toBytes(PDF.java:145) [pdf_2.10-0.5.jar:0.5]
at util.pdf.PDF.toBytes(PDF.java:140) [pdf_2.10-0.5.jar:0.5]
Caused by: javax.xml.transform.TransformerException: org.w3c.dom.DOMException: NOT_FOUND_ERR: An attempt is made to reference a node in a context where it does not exist.
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:732) ~[na:1.6.0_35]
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:336) ~[na:1.6.0_35]
at org.xhtmlrenderer.resource.XMLResource$XMLResourceBuilder.createXMLResource(XMLResource.java:189) ~[core-renderer-R8.jar:na]
at org.xhtmlrenderer.resource.XMLResource.load(XMLResource.java:79) ~[core-renderer-R8.jar:na]
at util.pdf.PDF.toStream(PDF.java:186) [pdf_2.10-0.5.jar:0.5]
at util.pdf.PDF.toBytes(PDF.java:168) [pdf_2.10-0.5.jar:0.5]
Caused by: org.w3c.dom.DOMException: NOT_FOUND_ERR: An attempt is made to reference a node in a context where it does not exist.
at org.apache.xerces.dom.ElementImpl.setIdAttributeNS(Unknown Source) ~[xercesImpl-2.8.1.jar:na]
at com.sun.org.apache.xalan.internal.xsltc.trax.SAX2DOM.startElement(SAX2DOM.java:201) ~[na:1.6.0_35]
at com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.closeStartTag(ToXMLSAXHandler.java:204) ~[na:1.6.0_35]
at com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.characters(ToXMLSAXHandler.java:524) ~[na:1.6.0_35]
at org.apache.xerces.parsers.AbstractSAXParser.characters(Unknown Source) ~[xercesImpl-2.8.1.jar:na]
at org.apache.xerces.impl.dtd.XMLDTDValidator.characters(Unknown Source) ~[xercesImpl-2.8.1.jar:na]
Since I remove the “id” attribute, it works out finely. The XHTML template above is valid given http://validator.w3.org/check
Issue Analytics
- State:
- Created 10 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Html validation error for property attribute - Stack Overflow
I am using few facebook social plugins and I am using the meta header. When validating the page, the W3C validator is throwing...
Read more >I am validating my website and I have an attribute value error ...
You have used the attribute named above in your document, but the document type you are using does not support that attribute for...
Read more >[SOLVED] Valid name, id, and class attributes in XHTML?
... and I wanted it to throw an error if the arguments for the name, id, or class attribute of the element isn't...
Read more >How should the problem of identifying ID semantics in XML ...
When a user agent processes an XHTML document as generic XML, it shall only recognize attributes of type ID (i.e. the id attribute...
Read more >Error when using epub:type attributes - Google Groups
xhtml(18,130): Fragment identifier is not defined. Check finished with errors epubcheck completed. The errors happen in epub v2 and epub v3.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
another way to work around is try to parse the xml document and then pass it to flying-saucer
I updated all the dependencies to the most recent version.