<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # XSD 指示器 通過指示器,我們可以控制在文檔中使用元素的方式。 ## 指示器 有七種指示器: Order 指示器: * All * Choice * Sequence Occurrence 指示器: * maxOccurs * minOccurs Group 指示器: * Group name * attributeGroup name ## Order 指示器 Order 指示器用于定義元素的順序。 ### All 指示器 &lt;all&gt; 指示器規定子元素可以按照任意順序出現,且每個子元素必須只出現一次: ``` <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> ``` **注意:** 當使用 &lt;all&gt; 指示器時,你可以把 &lt;minOccurs&gt; 設置為 0 或者 1,而只能把 &lt;maxOccurs&gt; 指示器設置為 1(稍后將講解 &lt;minOccurs&gt; 以及 &lt;maxOccurs&gt;)。 ### Choice 指示器 &lt;choice&gt; 指示器規定可出現某個子元素或者可出現另外一個子元素(非此即彼): ``` <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> ``` ### Sequence 指示器 &lt;sequence&gt; 規定子元素必須按照特定的順序出現: ``` <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 指示器用于定義某個元素出現的頻率。 **注意:** 對于所有的 "Order" 和 "Group" 指示器(any、all、choice、sequence、group name 以及 group reference),其中的 maxOccurs 以及 minOccurs 的默認值均為 1。 ### maxOccurs 指示器 &lt;maxOccurs&gt; 指示器可規定某個元素可出現的最大次數: ``` <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" 元素中最少出現一次(其中 minOccurs 的默認值是 1),最多出現 10 次。 ### minOccurs 指示器 &lt;minOccurs&gt; 指示器可規定某個元素能夠出現的最小次數: ``` <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" 元素中出現最少 0 次,最多出現 10 次。 **提示:**如需使某個元素的出現次數不受限制,請使用 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>Hege Refsnes</full_name> ? <child_name>Cecilie</child_name> </person> <person> ? <full_name>Tove Refsnes</full_name> ? <child_name>Hege</child_name> ? <child_name>Stale</child_name> ? <child_name>Jim</child_name> ? <child_name>Borge</child_name> </person> <person> ? <full_name>Stale Refsnes</full_name> </person> </persons> ``` 上面這個 XML 文件含有一個名為 "persons" 的根元素。在這個根元素內部,我們定義了三個 "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 指示器用于定義相關的數批元素。 ### 元素組 元素組通過 group 聲明進行定義: ``` <xs:group name="groupname"> ... </xs:group> ``` 您必須在 group 聲明內部定義一個 all、choice 或者 sequence 元素。下面這個例子定義了名為 "persongroup" 的 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> ``` 在您把 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="groupname"> ... </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> ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看