2016-08-02 8 views
1
내가 스키마를 만드는 방법에 대한 일하고 있어요,하지만 이러한 속성

의 xsd : 아이들과 함께 복합 타입, 속성 및 제한

에, 아이가 속성 복합 타입으로 제한을 정의 내 루트 요소 근처에 갇히지하고

이 은 (블라인드 형식)

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
<xsd:element name="foos"> 
    <xsd:complexType> 
     <xsd:sequence> 
      <xsd:element name="foo" type="FooType" minOccurs="1" maxOccurs="unbounded"/> 
     </xsd:sequence>   
    </xsd:complexType> 
</xsd:element> 
<xsd:complexType name="FooType"> 
    <xsd:attribute name="exchangeType" type="xsd:string" use="required"> 
     <xsd:simpleType> 
      <xsd:restriction base="xsd:string"> 
       <xsd:enumeration value="S" /> 
       <xsd:enumeration value="T" /> 
      </xsd:restriction> 
     </xsd:simpleType> 
    </xsd:attribute> 
    <xsd:sequence> 
     <xsd:element name="thing1" type="Thing1Type" /> 
     <xsd:element name="thing2" type="Thing2Type" /> 
    </xsd:sequence> 
</xsd:complexType> 
</xsd:schema> 

내가

어떤 생각이 속성을 통합 할 수있는 방법을 발견하고 그 제한 문제가 봤는데 .... 내가 지금까지 시도한 것입니다 에스?

답변

1

두 가지 주요 수정 :

  1. xsd:attribute 선언 할 수 없습니다 모두 로컬 xsd:simpleType@type 속성; @type 속성을 삭제했습니다.
  2. xsd:attribute 선언은 xsd:sequence 앞에 표시 할 수 없습니다. 후에 이동하십시오. 수정과

XSD 적용 :

이 XSD는 위의 수정 및 적용 다른 몇 가지 사소한 수정을 가지고 있으며, 현재 유효합니다

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <xsd:element name="foos"> 
    <xsd:complexType> 
     <xsd:sequence> 
     <xsd:element name="foo" type="FooType" 
        minOccurs="1" maxOccurs="unbounded"/> 
     </xsd:sequence>   
    </xsd:complexType> 
    </xsd:element> 
    <xsd:complexType name="FooType"> 
    <xsd:sequence> 
     <xsd:element name="thing1" type="Thing1Type" /> 
     <xsd:element name="thing2" type="Thing2Type" /> 
    </xsd:sequence> 
    <xsd:attribute name="exchangeType" use="required"> 
     <xsd:simpleType> 
     <xsd:restriction base="xsd:string"> 
      <xsd:enumeration value="S" /> 
      <xsd:enumeration value="T" /> 
     </xsd:restriction> 
     </xsd:simpleType> 
    </xsd:attribute> 
    </xsd:complexType> 
    <xsd:complexType name="Thing1Type"/> 
    <xsd:complexType name="Thing2Type"/> 
</xsd:schema> 
+0

감사합니다, @kjhughes이 많이 있습니다 더 많은 감각과 내가이 접근하는 방법에 필요한 명확성입니다 – kmancusi