Re: XML Validity and DTD dependance

Rich Salz scripsit:

> DTD's are ignorant of namespaces.  This means that you cannot write a
> normative DTD for a namespace (as you might do with XML Schema). The
> best you can hope to do is write something for expository purposes,
> using particular namespace prefixes as an example.  Each instance of
> a document would then have to rewrite the DTD to use the namespace
> prefixes that are used in the document.

The use of DTDs with namespaces is not so impossible as you make out.
In fact there is a well-known hacque involving parameter entities that
lets you parameterize namespace prefixes.  It's true that you are
still restricted to a one-to-one relationship between prefixes and
namespaces in a given document, but many consider that to be a Good Thing.

Here's an example:

<!ENTITY % xhtml "xhtml">
<!ENTITY % html "%xhtml;:html">
<!ENTITY % head "%xhtml;:head">
<!ENTITY % body "%xhtml;:body">
...
<!ELEMENT %html; (head,body)>
<!ELEMENT %head; ...>
<!ELEMENT %body; ...>
...

By redefining the parameter entity "xhtml" in the internal subset to
be the local prefix, one may use this DTD fragment to help validate any document
containing elements from the xhtml namespace.

-- 
Said Agatha Christie / To E. Philips Oppenheim  John Cowan
"Who is this Hemingway? / Who is this Proust?   jcowan@reutershealth.com
Who is this Vladimir / Whatchamacallum,         http://www.reutershealth.com
This neopostrealist / Rabble?" she groused.     http://www.ccil.org/cowan
        --author unknown to me; any suggestions?

Received on Wednesday, 13 April 2005 19:37:32 UTC