[jdom-interest] Accessing a DTD bundled in a jar file...

Rolf Lear rlear at algorithmics.com
Wed Oct 15 05:05:21 PDT 2003


Try to use the URL based build() method.

URL url = cl.getSystemResource("xml/" + fileName);
Document doc = new SAXBuilder().build(url);

Rolf

-----Original Message-----
From: Patrick JUSSEAU [mailto:patrick at openbase.com]
Sent: Wednesday, October 15, 2003 7:01 AM
To: jdom-interest at jdom.org
Subject: [jdom-interest] Accessing a DTD bundled in a jar file...


Hi,

I am trying to deploy one of my app using Java Web Start. JWS requires 
to put resources inside jar files. Since my app use xml files, I 
creates a xmlLib.jar file with the following output:

xml/test.xml
xml/test2.xml
xml/test.dtd

Inside my app, I use a ClassLoader to get xml file Resources as 
InputStream:

ClassLoader cl = getClass().getClassLoader();
inputStream = cl.getSystemResourceAsStream("xml/" + fileName);

The problem I have is that my xml file reference the test.dtd file as 
follow:
<!DOCTYPE PARAM SYSTEM "test.dtd">

I get the following exception when running my app
org.jdom.input.JDOMParseException: Error on line 2: Relative URI 
"test.dtd"; can not be resolved without a base URI.
         at org.jdom.input.SAXBuilder.build(SAXBuilder.java:381)
         at org.jdom.input.SAXBuilder.build(SAXBuilder.java:684)

I tried specifying a absolute http path to refer to the dtd file, which 
works but this is not really what I want to do. I want to keep my dtd 
file inside the jar file.

Any ideas?

Thanks in advance,

Patrick

_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20031015/3724f183/attachment.htm


More information about the jdom-interest mailing list