Can root name in DOCTYPE be a XSD-validity thing?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Can root name in DOCTYPE be a XSD-validity thing?

Leif Halvard Silli-4
Hello schema devs.

Can a XSD-based processor validate that a XHTML5 document contains the
HTML5 DOCTYPE type declaration? And can it do so without resorting
hacks? Can it be expressed in the XSD-language itself, or must the
processor performa an initial 'DTD-mode' check?

Note: The HTML5 DOCTYPE *declaration* doesn't reference a DOCTYPE
*definition*, so I do not ask if XSD can validate the 'ExternalID' or
'intSubset' part of the DOCTYEP declaration. I only wonder if XSD
allows checking that the 'name' part of the DOCTYPE matches the 'root
element type'. Since it is well-formed to include DOCTYPE declaration
without a DTD, and since XSD moves the validation from DTD to, well
XSD, it ought, it seems, be possible to use XSD to verify that the
DOCTYPE declaration contains the name of the root element (the same way
that XSD allows checking many things that, per XML 1.0, does not fall
under XML 1.0’s validity concept).

Background for my question is that XML editors/processors nowadays tend
to be schema based, even when a DTD is references. And hence, if XSD
doesn’t validate the DOCTYPE *declaration*, XSD could in fact label
constructs like this as 'validating':

  <!DOCTYPE NotTheHtmlRootElement>
  <html xmlns="http://www.w3.org/1999/xhtml"><head><title></title>
  </head><body><p/></body></html>

And in fact, it seems most XSD processor do say that the above is
validating. For example Libxml2 in XSD mode does. Just ask xmllint to
apply the XHTML 1.1 XSD[1] to  a XHTML 1.1 doc with '<DOCTYPE HTML'
instead of '<DOCTYPE html'[2]:

  xmllint --schema http://tinyurl.com/a9lrvfq http://tinyurl.com/bkhk86p

Even the well known Oxygen editor, which (by default) uses Xerces, does
in the abvoe case behave like Libxml2.

Now, if we move focus to processors that only consider DTD-validity,
then both the rxp processor and Libxml2 in DTD mode reports, for the
above document, that validation could not be performed due to lack of
DTD:

           rxp -V http://tinyurl.com/bkhk86p
  xmllint --valid http://tinyurl.com/bkhk86p

However, in the presence of a (supported) SYSTEM ID/URI, the some
processor are triggered into DTD-validation mode even if the ID/URI
leads nowhere, meaning that they check that the root element matches
root name in the document type declaration. Libxml2 (xmllint) does in
fact behave that way (even if it also, in that case, reports that the
root elements hasn’t been delcared.)

By the way: If we remove the XSD specific attributes from the markup of
the above test document, then Oxygen (Xerces) does in fact complain
that the root element doesn't match the document type declaration. And
it does so *without* complaining that the rest of the markup is
invalid. Is this because oXygen uses a XSD schema that includes DOCTYPE
validation? Or is it because it uses "DTD mode" for the DOCTYPE, and
then XSD mode for the rest of the document?

SOME "PHILOSOPHIC" QUESTIONS: According to XML 1.0, "validity
constraints" apply to all valid documents. Does XML by this mean "all
DTD-valid documents", noly? This is relevant since XML says that it is
a validity constraint that the DOCTYPE declaration matches the root.
Thus, it seems to me that if this validity constrain does *not* apply
to XSD, then XSD processor are, in fact, not validating processors.
(I.e. "validating processor" per XML 1.0, then means "DTD-validating
processor".) If so, then in one way, it is unlucky that 'validity' is
used by anything other than DTD-validity.

RELATED COMMENTS:

1) On one side, There seems to be confusion within the XML community
about the HTML5 doctype declaration. For example the XMLmind xml editor
developers (which has developed as XSD for XHTML5) had let themselves
convince that the HTML5 doctype was not well-formed - only when I made
them aware of Polyglot Markup, did they realize that it was well-formed
to include the HTML5 DOCTYPE.[3]

2) And on the other - but related(sic!) - side, we have the fact that
HTML5 doesn’t declare any "official" XHTML5 doctype declaration, which
is a reflection of the general, sceptic attitude in the XML community
these days, towards document type declarations and document type
definitions. Which more specifically is related to a focus on
well-formed as "good enough" (not to say "difficult enough") on one
side, as well as a focus on "better" methods for validations - namely
XML schemas.

3) But perhaps HTML5 goes a little bit too far, right now: Surely HTML5
could at least say that, if a DOCTYPE declaration is used, then the
'name' part of the 'doctypedecl' should match the root element of the
docuement?!?

FINALLY: My focus with this letter, is XML processor’s ability to
validate/create XHTML5 document that, as far as the *DOCTYPE
declaration* is concerned, are polyglot.

PS: I note with interest that the XSD schema files for the XSD language
itself, themselves (some of them) include document type declarations.
And so I wonder: What would happen if one altered the root names  
declared by the document type declaration in those XSD documents? Would
XSD-based processor stop working … ?

[1] http://tinyurl.com/as3k455
[2] http://tinyurl.com/a9lrvfq
[3]
http://www.xmlmind.com/pipermail/xmleditor-support/2013-January/010268.html
--
leif halvard silli
Reply | Threaded
Open this post in threaded view
|

Re: Can root name in DOCTYPE be a XSD-validity thing?

C. M. Sperberg-McQueen-2

On Feb 13, 2013, at 11:13 PM, Leif Halvard Silli wrote:

> Hello schema devs.
>
> Can a XSD-based processor validate that a XHTML5 document contains the
> HTML5 DOCTYPE type declaration? And can it do so without resorting
> hacks? Can it be expressed in the XSD-language itself, or must the
> processor performa an initial 'DTD-mode' check?

No.  Conforming XSD validators are not required to be sensitive to,
or aware of, the infoset's document type declaration information item,
and XSD provides no language for referring to properties of that
information item.

>
> Note: The HTML5 DOCTYPE *declaration* doesn't reference a DOCTYPE
> *definition*, so I do not ask if XSD can validate the 'ExternalID' or
> 'intSubset' part of the DOCTYEP declaration. I only wonder if XSD
> allows checking that the 'name' part of the DOCTYPE matches the 'root
> element type'. Since it is well-formed to include DOCTYPE declaration
> without a DTD, and since XSD moves the validation from DTD to, well
> XSD, it ought, it seems, be possible to use XSD to verify that the
> DOCTYPE declaration contains the name of the root element (the same way
> that XSD allows checking many things that, per XML 1.0, does not fall
> under XML 1.0’s validity concept).

You are quite right that there would be no logical contradiction in
a schema language spec that allowed the kind of check you have in
mind.  But no, it's not something XSD is designed to constrain, or to
allow schema authors to constrain.

> Background for my question is that XML editors/processors nowadays tend
> to be schema based, even when a DTD is references. And hence, if XSD
> doesn’t validate the DOCTYPE *declaration*, XSD could in fact label
> constructs like this as 'validating':
>
>  <!DOCTYPE NotTheHtmlRootElement>
>  <html xmlns="http://www.w3.org/1999/xhtml"><head><title></title>
>  </head><body><p/></body></html>
>
> And in fact, it seems most XSD processor do say that the above is
> validating. For example Libxml2 in XSD mode does. Just ask xmllint to
> apply the XHTML 1.1 XSD[1] to  a XHTML 1.1 doc with '<DOCTYPE HTML'
> instead of '<DOCTYPE html'[2]:
>
>  xmllint --schema http://tinyurl.com/a9lrvfq http://tinyurl.com/bkhk86p
>
> Even the well known Oxygen editor, which (by default) uses Xerces, does
> in the abvoe case behave like Libxml2.

The agreement or disagreement of the DOCTYPE declaration with
the name on the outermost element is not a property that affects the
schema-validity of any document with respect to any XSD schema.
So I'm happy to believe that these programs behave as you say, and
to say that their failure to object to the discrepancy between doctype
declaration and instance has no relation to their conformance or
non-conformance as XSD validators.

> ...
> By the way: If we remove the XSD specific attributes from the markup of
> the above test document, then Oxygen (Xerces) does in fact complain
> that the root element doesn't match the document type declaration. And
> it does so *without* complaining that the rest of the markup is
> invalid. Is this because oXygen uses a XSD schema that includes DOCTYPE
> validation? Or is it because it uses "DTD mode" for the DOCTYPE, and
> then XSD mode for the rest of the document?

I think the answer is that Oxygen's algorithm for deciding how to validate
a document, when validation is requested, will ignore a DOCTYPE
declaration if an xsi:schemaLocation hint is present.  (But I haven't
tested this hypothesis; I just know that Oxygen makes its best effort to
do something useful.)

> SOME "PHILOSOPHIC" QUESTIONS: According to XML 1.0, "validity
> constraints" apply to all valid documents. Does XML by this mean "all
> DTD-valid documents", noly? This is relevant since XML says that it is
> a validity constraint that the DOCTYPE declaration matches the root.
> Thus, it seems to me that if this validity constrain does *not* apply
> to XSD, then XSD processor are, in fact, not validating processors.
> (I.e. "validating processor" per XML 1.0, then means "DTD-validating
> processor".) If so, then in one way, it is unlucky that 'validity' is
> used by anything other than DTD-validity.

The only form of validity defined in the XML specification is DTD-based
validity.  So yes, the validity constraints of that spec relate to validation
against a DTD, and no, XSD validators are not 'validating processors'
within the meaning of XML spec.

The prose of the XSD spec generally tries to use the term 'schema-validity'
for the property that an XSD validator checks; there was some fear during
the drafting of XSD 1.0 that using the unqualified term "validity" would
confuse people.  The intervening years have shown that people are quite
happy to use the term "validity" in a broader sense and to distinguish
DTD-validity, RNG-validity, XSD-validity, etc. as needed.  So some readers
have felt that the XSD spec's consistent use of "schema-validity" instead
of just "validity" was an unnecessary affectation.  In future I shall refer
such comments to your message; you are the first reader I have encountered
to support the XSD spec's choice of terminology.


> PS: I note with interest that the XSD schema files for the XSD language
> itself, themselves (some of them) include document type declarations.
> And so I wonder: What would happen if one altered the root names  
> declared by the document type declaration in those XSD documents? Would
> XSD-based processor stop working … ?

Most XSD processors have hard-coded knowledge of the schema
for schema documents as specified in the XSD spec; it would be an
unusual processor that actually read the schema document for
schema documents on each startup.  (Not an impossible one, just
unusual.)  Processors with hard-coded knowledge of the schema for
schema documents would, I guess, be unaffected by a textual change
to the schema documents in the spec.  A processor that did read the
schema document for schema documents at startup might cease to work
if it checked the schema documents for DTD-validity and found that
the root element had the wrong name, but it is not (unless I am forgetting
something) a requirement of the XSD spec that XSD schema documents
be DTD-valid.

Thank you for your thoughtful and though-provoking message.

I hope this helps.

--
****************************************************************
* C. M. Sperberg-McQueen, Black Mesa Technologies LLC
* http://www.blackmesatech.com 
* http://cmsmcq.com/mib                 
* http://balisage.net
****************************************************************





Reply | Threaded
Open this post in threaded view
|

Re: Can root name in DOCTYPE be a XSD-validity thing?

Leif Halvard Silli-4
C. M. Sperberg-McQueen, Thu, 14 Feb 2013 12:12:14 -0700:
> On Feb 13, 2013, at 11:13 PM, Leif Halvard Silli wrote:

>> Can a XSD-based processor validate that a XHTML5 document contains the
>> HTML5 DOCTYPE type declaration?
   …

>> Note: The HTML5 DOCTYPE *declaration* doesn't reference a DOCTYPE
>> *definition*, so I do not ask if XSD can validate the 'ExternalID' or
>> 'intSubset' part of the DOCTYEP declaration. I only wonder if XSD
>> allows checking that the 'name' part of the DOCTYPE matches the 'root
>> element type'. Since it is well-formed to include DOCTYPE declaration
>> without a DTD, and since XSD moves the validation from DTD to, well
>> XSD, it ought, it seems, be possible to use XSD to verify that the
>> DOCTYPE declaration contains the name of the root element (the same way
>> that XSD allows checking many things that, per XML 1.0, does not fall
>> under XML 1.0’s validity concept).
>
> You are quite right that there would be no logical contradiction in
> a schema language spec that allowed the kind of check you have in
> mind.  But no, it's not something XSD is designed to constrain, or to
> allow schema authors to constrain.

Thanks! Perhaps, for the next update of the XSD language, you should
consider adding support for DOCTYPE declaration validation? One use
case: Allowing XSD to produce/validate documents that can be validated
both via DTD or via XSD. Another use case: correct DOCTYPE declaration
can increase the certainty that a particular schema should indeed be
applied to the particular document.

Regardless, I just now filed a bug against the HTML5 spec suggesting
that *if* the DOCTYPE is included, then authors should make it match
the root element.[*]

[*] https://www.w3.org/Bugs/Public/show_bug.cgi?id=20993

Note that the XML 1.0’s (DTD) validity concept, per the wording of the
spec, applies even when the declaration doesn’t reference an external
or internal DTD: [*] “[Definition: An XML document is valid if it has
an associated document type declaration and if the document complies
with the constraints expressed in it.]”

[*] http://www.w3.org/TR/REC-xml/#dt-valid

But one could, I guess, discuss which constraints a declaration such as
<!DOCTYPE html> expresses. Based on a comment from David Carlisle in
public-html@, then XML does not define (all) the ways a DTD can be
associated with a document. And so, if the DTD is associated via one of
those undefined means, then <!DOCTYPE html> probably represents the
constraints of that associated DTD. But if there is no associated DTD,
then <!DOCTYPE html> represents a document that cannot (DTD) validate
(since the validity constraint (namely: that the root/document name of
the DOCTYPE declaration matches the root element type defined in the
DTD) cannot be fulfilled).

That the DTD validity rules (and thus, as well, the well-formed rule)
applies *even* to <!DOCTYPE html> can perhaps be seen as a thing which
allows to define entirely new (XSD-based) validity rules which
attribute *another* meaning that root/name part of the DOCTYPE?

>> Background for my question is that XML editors/processors nowadays tend
>> to be schema based, even when a DTD is references. And hence, if XSD
>> doesn’t validate the DOCTYPE *declaration*, XSD could in fact label
>> constructs like this as 'validating':
>>
>>  <!DOCTYPE NotTheHtmlRootElement>
>>  <html xmlns="http://www.w3.org/1999/xhtml"><head><title></title>
>>  </head><body><p/></body></html>
>>
>> And in fact, it seems most XSD processor do say that the above is
>> validating. For example Libxml2 in XSD mode does. Just ask xmllint to
>> apply the XHTML 1.1 XSD[1] to  a XHTML 1.1 doc with '<DOCTYPE HTML'
>> instead of '<DOCTYPE html'[2]:
>>
>>  xmllint --schema http://tinyurl.com/a9lrvfq http://tinyurl.com/bkhk86p
>>
>> Even the well known Oxygen editor, which (by default) uses Xerces, does
>> in the abvoe case behave like Libxml2.
>
> The agreement or disagreement of the DOCTYPE declaration with
> the name on the outermost element is not a property that affects the
> schema-validity of any document with respect to any XSD schema.
> So I'm happy to believe that these programs behave as you say, and
> to say that their failure to object to the discrepancy between doctype
> declaration and instance has no relation to their conformance or
> non-conformance as XSD validators.

A doctype such as
   <!DOCTYPE TheDocumentElement SYSTEM "ID" [<!--bla, bla-->] >
allows to verify

  a) that the DOCTYPE declaration is internally valid,
     namely, that its root/document name and the DTD’s definition
     of the root element type, are matching each others,
  b) that the root/name part of the DOCTYPE declaration
     matches the actual root element of the document (except that

The b) part does not seem technically necessary since this check could
even be performed by checking the document/root element against the
document/root element definition found in the DTD. But, at least, there
is a human element here. For instance, the DTD format may seem hard to
read and often is stored externally. And so, the root/name part of the
DOCTYPE declaration can anyhow play a technical role, namely the role
of increasing the certainty about the human intention - that the author
has indeed intended to author this document according to certain
grammar.

One of the most important things that a DTD does is that it defines
entities, e.g. character entities. And it seems that XML parser that
are not validating, will "see" those entities regardless of the root
element name of the DOCTYPE declaration. And, in fact, one could claim
that that is how the HTML5 specification says that XHTMl5 parsers
should behave, since it, for a set of 9 (expected to become 10)[*] well
known PUBLIC identifiers, recommends to always implement the
HTML5-defined set of character entities.

[*] http://lists.w3.org/Archives/Public/public-html-admin/2013Feb/0211

But it is striking that these entities are implemented even when the
document/root name part of DOCTYPE declaration does not match the root
element.

>> ...
>> By the way: If we remove the XSD specific attributes from the markup of
>> the above test document, then Oxygen (Xerces) does in fact complain
>> that the root element doesn't match the document type declaration. And
>> it does so *without* complaining that the rest of the markup is
>> invalid. Is this because oXygen uses a XSD schema that includes DOCTYPE
>> validation? Or is it because it uses "DTD mode" for the DOCTYPE, and
>> then XSD mode for the rest of the document?
>
> I think the answer is that Oxygen's algorithm for deciding how to validate
> a document, when validation is requested, will ignore a DOCTYPE
> declaration if an xsi:schemaLocation hint is present.  (But I haven't
> tested this hypothesis; I just know that Oxygen makes its best effort to
> do something useful.)

It would be interesting to hear from someone who tests or from the
Oxygen developers.

>> SOME "PHILOSOPHIC" QUESTIONS: According to XML 1.0, "validity
>> constraints" apply to all valid documents. Does XML by this mean "all
>> DTD-valid documents", noly? This is relevant since XML says that it is
>> a validity constraint that the DOCTYPE declaration matches the root.
>> Thus, it seems to me that if this validity constrain does *not* apply
>> to XSD, then XSD processor are, in fact, not validating processors.
>> (I.e. "validating processor" per XML 1.0, then means "DTD-validating
>> processor".) If so, then in one way, it is unlucky that 'validity' is
>> used by anything other than DTD-validity.
>
> The only form of validity defined in the XML specification is DTD-based
> validity.  So yes, the validity constraints of that spec relate to
> validation
> against a DTD, and no, XSD validators are not 'validating processors'
> within the meaning of XML spec.
>
> The prose of the XSD spec generally tries to use the term 'schema-validity'
> for the property that an XSD validator checks; there was some fear during
> the drafting of XSD 1.0 that using the unqualified term "validity" would
> confuse people.  The intervening years have shown that people are quite
> happy to use the term "validity" in a broader sense and to distinguish
> DTD-validity, RNG-validity, XSD-validity, etc. as needed.  So some readers
> have felt that the XSD spec's consistent use of "schema-validity" instead
> of just "validity" was an unnecessary affectation.  In future I shall refer
> such comments to your message; you are the first reader I have encountered
> to support the XSD spec's choice of terminology.

Thanks for confirming that XSD validated documents are not XML 1.0
valid.

Btw, I think it is good/OK when a text completely redefine a concept.
May be it would have been just as good or better if the XSD simply used
"valid" in the same way XML 1.0 does, but made it very clear that a)
XML speaks about DTD-valid, whereas XSD speaks about XSD-valid.

>> PS: I note with interest that the XSD schema files for the XSD language
>> itself, themselves (some of them) include document type declarations.
>> And so I wonder: What would happen if one altered the root names  
>> declared by the document type declaration in those XSD documents? Would
>> XSD-based processor stop working … ?
>
> Most XSD processors have hard-coded knowledge of the schema
> for schema documents as specified in the XSD spec; it would be an
> unusual processor that actually read the schema document for
> schema documents on each startup.  (Not an impossible one, just
> unusual.)  Processors with hard-coded knowledge of the schema for
> schema documents would, I guess, be unaffected by a textual change
> to the schema documents in the spec.  A processor that did read the
> schema document for schema documents at startup might cease to work
> if it checked the schema documents for DTD-validity and found that
> the root element had the wrong name, but it is not (unless I am forgetting
> something) a requirement of the XSD spec that XSD schema documents
> be DTD-valid.
>
> Thank you for your thoughtful and though-provoking message.
>
> I hope this helps.

Thanks. It was a great help for me!
--
Leif Halvard Silli
Reply | Threaded
Open this post in threaded view
|

Re: Can root name in DOCTYPE be a XSD-validity thing?

C. M. Sperberg-McQueen-2
Just one slightly pedantic footnote:

On Feb 15, 2013, at 4:00 AM, Leif Halvard Silli wrote:

> A doctype such as
>   <!DOCTYPE TheDocumentElement SYSTEM "ID" [<!--bla, bla-->] >
> allows to verify
>
>  a) that the DOCTYPE declaration is internally valid,
>     namely, that its root/document name and the DTD’s definition
>     of the root element type, are matching each others,
>  b) that the root/name part of the DOCTYPE declaration
>     matches the actual root element of the document (except that
>
> The b) part does not seem technically necessary since this check could
> even be performed by checking the document/root element against the
> document/root element definition found in the DTD.

As they are defined by the XML spec, DTDs do not have any
mechanism (other than the name given in the document type
declaration) for identifying a particular element as the document
element in an instance.  It is this which allows a DTD to be used
to perform structural validation either on a complete document
(for example, a book or an encyclopedia) or upon individual
elements which may be stored and managed in separate
entities (for example, a chapter in a book or an encyclopedia
entry).

So I don't think the check you have in mind can be performed
solely on the basis of a DTD's internal or external subset -- it
requires the document type declaration.


--
****************************************************************
* C. M. Sperberg-McQueen, Black Mesa Technologies LLC
* http://www.blackmesatech.com 
* http://cmsmcq.com/mib                 
* http://balisage.net
****************************************************************





Reply | Threaded
Open this post in threaded view
|

Re: Can root name in DOCTYPE be a XSD-validity thing?

Leif Halvard Silli-4
C. M. Sperberg-McQueen, Fri, 15 Feb 2013 08:15:39 -0700:
> Just one slightly pedantic footnote:

Great! :-)

> On Feb 15, 2013, at 4:00 AM, Leif Halvard Silli wrote:
>
>> A doctype such as
>>   <!DOCTYPE TheDocumentElement SYSTEM "ID" [<!--bla, bla-->] >
>> allows to verify
>>
>>  a) that the DOCTYPE declaration is internally valid,
>>     namely, that its root/document name and the DTD’s definition
>>     of the root element type, are matching each others,
>>  b) that the root/name part of the DOCTYPE declaration
>>     matches the actual root element of the document (except that
>>
>> The b) part does not seem technically necessary since this check could
>> even be performed by checking the document/root element against the
>> document/root element definition found in the DTD.
>
> As they are defined by the XML spec, DTDs do not have any
> mechanism (other than the name given in the document type
> declaration) for identifying a particular element as the document
> element in an instance.  It is this which allows a DTD to be used
> to perform structural validation either on a complete document
> (for example, a book or an encyclopedia) or upon individual
> elements which may be stored and managed in separate
> entities (for example, a chapter in a book or an encyclopedia
> entry).

Uh, I think I somehow misread the XML 1.0 statement “element type of
the root element” to mean “element of root element type”.

Hah, and I did not know that http://validator.w3.org would validate the
following:

<!DOCTYPE p PUBLIC "-//W3C//DTD XHTML 1.1//EN"
 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<p xmlns="http://www.w3.org/1999/xhtml" >Cool</p>

> So I don't think the check you have in mind can be performed
> solely on the basis of a DTD's internal or external subset -- it
> requires the document type declaration.

Right. And as such, it is a very flexible system since it allows any
element to serve as root. What about XSD in this regard? Perhaps XSD
”hard codes” which elements can serve as root element?
--
leif halvard silli
Reply | Threaded
Open this post in threaded view
|

Re: Can root name in DOCTYPE be a XSD-validity thing?

Noah Mendelsohn


On 2/17/2013 10:59 PM, Leif Halvard Silli wrote:
> Right. And as such, it is a very flexible system since it allows any
> element to serve as root. What about XSD in this regard? Perhaps XSD
> ”hard codes” which elements can serve as root element?

Nope. Actually, XSD doesn't provide a mechanism to identify a root at all.
You declare elements in the schema. Schema validators can either accept
whatever element happens to be in the document as the root, or can through
other means (e.g. command line arg or api) specify a desired root name.

These design choice was somewhat controversial, but that's how it works.

Noah

Reply | Threaded
Open this post in threaded view
|

Re: Can root name in DOCTYPE be a XSD-validity thing?

Liam R. E. Quin
In reply to this post by Leif Halvard Silli-4
On Mon, 2013-02-18 at 04:59 +0100, Leif Halvard Silli wrote:
> [...]
>
> Right. And as such, it is a very flexible system since it allows any
> element to serve as root. What about XSD in this regard? Perhaps XSD
> ”hard codes” which elements can serve as root element?

Some implementations do so, people have told me, but not in an
interoperable way - either by a program-level API, or assuming the first
(or last) top-level/global element in the schema is the root.

It's been a while since I heard of people having problems with this
though, so maybe the implementations were all relaxed.

Liam

--
Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://fromoldbooks.org/
Ankh: irc.sorcery.net irc.gnome.org freenode/#xml