Why is XML "stupid" about element ordering?

A

Arturius mac Aidan

I'm not sure if this has been addressed in more recent developments, but I'm
reading the MathML specification which states "For example, it is not
possible in XML to specify that the first child be interpreted one way, and
the second in another." Is there a compelling reason that XML does not
support that capability? Has it been fixed?

I recall attempting to create my own schemas a couple years ago, and finding
this limitation. For my purposes it was significant.
 
R

Richard Tobin

Arturius mac Aidan said:
I'm not sure if this has been addressed in more recent developments, but I'm
reading the MathML specification which states "For example, it is not
possible in XML to specify that the first child be interpreted one way, and
the second in another."

Since XML doesn't specify how elements are interpreted, this doesn't
make much sense. Applications can interpret XML any way they want to.
I recall attempting to create my own schemas a couple years ago, and finding
this limitation.

Now you are talking about schemas, which constrain XML and perhaps
assign types to it, rather than interpret it. It's true that you
can't use XML Schemas to specify different constraints on children of
an element with the same name, but there are all kinds of constraints
that you can't express.

-- Richard
 
A

Arturius mac Aidan

Richard said:
Since XML doesn't specify how elements are interpreted, this doesn't
make much sense. Applications can interpret XML any way they want to.

I was quoting the W3C's MathML2 Recommendation. There are rules which
determine how a noun should be interpreted based on its location in a
sentence or phrase. Those are rules of grammar. I'm going to have to give
this more thought before I can provide a concrete example of what I had
expected to work. As I say, it's been a couple years, and I have not been
working with XML much in the interim. I do know I was frustrated by the
inability to constrain attributes according the the context of the element
where they appeared.
Now you are talking about schemas, which constrain XML and perhaps
assign types to it, rather than interpret it. It's true that you
can't use XML Schemas to specify different constraints on children of
an element with the same name, but there are all kinds of constraints
that you can't express.

This is taken directly from the XML 1.0, 3rd edition:

"Definition: The XML document type declaration contains or points to markup
declarations that provide a grammar for a class of documents. This grammar
is known as a document type definition, or DTD. The document type
declaration can point to an external subset (a special kind of external
entity) containing markup declarations, or can contain the markup
declarations directly in an internal subset, or can do both. The DTD for a
document consists of both subsets taken together."

I would argue that the use of DTDs is defined in the XML Recommendation.
That definition may leave some room for extension within the framework of
XML, but XML DTDs are not autonomous structures. The are required to
conform to several requirements stated by the XML Recommendation.
 
R

Richard Tobin

Now you are talking about schemas, which constrain XML and perhaps
assign types to it, rather than interpret it. It's true that you
can't use XML Schemas to specify different constraints on children of
an element with the same name, but there are all kinds of constraints
that you can't express.
[/QUOTE]
This is taken directly from the XML 1.0, 3rd edition:

Ok, I was taking schemas to mean XML Schemas, but the point is the
same: DTDs allow you to place constraints on a document; they don't
restrict how you can interpret the document. You are quite at liberty
to have the one <foo> element mean something quite different from
another.

-- Richard
 
A

Arturius mac Aidan

This is taken directly from the XML 1.0, 3rd edition:

Ok, I was taking schemas to mean XML Schemas,[/QUOTE]

Had I not looked at the XML Recommendation for clarification, I would not
take issue with your drawing a distinction; however, in view of the useage
by the W3C, I believe "DTD" is intended to be inclusive of all XML grammar
definitions. That is, XSD definitions are DTDs in the sense that they
define a document type.
but the point is the
same: DTDs allow you to place constraints on a document; they don't
restrict how you can interpret the document. You are quite at liberty
to have the one <foo> element mean something quite different from
another.

Yes, but sometimes syntax and semantics are interrelated. I am not able to
dedicate the time to formulating a compelling example right now. I have
literally thousands of pages of technical material to cover in a short
period. I can offer the example of natural languages, and in particular,
the grammatically degenerate English language which relies heavily on
syntax to convey semantic interpretations. In an English sentence, the set
of words (and word-forms) which are permitted to immediately follow a noun
is determined by the role that noun plays in a sentence. So, for example,
if I have element definitions for parts of speech such as <noun/> <verb/>
<adverb/>, etc., the list of permissible tags allowed by the rules of
English grammar is determined by what precedes it in a sentence.

I do not believe XML DTDs (inclusive) are capable of codifying English
grammar in this sense. I'm not saying they should be. That's why I
suggested the example given is less than compelling.
 
P

Peter Flynn

Arturius said:
I was quoting the W3C's MathML2 Recommendation. There are rules which
determine how a noun should be interpreted based on its location in a
sentence or phrase. Those are rules of grammar. I'm going to have to
give this more thought before I can provide a concrete example of what
I had expected to work.

That would be useful, as I find it hard to imagine what you expect.
Are you implying that in the sentence

<para><productname>Word</productname> is like
<productname>WordPerfect</productname>.</para>

the first productname element should be treated differently to the
second?

///Peter
 

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,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top