4 messages in net.sourceforge.lists.saxon-help[saxon] function conversion rules for...
FromSent OnAttachments
Matthew RawlingsDec 18, 2008 1:54 pm 
Michael KayDec 18, 2008 4:36 pm 
Matthew RawlingsDec 19, 2008 2:29 am 
Michael KayDec 19, 2008 3:46 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:[saxon] function conversion rules for xs:QName to xs:string in fn:resolve-QName()Actions
From:Matthew Rawlings (matt@stickledown.com)
Date:Dec 18, 2008 1:54:56 pm
List:net.sourceforge.lists.saxon-help

I am getting an error when passing an xs:QName as the first parameter to the fn:resolve-QName() function.

I expected, according to the XQuery Function Conversion rules, that the xs:QName could be cast to a xs:string, because xs:QName is a sub-type of xs:string.

The query is:

" xquery version "1.0";

declare default element namespace "http://www.fpml.org/2008/FpML-4-5"; declare namespace fpml="http://www.fpml.org/2008/FpML-4-5"; declare namespace xsi="http://www.w3.org/2001/XMLSchema-instance"; declare namespace xs="http://www.w3.org/2001/XMLSchema";

element nnnn {count(/*[resolve-QName(@xsi:type, .) = xs:QName("ContractCreated")])} "

The command line and result is: " C:\working\ganny-ws\fpml-trunk\src\engine>java -cp C:\lib\saxonsa9-1-0-2j;C:\lib\saxonsa9-1-0-2j\saxon9sa.jar com.saxoni ca.Query -s:msg-ex51-contract-created.xml -s:msg-ex51-contract-created.xml -sa -val success.xq 2>&1 | more Error on line 8 XPTY0004: Required item type of first argument of resolve-QName() is xs:string; supplied value has item type xs:QName Query processing failed: Run-time errors were reported "

If I explicitly cast the xs:QName to a xs:string, then the query works fine. The query with the cast, and the command line and result are: " xquery version "1.0";

declare default element namespace "http://www.fpml.org/2008/FpML-4-5"; declare namespace fpml="http://www.fpml.org/2008/FpML-4-5"; declare namespace xsi="http://www.w3.org/2001/XMLSchema-instance"; declare namespace xs="http://www.w3.org/2001/XMLSchema";

element nnnn {count(/*[resolve-QName(xs:string(@xsi:type), .) = xs:QName("ContractCreated")])} " " C:\working\ganny-ws\fpml-trunk\src\engine>java -cp C:\lib\saxonsa9-1-0-2j;C:\lib\saxonsa9-1-0-2j\saxon9sa.jar com.saxoni ca.Query -s:msg-ex51-contract-created.xml -s:msg-ex51-contract-created.xml -sa -val success.xq 2>&1 | more <?xml version="1.0" encoding="UTF-8"?> <nnnn xmlns="http://www.fpml.org/2008/FpML-4-5">1</nnnn> "

I am using Saxon-SA 9-1-0-2.

The example XML document is from FpML. The example query is from page 257 of Priscilla Walmsley's book "XQuery". The query works fine in a few other popular XQuery tools. " <?xml version="1.0" encoding="UTF-8"?> <FpML xmlns="http://www.fpml.org/2008/FpML-4-5" xmlns:fpml="http://www.fpml.org/2008/FpML-4-5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="4-5" xsi:type="ContractCancelled" xsi:schemaLocation="http://www.fpml.org/2008/FpML-4-5 ../../../schema/fpml-main.xsd http://www.w3.org/2000/09/xmldsig# ../../../schema/xmldsig-core-schema.xsd"> <header> ... ... "

Why is the explicit cast to xs:string needed in Saxon, but not in other products?