[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Newbie Schema Restriction Question


xsd restriction complextype
I'm deriving types from UBL, some of which have elements which are required
by the specification.  I would like to derive the element types using
restriction, and use the derived types instead of the base types.  For
example, I'd like to derive MyLineItemType from restriction of the UBL
LineItemType and use MyLineItemType as an element within MyOrderLineType,
which is derived from a restriction of the UBL OrderLineType. However, when
I do this, I get the following error from the JAXB xjc utility:

[ERROR] rcase-RecurseLax.2: There is not a complete functional mapping
between t
he particles.
  line 20 of
file:/D:/Documents%20and%20Settings/chgtg6h/workspace/Order%20Inter
face/src/xsd/annotated/test/Child.xsd

[ERROR] derivation-ok-restriction.5.4.2: Error for type 'ChildType'.  The
partic
le of the type is not a valid restriction of the particle of the base.
  line 20 of
file:/D:/Documents%20and%20Settings/chgtg6h/workspace/Order%20Inter
face/src/xsd/annotated/test/Child.xsd


Here are the Schema files which I am using to test my requirements:

Parent.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  targetNamespace="parent"
  xmlns="parent"
  elementFormDefault="qualified"
  attributeFormDefault="unqualified">
  <xsd:import namespace="http://www.w3.org/2001/XMLSchema"
schemaLocation="http://www.w3.org/2001/XMLSchema"/>
  <xsd:element name="Parent" type="ParentType"/>
  <xsd:element name="Element" type="ElementType"/>
  <xsd:element name="String" type="xsd:string"/>
  <xsd:complexType name="ElementType">
    <xsd:sequence>
      <xsd:element ref="String" minOccurs="0" maxOccurs="1"></xsd:element>
    </xsd:sequence>
  </xsd:complexType>
  <xsd:complexType name="ParentType">
    <xsd:sequence>
      <xsd:element ref="Element" minOccurs="1" maxOccurs="1"></xsd:element>
    </xsd:sequence>
  </xsd:complexType>
</xsd:schema>

Child.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  targetNamespace="child"
  xmlns="child"
  xmlns:parent="parent"
  elementFormDefault="qualified"
  attributeFormDefault="unqualified">
  <xsd:import namespace="parent" schemaLocation="Parent.xsd"/>
  <xsd:import namespace="http://www.w3.org/2001/XMLSchema"
schemaLocation="http://www.w3.org/2001/XMLSchema"/>
  <xsd:element name="Child" type="ChildType"/>
  <xsd:element name="Element" type="RestrictedElementType"
substitutionGroup="parent:Element"/>
  <xsd:complexType name="RestrictedElementType">
    <xsd:complexContent>
      <xsd:restriction base="parent:ElementType">
        <xsd:sequence>
          <xsd:element ref="parent:String" minOccurs="1"
maxOccurs="1"></xsd:element>
        </xsd:sequence>
      </xsd:restriction>
    </xsd:complexContent>
  </xsd:complexType>
  <xsd:complexType name="ChildType">
    <xsd:complexContent>
      <xsd:restriction base="parent:ParentType">
        <xsd:sequence>
          <xsd:element ref="Element" minOccurs="1"
maxOccurs="1"></xsd:element>
        </xsd:sequence>
      </xsd:restriction>
    </xsd:complexContent>
  </xsd:complexType>
</xsd:schema>


Why can't I do this?  In this situation, the element "Element" in
"ChildType" has a type which is valid derivation of the "ElementType" in my
parent schema.  In the OO paradigm which I am familiar with, this is
perfectly legal.  For example, here is essentially the same situation in
Java:

Parent.java:
public class Parent {
	
	private Object element;
	
	public Object getElement() {
		return element;
	}
}

Child.java:
public class Child extends Parent {
	
	private String element;
	
	@Override
	public String getElement() {
		return element;
	}
}

Please help figure out how to accomplish my requirements in Schema.

Thanks!

John Schneider
ERP Analyst
Carrier Corporation
john.a.schneider@c...

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.