[
Lists Home |
Date Index |
Thread Index
]
Greetings xml-dev
I've been looking at a way to use xsd:union to extend
a list of enumerated values (a codelist in this case) as
follows:
<xsd:schema
xmlns="urn:oasis:names:prototype:ubl:schema:xsd:CurrencyCode-2.1"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:oasis:names:prototype:ubl:schema:xsd:CurrencyCode-2.1"
xmlns:cur="urn:un:unece:uncefact:codelist:draft:54217:2001"
xmlns:ccts="urn:oasis:names:draft:ubl:schema:xsd:CoreComponentParameters-1.1
"
elementFormDefault="qualified" attributeFormDefault="unqualified"
version="Ext">
<!-- ===== Imports ===== -->
<xsd:import namespace="urn:un:unece:uncefact:codelist:draft:54217:2001"
schemaLocation="../../../LatestDraft-UBL-2.0/xsdrt/common/CodeList_CurrencyC
ode_ISO_7_04.xsd"/>
<!-- ===== Type Definitions ===== -->
<xsd:simpleType name="CurrencyCodeContentType">
<xsd:union memberTypes="cur:CurrencyCodeContentType
ExtCurrencyCodeContentType" />
</xsd:simpleType>
<xsd:simpleType name="ExtCurrencyCodeContentType">
<xsd:restriction base="xsd:normalizedString">
<xsd:enumeration value="FQD" />
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
where the imported schema contains the original enumerated list I'm
extending
<xsd:schema
targetNamespace="urn:un:unece:uncefact:codelist:draft:54217:2001"
xmlns:clm54217="urn:un:unece:uncefact:codelist:draft:54217:2001"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xsd:simpleType name="CurrencyCodeContentType">
<xsd:restriction base="xsd:token">
<xsd:enumeration value="AED"/>
<xsd:enumeration value="AFN"/>
...
<xsd:enumeration value="ZMK"/>
<xsd:enumeration value="ZWD"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
Is this a valid derivation from the original CurrencyCodeContentType ?
I ask because when I try to create a substitutionGroup based in the derived
type
substituting an element based on the original type I find that the Microsoft
Development Environment 2003 (for VS.NET 2003) throws an error claiming
that the derivation isn't valid.
I'm aware that there is variation still in how parsers support
substitutionGroups
and maybe that is the problem here, but equally I'd like any confirmation
folk
can give:
that this is a tool error and/or
that the derivation using union is sufficient for use in a substitution
group
My substitution looks like this:
<xsd:element name="PricingCurrencyCode"
substitutionGroup="cbc:PricingCurrencyCode" type="PricingCurrencyCodeType"
/>
...
<xsd:complexType name="PricingCurrencyCodeType">
<xsd:simpleContent>
<xsd:extension base="sdt2-1:CurrencyCodeType"/>
</xsd:simpleContent>
</xsd:complexType>
where the sdt21:CurrencyCodeType looks like
<xsd:complexType name="CurrencyCodeType">
<xsd:simpleContent>
<xsd:extension base="cur:CurrencyCodeContentType">
<xsd:attribute name="listID" type="xsd:normalizedString" fixed="4217"
use="optional"/>
...
<xsd:attribute name="listSchemeURI" type="xsd:anyURI"
fixed="urn:oasis:names:prototype:ubl:schema:xsd:CurrencyCode-Ext"
use="optional"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
The error message I get tells me:
C:\Documents and
Settings\admin\Desktop\SubstitutionGroups\Prototype-UBL-2.1\xsdrt\common\UBL
-CommonBasicComponents-2.1.xsd(21):
'urn:oasis:names:prototype:ubl:schema:xsd:CommonBasicComponents-2.1:PricingC
urrencyCode' cannot be a member of substitution group with head element
'urn:oasis:names:draft:ubl:schema:xsd:CommonBasicComponents-2.0:PricingCurre
ncyCode'. An error occurred at C:\Documents and
Settings\admin\Desktop\SubstitutionGroups\Prototype-UBL-2.1\xsdrt\common\UBL
-CommonBasicComponents-2.1.xsd, (21, 3).
C:\Documents and
Settings\admin\Desktop\SubstitutionGroups\Prototype-UBL-2.1\xsdrt\common\UBL
-CommonBasicComponents-2.1.xsd(40): Invalid attribute restriction. An error
occurred at file:///C:/Documents and
Settings/admin/Desktop/SubstitutionGroups/Prototype-UBL-2.1/xsdrt/common/UBL
-SpecializedDatatypes-2.1.xsd, (40, 10).
XML Spy 2005 gives no such error and valids an instance with
...
<cbc:Note>sample</cbc:Note>
<cbc2-1:PricingCurrencyCode>FQD</cbc2-1:PricingCurrencyCode>
<cbc:LineExtensionTotalAmount
currencyID="GBP">100.00</cbc:LineExtensionTotalAmount>
...
as valid.
I attach a set of schemas which I've been using (zip file with extension
renamed to .zzz).
Many thanks
Stephen Green
SDG_SubstitutionGroups_20050718.zzz
|