Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XMLSchema and XML Validation problem

Reply
Thread Tools

XMLSchema and XML Validation problem

 
 
Robert Ludewig
Guest
Posts: n/a
 
      06-28-2004
This is my XML Schema (Sitemap.xsd) :

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlnss="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.htw-dresden.de/SitemapNS">
<xs:element name="Sitemap">
<xs:complexType>
<xs:all>
<xs:element name="Page">
<xs:complexType>
<xs:all>
<xs:element minOccurs="1" name="Title" type="xs:normalizedString"/>
<xs:element minOccurs="0" name="Description" type="xs:string"/>
<xs:element minOccurs="0" name="Linklist">
<xs:complexType>
<xs:sequence>
<xs:element name="Link" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="ID" type="xs:IDREF" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="ID" type="xs:ID" use="required"/>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>

And when I define a new XML file using this xsd it does not Validate:

<Sitemap xmlns="http://www.htw-dresden.de/SitemapNS"
xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.htw-dresden.de/SitemapNS Sitemap.xsd">
<Page>
</Page>
</Sitemap>

XMLSpy says: unexpected child element: <Page>
MSXML4 says: the content is not valid, expected: <Page>

WHY does that happen ?? Its a namespace problem right ? What am I doing
wrong ?


 
Reply With Quote
 
 
 
 
Richard Tobin
Guest
Posts: n/a
 
      06-28-2004
In article <>,
Robert Ludewig <> wrote:

><xs:schema xmlnss="http://www.w3.org/2001/XMLSchema"
>targetNamespace="http://www.htw-dresden.de/SitemapNS">


Add elementFormDefault="qualified".

-- Richard
 
Reply With Quote
 
 
 
 
Robert Ludewig
Guest
Posts: n/a
 
      06-28-2004
And why ?
I would have expected that if I don't want the namespace specification to be
required, that I have to do it with unqualified.
But it seems its the other way around?

What exactly does that elementFormDefault="qualified" do then?


 
Reply With Quote
 
Richard Tobin
Guest
Posts: n/a
 
      06-28-2004
In article <>,
Robert Ludewig <> wrote:

>And why ?


We need an FAQ. This question has been answered many times.

>I would have expected that if I don't want the namespace specification to be
>required, that I have to do it with unqualified.


Your Sitemap element has xmlns="http://www.htw-dresden.de/SitemapNS",
which makes that be the default namespace, so your unprefixed Page
element is in that namespace.

elementFormDefault="qualified" makes local element declarations apply
to elements in the target namespace (rather than in no namespace), which
is what you want.

Your schema would be right if your document looked like this:

<x:Sitemap xmlns="http://www.htw-dresden.de/SitemapNS"
xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.htw-dresden.de/SitemapNS Sitemap.xsd">
<Page>
</Page>
</x:Sitemap>

(i.e. if Page was in no namespace).

- Richard
 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      06-28-2004


Robert Ludewig wrote:

> And why ?
> I would have expected that if I don't want the namespace specification to be
> required, that I have to do it with unqualified.
> But it seems its the other way around?
>
> What exactly does that elementFormDefault="qualified" do then?


Check the spec, for a start the examples in the primer:
http://www.w3.org/TR/xmlschema-0/#QualLocals

--

Martin Honnen
http://JavaScript.FAQTs.com/

 
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
XMLSchema, validation Marcin Wielgus Java 0 03-16-2006 12:58 AM
XMLSchema syntax problem AL XML 4 11-08-2005 12:39 PM
XML Validation against XMLSchema ? Peter Fitzgibbons Ruby 1 10-17-2005 02:54 PM
PROBLEM: webservice, XmlNode return value, XMLSchema and WSDL g.fiorentini ASP .Net Web Services 0 09-10-2003 08:05 AM
how to read xmlschema from xml file? sudha ASP .Net 0 06-30-2003 07:41 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57