This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
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.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
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