<div dir="ltr"><div><div><div><div><div>I think sxpath is not as broken as you think. It certainly *is* desperately short of examples, and I'll add this one when I'm done. <br><br></div>I wouldn't call this complete success, but after much head-scratching and doc-reading, I got this to produce the expected result:<br><br>(((sxml:preceding (ntype?? 'www)) doc) ((sxpath `(aaa xxx)) doc))<br>; =><br>; '((www "\n" " " (zzz) "\n" " ")<br>; (www " www content " (xxx) (www "\n" " " (zzz) "\n" " ")))<br><br><br></div>That is, sxml:preceding needs to know about the whole doc (reasonable, given that it's back-traversing), and it acts as a filter. Is there some way to turn this around so that the sxml:preceding node appears in the sxpath chain? There might be, yes. Also, why do I have to use 'ntype??' instead of sxpath? Not sure. I think this library might gain a great deal from being a *teensy* bit less higher-order. <br><br></div>In the end, though... it's true that you might as well just use txpath.<br><br></div>(FYI, I'm planning to use this example in the docs, please let me know if that's not appropriate.)<br><br></div>Best, <br><br>John Clements<br><div><div><div><br></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 3, 2015 at 7:28 AM, Vincent St-Amour <span dir="ltr"><<a href="mailto:stamourv@ccs.neu.edu" target="_blank">stamourv@ccs.neu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I have not been able to get those axes working either. I've looked<br>
briefly at the implementation of `sxml:preceding`, and it's unclear to<br>
me how it could even work.<br>
<br>
Since `txpath` appears to work, I'd stick with that. I'm not sure why<br>
it's deprecated in favor of `sxpath`. Since, AFAICT, we're just<br>
packaging that library (i.e. not developing it) and its development<br>
appears to have stopped, I don't expect `txpath` to go anywhere.<br>
<br>
Vincent<br>
<br>
<br>
<br>
At Tue, 3 Mar 2015 06:56:34 -0500,<br>
<div class="HOEnZb"><div class="h5">Sanjeev K Sharma wrote:<br>
><br>
> On Mon, Mar 02, 2015 at 09:52:53AM -0500, Vincent St-Amour wrote:<br>
> > I recommend the short tutorial near the top of this document:<br>
> ><br>
> > <a href="http://pkg-build.racket-lang.org/doc/sxml/sxpath.html" target="_blank">http://pkg-build.racket-lang.org/doc/sxml/sxpath.html</a><br>
> ><br>
><br>
> Thanks for the suggested solution;<br>
><br>
> that was exactly the document I referred to<br>
><br>
> I have not been able to generate an sxpath working example of the axes listed at the bottom of that page. Aside from generating an example, from Oleg's documents to some other google hits I haven't found working examples either.<br>
><br>
> a simplified example (including your suggestion)<br>
><br>
> #lang racket (require sxml)(require sxml/html)<br>
> (define doc(html->xexp<br>
> "<AAA><br>
> <BBB><br>
> <CCC/><br>
> <www> www content <xxx/><www><br>
> <zzz/><br>
> </BBB><br>
> <XXX><br>
> <DDD> content in ccc<br>
> </DDD><br>
> </XXX><br>
> </AAA>"))<br>
><br>
> ((txpath"/aaa/xxx/preceding::ccc")doc)<br>
> ; '((ccc))<br>
><br>
><br>
> ((txpath"/aaa/xxx/preceding::www")doc)<br>
> ; '((www "\n" " " (zzz) "\n" " ")<br>
> ; (www<br>
> ; " www content "<br>
> ; (xxx)<br>
> ; (www "\n" " " (zzz) "\n" " ")))<br>
> ; '()<br>
><br>
> ((sxpath '(aaa xxx (sxml:preceding '(www)))) doc)<br>
> ; '()<br>
><br>
> ((sxpath '(aaa xxx (sxml:preceding (www)))) doc)<br>
> ; '()<br>
><br>
> ((sxpath'(aaa xxx (preceding:"www")))doc)<br>
> ; '()<br>
><br>
> ((sxpath '(aaa xxx ((sxml::preceding "www")))) doc)<br>
> ; '()<br>
><br>
> ((sxml:preceding ((sxpath '(aaa xxx www))))doc)<br>
> ; '()<br>
> ____________________<br>
> Racket Users list:<br>
> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</div></div></blockquote></div><br></div>