Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] dtd problems

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Elliotte Harold <elharo AT metalab.unc.edu>
  • To: luca <passani AT eunet.no>
  • Cc: xom-interest <xom-interest AT lists.ibiblio.org>
  • Subject: Re: [XOM-interest] dtd problems
  • Date: Mon, 20 Sep 2004 09:58:29 -0400

luca wrote:

I think you
just have to implement a way to tell XOM to ignore DTDs no
matter what. This is defying the purpose of XOM being
the tool for 80% of everyone's XML tasks

That's not going to happen, at least not in 1.0, probably not ever. Requiring the external DTD subset is a deliberate design decision that IMNSHO falls squarely in the 80%. There are reasons you might want to ignore this, but those use cases are less common, and I think on the 20% side of the cut. If you really need skipped entities (and it doesn't sound like you do) then XOM is not for you, but if all you want is to not load external resources, then you can do this by using a SAX EntityResolver.

For the time being, you should make a local copy of your DTD, and use a SAX EntityResolver to pick out that copy rather than the remote version at wapforum.org. You could implement this on top of catalogs using the Apache catalog resolver, or you could roll your own. It's not hard. Set up an XMLReader with this resolver, and then use that XMLReader to construct XOM's Builder. If you use the Apache catalog resolver, the code looks like this:

XMLReader reader = new org.apache.xerces.parsers.SAXParser();
reader = new org.apache.xml.resolver.tools.ResolvingXMLFilter(reader);
Builder parser = new Builder(reader);
Document doc = parser.build("http://www.example.org";);

You'd also need to set up the catalog file in the appropriate place.

Post-1.0, I would like to provide built in catalog support so you could replace a reference to an external DTD with a reference to a local copy (among other cool hacks). However, you'll always have to read something.

--
Elliotte Rusty Harold
elharo AT metalab.unc.edu




Archive powered by MHonArc 2.6.24.

Top of Page