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

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   XML schema -- specify a relationship between attributes?

[ Lists Home | Date Index | Thread Index ]
  • To: xml-dev@lists.xml.org
  • Subject: XML schema -- specify a relationship between attributes?
  • From: Stewart Johnson <stew@fatcaterpillar.org>
  • Date: Tue, 23 Nov 2004 03:55:06 +0800
  • User-agent: Mozilla Thunderbird 0.9 (Windows/20041103)

-----BEGIN PGP SIGNED MESSAGE-----
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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBokQaBGGH+7lrhRgRAk+oAKC4+mR5pnr++zBCskuxg0O2YaX8rQCeKELI
zJXUZ6AgGo9ys5L9oN/mSHw=
=jufi
-----END PGP SIGNATURE-----




 

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

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