|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] Advancing with XQuery articleMichael Kay mike at saxonica.comWed Oct 1 12:25:00 PDT 2008
Good article. A few comments: 1>XQuery allows you to bind a prefix to an empty string to indicate placing an element into the default element namespace I don't think that's correct. declare namespace p = ""; makes p unavailable for use. To quote: "If the URILiteral part of a namespace declaration is a zero-length string, any existing namespace binding for the given prefix is removed from the statically known namespaces. " 2>If you had a system-property() function, it would be relatively easy to implement XQuery function libraries made up of XQuery processor specific functions. It wouldn't actually help much, because the function bindings would still fail. You need a compile-time conditional, like XSLT 2.0's use-when (or some analog to xsl:import). 3>fn:not(fn:deep-equal($a,$b)) Why do so many people use the "fn:" prefix, it seems totally unnecessary? 4>Note: It's been kindly pointed out to me that these functions can check equality of datatypes as well I'm not sure what you mean by that, but it seems misleading. Datatypes aren't values and can't be compared. And if you mean that deep-equal() requires two values to have the same type, it doesn't - a decimal can still compare equal to a double. 5>fn:not(fn:boolean(fn:compare($a, $b))) Can't see why you would want to do this rather than using "eq". If you want to force codepoint collation, use a third argument to compare(), or use codepoint-equal(). 6>Note that this is a naive implementation of assertion (for example, even when disabled, it still calls the test:assert function, albeit with almost no processing cost). In Saxon there should be zero run-time cost - if($DEBUG) then ... else - gets optimized at compile time if DEBUG has a constant value. (In fact, a number of your examples will probably be evaluated entirely at compile time - check by using -explain. 7>As with the local:factorial example, you have a tail recursive function. No, the treewalker function is not tail-recursive. The recursive call is nested inside an element constructor which is itself inside a for loop. (But since the recursion depth is the depth of the XML tree, this doesn't matter.) 8>filter.xq Saxon will probably optimize this to declare function local:filter($func, $seq as item()*) as item()* { $seq[saxon:call($func, .)] }; but I wonder why you didn't write it that way? It seems to be the common XQuery trap of using complex FLWOR expressions where simple XPath expressions will do. Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: http://x-query.com/mailman/listinfo/talk > [mailto:http://x-query.com/mailman/listinfo/talk] On Behalf Of James Fuller > Sent: 01 October 2008 09:49 > To: Andrew Welch > Cc: http://x-query.com/mailman/listinfo/talk > Subject: Re: Advancing with XQuery article > > On Wed, Oct 1, 2008 at 10:39 AM, Andrew Welch > <http://x-query.com/mailman/listinfo/talk> wrote: > > Clicking "register now or sign in" takes me to "webpage not > available".... > > > > Any chance you can post it elsewhere? (having to register is lame > > even if it is "free") > > I have put PDF to here as well > > http://jim.fuller.name/x-advxquery-pdf.pdf > > I will put up the full package in a few days (e.g. source code) ... > occupied with another release currently. > > hth, J > > > > > > > > 2008/10/1 James Fuller <http://x-query.com/mailman/listinfo/talk>: > >> Hello All, > >> > >> I have had my xquery article published at IBM ... I > thought I would > >> post it here > >> > >> > http://www.ibm.com/developerworks/edu/x-dw-x-advxquery.html?S_TACT=10 > >> 5AGX06&S_CMP=HP > >> > >> You will need to logon to IBM for this tutorial (free register). > >> > >> To run code samples you will need Michael Kay's excellent SAXON-SA > >> XQuery and XSLT processor(yes, so u need to own it or have 30 day > >> trial) and Apache Ant (which is used to run code samples). > >> > >> cheers, Jim Fuller > >> _______________________________________________ > >> http://x-query.com/mailman/listinfo/talk > >> http://x-query.com/mailman/listinfo/talk > >> > > > > > > > > -- > > Andrew Welch > > http://andrewjwelch.com > > Kernow: http://kernowforsaxon.sf.net/ > > > _______________________________________________ > http://x-query.com/mailman/listinfo/talk > http://x-query.com/mailman/listinfo/talk
|
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
|






