- From: <bugzilla@jessica.w3.org>
- Date: Thu, 14 Jan 2016 00:22:56 +0000
- To: public-qt-comments@w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=29374 Bug ID: 29374 Summary: fn:transform Product: XPath / XQuery / XSLT Version: Candidate Recommendation Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P2 Component: XQuery 3.1 Assignee: jonathan.robie@gmail.com Reporter: benito@benibela.de QA Contact: public-qt-comments@w3.org Target Milestone: --- It is strange that in XQuery the function to load an xquery module has the long name fn:load-xquery-module, but the function to run an xsl transformation has the short name fn:transform. After all, when you write XQuery, XQuery is already implicitly used, so you rather expect a short fn:load-module or even just fn:module. While XSLT is an entire different language, so it seems more logical to have fn:run-xslt or fn:xsl-transform. Seems it was heavily influenced by a XSLT working group, but it is an XPath function, not an XSLT function... I hope a standalone XQuery processor is not required to support fn:transform. And unfortunately I already have a custom transform function in my implementation. Defined as pxp:transform($root as item()*, $f as function(*), $options as map()) as item()*){ for $i in $root return $f($i)!(if (. instance of node() and ( . is $i or $options("always-recurse") ) ) then ( typeswitch (.) case element() return element {node-name(.)} { @* ! $f(.), node()!pxp:transform(., $f, $options) } case document-node() return document { node() ! pxp:transform(., $f, $options) } default return . ) else . ) } pxp:transform($root as item()*, $f as function(*)) as item()* { pxp:transform($root, $f, {}) } pxp:transform($f as function(*)) as item()* { pxp:transform(., $f, {}) } That is quite useful to perform a map/filter over all nodes in a document. E.g. For example transform(/, function($x) { if (name($x) = "a") then <a>{$x/@*, <b>{$x/node()}</b>}</a> else $x } ) to make all a-links bold; or transform(/, function($x) { if (name($x) = "a") then () else $x } ) to remove them. -- You are receiving this mail because: You are the QA Contact for the bug.
Received on Thursday, 14 January 2016 00:23:01 UTC