correct use of xsi:schemaLocation

Discussion in 'XML' started by Sarah Tegtmeier, Jan 16, 2004.

  1. Hi

    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:

    example.xml
    ============
    <an:root xmlns:an="nsAnton"
    xmlns:bt="nsBerta"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="nsBerta antonFile.xsd">
    <!-- content -->
    </an:root>

    The schema definitions files used by example.xml are

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

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

    nsBerta.xsd
    ============
    <schema targetNamespace="nsBerta">
    <!-- vocabularry of schema nsBerta -->
    </schema>

    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
    message
    "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
    xsi:schemaLocation.

    yours sincerely

    Sarah
    Sarah Tegtmeier, Jan 16, 2004
    #1
    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. Ulf Heyder
    Replies:
    0
    Views:
    563
    Ulf Heyder
    Oct 16, 2003
  2. John
    Replies:
    1
    Views:
    946
    Bob Foster
    Oct 22, 2003
  3. Naresh Agarwal
    Replies:
    1
    Views:
    700
    Christian Ludwig
    Jan 13, 2004
  4. Tjerk Wolterink
    Replies:
    1
    Views:
    1,580
    Tjerk Wolterink
    Sep 1, 2005
  5. -saarland.de
    Replies:
    1
    Views:
    562
    Joe Kesselman
    Nov 21, 2006
Loading...

Share This Page