0
を使用してユニークとしてXML要素を定義します。私は、以下の関連するXSDを持つXMLファイルを持っているXSD
のcomplexTypeの要素「名前」「UpgraderConfigは、」ユニークである必要があります。 "UpgraderConfigContainer"定義に "unique"タグを追加しましたが、目的の動作を得ることができませんでした。
誰でも私が間違っていることについて助言してもらえますか?
<?xml version="1.0"?>
<xs:schema targetNamespace="http://www.hp.com/maas/1.0.0/UpgraderConfig"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:config="http://www.hp.com/maas/1.0.0/UpgraderConfig"
elementFormDefault="qualified"
version="1.0.0">
<xs:simpleType name="stringWithoutWhiteSpace">
<xs:annotation>
<xs:documentation>One or more occurrences of any character which is not whitespace (i.e. not space, tab, newline, return)</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:minLength value="1" />
<xs:pattern value="\S+" />
</xs:restriction>
</xs:simpleType>
<xs:complexType name="UpgraderConfigContainer">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="Upgrader" type="config:UpgraderConfig" >
<xs:unique name="uniqueUgraderName">
<xs:selector xpath="Upgrader"/>
<xs:field xpath="name"/>
</xs:unique>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="UpgraderConfig">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="className" type="config:stringWithoutWhiteSpace"/>
</xs:sequence>
</xs:complexType>
<xs:element name="UpgraderConfigs" type="config:UpgraderConfigContainer" />
</xs:schema>
私は含まれている要素がそれにユニークな制約を持つことしかできないことを知りませんでした。ありがとう、それは実際に動作します。 –