[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
XML Schema: Extension and Restriction from a Mixed Complex Type Base Type
- From: "Paul Hermans" <paul.hermans@amplexor.com>
- To: <xml-dev@lists.xml.org>
- Date: Fri, 25 Jul 2008 10:20:46 +0200
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]