XML Tutorial/XML Schema/minInclusive — различия между версиями

Материал из Web эксперт
Перейти к: навигация, поиск
 
м (1 версия)
 
(нет различий)

Текущая версия на 08:26, 26 мая 2010

Cardinality represents the number of occurrences of a specific element within a content model.

You can modify an element"s cardinality by specifying the minOccurs and maxOccurs attributes within the element declaration.
Some possible uses of the minOccursand maxOccursattributes include the following: 
<element name="first" type="string" minOccurs="2" maxOccurs="2"/> 
<element ref="target:first" maxOccurs="10"/> 
<element name="location" ""minOccurs="0" maxOccurs="unbounded"/> 
The default value for the minOccurs attribute and the maxOccurs attribute is 1.


minInclusive Defines the inclusive lower bound for a datatype with the ordered property

<xsd:simpleType name="editionType">
  <xsd:restriction base="xsd:nonNegativeInteger">
   <xsd:minInclusive value="1"/>
   <xsd:maxInclusive value="10"/>
  </xsd:restriction>
</xsd:simpleType>


The xsd:minInclusive facet specifies the highest possible value for an element

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="start_date">
    <xsd:simpleType>
      <xsd:restriction base="xsd:date">
        <xsd:minInclusive value="1999-07-25" />
      </xsd:restriction>
    </xsd:simpleType>
  </xsd:element>
</xsd:schema>

File: Data.xml 
<?xml version="1.0"?>
 
<start_date xmlns="http://www.wbex.ru">1999-07-25</start_date>