- From: Eoin Shanaghy <eoinshanaghy@iol.ie>
- Date: Tue, 25 Jun 2002 16:56:56 -0400 (EDT)
- To: <xmlschema-dev@w3.org>
Hi, I have been given an XML schema which looks like the one below. The purpose is to have an element, "base" which can be substituted by elements containing any complexType implementation, for example, "sub". Is it possible to accomplish this? Xerces (1.4.4) gives these errors: ERROR: org.xml.sax.SAXParseException: Schema error: Anonymous complexType: src-ct.2: Cannot find type definition for 'xs:base'. ERROR: org.xml.sax.SAXParseException: Schema error: Element sub which is part of a substitution must have a type which derives from the type of the element at the head of the substitution group. It seems that the extension for "sub" has to be the same type as "base", but how did I extend the anonymous complexType?? Thanks, Eoin <schema targetNamespace="http://www.demo.com/sample" elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.demo.com/sample"> <element name="root"> <complexType> <all> <element name="attrA" type="string"/> <element ref="xs:base"/> </all> </complexType> </element> <element name="base"> <complexType/> </element> <element name="sub" substitutionGroup="xs:base"> <complexType> <complexContent> <extension base="xs:base"> <all> <element name="subAttr" minOccurs="1"/> </all> </extension> </complexContent> </complexType> </element> </schema> Sample XML instance =================== <?xml version="1.0" encoding="UTF-8" ?> <root xmlns="http://www.demo.com/sample"> <attrA>Value here</attrA> <sub> <subAttr>Hello!</subAttr> </sub> </root>
Received on Wednesday, 26 June 2002 03:54:21 UTC