[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
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! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|