Re: Problems with the namespace of substitution groups

"Martin Bryan" <mtbryan@sgml.u-net.com> writes:

> I'm having trouble making substitution groups work. In the specification the
> example given of a substitution group has
> 
> <xs:element name="facet" type="xs:facet" abstract="true"/>
> 
>  <xs:element name="encoding" substitutionGroup="xs:facet">
> 
> where facet has been defined using <xs:complexType name="facet">
> 
> I'm trying to work out what the significance of the addition of the xs:
> namespace to the type definition for the abstract element and for the
> substitutionGroup attribute.

All references to definitions and declarations in XML Schema are via
qualified names (QNames).  Since 'facet' is a name in the XML Schema
namespace (which names both a (complex) type and an element),
references to it must be qualified with that namespace.

> Could this be something to do with the reason
> that if I try to import a file containing just the complexType and abstract
> element definitions into a schema that is designed to instatiate the
> abstract instances I start getting error messages from XML Spy?

Could be, I suppose.  Sample files would help diagnose the problem.
The following is a sketch of what I take it you have in mind

core.xsd:

<xs:schema targetNamespace="http://www.example.com/core"
           xmlns:c="http://www.example.com/core"
           xmlns:xs="http://www.w3.org/2000/10/XMLSchema">
 <xs:complexType name="t1">
    . . .
 </xs:complexType>

 <xs:element name="ce1" abstract="true" type="c:t1"/>

 . . .

</xs:schema>

example.xsd:

<xs:schema targetNamespace="http://www.example.com/local"
           xmlns:l="http://www.example.com/local"
           xmlns:c="http://www.example.com/core"
           xmlns:xs="http://www.w3.org/2000/10/XMLSchema">

 <xs:import namespace="http://www.example.com/core"
            schemaLocation="core.xsd"/>

 <xs:complexType name="l1">
  <xs:complexContent>
   <xs:extension base="c:t1">
    . . .
   </xs:extension>
  </xs:complexContent>
 </xs:complexType>

 <xs:element name="le1" type="l:l1" substitutionGroup="c:ce1"/>

 . . .

</xs:schema>


> What is the relationship of the name space of an abstract element or
> complexType definition to the targetNamespace and the null namespace
> (xmlns=...)  properties of the containing schemas?

I hope the above example clarifies this.  Declarations and definitions 
in a schema document _always_ declare/define things with names in the
targetNamespace of the <schema> document element which contains them.

ht
-- 
  Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
          W3C Fellow 1999--2001, part-time member of W3C Team
     2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
	    Fax: (44) 131 650-4587, e-mail: ht@cogsci.ed.ac.uk
		     URL: http://www.ltg.ed.ac.uk/~ht/

Received on Friday, 26 January 2001 07:24:00 UTC