Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Extensible enumerations in XML Schema

From: George Cristian Bina <george@---------.--->
To: andreas.ebbert-karroum@-----.---
Date: 11/28/2006 12:35:00 PM
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
www.---.com


andreas.ebbert-karroum@n... wrote:
> Hi,
> 
> my problem is the following. I have a complex type that has one attribu=
te 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 e=
numeration 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 el=
ement as substitution group.
> 5) Users can extend the enumeration, by repeating step 3&4 in an own sc=
hema, and provide a different enumeration simpleType, which ideally inclu=
des 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 d=
on't have to repeat all existing enums, but can somehow merge them in wit=
h 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:ExtendedRequestStat=
e" 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=DFe 1, 40472 D=FCsseldorf, Germany 
> 
> ----------------------------------------------------------------------
> This message is confidential. If you have received this message in erro=
r,
> please delete it from your system. You should not copy it for any purpo=
se,
> or disclose its contents to any other person. Internet communications a=
re
> not secure and therefore Nokia GmbH does not accept legal responsibilit=
y
> for the contents of this message as it has been transmitted over a publ=
ic
> 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=FCsseldorf, Germany and from the
> website at http://www.nokia.com/
> ----------------------------------------------------------------------
> 
> 


From andreas.ebbert-karroum@n... Tue Nov 28 09:39:36 2006
Received: from maggie.w3.org ([193.51.208.68])
	by frink.w3.org with esmtp (Exim 4.50)
	id 1GozRA-0003EJ-BE
	for xmlschema-dev@l...


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent