0

xml の xsd を設定しようとしていますが、要素の子要素の値が重複していないことを確認してください。以下は無効な xml の例です。

<NonSectorSpecific>
    <ElementTypes>
      <item>
        <Type>textarea</Type>
      </item>
      <item>
        <Type>select</Type>
      </item>
      <item>
        <Type>select</Type>
      </item>
    </ElementTypes>
  </NonSectorSpecific>

スキーマを正しく検証する xsd を作成しましたが、Type 要素に無効なキーがあるという例外をスローできません。

<xs:schema
  targetNamespace="http://internal.gug.icmemo.com/test"
  elementFormDefault="qualified"
  xmlns="http://internal.gug.icmemo.com/test"
  xmlns:o="http://internal.gug.icmemo.com/test"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
  <xs:element name="Configuration">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="NonSectorSpecific">
          <xs:complexType>
            <xs:sequence>
              <xs:element ref="ElementTypes"  minOccurs="0" maxOccurs="unbounded"/>          
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
    <xs:unique  name="PKElementType">
      <xs:selector xpath="NonSectorSpecific/ElementTypes/item/Type"/>
      <xs:field xpath="."/>
    </xs:unique >
 </xs:element>  

  <xs:complexType name="ElementType">
    <xs:sequence>
      <xs:element name="Type" type="xs:string" />
    </xs:sequence>
  </xs:complexType>   
  <xs:element name="ElementTypes">
    <xs:complexType>
      <xs:sequence minOccurs="0" maxOccurs="unbounded">
        <xs:element name="item" type="ElementType"/>
      </xs:sequence>
    </xs:complexType>      
  </xs:element>  
</xs:schema>

正直なところ、XMl を何年も扱ったことがなく、(属性ではなく) 要素値のキーの処理に関するオンライン ドキュメントが多すぎるように思えません。

4

1 に答える 1