W3C home > Mailing lists > Public > xmlschema-dev@w3.org > June 2002

Substitution Group

From: Eoin Shanaghy <eoinshanaghy@iol.ie>
Date: Tue, 25 Jun 2002 16:56:56 -0400 (EDT)
To: <xmlschema-dev@w3.org>
Message-ID: <HDEFINCOABHJGGCOPHOMKEAGCBAA.eoinshanaghy@iol.ie>


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
containing any complexType implementation, for example, "sub".  Is it
possible to accomplish

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??


<schema targetNamespace="http://www.demo.com/sample"

      <element name="root">
                     <element name="attrA" type="string"/>
                     <element ref="xs:base"/>

      <element name="base">

      <element name="sub" substitutionGroup="xs:base">
                   <extension base="xs:base">
                            <element name="subAttr" minOccurs="1"/>

Sample XML instance

<?xml version="1.0" encoding="UTF-8" ?>

<root xmlns="http://www.demo.com/sample">
    <attrA>Value here</attrA>
Received on Wednesday, 26 June 2002 03:54:21 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:57 UTC