W3C home > Mailing lists > Public > www-xml-schema-comments@w3.org > October to December 2000

Re: Extension of xsd:element.

From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
Date: 15 Nov 2000 15:32:44 +0000
To: Reinier Bos <rbos@baan.nl>
Cc: "'www-xml-schema-comments@w3.org'" <www-xml-schema-comments@w3.org>
Message-ID: <f5b3dgtxnc3.fsf@cogsci.ed.ac.uk>
Reinier Bos <rbos@baan.nl> writes:

> I'm wondering whether I'd be able to (validly) use the following schema:
> 
> <?xml version="1.0" encoding="UTF-8"?> 
> <xsd:schema targetNamespace="http://www.baan.com/xyz" 
>             xmlns:xyz="http://www.baan.com/xyz" 
>             xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"> 
> 
> 
>     <!-- Extend the default element with an 'x' attribute --> 
>     <xsd:complexType name="element"> 
>         <xsd:complexContent> 
>              <xsd:extension base="xsd:element"> 
>                   <xsd:attribute name="x" type="xsd:boolean" use="default"
> value="false"/> 
>              </xsd:extension> 
>         </xsd:complexContent> 
>     </xsd:complexType> 
> </xsd:schema> 

This isn't quite what you want, for two reasons:

 1) You haven't redefined xsd:element, you've defined a new type
called xyz:element, which is not the type of any element (so far);

 2) The schema for XML Schemas has the 'blockDefault' attribute set to 
'#all', which means you can't use any types you derive from type
defined therein.

> I was hoping that this would allow me to write something like this in
> another schema: 
> 
>  . 
>   . 
>    . 
>  <xsd:sequence> 
>      <xyz:element name="..." x="true"/> 
>  <xsd:sequence> 
>    .
>   .

You can already do very nearly that, without going to all this
trouble.  The schema for XML Schema derives almost all types from a
type which contains <anyAttribute namespace="##other"/>, so the
following is already acceptable without _any_ extra declarations:

  <xsd:sequence>
   <xsd:element name="..." xyz:x="true" .../>
  </xsd:sequence>

Hope this helps.

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 Wednesday, 15 November 2000 10:32:53 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Sunday, 6 December 2009 18:12:49 GMT