You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Mike Feldmeier <Mi...@wmirvdev.com> on 2002/07/10 20:44:53 UTC

Relative Path for DTD?

It sounds like a simple question, but I have not been able to come up with
an answer, either on the web or searching through archives.

I have an xml in a relative path from my working directory:
src/xml/document.xml

Inside of which I have a tag:
<!DOCTYPE document SYSTEM "document.dtd">

Where does it look for it?  I have tried placing the copies of the dtd in
every directory I could think of including the working directory and the
directory with the xml.  If I use an absolute path
(file:///c:/project/src/xml/document.dtd), it works great, but I don't want
to require a specific drive or directory.

Thanks



Re: Relative Path for DTD?

Posted by David Nutter <Da...@durham.ac.uk>.
On Wed, Jul 10, 2002 at 11:44:53AM -0700, Mike Feldmeier wrote:
> It sounds like a simple question, but I have not been able to come up with
> an answer, either on the web or searching through archives.
> 
> I have an xml in a relative path from my working directory:
> src/xml/document.xml
> 
> Inside of which I have a tag:
> <!DOCTYPE document SYSTEM "document.dtd">
> 
> Where does it look for it?  I have tried placing the copies of the dtd in
> every directory I could think of including the working directory and the
> directory with the xml.  If I use an absolute path
> (file:///c:/project/src/xml/document.dtd), it works great, but I don't want
> to require a specific drive or directory.

I have a set of XML documents similarly organised. I had trouble with
various tools finding the DTD so I started using the XCatalog
implementation in Xerces 1.4 to locate the DTD via a Formal Public
Identifier and a remapped DTD name. My catalog files look something
like this (HREF can be any valid URI obviously):

<!DOCTYPE XCatalog PUBLIC "-//DTD XCatalog//EN"
  "org/apache/xerces/readers/xcatalog.dtd">
<XCatalog>
  <Remap SystemID="artefact.dtd"
    HRef="file:///home/david/genesis/oscar/artefacts/artefact.dtd"/>
  <Map PublicID="-//DTD Artefact//EN"
    HRef="file:///home/david/genesis/oscar/artefacts/artefact.dtd"/>
</XCatalog>

My Artefact documents are then declared:

<?xml version="1.0"?> 
<!DOCTYPE artefact PUBLIC "-//DTD Artefact//EN" "artefact.dtd">
<artefact>
 ...
</artefact> 

Thus, wherever my XML files are on my hard drive so long as the
program can load the catalog it'll be able to find the DTD. Not an
ideal solution but at least the absolute paths are all in one place. 

Unfortunately the XCatalog implementation seems to have been removed
from Xerces 2.0 (is it no longer a standard?) but I imagine you can
obtain similar functionality by creating a custom
org.xml.sax.EntityResolver class though I haven't tried this. 

I too would be interested to know if there's a recommended
best-practice solution for this as though mine works I have no idea if
it is correct or portable. 

Regards,

-- 
David Nutter <da...@durham.ac.uk>	Research Assistant
Rm E326, Department Of Computer Science, 
University Of Durham, 
Durham, DH1 3LE			 Tel: +44(0)191 3747075

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org