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

Re: XML Schema Question: attributing an element with a datatype?

From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
Date: 04 Feb 2000 00:15:05 +0000
To: Roger Costello <costello@mitre.org>
Cc: xml-dev@ic.ac.uk, www-xml-schema-comments@w3c.org, jcs@mitre.org
Message-ID: <f5b9011akmu.fsf@cogsci.ed.ac.uk>
Roger Costello <costello@mitre.org> writes:

> I have created an XML Schema document for juice machines. Part of the
> description of each juice machine is its cost. One of the first things
> that I did is create a money datatype:
> 
>     <datatype name="money" source="decimal">
>         <scale value="2"/>
>     </datatype>
> 
> Then, I declared the cost element to be of type money:
> 
>     <element name="cost" type="money"/>
> 
> Seems reasonable, right?  Well, the next thing that I wanted to do was
> to add an attribute - currency - to the cost element.  This is where I
> ran into problems.  Attributes are typically declared like this:
> 
>     <element name="cost">
>         <type>
>             <attribute name="currency" type="string" minOccurs="1"/> 
>         <type>
>     </element>

    <element name="cost">
        <type source="money" derivedBy="extension">
            <attribute name="currency" type="string" minOccurs="1"/> 
        <type>
    </element>

is the solution you are looking for.

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 Thursday, 3 February 2000 19:15:10 GMT

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