Specify "Base URI" when using DTD and DocumentBuilder
843834Jul 9 2003 — edited Sep 10 2006Hei folks!
I have a problem I haven't been able to solve. I want to specify a DTD in a file in my application's "working directory" (where the application is located). I have specified my XML file like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE entries SYSTEM "exman.dtd">
<entries>
//lots of tags and stuff here..
<entries>
I use the following packages for parsing my XML to a org.w3c.dom.Document object:
javax.xml.parsers.DocumentBuilder;
javax.xml.parsers.DocumentBuilderFactory;
When trying to parse, I get the following error message:
org.xml.sax.SAXParseException: Relative URI "exman.dtd"; can not be resolved without a base URI.
I can't specify the absolute URI in my XML file because I don't know where the user will put the application (and what system the application will be run on). All I know is that the DTD file should be located in the same directory as the application files (i.e. the same place as the jar-file).
Is there a way of specifying the base URI for my DocumentBuilder?
Thank you SO much for any help!!
Regards,
Erik.