File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Locate SYSTEM entities when SAX parsing an XML document Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Locate SYSTEM entities when SAX parsing an XML document" Watch "Locate SYSTEM entities when SAX parsing an XML document" New topic
Author

Locate SYSTEM entities when SAX parsing an XML document

Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
I am trying to use javax.xml.parsers.SAXParser to parse an XML document. It is OK until the XML document tries to use SYSTEM entities to reference another XML document. You know the idea: -


Here's the existing parsing code: -


I need to tell the SAXParser how to find file "foo.xml". It is not an ordinary file, or an HTTP resource, but I could easily provide a method to locate it, via the relative path. I could return a Reader or an InputStream. The problem is I don't know what hook would allow me to do so.

Any suggestions?


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12759
    
    5
Isn't that the idea behind the EntityResolver interface?
Presumably you could implement the resolveEntity method in your custom class and create an InputSource pointing to the file.
See org.xml.sax.EntityResolver in the Javadocs

Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Locate SYSTEM entities when SAX parsing an XML document
 
Similar Threads
Parsing input from a string using JAXP, Xerces 1.4.1 with Visual Age
is this XML???
Using JAVA to parse an XML document
Unable to validate XML against the schema
Help me for xsd creation