[racket] sxpath, txpath and accessors

From: Sanjeev Sharma (throwit1 at gmail.com)
Date: Tue Mar 3 12:57:49 EST 2015

several blind spots, the last being the sxpath context as the argument that

(sxml:... [])
gets applied to

On Tue, Mar 3, 2015 at 12:49 PM, Sanjeev K Sharma <throwit1 at gmail.com> wrote:
> dang ... thanks so much
>
> I don't know how much time you saved me, this was the tack I was on
>
>
> #lang racket (require sxml);(require sxml/html)
> (define doc(ssax:xml->sxml(open-input-string"<AAA>
>    <BBB>
>       <CCC/>
>       <WWW> www content <ttt/></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>")   '()))
> (sxml:element? doc)
> (sxml:node? doc)
> (sxml:element?    ((txpath"/AAA/XXX/preceding::CCC")doc)); #f
> (sxml:element?(car((txpath"/AAA/XXX/preceding::CCC")doc)))
> (sxml:element?(car((sxpath'(AAA XXX))doc)))
> (sxml:node?   (car((sxpath'(AAA XXX))doc)))
> (sxml:node?((sxpath'(AAA XXX))doc))
>
> ((    (sxml:preceding '*)doc)'(// XXX))
> ((    (sxml:preceding '*any*)doc)'(// XXX))
> ((    (sxml:preceding '*any*)(cdr doc))'(// XXX))
> ((    (sxml:preceding '*)(cdr doc))'(// XXX))
> ((    (sxml:preceding '*any*)(cadr doc))'(// XXX))
> ((    (sxml:preceding '*)(cadr doc))'(// XXX))
>
> ((    (sxml:preceding '*any*) doc) '(AAA XXX))
> ((    (sxml:preceding '*any*) doc) '(// XXX))
> ((    (sxml:preceding (ntype?? '*any*)) doc) '(// XXX))
> ((    (sxml:preceding (ntype?? '*text*)) doc) '("content"))
> ((    (sxml:preceding 'ntype??) doc)'(XXX))
> ((    (sxml:preceding ntype??) doc)'(// XXX))
> ((    (sxml:preceding '*) doc) '(// XXX))
> ((    (sxml:preceding (ntype?? '*)) doc) '(// XXX))
>
> ((  (sxml:preceding '*any*)doc)'(AAA XXX))
> ((  (sxml:preceding '*)doc)'(AAA XXX))
> ((  (sxml:preceding '*)doc)"//XXX")
> ;((  (sxml:preceding '*)doc)((txpath"//XXX"))) ; ERROR
> ((  (sxml:preceding '@)doc)'(AAA XXX))
>
> ((  (sxml:preceding '*any*)doc)"/AAA/XXX/")
> ((  (sxml:preceding '*any*)doc)"//XXX")
>
> ((  (sxml:preceding '(WWW))  doc)doc)
> ((  (sxml:preceding '(CCC))  doc)doc)
>
> ((  (sxml:preceding '*any*)  doc)'CCC)
> ((  (sxml:preceding '*any*)  doc)'(CCC))
> ((  (sxml:preceding '*any*)  doc)"CCC")
>
> ((  (sxml:preceding '@)  doc)'(CCC))
> ((  (sxml:preceding '*)  doc)'(CCC))
> ((  (sxml:preceding '*)  doc)'((CCC)))
> ((  (sxml:preceding '*)  doc)"CCC")
>
> ((  (sxml:preceding ntype??) doc)'(CCC))
> ((  (sxml:preceding 'ntype??) doc)'(CCC))
> ((  (sxml:preceding (ntype?? '*)) doc)'(CCC))
>
> ((  (sxml:preceding equal?)  doc)'CCC)
> ((  (sxml:preceding equal?)  doc)'(CCC))
> ((  (sxml:preceding 'equal?)  doc)'(CCC))
> ((  (sxml:preceding equal?)  doc)"CCC")
> ((  (sxml:preceding equal?)  doc)"WWW")
> ((  (sxml:preceding 'equal?)  doc)'(WWW))
>
> ((txpath"/AAA/XXX/preceding::CCC")doc)
> ((txpath"/AAA/XXX/preceding::WWW")doc)
>
>
>
> ((sxpath '(AAA XXX (sxml:preceding '(WWW)))) doc)
> ((sxpath '(AAA XXX (sxml:preceding (WWW)))) doc)
>
> ((sxpath'(AAA XXX (preceding:"WWW")))doc)
> ((sxpath '(aaa xxx ((sxml::preceding "www")))) doc)
> ((sxpath '(AAA XXX ((sxml::preceding "WWW")))) doc)
> ((sxpath '(AAA XXX ((sxml::preceding "WWW")))) doc)
>
> ((ntype?? 'www)doc)
> ((sxpath '(aaa xxx ((sxml:preceding (ntype?? 'www))))) doc)
>
> ;((sxml:preceding ((sxpath '(aaa xxx www))))doc)
>
> ; ((sxpath '(aaa xxx ((sxml:preceding '(bbb))))) doc)
> ; ((sxpath '(aaa xxx ((sxml:preceding '(ccc))))) doc)
> ; ((sxpath '(aaa xxx ((sxml::preceding "www")))) doc)
> ;
> ; ((sxpath '(aaa xxx (sxml:preceding (www)))) doc)
> ;
> ; ;((sxml:preceding ((sxpath '(aaa xxx www)doc)
> ;
> ;
> ; ;((txpath"/aaa/xxx/fff/ddd/ancestor::")doc)
> ; ;((sxpath '(aaa xxx fff((sxml:ancestor)))) doc)
> ;
> ;
> ; (sxml:element? doc)
> ; ((ntype?? 'www)doc)
> ; ((ntype-names?? '(aaa ccc xxx))doc)
> ;
> ;
> ;
> ; ;((txpath"/aaa/xxx/preceding::ccc")doc)
> ; ((sxpath '(aaa xxx ((sxml:preceding '(ccc))))) doc)
> ; ;((sxpath '(aaa xxx (sxml:preceding (ntype?? 'ccc)))) doc)
> ; ((ntype?? 'ccc)doc)
> ;
> ; ;((sxpath '(aaa xxx :preceding '(ccc)) doc)
> ; ;((sxpath '((sxml:preceding '(aaa xxx ccc)))) doc)
> ; ;((sxml:preceding '(ccc) doc))
> ;
> ; ((sxpath '(aaa xxx '(sxml:preceding '(www)))) doc)
> ; ((sxpath '(aaa xxx (sxml:preceding '(www)))) doc)
> ;
> ;
> ;
> ; ; ((txpath"/aaa/xxx/preceding::www/following::lll")doc);expect '((lll) (lll))
> ; ; ((txpath"/aaa/xxx/preceding::www/following")doc)
> ; ; ((txpath"/aaa/xxx/preceding::ccc")doc)
> ;
> ;

Posted on the users mailing list.