W3C home > Mailing lists > Public > xmlschema-dev@w3.org > December 2002

defining the complex type of an element depending on the value of an attribute

From: Ernesto Wandeler <ernesto@wandeler.ch>
Date: Mon, 02 Dec 2002 10:23:30 -0800
Message-ID: <3DEBA522.7080804@wandeler.ch>
To: xmlschema-dev@w3.org


i am currently defining an XML Schema for a programming language which
is represented in XML and which was already used for some time without
any DTD or XML Schema.

now i would like to know whether it is possible to define the
complexType of an element depending on the value of an attribute of the

for example i have an element named <Expr> with an attribute named
"kind" and if "kind" equals "UnaryOp" then it must contain one <Op>
element and one <Expr> element. but if "kind" equals "BinaryOp" then it
must contain one <Expr> element followed by any number of <Op> and
<Expr> comibinations.

the XML could look for example like this:

<Expr kind="BinOpSeq">
	<Expr kind="UnaryOp">
		<Op name="dom"/>
		<Expr kind="Var" name="a"/>
	<Op name="!="/>
	<Expr kind="Set"/>
	<Op name="or"/>
	<Expr kind="UnaryOp">
		<Op name="dom"/>
		<Expr kind="Var" name="s"/>
	<Op name="!="/>
	<Expr kind="Set"/>

i think i could use a number of complexTypes inside a choice element but
then how could i link the choice to the attribute value of the parent

thank you very much for any help!


Ernesto Wandeler

Department of Electrical Engineering and Computer Science
University of California at Berkeley
545M Cory Hall
Berkeley, CA 94720-1770

Work:   +1 510 642 6873
Home:   +1 510 898 1565
Mobile: +41 76 349 4972
E-Mail: ernesto@wandeler.ch
Received on Monday, 2 December 2002 13:25:04 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:07 UTC