[jdom-interest] jdom and jdk1.4: EntityResolver no longer called
Kevin Jones
kevinj at develop.com
Wed Feb 20 06:59:49 PST 2002
You can tell JDOM which parser to use.
Try this
SAXBuilder sb = new SAXBuilder("org.apache.xerces.parsers.SAXParser",
true);
If you want to use Xerces2,
Kevin Jones
Developmentor
www.develop.com
> -----Original Message-----
> From: jdom-interest-admin at jdom.org
> [mailto:jdom-interest-admin at jdom.org] On Behalf Of
> abrighto at netscape.net
> Sent: 16 February 2002 22:53
> To: jdom-interest at jdom.org
> Subject: [jdom-interest] jdom and jdk1.4: EntityResolver no
> longer called
>
>
> Hi all,
>
> The new jdk1.4 runtime library now contains the org.xml packages,
> which kind of forces you to use them, it seems (I was previously
> using xerces.jar).
>
> Since upgrading to jdk1.4, I am having problems with DTDs not
> being resolved. The problem is that the EntityResolver is not
> being called. The error message is then:
>
> "Relative URI "UIInfo.dtd"; can not be resolved without a base URI"
>
> Here is the related code. Any ideas on how to make this work
> with jdk1.4?
>
> /** Parse the XML document */
> private static void _parseDocument(BufferedReader in) {
> SAXBuilder builder = new SAXBuilder(true);
> builder.setEntityResolver(new EntityResolver() {
> public InputSource resolveEntity (String publicId,
> String systemId) {
> URL url = Resources.getResource("UIInfo.dtd");
> try {
> return new InputSource(url.openStream());
> }
> catch(Exception e) {
> throw new RuntimeException("Error resolving entity: " +
> publicId + ": " + e.toString());
> }
> }
> });
>
> try {
> Document doc = builder.build(in);
> Element rootElement = doc.getRootElement();
> Iterator it = rootElement.getChildren().listIterator();
> while(it.hasNext()) {
> Element e = (Element)it.next();
> _parseElement(e);
> }
> }
> catch (JDOMException ex) {
> ex.printStackTrace();
> throw new RuntimeException("Error reading " +
> XML_FILE + ": " + ex.getMessage());
> }
> }
>
> Thanks,
> Allan Brighton
>
> --
>
>
>
>
> __________________________________________________________________
> Your favorite stores, helpful shopping tools and great gift
> ideas. Experience the convenience of buying online with
> Shop at Netscape! http://shopnow.netscape.com/
>
> Get your own FREE, personal Netscape Mail account today at
http://webmail.netscape.com/
_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@you
rhost.com
More information about the jdom-interest
mailing list