Page 1 of 1

[SOLVED] XSD aggegation of other elements

Posted: Thu Sep 16, 2004 6:14 am
by Jean-Yves
Hi,

Hope this is the right forum to post XML-related questions.

Is it possible to define an XSD (XML Schema) element so that it is an aggregation of two other elements within the same Schema. For example:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
	<xs:element name="example-xsd">
		<xs:complexType>
			<xs:sequence>
				<xs:element name="staff-name" type="xs:string"/>
				<xs:element name="company-name" type="xs:string"/>
				<xs:element name="status" type="xs:string"/>
				<xs:element name="week-commencing" type="xs:date"/>
				<xs:element name="aggregate-key" type="xs:string">
					<xs:annotation>
						<xs:documentation>value = staff-name + "~" + "week-commencing"</xs:documentation>
					</xs:annotation>
				</xs:element>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
</xs:schema>
So in the above example, in an instance ducument of this schema, if staff-name is jean-yves and week-commencing is 01-Jan-2005, then the aggregate key would be jean-yves~01-Jan-2005

This is required for a particular bit of Excel jiggery-pokery. Dont ask, just don't ask! The whole thing should be in Access anyway, but there you go.

Many thanks,
Jean-Yves

Posted: Mon Sep 20, 2004 4:15 am
by Jean-Yves
To answer my own question:

Apparently you cannot do this.