RE: Restricting a substitution group using <choice>

On the subject:

I'm trying to figure out  how  the <choice> equivalent of substitution
groups can accommodate the addition of new members. 

I've encountered a situation where I need to restrict the membership of a
substitution group in type "ns1:A" and then, in type "ns2:A" which extends
type "ns1:A", to have the benefit of including new substitution group
members that are added in ns2.

<xs:schema targetNamespace="ns1" xmlns="ns1"
xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
attributeFormDefault="unqualified">

	<xs:element name="E"  abstract="true"/>
	<xs:element name="E1" substitutionGroup="E"/>
	<xs:element name="E2" substitutionGroup="E"/>
	<xs:element name="E3" substitutionGroup="E"/>

	<xs:complexType name="Base">
		<xs:sequence>
			<xs:element name="X"/>
			<xs:element ref="E" />
			<xs:element name="Y"/>
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="A">
		<xs:complexContent>
			<xs:restriction base="Base">
				<xs:sequence>
					<xs:element name="X"/>

					<xs:choice maxOccurs="unbounded">
<!-- Restrict substitution group "E" here -->
						<xs:element ref="E1"/>
						<xs:element ref="E2"/>
					</xs:choice>
					<xs:element name="Y"/>
				</xs:sequence>
			</xs:restriction>
		</xs:complexContent>
	</xs:complexType>
</xs:schema>

<xs:schema targetNamespace="ns2" xmlns:ns1="ns1" xmlns="ns2"
xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
attributeFormDefault="unqualified">
	<xs:import namespace="ns1" schemaLocation="example-ns1.xsd"/>

	<xs:element name="E4" substitutionGroup="ns1:E"/> <!-- New element
E4 for substitution group ns1:E -->

	<xs:complexType name="A">
		<xs:complexContent>
			<xs:extension base="ns1:A"/> <!-- Would like choice
to include ns2:E4 -->
		</xs:complexContent>
	</xs:complexType>
</xs:schema>

I know I could build ns2:A off of ns1:Base and then re-restrict. But what if
ns1:A contains extensions or restrictions that belong as part of ns2:A? Will
I have to maintain ns1:A and ns2:A separately and remember to replay edits
from ns1:A on ns2:A?

Thanks

Mark



----------------------------------------------------------------------------
----
 
Mark Feblowitz                                   [t] 617.715.7231
Frictionless Commerce Incorporated     [f] 617.495.0188 
XML Architect                                     [e]
mfeblowitz@frictionless.com
400 Technology Square, 9th Floor 
Cambridge, MA 02139 
www.frictionless.com  
 

 

Received on Friday, 15 March 2002 13:14:45 UTC