Note that there are some explanatory texts on larger screens.

plurals
  1. POAre multiple calls to java SaxParser.parse(String, Handler) Legal?
    primarykey
    data
    text
    <p>I have a java SAX parser which I would like to call multiple times on the same Handler with different XML files. I am using this in conjunction with iText to create a multi-page PDF document where some pages have one XML tag map and other pages have another. For example,</p> <pre><code>parser.parse("xmlFile1", handler); parser.parse("xmlFile2", handler); </code></pre> <p>When I try to do this, I get a java.lang.RuntimeException thrown with the following stacktrace:</p> <pre><code>DocumentException: java.lang.RuntimeException: The document is not open. at com.lowagie.text.pdf.PdfWriter.getDirectContent(PdfWriter.java:695) at com.lowagie.text.pdf.PdfDocument.newPage(Unknown Source) at com.lowagie.text.pdf.PdfDocument.carriageReturn(Unknown Source) at com.lowagie.text.pdf.PdfDocument.add(Unknown Source) at com.lowagie.text.Document.add(Unknown Source) at myClass.myCode(Unknown Source) org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(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 javax.xml.parsers.SAXParser.parse(SAXParser.java:345) at javax.xml.parsers.SAXParser.parse(SAXParser.java:223) at myClass.myCode(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) </code></pre> <p>Does the SaxParser.parse method implicitly call document.close()? Or is there some other problem in my code which I need to isolate and correct?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload