XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
RE: [xml-dev] XML Schema: Extension and Restriction from a Mixed Complex Type Base Type

Hi George,

Thanks for the explanation.

It's interesting to note that of the whole collection of parsers I'm using (Saxon-SA, libXML, MS XML 6.0, .NET, XSV, Xerces) only Xerces throws the error.

Paul




-----Original Message-----
From: George Cristian Bina [mailto:george@oxygenxml.com]
Sent: Fri 25-7-2008 11:30
To: Paul Hermans
Cc: xml-dev@lists.xml.org
Subject: Re: [xml-dev] XML Schema: Extension and Restriction from a Mixed Complex Type Base Type
 
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@lists.xml.org
> subscribe: xml-dev-subscribe@lists.xml.org
> 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]


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

Copyright 1993-2007 XML.org. This site is hosted by OASIS