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

Conditional typing

From: Piccand Régis <regis.piccand@imtf.ch>
Date: Mon, 11 Feb 2002 10:17:58 +0100
Message-ID: <DF7EC83D7AFBD411965B0008C7596EC53ED578@imtfexchange.imtf.ch>
To: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
Hi all,

I'm trying to write a schema which allows an element to be of different
types, depending on the value of an attribute.

In details, I'm describing an electronic document, which <content> can be
either base64 binary or textual. Up to now, I used two different elements
that where in a choice section, like follows :


<xs:complexType>
	<xs:choice>
		<xs:element name="binary" type="xs:base64Binary"/>
		<xs:element name="text" type="xs:string"/>
	</xs:choice>
</xs:complexType>



Now, I'd like to use an attribute to say whether the content is bases64 or
textual.

	<xs:element name="test">
		<xs:complexType>
			<xs:attribute name="type" use="required">
				<xs:simpleType>
					<xs:restriction base="xs:string">
						<xs:enumeration
value="base64"/>
						<xs:enumeration
value="text"/>
					</xs:restriction>
				</xs:simpleType>
			</xs:attribute>
		</xs:complexType>
	</xs:element>

- Is this possible to do that in the actual version of xmlschema ?
- If not, is it planned to allow this kind of functionality ?
- Is it recommended to use "non-standard" schema languages (schematron ??) ?


Thanks in advance for your advices.

Régis
Received on Monday, 11 February 2002 04:25:00 GMT

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