XML Schema Question: attributing an element with a datatype?

Henry S. Thompson ht at cogsci.ed.ac.uk
Fri Feb 4 00:15:09 GMT 2000


Roger Costello <costello at 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 at cogsci.ed.ac.uk
		     URL: http://www.ltg.ed.ac.uk/~ht/

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ or CD-ROM/ISBN 981-02-3594-1
Please note: New list subscriptions and unsubscriptions
are  now ***CLOSED*** in preparation for list transfer to OASIS.





More information about the Xml-dev mailing list