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

Discussion in 'XML' started by Ingrid, Aug 3, 2004.

  1. Ingrid

    Ingrid Guest

    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...???
     
    Ingrid, Aug 3, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve Jorgensen
    Replies:
    0
    Views:
    565
    Steve Jorgensen
    Aug 9, 2005
  2. Replies:
    1
    Views:
    377
  3. tankbattle
    Replies:
    1
    Views:
    838
    George Bina
    Jul 21, 2006
  4. RolfK
    Replies:
    2
    Views:
    479
  5. Manuel Collado
    Replies:
    6
    Views:
    1,431
    Manuel Collado
    Oct 20, 2011
Loading...

Share This Page