Very basic question re: schema. Please advise...

Discussion in 'XML' started by austris.bahanovskis@gmail.com, Mar 11, 2007.

  1. Guest

    Hi,

    I must apollgize beforehand for the basic question but i was strugling
    to get my code fixed. I also must admit that this is my first .xml
    attempt and i failed to find answers on MS support site or searching
    this group.

    So, i can't get the schema right for this datafile.
    Data file:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <country xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="country2.xsd">
    <entry>
    <name>China</name>
    <population>22.2</population>
    <continent>Asia</continent>
    </entry>
    <entry>
    <name>France</name>
    <population>12</population>
    <continent>Europe</continent>
    </entry>
    </country>

    And this is the schema (i'm sure i'm getting the ComplexType/child/
    parent tags wrong):

    <xs:schema
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="country" type="Country"/>
    <xs:complexType name="Country">
    <xs:sequence>
    <xs:element name="entry" type="Entry"/>
    <xs:complexType name="Entry">
    <xs:sequence>
    <xs:element name="name" type="xs:string"/>
    <xs:element name="population" type="xs:decimal"/>
    <xs:element name="continent" type="xs:string"/>
    </xs:sequence>
    </xs:complexType>
    </xs:sequence>
    </xs:complexType>
    </xs:schema>

    I just haven't figured out the logic behind grouping the elements in
    the schema file - any advise would be greatly appreciated.

    Thanks!
    A.
    , Mar 11, 2007
    #1
    1. Advertising

  2. Guest

    On 11 Mar, 00:34, ""
    <> wrote:
    > Hi,
    >
    > ...
    > And this is the schema (i'm sure i'm getting the ComplexType/child/
    > parent tags wrong):
    >
    > <xs:schema
    > xmlns:xs="http://www.w3.org/2001/XMLSchema">
    > <xs:element name="country" type="Country"/>
    > <xs:complexType name="Country">
    > <xs:sequence>
    > <xs:element name="entry" type="Entry"/>
    > <xs:complexType name="Entry">
    > <xs:sequence>
    > <xs:element name="name" type="xs:string"/>
    > <xs:element name="population" type="xs:decimal"/>
    > <xs:element name="continent" type="xs:string"/>
    > </xs:sequence>
    > </xs:complexType>
    > </xs:sequence>
    > </xs:complexType>
    > </xs:schema>
    >
    > I just haven't figured out the logic behind grouping the elements in
    > the schema file - any advise would be greatly appreciated.


    You can either do:

    <xs:schema
    xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <xs:element name="country" type="Country"/>

    <xs:complexType name="Country">
    <xs:sequence>
    <xs:element name="entry">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="name" type="xs:string"/>
    <xs:element name="population" type="xs:decimal"/>
    <xs:element name="continent" type="xs:string"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>

    </xs:schema>

    Or (possibly better):

    <xs:schema
    xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <xs:element name="country" type="Country"/>

    <xs:complexType name="Country">
    <xs:sequence>
    <xs:element name="entry" type="Entry"/>
    </xs:sequence>
    </xs:complexType>

    <xs:complexType name="Entry">
    <xs:sequence>
    <xs:element name="name" type="xs:string"/>
    <xs:element name="population" type="xs:decimal"/>
    <xs:element name="continent" type="xs:string"/>
    </xs:sequence>
    </xs:complexType>

    </xs:schema>

    Note that a named complexType can only be at the global level (a
    direct child of the <schema> element). If you want a complexType to
    be local to an element, then don't give it a name, don't use type= on
    the <element> element, and have the complexType a child of the
    <element> element.

    HTH,

    Pete.
    --
    =============================================
    Pete Cordell
    Tech-Know-Ware Ltd
    for XML to C++ data binding visit
    http://www.tech-know-ware.com/lmx/
    http://www.codalogic.com/lmx/
    =============================================
    , Mar 12, 2007
    #2
    1. Advertising

  3. Guest

    On Mar 12, 9:27 am, wrote:
    > On 11 Mar, 00:34, ""
    >
    >
    >
    > <> wrote:
    > > Hi,

    >
    > > ...
    > > And this is the schema (i'm sure i'm getting the ComplexType/child/
    > > parent tags wrong):

    >
    > > <xs:schema
    > > xmlns:xs="http://www.w3.org/2001/XMLSchema">
    > > <xs:element name="country" type="Country"/>
    > > <xs:complexType name="Country">
    > > <xs:sequence>
    > > <xs:element name="entry" type="Entry"/>
    > > <xs:complexType name="Entry">
    > > <xs:sequence>
    > > <xs:element name="name" type="xs:string"/>
    > > <xs:element name="population" type="xs:decimal"/>
    > > <xs:element name="continent" type="xs:string"/>
    > > </xs:sequence>
    > > </xs:complexType>
    > > </xs:sequence>
    > > </xs:complexType>
    > > </xs:schema>

    >
    > > I just haven't figured out the logic behind grouping the elements in
    > > the schema file - any advise would be greatly appreciated.

    >
    > You can either do:
    >
    > <xs:schema
    > xmlns:xs="http://www.w3.org/2001/XMLSchema">
    >
    > <xs:element name="country" type="Country"/>
    >
    > <xs:complexType name="Country">
    > <xs:sequence>
    > <xs:element name="entry">
    > <xs:complexType>
    > <xs:sequence>
    > <xs:element name="name" type="xs:string"/>
    > <xs:element name="population" type="xs:decimal"/>
    > <xs:element name="continent" type="xs:string"/>
    > </xs:sequence>
    > </xs:complexType>
    > </xs:element>
    > </xs:sequence>
    > </xs:complexType>
    >
    > </xs:schema>
    >
    > Or (possibly better):
    >
    > <xs:schema
    > xmlns:xs="http://www.w3.org/2001/XMLSchema">
    >
    > <xs:element name="country" type="Country"/>
    >
    > <xs:complexType name="Country">
    > <xs:sequence>
    > <xs:element name="entry" type="Entry"/>
    > </xs:sequence>
    > </xs:complexType>
    >
    > <xs:complexType name="Entry">
    > <xs:sequence>
    > <xs:element name="name" type="xs:string"/>
    > <xs:element name="population" type="xs:decimal"/>
    > <xs:element name="continent" type="xs:string"/>
    > </xs:sequence>
    > </xs:complexType>
    >
    > </xs:schema>
    >
    > Note that a named complexType can only be at the global level (a
    > direct child of the <schema> element). If you want a complexType to
    > be local to an element, then don't give it a name, don't use type= on
    > the <element> element, and have the complexType a child of the
    > <element> element.
    >
    > HTH,
    >
    > Pete.
    > --
    > =============================================
    > Pete Cordell
    > Tech-Know-Ware Ltd
    > for XML to C++ data binding visithttp://www.tech-know-ware.com/lmx/http://www.codalogic.com/lmx/
    > =============================================



    Thanks Pete!
    But it still says (in both cases) when I refresh the list (with
    validation) in .xls:
    Error Code : -1072898028
    URL : >not-supplied>
    Reason : Element 'entry' is unexpected according to content model of
    parent element ' country'.
    Line : 0
    Column : 0
    File Offset : 0

    Any idea?

    It goes without saying that your help is greately appreciated!

    Austris
    , Mar 12, 2007
    #3
  4. Guest

    On 12 Mar, 19:34, ""
    <> wrote:
    > On Mar 12, 9:27 am, wrote:
    > > On 11 Mar, 00:34, ""

    >
    > > <> wrote:

    > ...
    > > Or (possibly better):

    >
    > > <xs:schema
    > > xmlns:xs="http://www.w3.org/2001/XMLSchema">

    >
    > > <xs:element name="country" type="Country"/>

    >
    > > <xs:complexType name="Country">
    > > <xs:sequence>
    > > <xs:element name="entry" type="Entry"/>
    > > </xs:sequence>
    > > </xs:complexType>

    >
    > > <xs:complexType name="Entry">
    > > <xs:sequence>
    > > <xs:element name="name" type="xs:string"/>
    > > <xs:element name="population" type="xs:decimal"/>
    > > <xs:element name="continent" type="xs:string"/>
    > > </xs:sequence>
    > > </xs:complexType>

    >
    > > </xs:schema>

    >
    >
    > Thanks Pete!
    > But it still says (in both cases) when I refresh the list (with
    > validation) in .xls:
    > Error Code : -1072898028
    > URL : >not-supplied>
    > Reason : Element 'entry' is unexpected according to content model of
    > parent element ' country'.
    > Line : 0
    > Column : 0
    > File Offset : 0
    >
    > Any idea?
    >
    > It goes without saying that your help is greately appreciated!
    >
    > Austris- Hide quoted text -
    >
    > - Show quoted text -


    This is a problem with the number of occurences of entry that the
    schema is expecting the xml instance to have.

    Try changing the line:

    <xs:element name="entry" type="Entry"/>

    to:

    <xs:element name="entry" type="Entry" minOccurs="0"
    maxOccurs="unbounded"/>

    HTH,

    Pete.
    --
    =============================================
    Pete Cordell
    Tech-Know-Ware Ltd
    for XML to C++ data binding visit
    http://www.tech-know-ware.com/lmx/
    http://www.codalogic.com/lmx/
    =============================================
    , Mar 12, 2007
    #4
  5. Guest

    On Mar 12, 8:42 pm, wrote:
    > On 12 Mar, 19:34, ""
    >
    >
    >
    > <> wrote:
    > > On Mar 12, 9:27 am, wrote:
    > > > On 11 Mar, 00:34, ""

    >
    > > > <> wrote:

    > > ...
    > > > Or (possibly better):

    >
    > > > <xs:schema
    > > > xmlns:xs="http://www.w3.org/2001/XMLSchema">

    >
    > > > <xs:element name="country" type="Country"/>

    >
    > > > <xs:complexType name="Country">
    > > > <xs:sequence>
    > > > <xs:element name="entry" type="Entry"/>
    > > > </xs:sequence>
    > > > </xs:complexType>

    >
    > > > <xs:complexType name="Entry">
    > > > <xs:sequence>
    > > > <xs:element name="name" type="xs:string"/>
    > > > <xs:element name="population" type="xs:decimal"/>
    > > > <xs:element name="continent" type="xs:string"/>
    > > > </xs:sequence>
    > > > </xs:complexType>

    >
    > > > </xs:schema>

    >
    > > Thanks Pete!
    > > But it still says (in both cases) when I refresh the list (with
    > > validation) in .xls:
    > > Error Code : -1072898028
    > > URL : >not-supplied>
    > > Reason : Element 'entry' is unexpected according to content model of
    > > parent element ' country'.
    > > Line : 0
    > > Column : 0
    > > File Offset : 0

    >
    > > Any idea?

    >
    > > It goes without saying that your help is greately appreciated!

    >
    > > Austris- Hide quoted text -

    >
    > > - Show quoted text -

    >
    > This is a problem with the number of occurences of entry that the
    > schema is expecting the xml instance to have.
    >
    > Try changing the line:
    >
    > <xs:element name="entry" type="Entry"/>
    >
    > to:
    >
    > <xs:element name="entry" type="Entry" minOccurs="0"
    > maxOccurs="unbounded"/>
    >
    > HTH,
    >
    > Pete.
    > --
    > =============================================
    > Pete Cordell
    > Tech-Know-Ware Ltd
    > for XML to C++ data binding visithttp://www.tech-know-ware.com/lmx/http://www.codalogic.com/lmx/
    > =============================================


    That was it!!
    Thanks a lot! What i really like about these groups is that people
    actually do respond and help!
    Thanks again!
    , Mar 13, 2007
    #5
    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. Markus
    Replies:
    1
    Views:
    1,497
    Markus
    Nov 23, 2005
  2. Raymond Arthur St. Marie II of III

    very Very VERY dumb Question About The new Set( ) 's

    Raymond Arthur St. Marie II of III, Jul 23, 2003, in forum: Python
    Replies:
    4
    Views:
    454
    Raymond Hettinger
    Jul 27, 2003
  3. aghazalp

    very very basic question

    aghazalp, Apr 2, 2006, in forum: Python
    Replies:
    6
    Views:
    335
    aghazalp
    Apr 2, 2006
  4. Peter

    Very very very basic question

    Peter, Feb 8, 2005, in forum: C Programming
    Replies:
    14
    Views:
    504
    Dave Thompson
    Feb 14, 2005
  5. mdh

    A very **very** basic question

    mdh, Sep 25, 2008, in forum: C Programming
    Replies:
    57
    Views:
    1,200
    August Karlstrom
    Sep 26, 2008
Loading...

Share This Page