Menu Specification Comments

Shaun McCance shaunm at wolfram.com
Sun Jun 15 18:29:11 EEST 2003


On Sun, 2003-06-15 at 10:04, Heinrich Wendel wrote:
> On Sunday 15 June 2003 12:50, Shaun McCance wrote:
> > On Sun, 2003-06-15 at 05:26, Havoc Pennington wrote:
> > > On Sun, Jun 15, 2003 at 08:37:06AM +0200, Heinrich Wendel wrote:
> > > > I said it needs a !unique! root element. Menu is not a unique
> > > > element. It can (and does in most cases) appear multiply times in a
> > > > .menu file.
> > >
> > > Ah, I see. I guess we have to add <useless-stupid-root-element>
> > > element then. I will ask Liam or Daniel to explain why that is in the
> > > XML spec. ;-)
> >
> > I've read the XML spec a number of times, and have never seen anything
> > to indicate that a unique root is necessary.  It's just another element,
> > like any other.  In fact, XML doesn't care which element you use as your
> > root element.  Either Heinrich has misread the spec, or I have.
> 
> 
> "There is exactly one element, called the root, or document element, no part 
> of which appears in the content of any other element.]" 
> (http://www.w3.org/TR/REC-xml#sec-well-formed

Ah.  No, you've misread it.  What this is saying is that no part of the
root (its start tag or its end tag) can be inside any other element's
content.  It's also saying that no other element may have any of its
parts outside of all other elements' content.  Basically, it's giving a
special case of what constitutes proper nesting for the boundary case of
a root element.

When reading the spec, an element refers so a specific instance of, say,
<foo/>, not to the generic class of all <foo/>'s.  The spec really does
not care what names you use for elements, or which elements you use as
the root.  In fact, people re-root XML documents all the time.  It's
very common practice, and is one of the benefits of XML.  To quote:

"This specification does not constrain the semantics, use, or (beyond
syntax) names of the element types and attributes, except that names
beginning with a match to (('X'|'x')('M'|'m')('L'|'l')) are reserved for
standardization in this or future versions of this specification."
http://www.w3.org/TR/REC-xml#NT-element

--
Shaun




More information about the xdg mailing list