Re: sxpath - or and not filters
Kirill Lisovsky <[email protected]> Fri, 9 Jan 2004 02:26:42 -0500 (EST)
| Newsgroups | gmane.lisp.scheme.ssax-sxml |
|---|---|
| Message-ID | <Pine.LNX.4.44.0401090140090.2336-100000@ant> |
Hello!
On Thu, 8 Jan 2004, Gordon Weakliem wrote:
> I'm trying to get the equivalent to the XPath "*|text()", in other words, I want to select just the text and element children of a node, not attributes. For this reason, *any* is too broad. For now, I can do sxml:content on the result of an sxpath, but I wonder if there's a more compact way to do this selection:
>
> (sxml:content (car ((sxpath '(atom:content) atom-ns) entry)))
>
> It looks like sxpath defines or@ and not@ operators, but I can't figure out how to use them and can't find an example, and my guesses haven't worked.
>Would these be the way to go, or is there a better way to do this?
Most universal way to do _anything_ like this (and more!) is to employ SXPath's
ability to use a function as a location step. Actually, symbols like *,
*text* etc. are just shortcuts for popular location step functions.
So, in SXPath you can define your own function (a luxury denied by XPath)
and use it in location path:
For example,
(define (content nodeset root vars)
(map sxml:content nodeset))
((sxpath `(atom:content ,content) atom-ns) entry)
BTW: you can use
((car-sxpath ...
instead of
(car ((sxpath ...
>Can someone provide an example of how these operators work?
(sxpath '(html (or@ head body)))
Please note that due to rewriting using ntype-names??
(see docs on "sxpath" function) only node names are acceptable,
and not special symbols like *text* etc.
Best regards,
Kirill.
-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software.
Perforce is the Fast Software Configuration Management System offering
advanced branching capabilities and atomic changes on 50+ platforms.
Free Eval! http://www.perforce.com/perforce/loadprog.html