|
[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.comThu Jan 10 10:34:04 PST 2008
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! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






