[xquery-talk] RE: What identifies an XML schema in XQuery, target namespace or schema location?

Michael Rys mrys at microsoft.com
Wed Jan 9 21:50:12 PST 2008


The XQuery spec makes it clear that it is the namespace URI of the schema and the local name of the component that uniquely identifies a schema component. Since equivalence of schema components from different schema files is not defined in XQuery, the result is system-dependent on how far the type equivalence investigation goes during the compilation/linking of the two modules.

Best regards
Michael

From: talk-bounces at x-query.com [mailto:talk-bounces at x-query.com] On Behalf Of Chen, Haifeng
Sent: Wednesday, January 09, 2008 6:34 PM
To: talk at x-query.com
Subject: [xquery-talk] What identifies an XML schema in XQuery, target namespace or schema location?

Dear XQuery experts,
I come to a question related to the schema import in XQuery. The following is the context,

Given two XSD files named hats1.xsd and hats2.xsd (note: contents of these two files are the same) stored at the current directory as following,
1.   hats1.xsd (A schema defines a simple type HatSize)

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

<xs:simpleType name="HatSize">
        <xs:restriction base="xs:integer">
            <xs:minInclusive value="1"/>
            <xs:maxInclusive value="10"/>
        </xs:restriction>
</xs:simpleType>

</xs:schema>

2.   hats2.xsd (A schema defines a simple type HatSize)

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

<xs:simpleType name="HatSize">
        <xs:restriction base="xs:integer">
            <xs:minInclusive value="1"/>
            <xs:maxInclusive value="10"/>
        </xs:restriction>
</xs:simpleType>

</xs:schema>

Given two XQuery files named module1.xq and module2.xq stored at the current directory as following,

3.   module1.xq (A module contains a function simply return a HatSize instance, importing schema hats1.xsd)

module namespace module1="http://www.hats.com/module1";
import schema namespace hats="http://www.hats.com/hats" at "hats1.xsd";

declare function module1:function1() as hats:HatSize
{
5 cast as hats:HatSize
};

4.   module2.xq (Main module call the function and test instance of HatSize over the instance, importing schema hats2.xsd)

import module namespace module1="http://www.hats.com/module1" at "module1.xq";
import schema namespace hats="http://www.hats.com/hats" at "hats2.xsd";

module1:function1() instance of hats:HatSize

Question:

What's the right result when evaluating on module2.xq?
A.   true
B.   false
C.   static error should be raised
D.   dynamic error should be raised

It is actually asking "what identifies an XML schema, target namespace or schema location?"

Thanks,
Haifeng Chen


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://x-query.com/pipermail/talk/attachments/20080109/d62fb916/attachment.htm


More information about the talk mailing list