[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XML Schema - Enumerated List to Allow Blank Value


xml enumerated list
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@l...
>   Tel: 571.633.7722
> ************************************************************************** 
>
>
>



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.