XML Tutorial/XML Schema/minInclusive

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

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"/>

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

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