[SOLVED] XSD aggegation of other elements

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
User avatar
Jean-Yves
Forum Contributor
Posts: 148
Joined: Wed Jul 02, 2003 2:13 pm
Location: West Country, UK

[SOLVED] XSD aggegation of other elements

Post 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
Last edited by Jean-Yves on Mon Sep 20, 2004 4:15 am, edited 1 time in total.
User avatar
Jean-Yves
Forum Contributor
Posts: 148
Joined: Wed Jul 02, 2003 2:13 pm
Location: West Country, UK

Post by Jean-Yves »

To answer my own question:

Apparently you cannot do this.
Post Reply