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

Hi

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
element?

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"/>
	</Expr>
	<Op name="!="/>
	<Expr kind="Set"/>
	<Op name="or"/>
	<Expr kind="UnaryOp">
		<Op name="dom"/>
		<Expr kind="Var" name="s"/>
	</Expr>
	<Op name="!="/>
	<Expr kind="Set"/>
</Expr>

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
element?

thank you very much for any help!

cheers
ernesto



-- 
----------------------------------------------------------------------
Ernesto Wandeler

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

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:35 GMT