(declare (block) (standard-bindings) (extended-bindings))
(begin
  (define std/xml/sxpath#string-null? string-empty?)
  (define std/xml/sxpath#nl (string '#\newline))
  (define std/xml/sxpath#cout
    (lambda _args173627_
      (for-each
       (lambda (_x173629_)
         (if (procedure? _x173629_) (_x173629_) (display _x173629_)))
       _args173627_)))
  (define std/xml/sxpath#cerr
    (lambda _args173623_
      (for-each
       (lambda (_x173625_)
         (if (procedure? _x173625_)
             (_x173625_ (current-error-port))
             (display _x173625_ (current-error-port))))
       _args173623_)))
  (define std/xml/sxpath#nodeset?
    (lambda (_x173618_)
      (let ((_$e173620_
             (if (pair? _x173618_) (not (symbol? (car _x173618_))) '#f)))
        (if _$e173620_ _$e173620_ (null? _x173618_)))))
  (define std/xml/sxpath#node-typeof?
    (lambda (_crit173611_)
      (lambda (_node173613_)
        (let ((_$e173615_ _crit173611_))
          (if (eq? '* _$e173615_)
              (if (pair? _node173613_)
                  (not (memq (car _node173613_) '(@ *PI*)))
                  '#f)
              (if (eq? '*any* _$e173615_)
                  '#t
                  (if (eq? '*text* _$e173615_)
                      (string? _node173613_)
                      (if (pair? _node173613_)
                          (eq? _crit173611_ (car _node173613_))
                          '#f))))))))
  (define std/xml/sxpath#node-eq?
    (lambda (_other173607_)
      (lambda (_node173609_) (eq? _other173607_ _node173609_))))
  (define std/xml/sxpath#node-equal?
    (lambda (_other173603_)
      (lambda (_node173605_) (equal? _other173603_ _node173605_))))
  (define std/xml/sxpath#node-pos
    (lambda (_n170608_)
      (lambda (_nodeset170610_)
        (if (not (std/xml/sxpath#nodeset? _nodeset170610_))
            '()
            (if (null? _nodeset170610_)
                _nodeset170610_
                (if (eqv? _n170608_ '1)
                    (list (car _nodeset170610_))
                    (if (negative? _n170608_)
                        ((std/xml/sxpath#node-pos
                          (+ _n170608_ '1 (length _nodeset170610_)))
                         _nodeset170610_)
                        (begin
                          (let ((_$e171978_ (positive? _n170608_)))
                            (if _$e171978_
                                _$e171978_
                                (begin
                                  (std/xml/sxpath#cerr
                                   '"failed assertion: "
                                   '(positive? n)
                                   std/xml/sxpath#nl
                                   '"bindings"
                                   '#\newline
                                   'n
                                   '": "
                                   _n170608_
                                   std/xml/sxpath#nl)
                                  (error '"assertion failure"))))
                          ((std/xml/sxpath#node-pos (- _n170608_ '1))
                           (cdr _nodeset170610_))))))))))
  (define std/xml/sxpath#filter
    (lambda (_pred?170597_)
      (lambda (_lst170599_)
        (let _loop170601_ ((_lst170603_
                            (if (std/xml/sxpath#nodeset? _lst170599_)
                                _lst170599_
                                (list _lst170599_)))
                           (_res170604_ '()))
          (if (null? _lst170603_)
              (reverse _res170604_)
              (let ((_pred-result170606_ (_pred?170597_ (car _lst170603_))))
                (_loop170601_
                 (cdr _lst170603_)
                 (if (and _pred-result170606_
                          (not (null? _pred-result170606_)))
                     (cons (car _lst170603_) _res170604_)
                     _res170604_))))))))
  (define std/xml/sxpath#take-until
    (lambda (_pred?170587_)
      (lambda (_lst170589_)
        (let _loop170591_ ((_lst170593_
                            (if (std/xml/sxpath#nodeset? _lst170589_)
                                _lst170589_
                                (list _lst170589_))))
          (if (null? _lst170593_)
              _lst170593_
              (let ((_pred-result170595_ (_pred?170587_ (car _lst170593_))))
                (if (and _pred-result170595_ (not (null? _pred-result170595_)))
                    '()
                    (cons (car _lst170593_)
                          (_loop170591_ (cdr _lst170593_))))))))))
  (define std/xml/sxpath#take-after
    (lambda (_pred?170577_)
      (lambda (_lst170579_)
        (let _loop170581_ ((_lst170583_
                            (if (std/xml/sxpath#nodeset? _lst170579_)
                                _lst170579_
                                (list _lst170579_))))
          (if (null? _lst170583_)
              _lst170583_
              (let ((_pred-result170585_ (_pred?170577_ (car _lst170583_))))
                (if (and _pred-result170585_ (not (null? _pred-result170585_)))
                    (cdr _lst170583_)
                    (_loop170581_ (cdr _lst170583_)))))))))
  (define std/xml/sxpath#map-union
    (lambda (_proc170572_ _lst170573_)
      (if (null? _lst170573_)
          _lst170573_
          (let ((_proc-res170575_ (_proc170572_ (car _lst170573_))))
            ((if (std/xml/sxpath#nodeset? _proc-res170575_) append cons)
             _proc-res170575_
             (std/xml/sxpath#map-union _proc170572_ (cdr _lst170573_)))))))
  (define std/xml/sxpath#node-reverse
    (lambda (_node-or-nodeset170570_)
      (if (not (std/xml/sxpath#nodeset? _node-or-nodeset170570_))
          (list _node-or-nodeset170570_)
          (reverse _node-or-nodeset170570_))))
  (define std/xml/sxpath#node-trace
    (lambda (_title170566_)
      (lambda (_node-or-nodeset170568_)
        (std/xml/sxpath#cout std/xml/sxpath#nl '"-->")
        (display _title170566_)
        (display '" :")
        (pretty-print _node-or-nodeset170568_)
        _node-or-nodeset170568_)))
  (define std/xml/sxpath#select-kids
    (lambda (_test-pred?170562_)
      (lambda (_node170564_)
        (if (null? _node170564_)
            _node170564_
            (if (not (pair? _node170564_))
                '()
                (if (symbol? (car _node170564_))
                    ((std/xml/sxpath#filter _test-pred?170562_)
                     (cdr _node170564_))
                    (std/xml/sxpath#map-union
                     (std/xml/sxpath#select-kids _test-pred?170562_)
                     _node170564_)))))))
  (define std/xml/sxpath#node-self std/xml/sxpath#filter)
  (define std/xml/sxpath#node-join
    (lambda _selectors170553_
      (lambda (_nodeset170555_)
        (let _loop170557_ ((_nodeset170559_ _nodeset170555_)
                           (_selectors170560_ _selectors170553_))
          (if (null? _selectors170560_)
              _nodeset170559_
              (_loop170557_
               (if (std/xml/sxpath#nodeset? _nodeset170559_)
                   (std/xml/sxpath#map-union
                    (car _selectors170560_)
                    _nodeset170559_)
                   ((car _selectors170560_) _nodeset170559_))
               (cdr _selectors170560_)))))))
  (define std/xml/sxpath#node-reduce
    (lambda _converters170544_
      (lambda (_nodeset170546_)
        (let _loop170548_ ((_nodeset170550_ _nodeset170546_)
                           (_converters170551_ _converters170544_))
          (if (null? _converters170551_)
              _nodeset170550_
              (_loop170548_
               ((car _converters170551_) _nodeset170550_)
               (cdr _converters170551_)))))))
  (define std/xml/sxpath#node-or
    (lambda _converters170532_
      (lambda (_node-or-nodeset170534_)
        (let _loop170536_ ((_result170538_ '())
                           (_converters170539_ _converters170532_))
          (if (null? _converters170539_)
              _result170538_
              (_loop170536_
               (append _result170538_
                       (let ((_$e170541_
                              ((car _converters170539_)
                               _node-or-nodeset170534_)))
                         (if _$e170541_ _$e170541_ '())))
               (cdr _converters170539_)))))))
  (define std/xml/sxpath#node-closure
    (lambda (_test-pred?170523_)
      (lambda (_node170525_)
        (let _loop170527_ ((_parent170529_ _node170525_) (_result170530_ '()))
          (if (null? _parent170529_)
              _result170530_
              (_loop170527_
               ((std/xml/sxpath#select-kids (std/xml/sxpath#node-typeof? '*))
                _parent170529_)
               (append _result170530_
                       ((std/xml/sxpath#select-kids _test-pred?170523_)
                        _parent170529_))))))))
  (define std/xml/sxpath#node-parent
    (lambda (_rootnode170517_)
      (lambda (_node170519_)
        (if (std/xml/sxpath#nodeset? _node170519_)
            (std/xml/sxpath#map-union
             (std/xml/sxpath#node-parent _rootnode170517_)
             _node170519_)
            (let ((_pred170521_
                   (std/xml/sxpath#node-or
                    (std/xml/sxpath#node-reduce
                     (std/xml/sxpath#node-self
                      (std/xml/sxpath#node-typeof? '*))
                     (std/xml/sxpath#select-kids
                      (std/xml/sxpath#node-eq? _node170519_)))
                    (std/xml/sxpath#node-join
                     (std/xml/sxpath#select-kids
                      (std/xml/sxpath#node-typeof? '@))
                     (std/xml/sxpath#select-kids
                      (std/xml/sxpath#node-eq? _node170519_))))))
              ((std/xml/sxpath#node-or
                (std/xml/sxpath#node-self _pred170521_)
                (std/xml/sxpath#node-closure _pred170521_))
               _rootnode170517_))))))
  (define std/xml/sxpath#sxpath
    (lambda (_path170503_)
      (lambda (_nodeset170505_)
        (let _loop170507_ ((_nodeset170509_ _nodeset170505_)
                           (_path170510_ _path170503_))
          (if (null? _path170510_)
              _nodeset170509_
              (if (std/xml/sxpath#nodeset? _nodeset170509_)
                  (std/xml/sxpath#map-union
                   (std/xml/sxpath#sxpath _path170510_)
                   _nodeset170509_)
                  (if (procedure? (car _path170510_))
                      (_loop170507_
                       ((car _path170510_) _nodeset170509_)
                       (cdr _path170510_))
                      (if (eq? '// (car _path170510_))
                          (_loop170507_
                           ((if (std/xml/sxpath#nodeset? _nodeset170509_)
                                append
                                cons)
                            _nodeset170509_
                            ((std/xml/sxpath#node-closure
                              (std/xml/sxpath#node-typeof? '*any*))
                             _nodeset170509_))
                           (cdr _path170510_))
                          (if (symbol? (car _path170510_))
                              (_loop170507_
                               ((std/xml/sxpath#select-kids
                                 (std/xml/sxpath#node-typeof?
                                  (car _path170510_)))
                                _nodeset170509_)
                               (cdr _path170510_))
                              (if (and (pair? (car _path170510_))
                                       (eq? 'equal? (caar _path170510_)))
                                  (_loop170507_
                                   ((std/xml/sxpath#select-kids
                                     (apply std/xml/sxpath#node-equal?
                                            (cdar _path170510_)))
                                    _nodeset170509_)
                                   (cdr _path170510_))
                                  (if (and (pair? (car _path170510_))
                                           (eq? 'eq? (caar _path170510_)))
                                      (_loop170507_
                                       ((std/xml/sxpath#select-kids
                                         (apply std/xml/sxpath#node-eq?
                                                (cdar _path170510_)))
                                        _nodeset170509_)
                                       (cdr _path170510_))
                                      (if (pair? (car _path170510_))
                                          (let _reducer170512_ ((_nodeset170514_
;;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                         (if (symbol? (caar _path170510_))
                             ((std/xml/sxpath#select-kids
                               (std/xml/sxpath#node-typeof?
                                (caar _path170510_)))
                              _nodeset170509_)
                             (_loop170507_
                              _nodeset170509_
                              (caar _path170510_))))
                        (_reducing-path170515_ (cdar _path170510_)))
;;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
                                            (if (null? _reducing-path170515_)
                                                (_loop170507_
                                                 _nodeset170514_
                                                 (cdr _path170510_))
                                                (if (number? (car _reducing-path170515_))
                                                    (_reducer170512_
                                                     ((std/xml/sxpath#node-pos
                                                       (car _reducing-path170515_))
                                                      _nodeset170514_)
                                                     (cdr _reducing-path170515_))
                                                    (_reducer170512_
                                                     ((std/xml/sxpath#filter
                                                       (std/xml/sxpath#sxpath
                                                        (car _reducing-path170515_)))
                                                      _nodeset170514_)
                                                     (cdr _reducing-path170515_)))))
                                          (error '"Invalid path step: "
                                                 (car _path170510_)))))))))))))))
