[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
Re: [xml-dev] What does an empty element denote?
- From: Michael Kay <mike@saxonica.com>
- To: "Costello, Roger L." <costello@mitre.org>
- Date: Tue, 2 Jun 2015 14:43:55 +0100
I don’t know what validator you are using. It seems Saxon accepts <Test3/> as a valid instance of your Test3 declaration, but I’m inclined to think that it is wrong to do so. XSD 1.0 part 1 section 3.8.4 clause 2 says
<quote>If the {compositor} is choice, then there must be a particle among the {particles} such that the sequence is ·valid· with respect to that particle</quote>
In this case {particles} is empty, so there is no particle for which the sequence is valid, and therefore the sequence is invalid. <xs:choice/> should have no valid instances.
XSD 1.1 says the same thing in much more formal language, which I don’t claim to have fully understood. But it stands to reason: when you have a choice, your content must satisfy at least one branch of the choice, and if there are zero branches, then it cannot possibly do so.
Incidentally, the paper you cite (which, along with Brzozowski’s work, I really must try to understand one day…) seems to use the words “string” and “sequence” interchangeably. Usually in the XML world we use string to mean a string of characters, but in the world of formal grammars, a string is a sequence of symbols from some alphabet, and in the world of schema languages, that alphabet is typically the set of permitted element names.
Michael Kay
Saxonica
> On 2 Jun 2015, at 13:15, Costello, Roger L. <costello@mitre.org> wrote:
>
> Hi Folks,
>
>
>
> This XML Schema declares an element with a content model that is a simple type:
>
>
>
> <xs:element name="Test1">
> <xs:simpleType>
> <xs:restriction base="xs:int">
> <xs:minInclusive value="0" />
> <xs:maxInclusive value="9" />
> </xs:restriction>
> </xs:simpleType>
> </xs:element>
>
>
>
> In an XML instance document, the value of <Test1> can be 0, 1, …, 9.
>
>
>
> The content model of Test1 denotes this set: {0, 1, …, 9}
>
>
>
> Now consider this XML Schema, it declares an element with a content model that is a complex type with an empty sequence:
>
>
>
> <xs:element name="Test2">
> <xs:complexType>
> <xs:sequence/>
> </xs:complexType>
> </xs:element>
>
>
>
> Lastly, consider this XML Schema, it declares an element with a content model that is a complex type that is an empty choice:
>
> <xs:element name="Test3">
> <xs:complexType>
> <xs:choice/>
> </xs:complexType>
> </xs:element>
>
>
>
> Michael Sperberg-McQueen wrote an article [1] which says that a content model which is an empty sequence denotes a set with an empty string, { ε }. So the value of <Test2> must be a string of length zero. Here’s how a string of length zero is physically expressed in an XML instance document:
>
>
> <Test2></Test2>
>
>
>
> MSM says that a content model that is an empty choice denotes an empty set, {}. That puzzled me, so I created an XML instance document containing <Test3>:
>
>
> <Test3></Test3>
>
>
>
> and validated it against the schema. It validated!
>
>
>
> Okay, I’m confused. In an XML instance document, does an empty element denote that the element’s value is ε (the empty string, i.e., a string of length zero), or does an empty element denote that the element has no value, i.e., the set of allowable values is the empty set?
>
>
>
> Can you give a concrete example that illustrates how Test2’s content is different than Test3’s content?
>
>
>
> /Roger
>
>
>
> [1] http://conferences.idealliance.org/extreme/html/2005/SperbergMcQueen01/EML2005SperbergMcQueen01.html#id2624489
>
>
>
>
>
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]