• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Locate SYSTEM entities when SAX parsing an XML document

 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic