Extending an enumerated list

I'm trying to come up with a reasonable way to define an enumerated list 
for content in an element or attribute and also be able to extending that 
list without editing the original schema that my organization publishes. We 
would love a method that works with xsd:redefine but there doesn't seem to 
be a way to do it there - we can restrict the list, but we cannot extend it.

Any ideas? The closest we have come is to set the main schema up to use 
substitution groups, but this has the draw back of creating a new element 
instead of extending the original list.

I got to thinking that I should be able to combine an XML/SGML trick of 
using general entities as I will describe below. This isn't using 
xsd:redefine and if it works it would have the advantage of keeping my 
extensions in a separate file.


Here is how I want to setup the Schema:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsd:schema [
<!-- Define the name and path to an external file - this is the modified 
entities-->
<!ENTITY % entity-defs SYSTEM "ACMEentity-file.xsd">
<!-- Now reference the file into this schema -->
%entity-defs;
]>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns="http://www.ACORD.org/standards/PC_Surety/ACORD1.3.0/xml/" 
elementFormDefault="unqualified" attributeFormDefault="unqualified" 
targetNamespace="http://www.ACORD.org/standards/PC_Surety/ACORD1.3.0/xml/" 
version="1.3.0">
<xsd:complexType name="AddressType">
	<xsd:simpleContent>
		<xsd:restriction base="OpenEnum">
			<xsd:enumeration value="BillingAddress"/>
			<xsd:enumeration value="BranchOffice"/>
			<xsd:enumeration value="PreviousAddress"/>
			<xsd:enumeration value="RecipientAddress"/>
			<xsd:enumeration value="ShippingAddress"/>
			<xsd:enumeration value="StreetAddress"/>
		    &AddressType_entity;
		 </xsd:restriction>
	</xsd:simpleContent>
</xsd:complexType>


Now the entity file would contain this:


<!ENTITY AddressType_entity '
             <xsd:enumeration value="com.acme_CollegeAddress"/>
             <xsd:enumeration value="com.acme_BoardingSchoolOffice"/>
             <xsd:enumeration value="com.acme_StorageLocationAddress"/>
	' >
					
<!ENTITY AirBagStatus_entity ''>
<!ENTITY AirBagType_entity ''>

So far Xerces J and XML Spy do not like this, but is there any reason that 
this is "wrong"? It seems to me to be valid XML and if the XML parser works 
before the schema parser it would seem that the entities would be expanded 
in place before it got to this.

If this worked it would go along way to solving my problem without it 
creating too much overhead or new types or new elements, that too me is the 
wrong result of an extension.

Comments?

..dan
---------------------------------------------------------------------------
Danny Vint
http://www.dvint.com


     

Received on Sunday, 29 June 2003 19:26:09 UTC