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

XQuery - Grammar? Implementations?

Ronald Bourret rpbourret at rpbourret.com
Fri Jan 30 21:59:03 PST 2009


  XQuery - Grammar? Implementations?
Hello,

[1] succeeds (correctly) because of the function conversion rules listed 
in section 3.1.5 (Function Calls). These "are used to convert an 
argument value or a return value to its expected type". The rule that 
applies to [1] is that, when a function argument has an atomic type, 
argument values are atomized. Atomization (section 2.4.2.) converts 
sequences of nodes to sequences of atomic values. For [1], the node 
value <X>Y</X> is converted to "Y".

[2] fails (correctly) because $a is declared to be an xs:string and 
<X>Y</X> is not a string. Section 3.8.1 (For and Let Clauses) states the 
following in the 14th paragraph (not counting examples):

    "If the type of a value bound to the variable does not match the 
declared type according to the rules for SequenceType matching, a type 
error is raised [err:XPTY0004]"

[3] succeeds correctly because casting explicitly converts <X>Y</X> to a 
string, which is the type expected by the function. Note that [3] does 
explicitly what [1] does implicitly.

-- Ron

Yoshi Okamoto wrote:
> Dear XQuery subscribers,
> 
> I am sometimes fighting to understand all the details of the XQuery grammar. If you have some time, I would be delighted if you could have a look at the following example: I have defined a function with a single string argument:
> 
>   [0]  declare function local:f($a as xs:string) { $a };
> 
> If I pass on an element as follows:
> 
>   [1]  let $a := <X>Y</X> return local:f($a)
> 
> it is accepted by most XQuery implementations which I tried (I am testing with Saxon, BaseX, MonetDB, Zorba, Qizx, Kawa and MXQuery). However, when I cast the element before passing it on:
> 
>   [2]  let $a as xs:string := <X>Y</X> return local:f($a)
> 
> some implementations (also Saxon, which I regard as reference implementation) return [XPTY0004] as error. A third version with an explicit cast:
> 
>   [3]  let $a := xs:string(<X>Y</X>) return local:f($a)
> 
> is finally accepted by all implementations.
> 
> If possible, can someone tell me what the difference are between the versions, especially [1] and [2]? I tried to find the answer in the specification, but I was not successful.
> 
> Thank you very much for your attention and help!
> 
> Best Regards,
> Yoshi Okamoto
> 
> 
>       
> _______________________________________________
> http://x-query.com/mailman/listinfo/talk
> http://x-query.com/mailman/listinfo/talk
> 
> 
> ------------------------------------------------------------------------
> 
> 
> No virus found in this incoming message.
> Checked by AVG - http://www.avg.com 
> Version: 8.0.233 / Virus Database: 270.10.16/1926 - Release Date: 1/30/2009 5:31 PM
> 


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-2011 All Rights Reserved.