Generating Restrictions in XML Schema Dynamically Using VB.NET 2005: Preliminaries - Differences between xxxExclusive and xxxInclusive
(Page 5 of 5 )
This has caused a lot of confusion among several beginners when they design a new XML Schema. Let us consider the following fragment of XML Schema:
<xs:element name="age">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:minExclusive value="1" />
<xs:maxExclusive value="100" />
</xs:restriction>
</xs:simpleType>
</xs:element>
According to the above code fragment, both values are “exclusive” during validation. That means the “Age” element can have data between 2 and 99 (both inclusive) only. Let us consider the following code fragment:
<xs:element name="age">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:minInclusive value="1" />
<xs:maxInclusive value="100" />
</xs:restriction>
</xs:simpleType>
</xs:element>
According to the above code fragment, both values are “inclusive” during validation. That means the “Age” element can have data between 1 and 100 (both inclusive) only. We can also mix them according to our necessity. Let us consider the following code fragment:
<xs:element name="age">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:minExclusive value="1" />
<xs:maxInclusive value="100" />
</xs:restriction>
</xs:simpleType>
</xs:element>
According to the above code fragment, the “Age” element can have data between 2 and 100 (both inclusive) only. Let us consider the following code fragment:
<xs:element name="age">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:minInclusive value="1" />
<xs:maxExclusive value="100" />
</xs:restriction>
</xs:simpleType>
</xs:element>
According to the above code fragment, the “Age” element can have data between 1 and 99 (both inclusive) only.
I hope the above examples clear up any confusion among the usage of “Inclusive” and “Exclusive” facets available when making restrictions in XML Schema.
The upcoming article will dig further into the details of restrictions using .NET. So keep notified by signing up for a newsletter. Any comments, suggestions, feedback, bugs, errors, enhancements are highly appreciated at jag_chat@yahoo.com
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |