OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Versioning of Enums

[ Lists Home | Date Index | Thread Index ]

It appears to be a common practice when, if you have a schema which includes 
a volatile code-list (enumeration), to externalise it into its own 
[chameleon] schema and then include that schema into the main [transaction] 
schema. I just wanted to see whether others have experience of using this 
approach and if any issues arise from it ?

In our case the enumerated values of of type xs:string (not sure if this 
matters but it might)

We also get our schema from a standards body who define the standard market 
values. Naturally :-) my business colleagues are not always satisfied with 
that and want to both extend and restrict the values used. So in this case I 
am thinking of :-

a. creating another schema to contain OUR custom enum values
b. creating another schema that imports my custom codes and the market 
standard and :-
    - contains a type which is a restriction of the market standard enum
    - contains a type which is a union of the restricted market standard and 
custom enum.

Does this seems reasonable ? here's a rough example using the oft described 
'currency code' example :-

Market Standard Schema (BaseCodes.xsd)
===============

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
elementFormDefault="qualified" version="1.0">
	<xs:simpleType name="iso3currency">
		<xs:annotation>
			<xs:documentation>ISO-4217 3-letter currency codes. Only a subset are 
defined here.</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:length value="3"/>
			<xs:enumeration value="AUD"/>
			<xs:enumeration value="BRL"/>
			<xs:enumeration value="CAD"/>
			<xs:enumeration value="CNY"/>
			<xs:enumeration value="EUR"/>
			<xs:enumeration value="GBP"/>
			<xs:enumeration value="INR"/>
			<xs:enumeration value="JPY"/>
			<xs:enumeration value="RUR"/>
			<xs:enumeration value="USD"/>
		</xs:restriction>
	</xs:simpleType>
</xs:schema>

My Custom Schema (MYCurrencyCodes.xsd)
============

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
xmlns="http://www.someorg.com/ws/2006/02/codelists"; 
targetNamespace="http://www.someorg.com/ws/2006/02/codelists"; 
elementFormDefault="qualified" attributeFormDefault="unqualified">
	<xs:simpleType name="iso3currency">
		<xs:restriction base="xs:string">
			<xs:length value="3"/>
			<xs:enumeration value="abc"/>
			<xs:enumeration value="def"/>
			<xs:enumeration value="ghi"/>
			<xs:enumeration value="jkl"/>
			<xs:enumeration value="mno"/>
			<xs:enumeration value="pqr"/>
			<xs:enumeration value="stu"/>
			<xs:enumeration value="vwx"/>
			<xs:enumeration value="yza"/>
		</xs:restriction>
	</xs:simpleType>
</xs:schema>

The schema to INCLUDE in the main transaction (CombinedCurrencyCodes.xsd)
=============================

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
xmlns:my="http://www.someorg.com/ws/2006/02/codelists"; 
elementFormDefault="qualified" attributeFormDefault="unqualified">
	<xs:include schemaLocation="BaseCodes.xsd"/>
	<xs:import namespace="http://www.someorg.com/ws/2006/02/codelists"; 
schemaLocation="MYCurrencyCodes.xsd"/>
	<xs:simpleType name="iso3currencyRestricted">
		<xs:restriction base="iso3currency">
			<xs:enumeration value="CNY"/>
			<xs:enumeration value="EUR"/>
			<xs:enumeration value="GBP"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="MYiso3currency">
		<xs:union memberTypes="iso3currencyRestricted my:iso3currency"/>
	</xs:simpleType>
</xs:schema>

The main schema
===========

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
xmlns="urn:www.polaris-uk.co.uk/codelist/example" 
targetNamespace="urn:www.polaris-uk.co.uk/codelist/example" 
elementFormDefault="qualified">
	<xs:include schemaLocation="CombinedCurrencyCodes.xsd"/>
	<xs:element name="accountSummary">
		<xs:complexType>
			<xs:sequence>
				<xs:element ref="timestamp"/>
				<xs:element ref="currency"/>
				<xs:element ref="balance"/>
				<xs:element ref="interest"/>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:element name="timestamp" type="xs:dateTime"/>
	<xs:element name="currency" type="MYiso3currency"/>
	<xs:element name="balance" type="xs:decimal"/>
	<xs:element name="interest">
		<xs:complexType>
			<xs:simpleContent>
				<xs:extension base="xs:decimal">
					<xs:attribute name="rounding" type="roundingDirection" use="required"/>
				</xs:extension>
			</xs:simpleContent>
		</xs:complexType>
	</xs:element>
	<xs:simpleType name="roundingDirection">
		<xs:annotation>
			<xs:documentation>Whether the interest is rounded up, down, or to the 
nearest round value.</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:enumeration value="up"/>
			<xs:enumeration value="down"/>
			<xs:enumeration value="nearest"/>
		</xs:restriction>
	</xs:simpleType>
</xs:schema>






 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS