프로젝트의 기존 XML 파일의 유효성을 검사하려고합니다.고유 한 입자 오류가 발생하여 임의의 순서로 여러 자식 요소를 허용하려고합니다.
즉<resources>
<file name="one" path="C:\test\one.txt" />
<cache path="C:\test\cache\" />
<file name="two" path="C:\test\two.txt" />
<bundle name="myFolder">
<file name="three" path="C:\test\three.txt" />
<file name="four" path="C:\test\four.txt" />
</bundle>
<file name="one" path="C:\test\one.txt" />
<bundle name="myFolder">
<file name="three" path="C:\test\three.txt" />
<file name="four" path="C:\test\four.txt" />
</bundle>
<file name="one" path="C:\test\one.txt" />
</resources>
가, 내가 원하는 것은 가장 한 cache
요소에서 아이들에게
- 을 가지고 루트 요소
resources
와 구조가 어떤 순서 - 임의의 수에 : 같은 예 구조가 보인다 순서
bundle
에file
및bundle
요소들의file
요소 임의의 개수를 포함 17,451,515,
이 (this answer에서 그리기) 내 현재 XSD입니다 :
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:complexType name="cache">
<xs:attribute name="path" type="xs:string" />
</xs:complexType>
<xs:complexType name="file">
<xs:attribute name="name" type="xs:string" />
<xs:attribute name="path" type="xs:string" />
</xs:complexType>
<xs:complexType name="bundle">
<xs:choice maxOccurs="unbounded">
<xs:element name="file" type="file" maxOccurs="unbounded" />
</xs:choice>
<xs:attribute name="type" />
<xs:attribute name="name" />
</xs:complexType>
<xs:group name="unboundednoncache">
<xs:choice>
<xs:element name="file" type="file" />
<xs:element name="bundle" type="bundle" />
</xs:choice>
</xs:group>
<xs:element name="resources">
<xs:complexType>
<xs:sequence>
<!-- Validates if this next line is removed,
and the cache element is moved to first -->
<xs:group ref="unboundednoncache" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="cache" type="cache" minOccurs="0" maxOccurs="1" />
<xs:group ref="unboundednoncache" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
이 나에게 오류를 제공합니다
Cos-nonambig: File And File (or Elements From Their Substitution Group) Violate "Unique Particle Attribution". During Validation Against This Schema, Ambiguity Would Be Created For Those Two Particles.
내가 처음 <xs:group>
를 제거하면 내가 확인하는 최초의 XSD를 얻을 수 있습니다 XSD에서 cache
요소를 XML의 첫 번째 하위 항목으로 이동 시키되 캐시 요소를 아무 곳에서나 유효하게 만들고 싶습니다.
(이전 버전에 내가 사용 하였다. 나도 원하지 않는 다수의 캐시 요소를
<xs:choice maxOccurs="unbounded">
<xs:element name="cache" type="cache" minOccurs="0" maxOccurs="1" />
<xs:element name="file" type="file" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="bundle" type="bundle" minOccurs="0" maxOccurs="unbounded" />
</xs:choice>
..하지만 그 수)
왜 내 XSD 위반 않는다 "독특한 입자 기여도 "를 수정하려면 어떻게해야합니까? 스키마 문서에서