[XSL-LIST Mailing List Archive Home]
[Reply To This Message]
Re: XQuery Updates in XSLT
Subject: Re: XQuery Updates in XSLT|
From: Robert Koberg <rob@xxxxxxxxxx>
Date: Wed, 29 Oct 2008 16:38:56 -0400
On Oct 29, 2008, at 4:15 PM, John Snelson wrote:
Robert Koberg wrote:
On Oct 29, 2008, at 3:48 PM, John Snelson wrote:
Robert Koberg wrote:
On Oct 29, 2008, at 3:21 PM, Scott Trenda wrote:
I think John is confusing the meaning of "functional" here.
meant "functional" as in "based on functions/templates, like
Scheme (as opposed to imperative)", and perhaps John interpreted
"functional" to mean "it works, it's not broken".
I am sure John knows what functional means. I was commenting
use of XQuery as opposed to xsl's identity template with some
templates. It sounds like he think XQuery is better at this type of
Yes. It's a few lines of easily readable XQuery Update, versus a few
complete XSLT templates and an explanation of how the identity
Really? Show me how you use typeswitch (or whatever you would like to
use) to handle the XSL equivalent of exception templates in a few
Problem: In a copy of the original document, rename the "name"
of "product" elements to "id".
XQuery Update solution:
copy $a := doc(...)
modify for $p in $a//product return rename node $p/@name as "id"
Way too simplistic for the real world. And, by
Now the problem has changed. Also, lets imagine there were other
elements beside product involved - like a label, abstract and price.
(I am not even getting into mixed content... yet :) )
You need to
* change the name attr to an id attr
* you need to change product elem into item elem
* you need to wrap all products that start with the same letter
(derived from name attr value) with an items element
* you need to change abstract to description.
Then, you need to make it into XHTML for the web :)
I don't expect you too actually do it, just ADMIT damnit! :)
BTW, you do realize you are on an XSL list, you heathen. :)
XSLT 2.0 solution:
The XQuery Update solution clearly matches the problem definition
better, and is shorter. It would be even shorter if you wanted to
perform the update in-place.
John Snelson, Oracle Corporation http://snelson.org.uk/john
Berkeley DB XML: http://oracle.com/database/berkeley-db/xml
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