Use of Substitution Groups

Henry, Dan, etc.,

Is this the scenario that you are talking about?

personName and personNameWithMiddle are of 2 different types that are in
the substitution group for AbstractPersonName.  It's more interesting
when the personNameWithMiddle is in a different schema doc and
namespace, but this is the heart of it.  

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://www.example.org/name/1" 
      xmlns:namens="http://www.example.org/name/1"> 

 <xs:element name="AbstractPersonName" abstract="true"/>
 <xs:element name="personName" type="namens:nameType"
substitutionGroup="namens:AbstractPersonName"/>
  
 <xs:complexType name="nameType">
	 <xs:sequence minOccurs="0" maxOccurs="unbounded">
		 <xs:choice>
			 <xs:element ref="namens:given" /> 
			 <xs:element ref="namens:family" /> 
		  </xs:choice>
	  </xs:sequence>
	  <xs:anyAttribute namespace="##any" processContents="strict" />

  </xs:complexType>
  
  <xs:element name="given" type="xs:string"/>
  <xs:element name="family" type="xs:string"/>
  
 <xs:complexType name="nameWithMiddleType">
	 <xs:sequence minOccurs="0" maxOccurs="unbounded">
		 <xs:choice>
		   <xs:element ref="namens:given" /> 
		   <xs:element ref="namens:family" /> 
		   <xs:element ref="namens:middle" minOccurs="0"/>
		 </xs:choice>
	 </xs:sequence>
     <xs:anyAttribute namespace="##any" processContents="strict" /> 
  </xs:complexType>
  
  <xs:element name="middle" type="xs:string"/>
  <xs:element name="personNameWithMiddle"
type="namens:nameWithMiddleType"
substitutionGroup="namens:AbstractPersonName"/>
  
</xs:schema>

Cheers,
Dave

Received on Monday, 23 April 2007 19:56:58 UTC