whats wrong with this schema ...

Discussion in 'XML' started by shyam, Jun 14, 2006.

  1. shyam

    shyam Guest

    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
     
    shyam, Jun 14, 2006
    #1
    1. Advertising

  2. 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
    ----------------------------------

    *** Sent via Developersdex http://www.developersdex.com ***
     
    Priscilla Walmsley, Jun 14, 2006
    #2
    1. Advertising

  3. shyam

    shyam Guest

    Priscilla Walmsley wrote:
    > 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
     
    shyam, Jun 15, 2006
    #3
  4. 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

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

    *** Sent via Developersdex http://www.developersdex.com ***
     
    Priscilla Walmsley, Jun 15, 2006
    #4
    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. Alexandre Martins

    Whats wrong with this provider ??

    Alexandre Martins, Aug 14, 2003, in forum: ASP .Net
    Replies:
    5
    Views:
    366
    Guenther Liebowitz
    Aug 14, 2003
  2. Markus
    Replies:
    1
    Views:
    1,640
    Markus
    Nov 23, 2005
  3. Matthew
    Replies:
    7
    Views:
    800
    Priscilla Walmsley
    Jan 7, 2005
  4. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,314
    Stanimir Stamenkov
    Apr 25, 2005
  5. TS

    Whats wrong with this schema?

    TS, Feb 13, 2004, in forum: ASP .Net Web Services
    Replies:
    2
    Views:
    190
    Yan-Hong Huang[MSFT]
    Feb 16, 2004
Loading...

Share This Page