[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

What identifies an XML schema in XQuery, target namespace or schema location?

Chen, Haifeng haifeng.chen at intel.com
Thu Jan 10 10:34:04 PST 2008


  What identifies an XML schema in XQuery
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/20080110/4ca1a6ee/attachment-0001.htm


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.