2014-12-05 1 views
0

따르면 XML Schema specification of whitespace에 무시 , 그리고 패턴은 만족되어서는 안된다. 그러나 그것의 유효한. 그래서, 내 질문은 입니다. 왜이 XML은이 스키마에 유효합니까?XML 스키마 조합은 공백 재산

XML합니다 (whitesepaces 통지) :

<?xml version="1.0" encoding="UTF-8" ?> 
<elem> Hello   world</elem> 

XML 스키마 (패턴 제한 통지) :

<?xml version="1.0" encoding="UTF-8" ?> 
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
    <xs:simpleType name="myUnion"> 
     <xs:union memberTypes="xs:string"> 
     </xs:union> 
    </xs:simpleType> 

    <xs:element name="elem"> 
     <xs:simpleType> 
      <xs:restriction base="myUnion"> 
       <xs:pattern value="Hello world" /> 
      </xs:restriction> 
     </xs:simpleType> 
    </xs:element> 
</xs:schema> 

편집이 :의 Xerces는 유효 말한다 색슨가 말한다 유효하지. Thats는 Xerces 버그 인 것 같습니다. 우리는이 같은 노조 정의하면

그러나 : 다시

<xs:simpleType name="myUnion"> 
    <xs:union> 
     <xs:simpleType> 
      <xs:restriction base="xs:string"> 
       <xs:whiteSpace value="collapse"/> 
      </xs:restriction> 
     </xs:simpleType> 
    </xs:union> 
</xs:simpleType> 

을, Xerces에 색슨이 유효하지 말한다, 그 유효을 말한다. 그러나 이번에는 Saxon 버그 인 것 같습니다 (공백이 없어야하고 패턴을 만족해야합니다). 어떻게 생각해?

답변

1

누가 유효하다고 말합니까?

색슨는 말한다 :

Processing file:/Users/mike/Desktop/temp/test.xml 
Validation error on line 2 of test.xml: 
    XSD: The content " Hello   world" of element <elem> does not match the required 
    simple type. Value " Hello   world" contravenes the pattern facet "Hello world" 
    of the type of element elem 
    Validating /elem[1] 
    See http://www.w3.org/TR/xmlschema11-2/#cvc-datatype-valid clause 1 
Validation error on line 2 column 37 of test.xml: 
    XSD: One or more validation errors were reported 
Validation unsuccessful 

과 색슨은 일반적으로 그것을 바로 ;-)

+0

미안 해요, 난 그냥 편집 한 내 질문을 가져옵니다. – sergioFC

+0

Saxon이 잘못된 것으로 보이는 Xerces가 옳은 새로운 예를 살펴보십시오. – sergioFC

+1

네, 아마도 당신이 옳다고 생각합니다. XSD 파트 2에서 확실한 텍스트를 찾기가 힘듭니다. 패턴 패싯은 "어휘 공간의 값"에서 작동하도록 정의되고 공백 패싯은 "정규화 된 값"을 결정합니다. 나는 이것들이 똑같은지 100 % 확신하지 못한다. 그러나 Part 1에서는 제약 조건에 대해 유효해야하는 정규화 된 값이라는 것을 분명히 했으므로 어휘 공간에 적용되는 패턴에 관한 내용이 해당 용어를 선택하지 못한 것 같습니다. –