最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

XSD 復(fù)合類型指示器

通過指示器,我們可以控制在文檔中使用元素的方式。

指示器

有七種指示器:

Order 指示器:

  • All
  • Choice
  • Sequence

Occurrence 指示器:

  • maxOccurs
  • minOccurs

Group 指示器:

  • Group name
  • attributeGroup name

Order 指示器

Order 指示器用于定義元素的順序。

All 指示器

<all> 指示器規(guī)定子元素可以按照任意順序出現(xiàn),且每個子元素必須只出現(xiàn)一次:

<xs:element name="person">
  <xs:complexType>
    <xs:all>
      <xs:element name="firstname" type="xs:string"/>
      <xs:element name="lastname" type="xs:string"/>
    </xs:all>
  </xs:complexType>
</xs:element>

注釋:當(dāng)使用 <all> 指示器時,你可以把 <minOccurs> 設(shè)置為 0 或者 1,而只能把 <maxOccurs> 指示器設(shè)置為 1(稍后將講解 <minOccurs> 以及 <maxOccurs>)。

Choice 指示器

<choice> 指示器規(guī)定可出現(xiàn)某個子元素或者可出現(xiàn)另外一個子元素(非此即彼):

<xs:element name="person">
  <xs:complexType>
    <xs:choice>
      <xs:element name="employee" type="employee"/>
      <xs:element name="member" type="member"/>
    </xs:choice>
  </xs:complexType>
</xs:element>

提示:如需設(shè)置子元素出現(xiàn)任意次數(shù),可將 <maxOccurs> (稍后會講解)設(shè)置為 unbounded(無限次)。

Sequence 指示器

<sequence> 規(guī)定子元素必須按照特定的順序出現(xiàn):

<xs:element name="person">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="firstname" type="xs:string"/>
      <xs:element name="lastname" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>

Occurrence 指示器

Occurrence 指示器用于定義某個元素出現(xiàn)的頻率。

注釋:對于所有的 "Order" 和 "Group" 指示器(any、all、choice、sequence、group name 以及 group reference),其中的 maxOccurs 以及 minOccurs 的默認值均為 1。

maxOccurs 指示器

<maxOccurs> 指示器可規(guī)定某個元素可出現(xiàn)的最大次數(shù):

<xs:element name="person">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="full_name" type="xs:string"/>
      <xs:element name="child_name" type="xs:string" maxOccurs="10"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>

上面的例子表明,子元素 "child_name" 可在 "person" 元素中最少出現(xiàn)一次(其中 minOccurs 的默認值是 1),最多出現(xiàn) 10 次。

minOccurs 指示器

<minOccurs> 指示器可規(guī)定某個元素能夠出現(xiàn)的最小次數(shù):

<xs:element name="person">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="full_name" type="xs:string"/>
      <xs:element name="child_name" type="xs:string"
      maxOccurs="10" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>

上面的例子表明,子元素 "child_name" 可在 "person" 元素中出現(xiàn)最少 0 次,最多出現(xiàn) 10 次。

提示:如需使某個元素的出現(xiàn)次數(shù)不受限制,請使用 maxOccurs="unbounded" 這個聲明:

一個實際的例子:

名為 "Myfamily.xml" 的 XML 文件:

<?xml version="1.0" encoding="ISO-8859-1"?>

<persons xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="family.xsd">

<person>
<full_name>Tony Smith</full_name>
<child_name>Cecilie</child_name>
</person>

<person>
<full_name>David Smith</full_name>
<child_name>Jogn</child_name>
<child_name>mike</child_name>
<child_name>kyle</child_name>
<child_name>mary</child_name>
</person>

<person>
<full_name>Michael Smith</full_name>
</person>

</persons>

上面這個 XML 文件含有一個名為 "persons" 的根元素。在這個根元素內(nèi)部,我們定義了三個 "person" 元素。每個 "person" 元素必須含有一個 "full_name" 元素,同時它可以包含多至 5 個 "child_name" 元素。

這是schema文件"family.xsd":

<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">

<xs:element name="persons">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="person" maxOccurs="unbounded">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="full_name" type="xs:string"/>
            <xs:element name="child_name" type="xs:string"
            minOccurs="0" maxOccurs="5"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
</xs:element>

</xs:schema>

Group 指示器

Group 指示器用于定義相關(guān)的數(shù)批元素。

元素組

元素組通過 group 聲明進行定義:

<xs:group name="組名稱">
  ...
</xs:group>

您必須在 group 聲明內(nèi)部定義一個 all、choice 或者 sequence 元素。下面這個例子定義了名為 "persongroup" 的 group,它定義了必須按照精確的順序出現(xiàn)的一組元素:

<xs:group name="persongroup">
  <xs:sequence>
    <xs:element name="firstname" type="xs:string"/>
    <xs:element name="lastname" type="xs:string"/>
    <xs:element name="birthday" type="xs:date"/>
  </xs:sequence>
</xs:group>

在您把 group 定義完畢以后,就可以在另一個定義中引用它了:

<xs:group name="persongroup">
  <xs:sequence>
    <xs:element name="firstname" type="xs:string"/>
    <xs:element name="lastname" type="xs:string"/>
    <xs:element name="birthday" type="xs:date"/>
  </xs:sequence>
</xs:group>

<xs:element name="person" type="personinfo"/>

<xs:complexType name="personinfo">
  <xs:sequence>
    <xs:group ref="persongroup"/>
    <xs:element name="country" type="xs:string"/>
  </xs:sequence>
</xs:complexType>

屬性組

屬性組通過 attributeGroup 聲明來進行定義:

<xs:attributeGroup name="組名稱">
  ...
</xs:attributeGroup>

下面這個例子定義了名為 "personattrgroup" 的一個屬性組:

<xs:attributeGroup name="personattrgroup">
  <xs:attribute name="firstname" type="xs:string"/>
  <xs:attribute name="lastname" type="xs:string"/>
  <xs:attribute name="birthday" type="xs:date"/>
</xs:attributeGroup>

在您已定義完畢屬性組之后,就可以在另一個定義中引用它了,就像這樣:

<xs:attributeGroup name="personattrgroup">
  <xs:attribute name="firstname" type="xs:string"/>
  <xs:attribute name="lastname" type="xs:string"/>
  <xs:attribute name="birthday" type="xs:date"/>
</xs:attributeGroup>

<xs:element name="person">
  <xs:complexType>
    <xs:attributeGroup ref="personattrgroup"/>
  </xs:complexType>
</xs:element>
茶陵县| 梨树县| 嘉兴市| 江城| 河间市| 津南区| 噶尔县| 故城县| 洪雅县| 长乐市| 平塘县| 棋牌| 韶山市| 镇雄县| 辽阳县| 宜阳县| 临颍县| 公安县| 天柱县| 措勤县| 体育| 定襄县| 霞浦县| 兰考县| 扶风县| 宁安市| 江西省| 阳原县| 苗栗县| 团风县| 清镇市| 酒泉市| 泸水县| 红安县| 五指山市| 山东| 抚顺县| 贵南县| 萨嘎县| 平遥县| 遂平县|