Quantcast
Channel: Planet Apache
Viewing all articles
Browse latest Browse all 9364

Mukul Gandhi: XSD: schema type definition for empty content models

$
0
0
I'm inclined to write a little post, suggesting a correction (perhaps a better schema design) to an XML schema document I wrote in the blog post, http://mukulgandhi.blogspot.com/2010/07/xsd-11-xml-schema-design-approaches.html [1].

In this post [1], I suggested the following XML schema type definition for empty content models:
  <xs:complexType name="EMPTY"> 
<xs:complexContent>
<xs:restriction base="xs:anyType" />
</xs:complexContent>
</xs:complexType>

Instead of the above schema type definition, I find the following (which is simpler I believe) schema type definition [2] (intending to constrain an XML element) to be better instead:
  <xs:element name="X">
<xs:complexType/>
</xs:element>

The element definition [2] above intends to validate an XML fragment like following:
  <X/>

In the above example, I intend to suggest that there must not be any child nodes (and neither any XML attributes on an element) within element "X". Interestingly the XML Schema language, only allows constraining XML element and attribute nodes (and optionally these being XML namespace aware) and it doesn't bother about other XML infoset components like comments, processing-instructions and so on (which are present in XPath data model for example) [A] -- this means that any other kinds of nodes, than XML elements and attributes are ignored by XML Schema language and a compliant XML schema validator. This nature [A] of XML schema language is OK as I've learnt.

I hope the corrections I've shared in this post is appreciated by folks who've read my earlier post cited above [1].

Viewing all articles
Browse latest Browse all 9364

Latest Images

Trending Articles



Latest Images