2016-12-03 8 views
1

항상 생각했듯이 xs:restriction은 특정 simpleType 또는 complexType을 제한하기 위해 사용되었으므로 이름은 restriction입니다. 하지만 아래의 xsd 스 니펫은 정확합니다. Norwegian_customer을 살펴보면 country이 complexType으로 덮어 쓰기 때문에 확장되어 있으며 제한적이지 않습니다. 이름이 바뀌 었습니다. xs:restriction은 무엇을 제공하기를 원합니까? xs:restriction은 수퍼 집합이 xs:extension입니까? 스 니펫의 유효성은 WebStorm입니다.이 complexType 정의가 올바른 이유는 무엇입니까?

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

    <xs:complexType name="Norwegian_customer"> 
    <xs:complexContent> 
     <xs:restriction base="customer"> 
     <xs:sequence> 
      <xs:element name="firstname" type="xs:string"/> 
      <xs:element name="lastname" type="xs:string"/> 
      <xs:element name="country1"> 
      <xs:complexType> 
       <xs:sequence> 
       <xs:element name="firstname" type="xs:string"/> 
       <xs:element name="lastname" type="xs:string"/> 
       <xs:element name="country" type="xs:string"/> 
       </xs:sequence> 
      </xs:complexType> 
      </xs:element> 
     </xs:sequence> 
     </xs:restriction> 
    </xs:complexContent> 
    </xs:complexType> 

답변

2

그러나 XSD 아래 니펫을 맞습니다.

아니요, XSD 스 니펫이 올바르지 않습니다.. Norwegian_customercustomer의 유효한 제한 사항이 아니기 때문에 country, country1 만 허용됩니다. 제한된 기본 형식의 콘텐츠 모델 부분은 파생 형식에서 명시 적으로 허용되어야합니다.

스 니펫은 WebStorm에서 유효성이 검사됩니다.

Webstorm이이 XSD의 유효성을 검사하면 부적합한 것입니다.

특히, W3C XML Schema Part 1: Structures Second Edition 참고 : 다음과 같이 Xerces를 기반 유효성 검사기가 당신을 통보 한 것으로

참고 :

[오류] try.xsd : 13 : 45 : rcase-Recurse.2 : 입자 사이에 완전한 기능 매핑이 없습니다.

[오류] try.xsd : 13 : 45 : derivation-ok-restriction.5.4.2 : 'Norwegian_customer'유형의 오류입니다. 유형의 입자가 기본 입자의 유효한 제한 사항이 아닙니다.