Restrictions in XML Schema

P

Paul Johnston

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
 
J

jesper.tverskov

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top