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

RE: Schema definition of element with optional children


define fawcett
You can't declare the type of the element to be conditional on one of its
attributes, unless the attribute has the magic name xsi:type. Your only
options are (a) to define a type that's sufficiently permissive to allow all
the options, and then do extra validation using some other technology, or
(b) to use different element names for the two cases. Alternatively, in this
case you could use the magic xsi:nil attribute to mean status="deleted". 

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: Joe Fawcett [mailto:joefawcett@h...] 
> Sent: 02 May 2006 14:48
> To: xml-dev@l...
> Subject:  Schema definition of element with optional children
> 
> Dear All
> 
> I'm struggling to find the best way to restrict an element 
> that holds address data.
> If the address is to be deleted it will look like this:
> <address recordStatus="deleted"/>
> 
> if it's new or an update it will be along the lines of:
> 
> <address recordStatus="inserted">
>   <addressLine1></addressLine1>
>   <addressLine2></addressLine2>
>   <city></city>
>   <postCode></postCode>
>   <country></country>
> </address>
> 
> with various fields being optional, these are UK addresses only.
> 
> What's the most efficient way to declare this using XSD only 
> as I believe I can't say, "if recordStatus = 'deleted' then..." etc?
> 
> I believe I have to give a choice of two types but this seems tedious?
> 
> Thanks
> 
> Joe
> 
> 
> 
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org 
> <http://www.xml.org>, an initiative of OASIS 
> <http://www.oasis-open.org>
> 
> The list archives are at http://lists.xml.org/archives/xml-dev/
> 
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://www.oasis-open.org/mlmanage/index.php>
> 


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.