XML Tutorial/XML Schema/maxExclusive

Материал из Web эксперт
Версия от 11:26, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Constrain a data type to be a single constant value:

   <source lang="xml">

<?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

 targetNamespace="http://www.wbex.ru" xmlns="http://www.wbex.ru"
 elementFormDefault="qualified">
 <xs:simpleType name="TheAnswer">
   <xs:restriction base="xs:integer">
     <xs:minInclusive value="42" />
     <xs:maxInclusive value="42" />
   </xs:restriction>
 </xs:simpleType>

</xs:schema></source>


Element"s content must be lower than (and not equal to) the xsd:maxExclusive value.

   <source lang="xml">

File: Schema.xsd <?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"

 targetNamespace="http://www.wbex.ru" 
 xmlns="http://www.wbex.ru"
 elementFormDefault="qualified">
 <xsd:element name="population">
   <xsd:simpleType>
     <xsd:restriction base="xsd:integer">
       <xsd:maxExclusive value="5000" />
     </xsd:restriction>
   </xsd:simpleType>
 </xsd:element>

</xsd:schema>

File: Data.xml <?xml version="1.0"?> <population xmlns="http://www.wbex.ru">5000</population></source>


maxExclusive Defines the exclusive upper bound for a datatype with the ordered property

   <source lang="xml">

<xsd:simpleType name="upperType">

 <xsd:restriction base="integer">
  <xsd:maxExclusive value="101"/>
 </xsd:restriction>

</xsd:simpleType></source>


minExclusive, minInclusive, maxExclusive, maxInclusive

   <source lang="xml">

<?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

 targetNamespace="http://www.wbex.ru" 
 xmlns="http://www.wbex.ru"
 elementFormDefault="qualified">
 <xs:simpleType name="negativeInteger">
   <xs:annotation>
     <xs:documentation source="http://www.w3.org/TR/xmlschema-2/#negativeInteger" />
   </xs:annotation>
   <xs:restriction base="xs:nonPositiveInteger">
     <xs:maxInclusive value="-1"/>
   </xs:restriction>
 </xs:simpleType>

</xs:schema></source>