I tried to send this  twice now- this is the 3rd attempt, I hope no one gets 
this 3 times / gets pissed.

on this page
~/.racket/6.1.1/pkgs/sxml/sxml/doc/sxml/sxpath.html

I read this:

"Like sxpath, but only accepts an XPath query in string form, using the 
standard XPath syntax.

Deprecated; use sxpath instead."

so I'd like to get the hang of sxpath but I'm somehow stuck on how to translate 
txpath syntax to sxpath syntax for axes and accessors

after the example document below are some of the variations I tried

#lang racket (require sxml)(require sxml/html)
(define doc(html->xexp
"<AAA>
   <BBB>
      <CCC/>
      <www> www content <xxx/><www>
      <zzz/>
   </BBB>
   <XXX>
      <DDD>
           <EEE/>
           <FFF>
              <HHH/>
              <GGG>
                 <JJJ>content under jjj
                    <QQQ><lll/>content under qqq</qqq>
                    <rrr/>
                 </JJJ>
                 <JJJ/>
              </GGG>
              <HHH/>
           </FFF>
      </DDD>
   </XXX>
   <CCC>content in ccc
      <DDD/>
   </CCC>
</AAA>"))


((txpath"/aaa/xxx/preceding::*")doc);expect;'((zzz) ... (www "\n" "      " 
(zzz) "\n" "   "))))

((txpath"/aaa/xxx/preceding::zzz")doc);expect '((zzz))
((txpath"/aaa/xxx/preceding::www")doc);expect '((www "\n" " ...   " (zzz) "\n" 
"   ")))
((txpath"/aaa/xxx/preceding::www/following::lll")doc);expect '((lll) (lll))

;from the doc,
;lists in the s-expression syntax correspond to string concatenation in the 
txpath syntax.
;((sxpath'(aaa xxx ddd fff ggg jjj qqq))doc);expect '((qqq (lll) "content under 
qqq"))

((sxpath'(aaa xxx preceding))doc)

((sxpath'(aaa xxx preceding::www))doc)
((sxpath'(aaa xxx preceding::zzz))doc)
((sxpath'(aaa xxx preceding::bbb))doc)

((sxpath'(aaa xxx "preceding"))doc)
((sxpath'(aaa xxx "preceding::zzz"))doc);
((sxpath'(aaa xxx "preceding::www"))doc);

((sxpath'(aaa xxx "preceding::*"))doc)
;((sxpath "/aaa/xxx/preceding::*")doc); works
((sxpath'(aaa xxx preceding::*))doc)
((sxpath'(aaa (xxx (preceding::*))))doc)
((sxpath'(aaa (xxx (preceding::*))))doc)
((sxpath'(aaa (xxx (preceding::"*"))))doc)
((sxpath'(aaa (xxx "preceding::*")))doc)
((sxpath'(aaa (xxx ("preceding::*"))))doc)

((sxpath'(aaa xxx preceding::*))doc)
((sxpath'(aaa xxx preceding::*))doc)
((sxpath'(aaa xxx "preceding::*"))doc)
((sxpath'(aaa xxx ,"preceding::*"))doc)
((sxpath'(// aaa /xxx /"preceding::*"))doc)

;((sxpath'(//aaa /xxx/preceding"::*"))doc); error
;(sxml:preceding::*(sxpath'(aaa xxx))doc); error

((sxml:preceding 'eq) doc) ;#<procedure:...l/sxpath-ext.rkt:578:4>
((sxml:preceding(sxpath'(aaa xxx)))doc);#<procedure:...l/sxpath-ext.rkt:578:4>




I'd like to get the other axes and accessors working but now that I've spent 
some time on this I also REALLY want to know what my blind spot is here.  Hope 
I didn't miss something glaringly obvious.

____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to