- From: George Cristian Bina <george@oxygenxml.com>
- Date: Tue, 28 Nov 2006 10:34:48 +0200
- To: andreas.ebbert-karroum@nokia.com
- Cc: xmlschema-dev@w3.org
Hi,
You can define the base state to be anySimpleType. Then define the
extendedRequestState as a union:
<xs:simpleType name="extendedRequestState">
<xs:union memberTypes="ns0:RequestState">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="open.running.new1"/>
<xs:enumeration value="open.running.new1"/>
<xs:enumeration value="open.running.new1"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
As a side note, in Relax NG that is really easy, assume that the base
schema defines a test element with 2 possible values, all it has to do
is to specify those values in a named pattern and allow it to be
combined with other patterns with the same name:
<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<start>
<element name="test">
<ref name="testValues"/>
</element>
</start>
<define name="testValues" combine="choice">
<choice>
<value>ABORTED</value>
<value>PARTIALLY_COMPLETED</value>
</choice>
</define>
</grammar>
Then the user will include this schema and specify in a testValues
pattern the additional values he wants to be allowed:
<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<include href="test.rng"/>
<define name="testValues" combine="choice">
<choice>
<value>open.running.new1</value>
<value>open.running.new2</value>
<value>open.running.new3</value>
</choice>
</define>
</grammar>
in compact syntax that will be
start = element test { testValues }
testValues |= "ABORTED" | "PARTIALLY_COMPLETED"
and:
include "test.rnc"
testValues |=
"open.running.new1" | "open.running.new2" | "open.running.new3"
Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
andreas.ebbert-karroum@nokia.com wrote:
> Hi,
>
> my problem is the following. I have a complex type that has one attribute that is based on an enumeration. The XML schema that I define is fixed, but a customer/user of that schema should be able to add items to the enumeration in an additional schema.
>
> Currently the approach is:
> 1) use an element reference in the complex type
> 2) have an abstract element of type string
> 3) define a simple type that contains the enum literals based on string
> 4) have another element, that is of simple type and has the abstract element as substitution group.
> 5) Users can extend the enumeration, by repeating step 3&4 in an own schema, and provide a different enumeration simpleType, which ideally includes the enum values of the original/parent simpleType.
>
> Details to the steps are further down.
> My questions are:
> => Is there a better way to do this? For example that a client/user don't have to repeat all existing enums, but can somehow merge them in with a union simple type?
> => How could a complex type definition look like that is an array of the enum, and is also capable of using the customer extension?
>
> 1)
> <complexType name="BusinessInteractionValue">
> <complexContent>
> <extension base="ns3:EntityValue">
> <sequence>
> <element ref="ns0:baseState" minOccurs="0"/>
> </sequence>
> </extension>
> </complexContent>
> </complexType>
>
> 2)
> <element name="baseState" type="string" abstract="true"/>
>
> 3)
> <element name="state" type="ns0:RequestState" substitutionGroup="ns0:baseState"/>
>
> 4)
> <simpleType name="RequestState">
> <restriction base="string">
> <enumeration value="ABORTED"/>
> ...
> <enumeration value="PARTIALLY_COMPLETED"/>
> </restriction>
> </simpleType>
>
> 5) -- in a separate schema --
> <simpleType name="ExtendedRequestState">
> <restriction base="string">
> <enumeration value="ABORTED"/>
> ...
> <enumeration value="PARTIALLY_COMPLETED"/>
> <enumeration value="open.running.new1"/>
> <enumeration value="open.running.new2"/>
> <enumeration value="open.running.new3"/>
> </restriction>
> </simpleType>
> <element name="extendedRequestState" type="aek:ExtendedRequestState" substitutionGroup="om:baseState"/>
>
> _ __ _ _
> //\ndreas.[|-bbert-[]/arroum(a)[|\|okia.com
> `- `
> Andreas Ebbert-Karroum
> Senior Software Design Engineer
> Nokia Networks Services / Middleware
> phone: +49-211-94123928, fax: +49-211-9412-3838
> Heltorfer Straße 1, 40472 Düsseldorf, Germany
>
> ----------------------------------------------------------------------
> This message is confidential. If you have received this message in error,
> please delete it from your system. You should not copy it for any purpose,
> or disclose its contents to any other person. Internet communications are
> not secure and therefore Nokia GmbH does not accept legal responsibility
> for the contents of this message as it has been transmitted over a public
> network. Thank you.
> Nokia GmbH, Nokia Networks is a German Company. Further information
> about the Company is available from its principal offices at
> Heltorferstrasse 1, D-40472, Düsseldorf, Germany and from the
> website at http://www.nokia.com/
> ----------------------------------------------------------------------
>
>
Received on Tuesday, 28 November 2006 08:35:24 UTC