0

我无法定义元素的内容类型(“电话号码”),同时定义具有枚举限制的属性(“位置”)。

这是我卡住的地方:

<xs:element name="phonenumbers">
    <xs:complexType>
        <xs:sequence maxOccurs="unbounded">
            <xs:element name="phonenumber">
                <!--
                Try #1:
                Define the type of the attribute "location" and the
                content-type of the element "phonenumber". But without
                enumeration restrictions on "location".
                -->

                <xs:complexType>
                    <xs:simpleContent>
                        <xs:extension base="xs:integer">
                            <xs:attribute name="location" type="xs:string"/>                                                        
                        </xs:extension>                                                    
                    </xs:simpleContent>
                </xs:complexType>

                <!--
                Try #2:
                Enumerables in attribute "location" with no content-type
                of the element "phonenumber", thus being unable to put
                anything in it.
                -->

                <xs:complexType>                                                
                    <xs:attribute name="location">
                        <xs:simpleType>
                            <xs:restriction base="xs:string">
                                <xs:enumeration value="Home"/>
                                <xs:enumeration value="Work"/>
                                <xs:enumeration value="Mobile"/>
                            </xs:restriction>
                        </xs:simpleType>
                    </xs:attribute>
                </xs:complexType>

            </xs:element>
        </xs:sequence>
    </xs:complexType>
</xs:element>
4

1 回答 1

2

关于什么

<xs:element name="phonenumbers">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="phonenumber" minOccurs="0" maxOccurs="unbounded">
        <xs:complexType>
          <xs:simpleContent>
            <xs:extension base="xs:integer">
              <xs:attribute name="location" use="required">
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:enumeration value="Home"/>
                    <xs:enumeration value="Work"/>
                    <xs:enumeration value="Mobile"/>
                  </xs:restriction>
                </xs:simpleType>
              </xs:attribute>
            </xs:extension>
          </xs:simpleContent>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
</xs:element>
于 2008-11-05T11:09:17.703 回答