Content model ANY

R

Richard Light

A literal-minded reading of the XML 1.0 Spec suggests that elements with
content model ANY should not have comments or PIs as their immediate
children. Is there a particular reason for this?

Richard Light
 
D

David Håsäther

Richard Light said:
A literal-minded reading of the XML 1.0 Spec suggests that
elements with content model ANY should not have comments or PIs as
their immediate children.

What in the spec made you draw that conclusion? Comments and PIs can
appear directly in an element with a content model of ANY.
 
R

Richard Light

David Håsäther said:
What in the spec made you draw that conclusion? Comments and PIs can
appear directly in an element with a content model of ANY.

So I previously assumed myself. However, the absence of any mention of
them in the relevant validity constraint led me to ask the question.

This is the section I was reading:
-------------------------------------------------------------------------
--------------------------
Validity constraint: Element Valid

An element is valid if there is a declaration matching elementdecl where
the Name matches the element type, and one of the following holds:

1. The declaration matches EMPTY and the element has no content
(not even entity references, comments, PIs or white space).
2. The declaration matches children and the sequence of child
elements belongs to the language generated by the regular expression in
the content model, with optional white space, comments and PIs (i.e.
markup matching production [27] Misc) between the start-tag and the
first child element, between child elements, or between the last child
element and the end-tag. Note that a CDATA section containing only white
space or a reference to an entity whose replacement text is character
references expanding to white space do not match the nonterminal S, and
hence cannot appear in these positions; however, a reference to an
internal entity with a literal value consisting of character references
expanding to white space does match S, since its replacement text is the
white space resulting from expansion of the character references.
3. The declaration matches Mixed and the content (after
replacing any entity references with their replacement text) consists of
character data, comments, PIs and child elements whose types match names
in the content model.
4. The declaration matches ANY, and the content (after replacing
any entity references with their replacement text) consists of character
data and child elements whose types have been declared.
-------------------------------------------------------------------------
--------------------------

You will notice that the absence of comments and PIs is explicitly
mentioned in case 1 (EMPTY), and their presence is explicitly mentioned
in 2 and 3. So I am assuming that the absence of any mention of them in
case 4 (ANY) means they are not allowed.

Richard Light
 
R

Richard Tobin

Richard Light said:
A literal-minded reading of the XML 1.0 Spec suggests that elements with
content model ANY should not have comments or PIs as their immediate
children. Is there a particular reason for this?

Yes. It's a mistake.

It was corrected in an erratum:

http://www.w3.org/XML/xml-V10-3e-errata#E05

The fact that it was corrected so late suggests that almost everyone
was so sure of what it really meant that they didn't bother to read
the text closely!

-- Richard
 
R

Richard Light

Richard Tobin said:
Yes. It's a mistake.

It was corrected in an erratum:

http://www.w3.org/XML/xml-V10-3e-errata#E05

The fact that it was corrected so late suggests that almost everyone
was so sure of what it really meant that they didn't bother to read
the text closely!

Thanks. When you're tasked with making an XML validator which conforms
to the spec, these little details suddenly start to matter ...

Richard
 
R

Richard Tobin

It was corrected in an erratum:

And, it turns out, it was introduced in an earlier erratum. The
original XML spec didn't have that wording.

-- Richard
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top