- From: <bugzilla@jessica.w3.org>
- Date: Tue, 14 Jun 2011 01:08:07 +0000
- To: public-qt-comments@w3.org
http://www.w3.org/Bugs/Public/show_bug.cgi?id=12951
Summary: Simple mapping operator
Product: XPath / XQuery / XSLT
Version: Working drafts
Platform: PC
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: XPath 3.0
AssignedTo: jonathan.robie@redhat.com
ReportedBy: evan@evanlenz.net
QAContact: public-qt-comments@w3.org
Forgive my ignorance on whether or not this is already in the works, but I'd
like to commend the addition of a "simple mapping operator" to XPath, exactly
along the lines described here (whether "!" is chosen or something else):
http://lists.w3.org/Archives/Public/public-qt-comments/2003Dec/0061.html
The "/" operator is powerful but limited. Here's a real-world example:
/html/head/script/@src/unparsed-text(
resolve-uri(
concat('..',.),
$invoked-module-uri
)
)
The nesting of parentheses is a pain to both read and write. JavaScript
developers, among others, recognize this and that's largely why jQuery has
grown so popular, with its simple chaining mechanism.
I'd much rather be able to type something like this:
/html/head/script/@src ! concat('..',.)
! resolve-uri(.,$invoked-module-uri)
! unparsed-text(.)
In the meantime, I can resort to a jQuery-like library approach (that requires
5 more characters) and trades performance for expressivity:
/html/head/script/@src/_:_(concat('..',.))
/_:_(resolve-uri(.,$invoked-module-uri))
/unparsed-text(.)
declare function _:_($items as item()*) {
for $item in $items return <item>{$item}</item>
};
But it would obviously be much better to add a simple mapping operator to the
language itself. See the above link for Michael Kay's simple description of the
semantics. Basically, it would behave like "/" except not be limited to node
sequences, and it would retain order and duplicate node references.
--
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
Received on Tuesday, 14 June 2011 01:08:09 UTC