Enumerations inside elements with attributes

Here is a sample instance document:

<fruit>apple</fruit>

The XSD for it looks like:

<element name="fruit>
	<simpleType base="string">
		<enumeration name="apple"/>
		<enumeration name="orange"/>
		<enumeration name="peach"/>
	</simpleType>
</element>

As you would expect, very straight forward.  The enumerated list
{apple,organge,peach} only ever occurs inside of the "fruit" element, so
the simpleType is declared annonymously.  Now take a second example:

<fruit source="Canada">apple</fruit>

Source is some string

Following the format of the above schema fragment, one would naively
expect the following to work:

<element name="fruit">
	<complexType base="string" deriveBy="extension">
		<attribute name="source" type="string"/>
		<enumeration name="apple"/>
		<enumeration name="orange"/>
		<enumeration name="peach"/>
	</complexType>
</element>

The use of a simpleType as the base of the complexType and the
'deriveBy="extension"' attribute should be enough to allow enumerations
to exist inside the complexType.  There is no ambiguity of what the
enumeration applies to.  The problem is that XSV reports that
enumerations are not allowed inside complexTypes, so I am forced to do
the following:

<element name="fruit">
	<complexType base="FruitEnumeration" deriveBy="extension>
		<attribute name="source" type="string"/>
	</complexType>
</element>

<simpleType name="FruitEnumeration" base="string">
	<enumeration name="apple"/>
	<enumeration name="orange"/>
	<enumeration name="peach"/>
</simpleType>

My problem is that I do NOT want to generate "FruitEnumeration".  In my
specific problem, these schemas are being generated in an automated
fashion, and only certain types should have to be named, and the rest
declared anonymously.  I would very much like to know if I have
overlooked some issue that would avoid having to explicitly create a
named simpleType containing the enumeration.  Even something like the
following would be OK:

<element name="fruit">
	<complexType base="string" deriveBy="extension">
		<attribute name="source" type="string"/>
		<simpleType base="string">
			<enumeration name="apple"/>
			<enumeration name="orange"/>
			<enumeration name="peach"/>
		<simpleType>
	</complexType>
</element>

Since the XSDL WD suggests that all facets and enumerations ARE
permitted inside a complexType element, I am confused as to whether this
is an XSV implementation issue, or an inconsistency in the WD.

Regards,

Ian Stokes-Rees

-- 
ian.stokes-rees@decisionsoft.com          tel: +1865 203 192
DecisionSoft Ltd.                         fax: +1865 203 194
www.decisionsoft.com                      Oxford, UK, OX2 OEA

Received on Tuesday, 29 August 2000 10:52:36 UTC