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

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"
            xmlns:x="http://www.w3.org/XML/1998/namespace">

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

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

</xsd:schema>

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.

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