469,945 Members | 2,262 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,945 developers. It's quick & easy.

correct use of xsi:schemaLocation


I have a question about the correct use of the attribute
xsi:schemaLocation. My programm has to process XML files where the value of
this attribute causes some problems. The programm is written in C++
using Xerces C++ version 2.3.0. An older older version of the programm
used Xerces C++ version 1.6.0.

The XML files look like the following example:

<an:root xmlns:an="nsAnton"
xsi:schemaLocation="nsBerta antonFile.xsd">
<!-- content -->

The schema definitions files used by example.xml are

<schema targetNamespace="nsAnton">
<include schemaLocation="nsAnton.xsd"/>
<import namespace="nsBerta" schemaLocation="nsBerta.xsd"/>

<schema targetNameSpace="nsAnton">
<element name="root">
<!-- content of root-element -->

<schema targetNamespace="nsBerta">
<!-- vocabularry of schema nsBerta -->

When I validate file example.xml with a SAX parser using Xerces C++
version 1.6.0 the file is recognized as valid. xmlspy (professional
edition version 5, release 4) also tells me that the file is valid.
But when i run a SAX parser using Xerces C++ verion 2.3.0 i got the
"Schema in antonFile.xsd has a different target namespace
from the one specified in the instance document nsBerta."
and the file is considered as invalid.

So i have two validation results one from Xerces C++ 1.6.0 and xmlspy
5.4 and one from Xerces C++ 2.3.0. But which one is correct?
When I change the value of the schema location attribute to

xsi:schemaLocation="nsAnton antonFile.xsd"

the file is considered as valid by all of the three parsers. Hence the
two different validation results of file example.xml are caused by

xsi:schemaLocation="nsBerta antonFile.xsd"

in my opinion the classification of Xerces C++ 2.3.0 is correct
because the target namespace of antonFile.xsd is nsAnton and not
nsBerta. I would expect that the target namepace of the schema
defintion file must match the namespace to which the schema definition
file is connected by the attribute xsi:schemaLocation, i.e. in

xsi:schemaLocation="namespace namespaceFile.xsd"

the condition

namespace == TARGET-NAMESPACE ( namespaceFile.xsd )

must be satisfied.

Is my interpretation correct?

The W3C recommendation (http://www.w3.org/TR/xmlschema-1/) states that
the value of the attribute xsi:schemaLocation gives only a hint where an
application can find the definition of a namespace but an application
must not use this information.

I would appreciate information about the correct use of the attribute

yours sincerely

Jul 20 '05 #1
0 10492

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Ron James | last post: by
reply views Thread by kolja2003 | last post: by
2 posts views Thread by grochmal | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.