tags:

views:

22

answers:

2

I'm having trouble validating a schema I created. "cvc-elt.1: Cannot find the declaration of element 'category'."

xsd

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;

<xs:element name="list">
<xs:complexType>
    <xs:sequence>
        <xs:element name="category" type="categoryType" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
</xs:complexType>
</xs:element>

<xs:complexType name="categoryType">
    <xs:sequence>
        <xs:element name="name" type="xs:string"/>
        <xs:element name="desc"  type="xs:string"/>
        <xs:element name="icon" type="xs:base64Binary"/>
        <xs:element name="poi" type="poiType"  minOccurs="0"  maxOccurs="unbounded"/>
    </xs:sequence>
</xs:complexType>

<xs:complexType name="poiType">
    <xs:sequence>
        <xs:element name="name" type="xs:string"/>
        <xs:element name="desc"  type="xs:string"/>
        <xs:element name="longitude"  type="xs:long"/>
        <xs:element name="latitude"  type="xs:long"/>
        <xs:element name="url" type="xs:string" minOccurs="0"  maxOccurs="unbounded"/>
        <xs:element name="image" type="xs:base64Binary" minOccurs="0"  maxOccurs="unbounded"/>  
    </xs:sequence>
</xs:complexType>

</xs:schema>

xml

<?xml version="1.0" encoding="UTF-8"?>
<list SchemaLocation="sem.xsd">

<category>

<name>Sehenswürdigkeiten</name>
<desc>sehenswerte und berühmte Orte, die man gesehen haben muss</desc>
<icon>...</icon>

<poi>
<name>Linzer Landhaus</name>
<desc>Sitz des Oberösterreichsichen Landtags</desc>
<url>http://www.linz.at/tourismus/7569.asp&lt;/url&gt;
<longitude>48.304107</longitude>
<latitude>14.286025</latitude>
<image>...</image>
</poi>

<poi>
<name>Ars Electronica</name>
<desc>Museum der digitalen Künste</desc>
<url>http://www.aec.at&lt;/url&gt;
<longitude>48.309788</longitude>
<latitude>14.284179</latitude>
<image>...</image>
<image>...</image>
</poi>

</category>

<category>...</category>

</list>

any idea whats wrong? cheers hoax

+1  A: 

The problem is probably with the line:

<list SchemaLocation="sem.xsd">

You haven't indicated that SchemaLocation is anything special, it just looks like another attribute.

It should be:

<list xsi:schemaLocation="sem.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;

See here for a more detailed explanation.

skaffman
that gets me:<list xsi:schemaLocation="sem.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">SchemaLocation: schemaLocation value = 'sem.xsd' must have even number of URI's.<list xsi:schemaLocation="http://www.w3.org/2001/XMLSchema sem.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema">The prefix "xsi" for attribute "xsi:schemaLocation" associated with an element type "list" is not bound.
Hoax
@Hoax: Like I said, read the link for a better explanation.
skaffman
thx for your help
Hoax
A: 
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="sem.xsd">

does the trick =)

Hoax