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

Re: XML Schema: Extension and Restriction from a MixedComplex

  • From: George Cristian Bina <george@o...>
  • To: Paul Hermans <paul.hermans@a...>
  • Date: Fri, 25 Jul 2008 12:30:32 +0300

Re:  XML Schema: Extension and Restriction from a MixedComplex
Hi Paul,

Xerces follows the rules specified in the XML Schema 1.0 specification 
and in your case there is clearly no complete mapping from

<xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>

to

<xs:element name="a" type="xs:date"/>
<xs:element name="b" type="xs:date" minOccurs="0"/>

See point 2 from
http://www.w3.org/TR/xmlschema-1/#rcase-Recurse
2 There is a complete ·order-preserving· functional mapping from the 
particles in the {particles} of R to the particles in the {particles} of 
B such that all of the following must be true:
2.1 Each particle in the {particles} of R is a ·valid restriction· of 
the particle in the {particles} of B it maps to as defined by Particle 
Valid (Restriction) (§3.9.6).
2.2 All particles in the {particles} of B which are not mapped to by any 
particle in the {particles} of R are ·emptiable· as defined by Particle 
Emptiable (§3.9.6).

If you change the extended type as below then the restriction should work:

<xs:complexType name="SimpleLiteralExtended">
         <xs:complexContent mixed="true">
             <xs:extension base="SimpleLiteral">
                 <xs:sequence>
                     <xs:any processContents="lax"/>
                     <xs:any processContents="lax" minOccurs="0" 
maxOccurs="unbounded"/>
                 </xs:sequence>
             </xs:extension>
         </xs:complexContent>
     </xs:complexType>

Best Regards,
George
-- 
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Paul Hermans wrote:
> 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
>   
> 
> _______________________________________________________________________
> 
> XML-DEV is a publicly archived, unmoderated list hosted by OASIS
> to support XML implementation and development. To minimize
> spam in the archives, you must subscribe before posting.
> 
> [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
> Or unsubscribe: xml-dev-unsubscribe@l...
> subscribe: xml-dev-subscribe@l...
> List archive: http://lists.xml.org/archives/xml-dev/
> List Guidelines: http://www.oasis-open.org/maillists/guidelines.php
> 


[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.