Hi !
Sometimes ago I posted a question regarding the use of the PUBLIC vs SYSTEM declaration in an XML file. After reading the initial answers and after gaining a little more experience with XML I came up with the following conclusions:
SYSTEM declaration can be used to specify a file on the local file system like:
<!DOCTYPE RootElement SYSTEM "C:\validate.dtd">
The problem with this approach is that if the file is made public the path specified on the local file system will not have any meaning any more. Even if the path specified in the SYSTEM declaration *is* a URL:
<!DOCTYPE RootElement SYSTEM "http://www.mihaiu.name/validate.dtd">
the parser might be unable to retrieve the DTD file if the system is not connected to the Internet.
The PUBLIC declaration constitutes a partial solution to this problem. The string contained in a PUBLIC declaration is not an URL but an URN (Uniform Resource Name). A URN does not pinpoint the precise location of the resource, but only clearly specify its name. The *parser* of the document must be smart enough to be able to generate a URL from a URN using some internal logic.
Example of a PUBLIC declaration:
<!DOCTYPE RootElement PUBLIC "mihaiu/validate.dtd"
SYSTEM "http://www.mihaiu.name/validate.dtd">
In this case, a custom parser that already has a catalogue of DTDs published by mihaiu can generate a URL from the PUBLIC declaration. The generated URL can look like
c:\DTDs\validate.dtd
There is no standard way to convert a URN to a URL, so, if this conversion fails because the parser does not contain the internal logic to perform such a conversion (or for whatever other reason) the parser will attempt to use the SYSTEM declaration which in this case resolves to
http://www.mihaiu.name/validate.dtd
Important observation:
Since there is no standard way to generate a URL from a URN the PUBLIC declarations can only be useful for customized parsers !!! (e.g. they are not useful for general purpose parsers like Xerces)
DID I GOT IT RIGHT ?
Regards,
Razvan
www.mihaiu.name
Sometimes ago I posted a question regarding the use of the PUBLIC vs SYSTEM declaration in an XML file. After reading the initial answers and after gaining a little more experience with XML I came up with the following conclusions:
SYSTEM declaration can be used to specify a file on the local file system like:
<!DOCTYPE RootElement SYSTEM "C:\validate.dtd">
The problem with this approach is that if the file is made public the path specified on the local file system will not have any meaning any more. Even if the path specified in the SYSTEM declaration *is* a URL:
<!DOCTYPE RootElement SYSTEM "http://www.mihaiu.name/validate.dtd">
the parser might be unable to retrieve the DTD file if the system is not connected to the Internet.
The PUBLIC declaration constitutes a partial solution to this problem. The string contained in a PUBLIC declaration is not an URL but an URN (Uniform Resource Name). A URN does not pinpoint the precise location of the resource, but only clearly specify its name. The *parser* of the document must be smart enough to be able to generate a URL from a URN using some internal logic.
Example of a PUBLIC declaration:
<!DOCTYPE RootElement PUBLIC "mihaiu/validate.dtd"
SYSTEM "http://www.mihaiu.name/validate.dtd">
In this case, a custom parser that already has a catalogue of DTDs published by mihaiu can generate a URL from the PUBLIC declaration. The generated URL can look like
c:\DTDs\validate.dtd
There is no standard way to convert a URN to a URL, so, if this conversion fails because the parser does not contain the internal logic to perform such a conversion (or for whatever other reason) the parser will attempt to use the SYSTEM declaration which in this case resolves to
http://www.mihaiu.name/validate.dtd
Important observation:
Since there is no standard way to generate a URL from a URN the PUBLIC declarations can only be useful for customized parsers !!! (e.g. they are not useful for general purpose parsers like Xerces)
DID I GOT IT RIGHT ?
Regards,
Razvan
www.mihaiu.name