xml SYSTEM vs PUBLIC

R

Razvan

Hi !





In an XML DOCTYPE declaration you can use either PUBLIC or
SYSTEM attributes:

<!DOCTYPE RootElement SYSTEM "SomeDTD.dtd">
<!DOCTYPE RootElement PUBLIC "SomeDTD.dtd">

When should I use SYSTEM and when should I use PUBLIC ?




Regards,
Razvan
 
D

David Carlisle

Hi !





In an XML DOCTYPE declaration you can use either PUBLIC or
SYSTEM attributes:

<!DOCTYPE RootElement SYSTEM "SomeDTD.dtd">
<!DOCTYPE RootElement PUBLIC "SomeDTD.dtd">

When should I use SYSTEM and when should I use PUBLIC ?




Regards,
Razvan


No, you could do that in SGML but in XML you _Always_ have to have a
SYSTEM identifier. If you use PUBLIC you gave to give _both_ a public ID
and the SYSTEM.

Although XML doesn't enforce this PUBLIC identifiers usually follow the
Formal Public Identifier syntax which has a bunch of fields separated by
/ that encode the author and identity of the dtd file but not (usually0
its location. eg MathML uses:

<!DOCTYPE math
PUBLIC "-//W3C//DTD MathML 2.0//EN"
"http://www.w3.org/Math/DTD/mathml2/mathml2.dtd"
The PUBLIC Identifier "-//W3C//DTD MathML 2.0//EN shows it's (not from
ISO, the -) is from W3C is called DTD MathML 2.0 and uses English as
its documentaion, (one possible) URI where you might actually find the
thing is given by the SYSTEM ID
"http://www.w3.org/Math/DTD/mathml2/mathml2.dtd"

David
 
R

Razvan

Hi David,




Thanks for your answer.


No, you could do that in SGML but in XML you _Always_ have to have a
SYSTEM identifier.


If that is true then why have a PUBLIC identifier at all ? What is
their purpose ?

Is there some limitation to the type of data that you can put in
SYSTEM vs. PUBLIC identifiers ? For example: SYSTEM only supports URLs
(like http://www.w3c.org/ ) while PUBLIC only supports local paths ?
(this is just an example)



Regards,
Razvan
 
D

David Carlisle

If that is true then why have a PUBLIC identifier at all ? What is
their purpose

beware that you are skirting on the edge of a very deep "debate":)
Basically the public identifier gives a unique canonical name for the
dtd that you can recognise; whereas the SYSTEM identifier may well point
at a local path on the original author's system that doesn't make sense
on yours. An XML parser may use either (or both) identifiers to find the
file.

So if you have an xml parser that has an xml catalogue of some sort that
recognises say XHTML or Docbokk PUBLIC identifier, the file will work
even if the system ID points at a file not accessable to you as your
parser can use the catalogue to map the public ID to a local
copy. Conversely if you don't have that public id in your catalogue (or
if there is no public id) then you can perhaps find the file directly by
using the system id.

When the syntax was invented, for sgml, this last step would most
likely fail as it would be a local file name so it would assume that you
had local files in the same position. In XML when the SYSTEM is supposed
to be a URI and so perhaps usable from anywhere in the world there is an
argument (that I don't personally hold, but which is not unreasonable,
and comes up often) that the SYSTEM ID is all you need and PUBLIC IDs no
longer serve a purpose.

David
 
R

Razvan

Hi !



Look what I've found on a web site:
(http://www.adp-gmbh.ch/xml/dtd.html)


SYSTEM
<!DOCTYPE root-element SYSTEM "http://xyz.qq/abc/def.dtd">

SYSTEM means that a validating parser needs the dtd when it validates
an XML document.


PUBLIC
<!DOCTYPE root-element PUBLIC "path/abc/def.dtd">

PUBLIC means that a validating parser might use a 'cached' ????
version of the DTD.


Mixing
<!DOCTYPE root-element PUBLIC "path/abc/def.dtd"
"http://xyz.qq/abc/def.dtd">

This form uses http://xyz.qq.abc.def.dtd only if path/abc/def.dtd is
not available.



Regards,
Razvan
 
D

David Carlisle

Look what I've found on a web site:

Don't believe everything you read:)

if in doubt go back to teh definition:

http://www.w3.org/TR/2004/REC-xml11-20040204/#NT-ExternalID

[75] ExternalID ::= 'SYSTEM' S SystemLiteral
| 'PUBLIC' S PubidLiteral S SystemLiteral


which says that an ExternalID is either SYSTEM followed by a literal or
PUBLIC followed by two literals separated by white space. there is not
an option of having PUBLIC followed by just one literal. (except for the
declarations of notations which also include a special PUBLIC-only
production 83).

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top