OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] XML Schema - Enumerated List to Allow Blank Value

[ Lists Home | Date Index | Thread Index ]

Hi Joe,

> I seem to recall that there was a posting on this a while back, but I 
> could not locate it in the archives.
>
> What I need to do is simple:  To be able to specify in a W3C Schema 
> that an element can be one of X listed values, or blank.  I seem to 
> recall that there was a union between an <xsd:restriction 
> base="xsd:NMTOKEN"> with X values listed, and an <xsd:restriction 
> base="xsd:NMTOKEN"> with no values listed (or something to that effect).
>
Since the xs:NMTOKEN datatype don't allow an empty value I don't think 
you can create this as a union between two types that use xs:NMTOKEN as 
the base type. However, you can easily to this by creating a union of 
one enumerated xs:NMTOKEN type and one empty xs:string type. Here is an 
example:

<xs:simpleType name="myEnum">
    <xs:union>
        <xs:simpleType>
            <xs:restriction base="xs:NMTOKEN">
                <xs:enumeration value="A"/>
                <xs:enumeration value="B"/>
                <xs:enumeration value="C"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType>
            <xs:restriction base="xs:string">
                <xs:enumeration value=""/>
            </xs:restriction>
        </xs:simpleType>
    </xs:union>
</xs:simpleType>

Cheers,
/Eddie

> Thanks in advance,
> Joe Chiusano
> LMI
>
>
> ************************************************************************** 
>
>   Joseph M. Chiusano
>   Logistics Management Institute
>   2000 Corporate Ridge
>   McLean, VA 22102
>   Email: jchiusano@lmi.org
>   Tel: 571.633.7722
> ************************************************************************** 
>
>
>






 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS