Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Very basic question re: schema. Please advise...

Reply
Thread Tools

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

 
 
austris.bahanovskis@gmail.com
Guest
Posts: n/a
 
      03-11-2007
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 xmlnssi="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
xmlnss="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.

 
Reply With Quote
 
 
 
 
usenet@tech-know-ware.com
Guest
Posts: n/a
 
      03-12-2007
On 11 Mar, 00:34, "(E-Mail Removed)"
<(E-Mail Removed)> wrote:
> Hi,
>
> ...
> And this is the schema (i'm sure i'm getting the ComplexType/child/
> parent tags wrong):
>
> <xs:schema
> xmlnss="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
xmlnss="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
xmlnss="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/
=============================================


 
Reply With Quote
 
 
 
 
austris.bahanovskis@gmail.com
Guest
Posts: n/a
 
      03-12-2007
On Mar 12, 9:27 am, (E-Mail Removed) wrote:
> On 11 Mar, 00:34, "(E-Mail Removed)"
>
>
>
> <(E-Mail Removed)> wrote:
> > Hi,

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

>
> > <xs:schema
> > xmlnss="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
> xmlnss="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
> xmlnss="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

 
Reply With Quote
 
usenet@tech-know-ware.com
Guest
Posts: n/a
 
      03-12-2007
On 12 Mar, 19:34, "(E-Mail Removed)"
<(E-Mail Removed)> wrote:
> On Mar 12, 9:27 am, (E-Mail Removed) wrote:
> > On 11 Mar, 00:34, "(E-Mail Removed)"

>
> > <(E-Mail Removed)> wrote:

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

>
> > <xs:schema
> > xmlnss="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/
=============================================

 
Reply With Quote
 
austris.bahanovskis@gmail.com
Guest
Posts: n/a
 
      03-13-2007
On Mar 12, 8:42 pm, (E-Mail Removed) wrote:
> On 12 Mar, 19:34, "(E-Mail Removed)"
>
>
>
> <(E-Mail Removed)> wrote:
> > On Mar 12, 9:27 am, (E-Mail Removed) wrote:
> > > On 11 Mar, 00:34, "(E-Mail Removed)"

>
> > > <(E-Mail Removed)> wrote:

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

>
> > > <xs:schema
> > > xmlnss="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!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I found some very odd behaviour in Python's very basic types Sunjay Varma Python 4 03-10-2011 05:05 PM
A very **very** basic question mdh C Programming 57 09-26-2008 03:25 PM
very very basic question aghazalp Python 6 04-02-2006 09:35 PM
Very very very basic question Peter C Programming 14 02-14-2005 09:46 AM
very Very VERY dumb Question About The new Set( ) 's Raymond Arthur St. Marie II of III Python 4 07-27-2003 12:09 AM



Advertisments