(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 _args4675_
      (for-each
       (lambda (_x4677_) (if (procedure? _x4677_) (_x4677_) (display _x4677_)))
       _args4675_)))
  (define std/xml/sxpath#cerr
    (lambda _args4671_
      (for-each
       (lambda (_x4673_)
         (if (procedure? _x4673_)
             (_x4673_ (current-error-port))
             (display _x4673_ (current-error-port))))
       _args4671_)))
  (define std/xml/sxpath#nodeset?
    (lambda (_x4666_)
      (let ((_$e4668_ (if (pair? _x4666_) (not (symbol? (car _x4666_))) '#f)))
        (if _$e4668_ _$e4668_ (null? _x4666_)))))
  (define std/xml/sxpath#node-typeof?
    (lambda (_crit4659_)
      (lambda (_node4661_)
        (let ((_$e4663_ _crit4659_))
          (if (eq? '* _$e4663_)
              (if (pair? _node4661_)
                  (not (memq (car _node4661_) '(@ *PI*)))
                  '#f)
              (if (eq? '*any* _$e4663_)
                  '#t
                  (if (eq? '*text* _$e4663_)
                      (string? _node4661_)
                      (if (pair? _node4661_)
                          (eq? _crit4659_ (car _node4661_))
                          '#f))))))))
  (define std/xml/sxpath#node-eq?
    (lambda (_other4655_) (lambda (_node4657_) (eq? _other4655_ _node4657_))))
  (define std/xml/sxpath#node-equal?
    (lambda (_other4651_)
      (lambda (_node4653_) (equal? _other4651_ _node4653_))))
  (define std/xml/sxpath#node-pos
    (lambda (_n1656_)
      (lambda (_nodeset1658_)
        (if (not (std/xml/sxpath#nodeset? _nodeset1658_))
            '()
            (if (null? _nodeset1658_)
                _nodeset1658_
                (if (eqv? _n1656_ '1)
                    (list (car _nodeset1658_))
                    (if (negative? _n1656_)
                        ((std/xml/sxpath#node-pos
                          (+ _n1656_ '1 (length _nodeset1658_)))
                         _nodeset1658_)
                        (begin
                          (let ((_$e3026_ (positive? _n1656_)))
                            (if _$e3026_
                                _$e3026_
                                (begin
                                  (std/xml/sxpath#cerr
                                   '"failed assertion: "
                                   '(positive? n)
                                   std/xml/sxpath#nl
                                   '"bindings"
                                   '#\newline
                                   'n
                                   '": "
                                   _n1656_
                                   std/xml/sxpath#nl)
                                  (error '"assertion failure"))))
                          ((std/xml/sxpath#node-pos (- _n1656_ '1))
                           (cdr _nodeset1658_))))))))))
  (define std/xml/sxpath#filter
    (lambda (_pred?1645_)
      (lambda (_lst1647_)
        (let _loop1649_ ((_lst1651_
                          (if (std/xml/sxpath#nodeset? _lst1647_)
                              _lst1647_
                              (list _lst1647_)))
                         (_res1652_ '()))
          (if (null? _lst1651_)
              (reverse _res1652_)
              (let ((_pred-result1654_ (_pred?1645_ (car _lst1651_))))
                (_loop1649_
                 (cdr _lst1651_)
                 (if (and _pred-result1654_ (not (null? _pred-result1654_)))
                     (cons (car _lst1651_) _res1652_)
                     _res1652_))))))))
  (define std/xml/sxpath#take-until
    (lambda (_pred?1635_)
      (lambda (_lst1637_)
        (let _loop1639_ ((_lst1641_
                          (if (std/xml/sxpath#nodeset? _lst1637_)
                              _lst1637_
                              (list _lst1637_))))
          (if (null? _lst1641_)
              _lst1641_
              (let ((_pred-result1643_ (_pred?1635_ (car _lst1641_))))
                (if (and _pred-result1643_ (not (null? _pred-result1643_)))
                    '()
                    (cons (car _lst1641_) (_loop1639_ (cdr _lst1641_))))))))))
  (define std/xml/sxpath#take-after
    (lambda (_pred?1625_)
      (lambda (_lst1627_)
        (let _loop1629_ ((_lst1631_
                          (if (std/xml/sxpath#nodeset? _lst1627_)
                              _lst1627_
                              (list _lst1627_))))
          (if (null? _lst1631_)
              _lst1631_
              (let ((_pred-result1633_ (_pred?1625_ (car _lst1631_))))
                (if (and _pred-result1633_ (not (null? _pred-result1633_)))
                    (cdr _lst1631_)
                    (_loop1629_ (cdr _lst1631_)))))))))
  (define std/xml/sxpath#map-union
    (lambda (_proc1620_ _lst1621_)
      (if (null? _lst1621_)
          _lst1621_
          (let ((_proc-res1623_ (_proc1620_ (car _lst1621_))))
            ((if (std/xml/sxpath#nodeset? _proc-res1623_) append cons)
             _proc-res1623_
             (std/xml/sxpath#map-union _proc1620_ (cdr _lst1621_)))))))
  (define std/xml/sxpath#node-reverse
    (lambda (_node-or-nodeset1618_)
      (if (not (std/xml/sxpath#nodeset? _node-or-nodeset1618_))
          (list _node-or-nodeset1618_)
          (reverse _node-or-nodeset1618_))))
  (define std/xml/sxpath#node-trace
    (lambda (_title1614_)
      (lambda (_node-or-nodeset1616_)
        (std/xml/sxpath#cout std/xml/sxpath#nl '"-->")
        (display _title1614_)
        (display '" :")
        (pretty-print _node-or-nodeset1616_)
        _node-or-nodeset1616_)))
  (define std/xml/sxpath#select-kids
    (lambda (_test-pred?1610_)
      (lambda (_node1612_)
        (if (null? _node1612_)
            _node1612_
            (if (not (pair? _node1612_))
                '()
                (if (symbol? (car _node1612_))
                    ((std/xml/sxpath#filter _test-pred?1610_) (cdr _node1612_))
                    (std/xml/sxpath#map-union
                     (std/xml/sxpath#select-kids _test-pred?1610_)
                     _node1612_)))))))
  (define std/xml/sxpath#node-self std/xml/sxpath#filter)
  (define std/xml/sxpath#node-join
    (lambda _selectors1601_
      (lambda (_nodeset1603_)
        (let _loop1605_ ((_nodeset1607_ _nodeset1603_)
                         (_selectors1608_ _selectors1601_))
          (if (null? _selectors1608_)
              _nodeset1607_
              (_loop1605_
               (if (std/xml/sxpath#nodeset? _nodeset1607_)
                   (std/xml/sxpath#map-union
                    (car _selectors1608_)
                    _nodeset1607_)
                   ((car _selectors1608_) _nodeset1607_))
               (cdr _selectors1608_)))))))
  (define std/xml/sxpath#node-reduce
    (lambda _converters1592_
      (lambda (_nodeset1594_)
        (let _loop1596_ ((_nodeset1598_ _nodeset1594_)
                         (_converters1599_ _converters1592_))
          (if (null? _converters1599_)
              _nodeset1598_
              (_loop1596_
               ((car _converters1599_) _nodeset1598_)
               (cdr _converters1599_)))))))
  (define std/xml/sxpath#node-or
    (lambda _converters1580_
      (lambda (_node-or-nodeset1582_)
        (let _loop1584_ ((_result1586_ '())
                         (_converters1587_ _converters1580_))
          (if (null? _converters1587_)
              _result1586_
              (_loop1584_
               (append _result1586_
                       (let ((_$e1589_
                              ((car _converters1587_) _node-or-nodeset1582_)))
                         (if _$e1589_ _$e1589_ '())))
               (cdr _converters1587_)))))))
  (define std/xml/sxpath#node-closure
    (lambda (_test-pred?1571_)
      (lambda (_node1573_)
        (let _loop1575_ ((_parent1577_ _node1573_) (_result1578_ '()))
          (if (null? _parent1577_)
              _result1578_
              (_loop1575_
               ((std/xml/sxpath#select-kids (std/xml/sxpath#node-typeof? '*))
                _parent1577_)
               (append _result1578_
                       ((std/xml/sxpath#select-kids _test-pred?1571_)
                        _parent1577_))))))))
  (define std/xml/sxpath#node-parent
    (lambda (_rootnode1565_)
      (lambda (_node1567_)
        (if (std/xml/sxpath#nodeset? _node1567_)
            (std/xml/sxpath#map-union
             (std/xml/sxpath#node-parent _rootnode1565_)
             _node1567_)
            (let ((_pred1569_
                   (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? _node1567_)))
                    (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? _node1567_))))))
              ((std/xml/sxpath#node-or
                (std/xml/sxpath#node-self _pred1569_)
                (std/xml/sxpath#node-closure _pred1569_))
               _rootnode1565_))))))
  (define std/xml/sxpath#sxpath
    (lambda (_path1551_)
      (lambda (_nodeset1553_)
        (let _loop1555_ ((_nodeset1557_ _nodeset1553_) (_path1558_ _path1551_))
          (if (null? _path1558_)
              _nodeset1557_
              (if (std/xml/sxpath#nodeset? _nodeset1557_)
                  (std/xml/sxpath#map-union
                   (std/xml/sxpath#sxpath _path1558_)
                   _nodeset1557_)
                  (if (procedure? (car _path1558_))
                      (_loop1555_
                       ((car _path1558_) _nodeset1557_)
                       (cdr _path1558_))
                      (if (eq? '// (car _path1558_))
                          (_loop1555_
                           ((if (std/xml/sxpath#nodeset? _nodeset1557_)
                                append
                                cons)
                            _nodeset1557_
                            ((std/xml/sxpath#node-closure
                              (std/xml/sxpath#node-typeof? '*any*))
                             _nodeset1557_))
                           (cdr _path1558_))
                          (if (symbol? (car _path1558_))
                              (_loop1555_
                               ((std/xml/sxpath#select-kids
                                 (std/xml/sxpath#node-typeof?
                                  (car _path1558_)))
                                _nodeset1557_)
                               (cdr _path1558_))
                              (if (and (pair? (car _path1558_))
                                       (eq? 'equal? (caar _path1558_)))
                                  (_loop1555_
                                   ((std/xml/sxpath#select-kids
                                     (apply std/xml/sxpath#node-equal?
                                            (cdar _path1558_)))
                                    _nodeset1557_)
                                   (cdr _path1558_))
                                  (if (and (pair? (car _path1558_))
                                           (eq? 'eq? (caar _path1558_)))
                                      (_loop1555_
                                       ((std/xml/sxpath#select-kids
                                         (apply std/xml/sxpath#node-eq?
                                                (cdar _path1558_)))
                                        _nodeset1557_)
                                       (cdr _path1558_))
                                      (if (pair? (car _path1558_))
                                          (let _reducer1560_ ((_nodeset1562_
                                                               (if (symbol? (caar _path1558_))
;;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                           ((std/xml/sxpath#select-kids
                             (std/xml/sxpath#node-typeof? (caar _path1558_)))
                            _nodeset1557_)
                           (_loop1555_ _nodeset1557_ (caar _path1558_))))
                      (_reducing-path1563_ (cdar _path1558_)))
;;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
                                            (if (null? _reducing-path1563_)
                                                (_loop1555_
                                                 _nodeset1562_
                                                 (cdr _path1558_))
                                                (if (number? (car _reducing-path1563_))
                                                    (_reducer1560_
                                                     ((std/xml/sxpath#node-pos
                                                       (car _reducing-path1563_))
                                                      _nodeset1562_)
                                                     (cdr _reducing-path1563_))
                                                    (_reducer1560_
                                                     ((std/xml/sxpath#filter
                                                       (std/xml/sxpath#sxpath
                                                        (car _reducing-path1563_)))
                                                      _nodeset1562_)
                                                     (cdr _reducing-path1563_)))))
                                          (error '"Invalid path step: "
                                                 (car _path1558_)))))))))))))))
