Restrictions in XML Schema

Discussion in 'XML' started by Paul Johnston, Nov 8, 2006.

  1. Hi
    Working my way through "Learning XML" by Erik Ray and have a question
    if someone can help me.
    Using Oxygen 7.2
    Doing the section on XML Schema

    And have a problem with the section below which raise the error:
    E s4s-elt-invalid-content.1: The content of '#AnonType_age' is
    invalid. Element 'restriction' is invalid, misplaced, or occurs too
    often.

    <xs:element name="age">
    <xs:complexType>
    <xs:restriction base="xs:integer">
    <xs:minInclusive value="0"/>
    <xs:maxInclusive value="200"/>
    </xs:restriction>
    </xs:complexType>
    </xs:element>


    It parses if I use:

    <xs:element name="age">
    <xs:simpleType>
    <xs:restriction base="xs:integer">
    <xs:minInclusive value="0"/>
    <xs:maxInclusive value="200"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>

    Am I allowed to place a restriction on a simpleType but not a
    complexType as it seems ?

    TIA Paul
     
    Paul Johnston, Nov 8, 2006
    #1
    1. Advertising

  2. Paul Johnston

    Guest

    Hi Paul

    A complexType means that the element has elements as content or both
    elements and data and or attributes. Since you have only specified data
    as content it is not a complexType but a simpleType.

    Cheers,

    Jesper Tverskov
    www.xmltraining.biz


    On Nov 8, 10:45 am, Paul Johnston <>
    wrote:
    > Hi
    > Working my way through "Learning XML" by Erik Ray and have a question
    > if someone can help me.
    > Using Oxygen 7.2
    > Doing the section on XML Schema
    >
    > And have a problem with the section below which raise the error:
    > E s4s-elt-invalid-content.1: The content of '#AnonType_age' is
    > invalid. Element 'restriction' is invalid, misplaced, or occurs too
    > often.
    >
    > <xs:element name="age">
    > <xs:complexType>
    > <xs:restriction base="xs:integer">
    > <xs:minInclusive value="0"/>
    > <xs:maxInclusive value="200"/>
    > </xs:restriction>
    > </xs:complexType>
    > </xs:element>
    >
    > It parses if I use:
    >
    > <xs:element name="age">
    > <xs:simpleType>
    > <xs:restriction base="xs:integer">
    > <xs:minInclusive value="0"/>
    > <xs:maxInclusive value="200"/>
    > </xs:restriction>
    > </xs:simpleType>
    > </xs:element>
    >
    > Am I allowed to place a restriction on a simpleType but not a
    > complexType as it seems ?
    >
    > TIA Paul
     
    , Nov 20, 2006
    #2
    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. Jean-Marie Condom
    Replies:
    2
    Views:
    415
    Jean-Marie Condom
    Nov 26, 2004
  2. Markus
    Replies:
    1
    Views:
    1,637
    Markus
    Nov 23, 2005
  3. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,312
    Stanimir Stamenkov
    Apr 25, 2005
  4. ruediger
    Replies:
    0
    Views:
    589
    ruediger
    May 6, 2006
  5. sqlsurfing
    Replies:
    0
    Views:
    894
    sqlsurfing
    Jan 27, 2010
Loading...

Share This Page