XML.com: XML From the Inside Out

XML.comWebServices.XML.comO'Reilly Networkoreilly.com
  Articles | Weblogs | Newsletter | Safari Bookshelf
advertisement

Article:
 Understanding W3C Schema Complex Types
Subject: From DTD to W3C Schema... combining datatyping and attribute values
Date: 2004-08-03 04:59:33
From: Ingrid

Am I right in thinking that datatyping at element level ie <xs:element name="num" type="xs:integer">


and specifying a choice of attribute values ie


<xs:attribute name="kind">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="volume_number"/>
<xs:enumeration value="page_range"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>


......does not go together??????


**************************


Setting out to convert the following DTD element specification...
<!ELEMENT num (#PCDATA | emph)*>
<!ATTLIST num
kind (volume_number | page_range) #REQUIRED>


... into Schema....
<xs:element name="num">
<xs:complexType mixed="true">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="emph"/>
</xs:sequence>
<xs:attribute name="kind" use="required">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="volume_number"/>
<xs:enumeration value="page_range"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>


.... I realised, that if I want to make use of the additional datatyping capabilites of Schema (ie adding a datatype of xs:integer to the element "num" to allow numerical element content only, for example), I cannot at the same time specify a choice of required attribute values, i.e. volume_number and page_range for this element. As soon as I give the element a datatype
ie <xs:element name="num" type="xs:integer"> no further child element or attribute specifications are allowed...


I know I can set the integer at the attribute level, which means that the data needs to be entered within the <num ...."31"> tag rather than between an opening and closing
<num kind="volume_number">31</num>
but the element is part of a digitisation project template for transcribers and the idea is, to set up the template in such a way that it can check data entry at element level, ie keyers only need to enter data between element tags, not at attribute level....


I guess I am stuck with adding child elements to the <num> element ie <volume_number> <page_range> and add some datatyping to these...???




Previous Message Previous Message   Next Message Next Message

Sponsored By:


Contact Us | Our Mission | Privacy Policy | Advertise With Us | | Submissions Guidelines
Copyright © 2008 O'Reilly Media, Inc. | (707) 827-7000 / (800) 998-9938