whats wrong with this schema ...

S

shyam

Hi ALL

Just started to learm Schemas and I am stuck with this


==================================================================
<xs:complexType>
.......
<xs:sequence>
......
<xs:element name="ABNFRULESET" type="xs:token" maxOccurs="1">
<xs:simpleType>
<xs:list itemType="xs:token">
<xs:restriction base="xs:token">
<xs:pattern value="\p{IsBasicLatin}*"/>
</xs:restriction>
</xs:list>
</xs:simpleType>
</xs:element>
......
</xs:sequence>
.......
</xs:complexType>

==================================================================

The validator says

"The 'http://www.w3.org/2001/XMLSchema:restriction' element is not
supported in this context."

Basically what I intend to do is to have it accept list of tokens with
the restriction that the tokens should be of english language
characters

for example

<ABNFRULESET>
"hello" world / [ are u there ]
</ABNFRULESET>

I am not able to figure out how to put this restriction in the list in
another way

thanks
Shyam
 
P

Priscilla Walmsley

Hi,

You almost had it. You need an extra xs:simpleType element in there.
Also, you don't want to use itemType - it's an either/or thing - either
you specify the itemType attribute OR a simpleType child.

<xs:element name="ABNFRULESET" type="xs:token" maxOccurs="1">
<xs:simpleType>
<xs:list>
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:pattern value="\p{IsBasicLatin}*"/>
</xs:restriction>
</xs:simpleType>
</xs:list>
</xs:simpleType>
</xs:element>

Some more examples of list types are at:

http://www.datypic.com/books/defxmlschema/chapter11.html

Hope that helps,
Priscilla
 
S

shyam

Priscilla said:
Hi,

You almost had it. You need an extra xs:simpleType element in there.
Also, you don't want to use itemType - it's an either/or thing - either
you specify the itemType attribute OR a simpleType child.

<xs:element name="ABNFRULESET" type="xs:token" maxOccurs="1">
<xs:simpleType>
<xs:list>
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:pattern value="\p{IsBasicLatin}*"/>
</xs:restriction>
</xs:simpleType>
</xs:list>
</xs:simpleType>
</xs:element>

Some more examples of list types are at:

http://www.datypic.com/books/defxmlschema/chapter11.html

Hope that helps,
Priscilla

----------------------------------
Priscilla Walmsley
Author, Definitive XML Schema
XQuery
http://www.datypic.com
----------------------------------



Thanks Priscilla Actually I figured this out before I saw your post but
now I have a bigger problem

I have now fully composed my xsd which is as follows

================================================================
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3schools.com"
xmlns="http://www.w3schools.com" elementFormDefault="qualified">
<xs:element name="PROTOHEADERENTRY">
<xs:complexType>
<xs:sequence>
<xs:element name="ABNFGRAMMER" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="ABNFRULESET" maxOccurs="1">
<xs:simpleType>
<xs:list>
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:pattern value="\p{IsBasicLatin}*"/>
</xs:restriction>
</xs:simpleType>
</xs:list>
</xs:simpleType>
</xs:element>
<xs:element name="ABNFEXCEPTION" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="RULENAME" type="xs:token"/>
<xs:attribute>
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="MANDATORY"/>
<xs:enumeration value="IGNORESEQ"/>
<xs:enumeration value="IGNORECASE"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="NAME" type="xs:token"/>
<xs:attribute name="HEADERSEQNUM" type="positiveInteger"/>
</xs:complexType>
</xs:element>
<xs:element name="ABNFBASIC">
<xs:complexType>
<xs:sequence>
<xs:element name="RULESTRING" type="xs:string" maxOccurs="1"/>
</xs:sequence>
<xs:attribute name="ABNFBASICNAME" type="NMTOKEN"/>
</xs:complexType>
</xs:element>
<xs:element name="ABNFRULE">
<xs:complexType>
<xs:sequence>
<xs:element name="RULESTRING" type="xs:string" maxOccurs="1"/>
</xs:sequence>
<xs:attribute name="RULENAME" type="NMTOKEN"/>
</xs:complexType>
</xs:element>
<xs:element name="PROTOHEADER">
<xs:complexType>
<xs:attribute name="PROTOHEADERNAME" type="xs:token"/>
<xs:attribute name="ENTRYSEQNUM" type="xs:positiveInteger"/>
</xs:complexType>
</xs:element>
<xs:element name="PROTODEF">
<xs:complexType>
<xs:sequence>
<xs:element name="PROTOTABLE">
<xs:complexType>
<xs:sequence>
<xs:element ref="PROTOHEADER" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element ref="PROTOHEADERENTRY" maxOccurs="unbounded"/>
<xs:element ref="ABNFRULE" maxOccurs="unbounded"/>
<xs:element ref="ABNFBASIC" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="PROTOCOLNAME" type="xs:token"/>
<xs:attribute name="PROJECTNAME" type="xs:string"/>
</xs:complexType>
<xs:key name="KEYHEADERNUM">
<xs:selector xpath="PROTOHEADERENTRY"/>
<xs:field xpath="HEADERSEQNUM"/>
</xs:key>
<xs:keyref name="KEYENTRYNUM">
<xs:selector xpath="PROTOHEADER"/>
<xs:field xpath="ENTRYSEQNUM"/>
</xs:keyref>
</xs:element>
</xs:schema>
===============================================================

And now when I give it to the validator I get the following

=============================================================
For attribute '???', either the name or the ref attribute must be
present, but not both.

If ref is present, all of 'simpleType', 'form', 'type', and 'use' must
be absent.

The referring attribute must be present.
=============================================================
This is the web based validator at the w3school site and it doesnt show
the line numbers so I cant figure out where exactly is the problem.

Ant help will be appreciated

Also can someone point me to a good freeware which can validate xsd

thanks
Shyam
 
P

Priscilla Walmsley

Hi Shyam,

The second attribute of ABNFEXCEPTION doesn't have a name, only a
simpleType child. That must be the problem.

Hope that helps,
Priscilla
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top