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

Conditional xml Schema

  • To: xml-dev@l...
  • Subject: Conditional xml Schema
  • From: "Jagdishwar B" <jagdishwar.beemanati@g...>
  • Date: Sun, 11 Jun 2006 11:42:32 +0200
  • Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=BKpkXaiHxVJRC/TJYtjI9dHRvDlr3tKS0g5l9+XBnUMRPMBd3aUWowsUq21CVN91g/ovwy0BuLlvwkEyJC8q4YQGvZUK/dUNorH6wo3qvmLCmutqcRd+6X5mcsRuppr0I04lhMO2oXUDeoRgwrumxcSfydBr2QdmeoW7qsZmiXc=

xml schema conditional
Hi all,

Is it possible to define the xml schema (xsd) conditionally based on
certain values.

For e.g.
My xml document is:
	<fruit myAttr="Apple">
	<fruit myAttr="Mango">

the xsd file should define the structure (i mean put the constraints)
in such a way that:
if the <fruit> element has myAttr="Apple", then it should force to
have <elementApple1> child element, and
if the <fruit> element has myAttr="Mango", then it should force to
have <elementMango1> child element

I created following schema,

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
	<xs:element name="fruit">
				<xs:element name="elementApple1" type="xs:string"/>
				<xs:element name="elementMango1" type="xs:string"/>
			<xs:attribute name="myAttr" type="xs:string" use="required"></xs:attribute>
	<xs:element name="myRoot">
				<xs:element ref="fruit" maxOccurs="unbounded"/>

but the above schema is allowing '<fruit myAttr="Apple">' to contain
'<elementMango1>' child element.

basically i would like to have different structure for the <fruit>
elements depending upon the vaule present in myAttr attribute.

Thanks in advance.
Jagdishwar B


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.