[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: What does an empty element denote?

  • From: Mukul Gandhi <gandhi.mukul@gmail.com>
  • To: "Costello, Roger L." <costello@mitre.org>
  • Date: Thu, 11 Jun 2015 13:11:11 +0530

Re:  What does an empty element denote?
I've few things to say on the original post as well illustrated by Roger. Few of my comments are inline,

On 2 June 2015 at 17:45, 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}


From what I had read in the XSD 1.0 specification (and those facts haven't changed in XSD 1.1), this example doesn't define a content model at all for element "Test1". A content model of an element ("Test1" in this case), ought to specify 0-1 child elements. In this case, an XML element instance "Test1" can have one of the simpleType value from the 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, {}.


I cannot dispute MSM's logic as explained by Roger. It seems correct to me.
 

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?


As is mentioned in these example, I was tempted to explain the difference between Test2 and Test3's content as I seem to understand from the XSD 1.0 / 1.1 specifications. The element declaration's Test2 and Test3 at a low level will validate the same content which is empty in both the cases for Test2 and Test3. The presence of <xs:sequence/> in Test2 and <xs:choice> in Test3 are essentially equivalent from the validation perspective, although an XSD validator can adopt different means to understand the syntax of xs:sequence and xs:choice.
 



--
Regards,
Mukul Gandhi


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.