W3C home > Mailing lists > Public > xmlschema-dev@w3.org > September 2000

Re: Global attributes from other namespaces, how to use?

From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
Date: 29 Sep 2000 08:57:46 +0100
To: ramesh@eNode.com
Cc: <xmlschema-dev@w3.org>
Message-ID: <f5b3dij7hqd.fsf@cogsci.ed.ac.uk>
ramesh@eNode.com writes:

This list is for schema processor implementors -- please send general
schema questions to another list, e.g. xml-dev.

> I need to define a complex type called Title, in which I have to use the
> global attributes xml:lang and xlink:type from their respective namespaces.
> How do I do that?
> Is this the proper way? What should I put for the XML namespace?
> <xsd:complexType name="Title">
>     <xsd:simpleContent>
>         <xsd:extension base="xsd:string">
>             <!-- Add xml:lang="en-US" global attribute -->
>             <xsd:attribute
>                     name="lang"
>                     namespace="What should I put here for XML1.0?"
>                     type="xsd:language"
>                     use="default" value="en-US"/>
>             <!-- Add xlink:type="title" global attribute -->
>             <xsd:attribute
>                     name="type"
>                     namespace="http://www.w3.org/1999/xlink"
>                     type="xsd:string"
>                     use="fixed" value="title"/>
>         </xsd:extension>
>     </xsd:simpleContent>
> </xsd:complexType>

If you actually want the global attributes, you have to reference
them.  The above will not work.

<xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"

<xsd:import namepace="http://www.w3.org/XML/1998/namespace"/>

<xsd:complexType name="Title">
        <xsd:extension base="xsd:string">
            <!-- Add xml:lang="en-US" global attribute -->
            <xsd:attribute ref="x:lang" use="optional"/>


That will do you for a non-defaulted use of xml:lang.  XLink is harder 
because there's no schema yet, and defaulting xml:lang is harder
because you have to define your own schema for the xml: namespace.

  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, 29 September 2000 03:57:48 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:14:47 UTC