[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] XML Schema Question: attributing an element with a datatype?
Hi Folks, 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> This declares currency to be a required attribute of cost. However, in adding this attribute, we have lost our nice typing of cost to money (i.e., cost of datatype money). Unless I am missing something obvious (which may well be the case), there is no way to specify a datatype for an element as well as assign attributes to it ... I must not be thinking clearly. Can someone tell me how to assign cost the datatype money as well as giving it the attribute currency? To provide more context to my question, I have included below the complete XML Schema which I am trying to enhance to give cost the attribute currency. /Roger ------------------------------------------------------------ juicers.xsd ------------------------------------------------------------ <?xml version="1.0"?> <!DOCTYPE schema SYSTEM "xml-schema.dtd"[ <!ATTLIST schema xmlns:j CDATA #IMPLIED> ]> <schema xmlns="http://www.w3.org/1999/XMLSchema" targetNamespace="http://www.juicers.org" xmlns:j="http://www.juicers.org"> <element name="warranty" type="string"/> <element name="guarantee" equivClass="j:warranty" type="string"/> <type name="appliance"> <element name="description" type="string"/> <element ref="j:warranty"/> </type> <type name="juiceAppliance" source="j:appliance" derivedBy="extension"> <element name="name" type="string"/> <element name="image" type="imageType"/> <element name="weight" type="integer"/> <element name="cost" type="money" maxOccurs="*"/> <element name="retailer" type="uri"/> <attribute name="id" type="ID" minOccurs="1"/> <attribute name="electric" type="boolean" minOccurs="1"/> <attribute name="type" minOccurs="1"> <datatype source="string"> <enumeration value="press"/> <enumeration value="gear"/> <enumeration value="centrifugal"/> </datatype> </attribute> </type> <element name="juicers"> <type> <element name="juicer" type="j:juiceAppliance" minOccurs="0" maxOccurs="*"/> </type> </element> <datatype name="money" source="decimal"> <scale value="2"/> </datatype> <datatype name="imageType" source="string"> <pattern value="(.)*.gif"/> <pattern value="(.)*.jpeg"/> <pattern value="(.)*.jpg"/> <pattern value="(.)*.bmp"/> </datatype> </schema> xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@i... 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.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|