Conditional typing

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 UTC