Pierre Attar wrote:
>
> I've got the following schema code :
> <xs:element name="ChoixEnumereMultiple">
> <xs:complexType>
> <xs:attribute name="type"
> type="ChoixEnumereMultipleType" use="required"/>
> </xs:complexType>
> </xs:element>
> <xs:simpleType name="ChoixEnumereMultipleType">
> <xs:restriction base="xs:NMTOKENS">
> <xs:enumeration value="choix1"/>
> <xs:enumeration value="choix2"/>
> <xs:enumeration value="choix3"/>
> </xs:restriction>
> </xs:simpleType>
>
> And I try to validate the following instance having two NMTOKEN
> separated by a space : <ChoixEnumereMultiple type="choix2 choix3"/>
>
>
> XSDVAlid answers :
> attribute "type" has invalid value "choix2 choix3": "choix2 choix3" is
> not one of the allowed values [cvc-enumeration-valid] [cvc-attribute.3]
>
>
> It seems that this is an error because it is possible to restrict
> NMTOKENS by an enumeration of values in an attribute.
Yes, it is possible to restrict NMTOKENS by an enumeration of values in
an attribute. You did it.
> Any idea of the problem ?
Yes, you have restricted the value of the *list* of NMTOKENS to be
"choix1" OR "choix2" OR "choix3". "choix2 choix3" is clearly *not* one
of the 3 valid choices.
Intuitively, the diagnostic of xsdvalid is 100% correct. Now, given the
complexity of the semantics of W3C XML Schema, may be you are right and
there is a bug in xsdvalid. (I'll not attempt to check this. Please ask
experts.)
> By the way, if someone is using other method, feel free to tell me your
> solution because I'm not fully glad with this one. What I try to de is
> to find the best base type that enable either multiple choice or single
> choice while defining context usages of the enumeration.
Pleas consider using what follows which, IMHO, feels much more ``natural'':
---
<xs:simpleType name="TypeChoixEnumere">
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="choix1"/>
<xs:enumeration value="choix2"/>
<xs:enumeration value="choix3"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="ChoixEnumereMultipleType">
<xs:restriction>
<xs:simpleType>
<xs:list itemType="TypeChoixEnumere" />
</xs:simpleType>
<xs:minLength value="1" />
</xs:restriction>
</xs:simpleType>
---
-------------- next part --------------
A non-text attachment was scrubbed...
Name: enum.xsd
Type: text/xml
Size: 718 bytes
Desc: not available
Url :
http://www.xmlmind.com/pipermail/xmleditor-support/attachments/20060703/4f95bf1a/attachment.xml
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tenum.xml
Type: text/xml
Size: 168 bytes
Desc: not available
Url :
http://www.xmlmind.com/pipermail/xmleditor-support/attachments/20060703/4f95bf1a/attachment-0001.xml