2010-01-08 6 views
3

다음 XML 조각은 표준 XML lib (Java 및 Scala로 시도 됨)를 사용하여 구문 분석 할 수 있습니다.XSD 요소의 비 결정적 출현을 갖는 XML 파일의 유효성 검사

<?xml version="1.0" encoding="UTF-8"?> 
<list> 
<a>value1</a> 
<b>value2</b> 
<a>value3</a> 
<a>value4</a> 
<a>value5</a> 
<b>value6</b> 
<b>value7</b> 
</list> 

'a'와 'b'요소가 혼합되어 표시됩니다 (비 결정적). 이 "혼합 된"동작을위한 XSD를 작성할 수 있습니까?

답변

9

이 작동합니다 .. :-)

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
    <xs:element name="list"> 
    <xs:complexType> 
     <xs:sequence> 
     <xs:choice maxOccurs="unbounded"> 
      <xs:element name="a" type="xs:string" /> 
      <xs:element name="b" type="xs:string" /> 
     </xs:choice> 
     </xs:sequence> 
    </xs:complexType> 
    </xs:element> 
</xs:schema>