On Thu, 19 Apr 2001, Andy Clark wrote:

> Jason Rizer wrote:
> > Hello.  One more quick DTD question: Where exactly
> > does the parser look for the specified DTD.  Current
> > Directory?  Classpath?  Somewhere else?  Sorry to be a
> > bother.
> 
> If the system identifier is relative, then the DTD entity
> (or other external parsed entity) will be located relative
> to where it's referenced. In other words, if the document
> is "file:///c:/docs/document.xml" and the DTD is specified
> as "grammar.dtd", then the parser will look for the DTD at
> "file:///c:/docs/grammar.dtd".

but it's not guaranteed to be in said directory. it's possible to have a
relative path reference to somewhere else on the same filesystem:

<!-- Note relative pathname to dtd. utz 010315 -->

<!DOCTYPE cpp SYSTEM "../../dtd/cpp.dtd">
<cpp partnerName="Blastro">
....... 
 
( works great at my house! :-)  )


so, the point being that a dtd is not guaranteed to be in a particular
location. Arguments can be made for a central 'blessed' dtd or for
copying it into each and every data directory. the choice is up to
somebody and it isnt always going to be you.


> This is an important point because a lot of people forget
> to set the systemId when using an InputSource -- most
> frequently in a custom EntityResolver that they've written
> but it can also be because of calling parse(InputSource).
> And without the systemId, the parser has no idea where to
> look for the entity! If it's not relative to the working
> directory of the Java program, then it will fail.

so this means that if you are trying to write code that evaluates what you
plan to do based on the dtd, you had either:

1. forced the dtd to be where your code expects it ( lucky u! u got to
   make the choice! )

2. use the cleverness alluded to previously to get the dtd name from the
   parser. ( i feel that this is the best way, but i think there is a
   chicken and egg problem that i may not be fully understanding )

3. do a File::Find (to use a perl-ism) and hope that it's the only dtd in
   the neigborhood. or that if it's not the only dtd, you have a mechanism
   for disambiguating it...

 
> -- 
> Andy Clark * IBM, TRL - Japan * [EMAIL PROTECTED]
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to