W3C home > Mailing lists > Public > xmlschema-dev@w3.org > January 2002

some problems regarding to transforming UML to XML Schema

From: <xiaofeng.wang@ps.ge.com>
Date: Mon, 14 Jan 2002 14:32:43 -0500
Message-ID: <DB5C7DE93F66D3119CAD0008C7E64031037623A6@flmlbx01psge.geips.ge.com>
To: xmlschema-dev@w3.org
Hello everybody:

I found a hard time to map inheritance defined in UML to XML Schema.
Usually, the complex type extension is used for inheritance. Then, two
issues raised:

(1) Use <sequence> or <all> ?
<sequence> specify the order of elements defined in it. But in UML, there is
no such specification for order. Attributes and associations defined in a
class may appear in any order. It seems <all> is good choice (??)

(2) How to use <all>
<all> does provide the flexibility for order. But it has other restrictions.
It seems hard for me to handle multi-level inheritance defined in UML.
Reference [1] shows an example for mapping Inheritance defined in UML to XML
Schema. It looks like:

	<xsd:element name = "Address" type = "Address" abstract = "true"/>
	<xsd:complexType name = "Address" abstract = "true">
		<xsd:all>
			<xsd:element name = "name" type = "xsd:string"/>
			<xsd:element name = "street" type = "xsd:string"/>
			<xsd:element name = "city" type = "xsd:string"/>
		</xsd:all>
	</xsd:complexType>
	<xsd:element name = "USAddress" type = "USAddress" substitutionGroup
= "Address"/>
	<xsd:complexType name = "USAddress">
		<xsd:complexContent>
			<xsd:extension base = "Address">
				<xsd:all>
					<xsd:element name = "state" type =
"xsd:string"/>
					<xsd:element name = "zip" type =
"xsd:positiveInteger"/>
				</xsd:all>
			</xsd:extension>
		</xsd:complexContent>
	</xsd:complexType>

This schema can't pass the validation check, and the error is "groups are
not allowed in ALL element".

But if I change the <all> defined in the base complex type to <sequence>, it
passed the validation check without any error. Could anybody please explain
this? If I define "MyAddress" as a sub-class of "USAddress", can I write the
schema like the following? I changed <all> of base class to <sequence> and
defined "MyAddress" as a child of "USAddress".

	<xsd:element name = "Address" type = "Address" abstract = "true"/>
	<xsd:complexType name = "Address" abstract = "true">
		<xsd:sequence>
			<xsd:element name = "name" type = "xsd:string"/>
			<xsd:element name = "street" type = "xsd:string"/>
			<xsd:element name = "city" type = "xsd:string"/>
		</xsd:sequence>
	</xsd:complexType>
	<xsd:element name = "USAddress" type = "USAddress" substitutionGroup
= "Address"/>
	<xsd:complexType name = "USAddress">
		<xsd:complexContent>
			<xsd:extension base = "Address">
				<xsd:all>
					<xsd:element name = "state" type =
"xsd:string"/>
					<xsd:element name = "zip" type =
"xsd:positiveInteger"/>
				</xsd:all>
			</xsd:extension>
		</xsd:complexContent>
	</xsd:complexType>
	<xsd:element name = "MyAddress" type = "MyAddress"/>
	<xsd:complexType name = "MyAddress">
		<xsd:complexContent>
			<xsd:extension base = "USAddress">
				<xsd:all>
					<xsd:element name = "Mystate" type =
"xsd:string"/>
					<xsd:element name = "Myzip" type =
"xsd:positiveInteger"/>
				</xsd:all>
			</xsd:extension>
		</xsd:complexContent>
	</xsd:complexType>

Reference:
[1] Dave Carlson "Modeling XML Vocabularies with UML, Part I, II, and III,"
<http://www.xml.com/pub/a/2001/08/22/uml.html>
	
Xiaofeng Wang
GE Network Solutions
1990 West NASA Blvd, Melbourne Florida, 32904
Voice: (321)435-5458, Fax: (321)435-5652
xiaofeng.wang@ps.ge.com
Received on Monday, 14 January 2002 14:33:25 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:26 GMT