Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > DTD to Schema (W3C): Is it possible to combine datatyping at element level and attribute value specifications???

Thread Tools

DTD to Schema (W3C): Is it possible to combine datatyping at element level and attribute value specifications???

Posts: n/a
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:restriction base="xs:token">
<xs:enumeration value="volume_number"/>
<xs:enumeration value="page_range"/>

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


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

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

..... 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...???
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
New to xml schema - does the dtd/schema validation happens always ? pramodr XML 3 04-05-2009 12:10 PM
xml schema to specify element type based on attribute value? James XML 2 07-28-2007 04:11 AM
[XSD] Schema for unknwn element names with known attribute value smoother XML 0 08-02-2006 10:30 PM
In xml schema, what's the difference between attribute "final" and "block" in element "element" tankbattle XML 1 07-21-2006 07:51 AM
Including a dtd into another dtd... possible? Asfand Yar Qazi XML 1 09-19-2003 12:10 PM