OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   RE: [xml-dev] Newbie Schema Restriction Question

[ Lists Home | Date Index | Thread Index ]

You may also wish to ask this on the UBL-DEV list, where you may get a
response from folks who may have had the same observation.

Joe

Joseph Chiusano
Associate
Booz Allen Hamilton
 
700 13th St. NW, Suite 1100
Washington, DC 20005
O: 202-508-6514  
C: 202-251-0731
Visit us online@ http://www.boozallen.com

-----Original Message-----
From: Schneider, John Adam CAR [mailto:John.A.Schneider@carrier.utc.com]

Sent: Friday, April 21, 2006 2:51 PM
To: xml-dev@lists.xml.org
Subject: [xml-dev] Newbie Schema Restriction Question

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@carrier.utc.com

-----------------------------------------------------------------
The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
initiative of OASIS <http://www.oasis-open.org>

The list archives are at http://lists.xml.org/archives/xml-dev/

To subscribe or unsubscribe from this list use the subscription
manager: <http://www.oasis-open.org/mlmanage/index.php>




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS