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

XML Schema: Extension and Restriction from a Mixed Complex Type Base Typ

  • From: "Paul Hermans" <paul.hermans@a...>
  • To: <xml-dev@l...>
  • Date: Fri, 25 Jul 2008 10:20:46 +0200

XML Schema: Extension and Restriction from a Mixed Complex Type Base Typ
I need to start and derive from following datatype.

<xs:complexType name="SimpleLiteral">
    <xs:annotation>
      <xs:documentation xml:lang="en"> This is the default type. It
        permits text content only with optional xml:lang attribute. 
        Text is allowed because
        mixed="true", but sub-elements are disallowed because minOccurs="0" and maxOccurs="0" are on
        the xs:any tag. 
        This complexType allows for restriction or extension permitting child
        elements. </xs:documentation>
    </xs:annotation>
    <xs:complexContent mixed="true">
      <xs:restriction base="xs:anyType">
        <xs:sequence>
          <xs:any processContents="lax" minOccurs="0" maxOccurs="0"/>
        </xs:sequence>
        <xs:attribute ref="xml:lang" use="optional"/>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>
  
  This is fine for instance elements such as:
  <a xml:lang="en">abcdefg</a>
  
  But in one case I need to have following model:
  <a>
    <b>2008-12-12</b>
    <c>2008-12-14</c> <!-- optional -->
  </a>
  
  In a normal world modeled as:
  <xs:complexType name="Temporal">
    <xs:sequence>
      <xs:element name="a" type="xs:date"/>
      <xs:element name="b" type="xs:date" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>
  
  Now my derivation approach:
  1) First extending by allowing elements
  <xs:complexType name="SimpleLiteralExtended">
    <xs:complexContent mixed="true">
      <xs:extension base="SimpleLiteral">
        <xs:sequence>
          <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  
  So far, so good.
  
  2) Restricting, getting rid of mixed, of the xml:lang attribute, and being more specific for the elements.
  <xs:complexType name="SimpleLiteralExtendedRestricted">
    <xs:complexContent>
      <xs:restriction base="SimpleLiteralExtended">
        <xs:sequence>
          <xs:element name="a" type="xs:date"/>
          <xs:element name="b" type="xs:date" minOccurs="0"/>
        </xs:sequence>
        <xs:attribute ref="xml:lang" use="prohibited"/>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>
  
  In Xerces-Java this leads to following error:
  "E [Xerces] derivation-ok-restriction.5.4.2: Error for type 'SimpleLiteralExtendedRestricted'.  
  The particle of the type is not a valid restriction of the particle of the base."
  
  If I comment out the second line, the error disappears.
  <xs:sequence>
          <xs:element name="a" type="xs:date"/>
          <!-- <xs:element name="b" type="xs:date" minOccurs="0"/> -->
  </xs:sequence>
  
  Can someone explain this behavior or is it a Xerces issue?
  
  The same works without problems in Saxon-SA.
  
  
  Paul
  


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


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.