xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
- From: Adam Constabaris <adamc AT email.unc.edu>
- To: xom-interest AT lists.ibiblio.org
- Subject: Re: [XOM-interest] EntityResolver
- Date: Tue, 24 Aug 2004 09:42:30 -0400
Peter Winkel wrote:
Message date : 23-08-2004 22:07
From : "Elliotte Rusty Harold" <elharo AT metalab.unc.edu>
To : "Peter van der Winkel" <p.van.der.winkel AT wanadoo.nl>
Copy to : xom-interest AT lists.ibiblio.org
Subject : Re: [XOM-interest] EntityResolver
At 6:25 PM +0200 8/23/04, Peter van der Winkel wrote:
Hello,
How can I give my custom EntityResolver to XOM ?
Set it on the XMLReader, and use the XMLReader to create the Builder.
This does not feel logical, because now I have to create an XmlReader of a
specific implementation. So I have to know which parsers are available. The
Builder already searches for a parser in order to obtain an XmlReader. So I
would say that a builder.setEntityResolver() is better.
Peter
That's not quite right. You can use standard JAXP mechanisms to get the XMLReader, and call setEntityResolver() on what you get from it.
import org.xml.sax.helpers.XMLReaderFactory;
import org.xml.sax.*;
XMLReader getEntityResolvingReader() throws SAXException {
EntityResolver er = new MyEntityResolver(); // or however you do it
in your code
XMLReader xr = XMLReaderFactory.createXMLReader();
xr.setEntityResolver( er );
return xr;
}
This will return an XMLReader of the class specified by the org.xml.sax.driver system property, which, if you have a recent JDK that includes JAXP, will have an appropriate value without any extra work on your part.
Unless I miss my guess, the point of providing an XMLReader-based constructor for the Builder class is to give you as much control as you could possibly want in configuring your builders when you need it, *without* polluting the Builder class with too many "convenience" methods. This keeps the API simple, which is an explicit design goal.
Or maybe I can just let elharo speak for himself ...
cheers,
AC
-
[XOM-interest] EntityResolver,
Peter van der Winkel, 08/23/2004
- Re: [XOM-interest] EntityResolver, Elliotte Rusty Harold, 08/23/2004
- <Possible follow-up(s)>
-
Re: Re: [XOM-interest] EntityResolver,
Peter Winkel, 08/24/2004
- Re: [XOM-interest] EntityResolver, Adam Constabaris, 08/24/2004
- Re: Re: [XOM-interest] EntityResolver, Elliotte Harold - java FAQ, 08/27/2004
Archive powered by MHonArc 2.6.24.