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

RE: XML schema -- specify a relationship between attributes?

  • To: "Stewart Johnson" <stew@f...>, <xml-dev@l...>
  • Subject: RE: XML schema -- specify a relationship between attributes?
  • From: "Chiusano Joseph" <chiusano_joseph@b...>
  • Date: Mon, 22 Nov 2004 16:29:45 -0500
  • Thread-index: AcTQzZjgrB6QVWbRT5aZhryDXAPyyQACCnng
  • Thread-topic: XML schema -- specify a relationship between attributes?

xml schema relationship
W3C Schema does not have the capability to satisy your requirement -
which is commonly known as a "co-occurrence constraint" requirement.
Your next options would be to consider using Schematron, or to use
programmatic means for this validation.

Kind Regards,
Joseph Chiusano
Booz Allen Hamilton
Strategy and Technology Consultants to the World

> -----Original Message-----
> From: Stewart Johnson [mailto:stew@f...] 
> Sent: Monday, November 22, 2004 2:55 PM
> To: xml-dev@l...
> Subject:  XML schema -- specify a relationship 
> between attributes?
> Hash: SHA1
> Hey All -
> I hope this is an appropriate place for this question.
> I'm stuck while trying to write a schema, hoping someone can 
> provide me with a flash of inspiration.
> One of the elements I'm specifying has two attributes, both 
> of which are optional. I want to express in the schema that 
> there's a relationship between the two -- that the second 
> attribute is optional only if the first one is not specified. ie:
> <myElement /> <!-- valid -->
> <myElement name="A" /> <!-- valid -->
> <myElement myattr="true" /> <!-- invalid because name isn't 
> specified --> <myElement myattr="true" name="A" /> <!-- valid -->
> So far my schema looks like this:
> <element name="myElement">
> 	<complexType>
> 		<attribute name="name" type="string" use="optional" />
> 		<attribute name="myattr" type="boolean" 
> use="optional" default="false" />
> 	</complexType>
> </element>
> That captures the default values and the optional nature of 
> the two elements, but it doesn't capture the relationship 
> between the two. Is there any xsd construct I can use to 
> express the relationship? I know how to do it with elements 
> (xsd:group, xsd:choice) but not with attributes.
> Thanks for any thoughts.
> Stewart
> Version: GnuPG v1.2.5 (MingW32)
> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
> iD8DBQFBokQaBGGH+7lrhRgRAk+oAKC4+mR5pnr++zBCskuxg0O2YaX8rQCeKELI
> zJXUZ6AgGo9ys5L9oN/mSHw=
> =jufi
> -----------------------------------------------------------------
> 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>


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.
First Name
Last Name
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.