<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2655.35">
<TITLE>RE: [jdom-interest] Accessing a DTD bundled in a jar file...</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2>Try to use the URL based build() method.</FONT>
</P>
<P><FONT SIZE=2>URL url = cl.getSystemResource("xml/" + fileName);</FONT>
<BR><FONT SIZE=2>Document doc = new SAXBuilder().build(url);</FONT>
</P>
<P><FONT SIZE=2>Rolf</FONT>
</P>
<P><FONT SIZE=2>-----Original Message-----</FONT>
<BR><FONT SIZE=2>From: Patrick JUSSEAU [<A HREF="mailto:patrick@openbase.com">mailto:patrick@openbase.com</A>]</FONT>
<BR><FONT SIZE=2>Sent: Wednesday, October 15, 2003 7:01 AM</FONT>
<BR><FONT SIZE=2>To: jdom-interest@jdom.org</FONT>
<BR><FONT SIZE=2>Subject: [jdom-interest] Accessing a DTD bundled in a jar file...</FONT>
</P>
<BR>
<P><FONT SIZE=2>Hi,</FONT>
</P>
<P><FONT SIZE=2>I am trying to deploy one of my app using Java Web Start. JWS requires </FONT>
<BR><FONT SIZE=2>to put resources inside jar files. Since my app use xml files, I </FONT>
<BR><FONT SIZE=2>creates a xmlLib.jar file with the following output:</FONT>
</P>
<P><FONT SIZE=2>xml/test.xml</FONT>
<BR><FONT SIZE=2>xml/test2.xml</FONT>
<BR><FONT SIZE=2>xml/test.dtd</FONT>
</P>
<P><FONT SIZE=2>Inside my app, I use a ClassLoader to get xml file Resources as </FONT>
<BR><FONT SIZE=2>InputStream:</FONT>
</P>
<P><FONT SIZE=2>ClassLoader cl = getClass().getClassLoader();</FONT>
<BR><FONT SIZE=2>inputStream = cl.getSystemResourceAsStream("xml/" + fileName);</FONT>
</P>
<P><FONT SIZE=2>The problem I have is that my xml file reference the test.dtd file as </FONT>
<BR><FONT SIZE=2>follow:</FONT>
<BR><FONT SIZE=2><!DOCTYPE PARAM SYSTEM "test.dtd"></FONT>
</P>
<P><FONT SIZE=2>I get the following exception when running my app</FONT>
<BR><FONT SIZE=2>org.jdom.input.JDOMParseException: Error on line 2: Relative URI </FONT>
<BR><FONT SIZE=2>"test.dtd"; can not be resolved without a base URI.</FONT>
<BR><FONT SIZE=2> at org.jdom.input.SAXBuilder.build(SAXBuilder.java:381)</FONT>
<BR><FONT SIZE=2> at org.jdom.input.SAXBuilder.build(SAXBuilder.java:684)</FONT>
</P>
<P><FONT SIZE=2>I tried specifying a absolute http path to refer to the dtd file, which </FONT>
<BR><FONT SIZE=2>works but this is not really what I want to do. I want to keep my dtd </FONT>
<BR><FONT SIZE=2>file inside the jar file.</FONT>
</P>
<P><FONT SIZE=2>Any ideas?</FONT>
</P>
<P><FONT SIZE=2>Thanks in advance,</FONT>
</P>
<P><FONT SIZE=2>Patrick</FONT>
</P>
<P><FONT SIZE=2>_______________________________________________</FONT>
<BR><FONT SIZE=2>To control your jdom-interest membership:</FONT>
<BR><FONT SIZE=2><A HREF="http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com" TARGET="_blank">http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com</A></FONT>
</P>
</BODY>
</HTML>