The implementation of SXPath axes with support for distinct document order This software is in Public Domain. IT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. Please send bug reports and comments to<EMAIL_ADDRESS>Dmitry Lizorkin The implementation of axes is based on the idea of context
Returns the last member of the lst lst is expected to be non-empty
Selects all attribute and child nodes of a given 'node' Node is not supposed to be a context
For a given node, returns its attribute nodes and attribute value nodes in document order Node is not supposed to be a context
Removes those members of the input 'nodeset' that are attributes or attribute values of a given 'node'. Nodeset is supposed to be in distinct document order. The order of attribute nodes in the 'nodeset' is supposed to be the same as in the original SXML document Works for ordinary nodes are well as for contexts
In this section, all axes expect the argument node-set in distinct document order, and return the result in distinct document order
Ancestor axis In general, every two nodes have have some common ancestors (at least the root of the document). When we obtain ancestors of the context node, only those of them must be added to the result which are different from the ancestors of the previous node in the input node-set
Ancestor-or-self axis See the comment for ddo:ancestor
Attribute axis The alias for drart:attribute, since no reordering or duplicate elimination is required
Child axis If the input node is such that node of the nodes is the descendant of another, draft:child will produce the result in distinct document order In the general case, the implementation for child axis is more complicated, since it must provide the correct ordering
Descendant axis We should take into account that one node in the input node set may be the descendant of the other node in the input node-set. Evaluation of descendant axis should not take the former node into account then, since its descendants won't add any new nodes to the result with respects to descendants of the latter node. Note that if the input node is such that node of the nodes is the descendant of another, draft:descendant will produce the result in distinct document order
Descendant-or-self axis See the comment for ddo:descendant Note that if the input node is such that node of the nodes is the descendant of another, draft:descendant-or-self will produce the result in distinct document order
Following axis The implementation exploits the idea expressed in http://pi3.informatik.uni-mannheim.de/publications/TR-02-011.pdf, that is, it is sufficient to calculate following for the first_dmax member of the input nodeset
Following-sibling axis
Namespace axis The alias for drart:namespace, since no reordering or duplicate elimination is required
Parent axis When locating a parent, the thing we should care about is that several nodes in the input node-set may have the same parent node
Preceding axis The implementation exploits the idea expressed in http://pi3.informatik.uni-mannheim.de/publications/TR-02-011.pdf, that is, it is sufficient to calculate preceding for the last_dmin member of the input nodeset
Preceding-sibling axis
Self axis The alias for drart:self, since no reordering or duplicate elimination is required num-ancestors is not used here
hierarchy within a document In this case, some axes can be implemented more effectively
Following axis for special case According to http://pi3.informatik.uni-mannheim.de/publications/TR-02-011.pdf, it is sufficient to calculate following for the first member of the input nodeset
Following-sibling axis for the special case We need only to care of duplicates removal, and ordering would be achieved automatically
Parent axis for the case when all nodes in the input node-set are located on the same level of hierarchy within a document In this case the parent axis can be computed with the O(n) complexity, n is the number of nodes in the document, compared to O(n^2) complexity for ddo:parent
Preceding axis for the special case The implementation exploits the idea expressed in http://pi3.informatik.uni-mannheim.de/publications/TR-02-011.pdf, that is, it is sufficient to calculate preceding for the last member of the input nodeset
Preceding-sibling axis for the special case
Result is represented in the form of pos-result ::= (listof pos-nodeset) pos-nodeset ::= (listof (cons node order-num)) Each pos-nodeset is a result of applying the axis to a single node in the input nodeset. Pos-result can be informally considered as (map axis-pos input-nodeset) Each node in the pos-nodeset comes with its order number. An order-num is an integer, possibly a negative one. A node precedes another node in document order if the order-num of the former node is less than the order-num of the latter node. Equal order-nums (in different pos-nodesets) correspond to equal nodes. Each pos-nodeset is sorted in accordance with the position() of each of its members. Consequently, order-nums increase within pos-nodeset for forward XPath axes and decrease for reverse XPath axes.
Ancestor axis, for position-based filtering
Ancestor-or-self axis, for position-based filtering
Child axis, for position-based filtering
Descendant axis, for position-based filtering When no node in the input node-set is a descendant of another node in the input node-set, the ordinary draft:descendant function can be used
Descendant-or-selt axis, for position-based filtering When no node in the input node-set is a descendant of another node in the input node-set, the ordinary draft:descendant function can be used
Following-sibling axis, for position-based filtering
Parent axis, for position-based filtering We won't reinvent the wheel here. We'll use ddo:parent and apply the fact that for every single input node the parent axis produces no more than a single result node
Preceding-sibling axis, for position-based filtering
hierarchy within a document In this case, some axes can be implemented more effectively
Following axis for the special case
Following-sibling axis for the special case
Parent axis, for position-based filtering This function has very much the same with ddo:parent-pos. In future, we should use a meta-function for paremetrization of these two
Preceding axis for the special case
Preceding-sibling axis for the special case
Returns the last member of the lst lst is expected to be non-empty
(define (ddo:list-last lst) (if (null? (cdr lst)) (car lst) (ddo:list-last (cdr lst))))
Selects all attribute and child nodes of a given 'node' Node is not supposed to be a context
(define (ddo:attr-child node) (cond ((or (not (pair? node)) ; Leaf node (null? (cdr node)) ; empty element (memq (car node) '(*PI* *COMMENT* *ENTITY*)) ; PI, Comment or Entity ) ; => no children '()) ((and (pair? (cadr node)) (eq? '@ (caadr node))) ; attribute node presented (append (cdadr node) ; attributes (filter sxml:node? (cddr node)))) (else ; no attributes (filter sxml:node? (cdr node)))))
For a given node, returns its attribute nodes and attribute value nodes in document order Node is not supposed to be a context
(define (ddo:attrs-and-values node) (apply append (map ; attribute and its content (lambda (a) (cons a (cdr a))) (sxml:attr-list node))))
Removes those members of the input 'nodeset' that are attributes or attribute values of a given 'node'. Nodeset is supposed to be in distinct document order. The order of attribute nodes in the 'nodeset' is supposed to be the same as in the original SXML document Works for ordinary nodes are well as for contexts
(define (ddo:discard-attributes node nodeset) (let loop ((attrs (ddo:attrs-and-values (sxml:context->node node))) (nset nodeset)) (if (or (null? attrs) (null? nset)) nset (loop (cdr attrs) (if (eq? (car attrs) (sxml:context->node (car nset))) (cdr nset) nset)))))
Ancestor axis In general, every two nodes have have some common ancestors (at least the root of the document). When we obtain ancestors of the context node, only those of them must be added to the result which are different from the ancestors of the previous node in the input node-set
(define (ddo:ancestor test-pred? . num-ancestors) (let ((num-anc (if (null? num-ancestors) 0 (car num-ancestors)))) (lambda (node) ; node or nodeset (let loop ((src (as-nodeset node)) (prev-ancestors '()) (res '())) (if (null? src) ; everyone processed (reverse res) (let ((curr (car src))) (if (sxml:context? curr) (let rpt ((curr-ancs (reverse (sxml:context->ancestors-u curr))) (dupl '())) (cond ((null? curr-ancs) ; no new ancestors (loop (cdr src) prev-ancestors res)) ((memq (car curr-ancs) prev-ancestors) ; member of the ancestorial chain (rpt (cdr curr-ancs) (cons (car curr-ancs) dupl))) (else ; the first different ancestor in a chain found (let creat ((new-ancestors dupl) (curr-ancs curr-ancs) (res res)) (cond ((null? curr-ancs) ; everyone processed (loop (cdr src) new-ancestors res)) ((test-pred? (car curr-ancs)) ; add to the result (creat (cons (car curr-ancs) new-ancestors) (cdr curr-ancs) (cons (draft:smart-make-context (car curr-ancs) new-ancestors num-anc) res))) (else ; this node doesn't satisfy the node test (creat (cons (car curr-ancs) new-ancestors) (cdr curr-ancs) res))))))) ; no ancestors for this node (loop (cdr src) prev-ancestors res))))))))
Ancestor-or-self axis See the comment for ddo:ancestor
(define (ddo:ancestor-or-self test-pred? . num-ancestors) (let ((num-anc (if (null? num-ancestors) 0 (car num-ancestors)))) (lambda (node) ; node or nodeset (let loop ((src (as-nodeset node)) (prev-ancestors '()) (res '())) (if (null? src) ; everyone processed (reverse res) (let rpt ((curr-ancs (reverse (sxml:context->content (car src)))) (dupl '())) (cond ((null? curr-ancs) ; no new ancestors (loop (cdr src) prev-ancestors res)) ((memq (car curr-ancs) prev-ancestors) ; member of the ancestorial chain (rpt (cdr curr-ancs) (cons (car curr-ancs) dupl))) (else ; the first different ancestor in a chain found (let creat ((new-ancestors dupl) (curr-ancs curr-ancs) (res res)) (cond ((null? curr-ancs) ; everyone processed (loop (cdr src) new-ancestors res)) ((test-pred? (car curr-ancs)) ; add to the result (creat (cons (car curr-ancs) new-ancestors) (cdr curr-ancs) (cons (draft:smart-make-context (car curr-ancs) new-ancestors num-anc) res))) (else ; this node doesn't satisfy the node test (creat (cons (car curr-ancs) new-ancestors) (cdr curr-ancs) res))))))))))))
Attribute axis The alias for drart:attribute, since no reordering or duplicate elimination is required
(define ddo:attribute draft:attribute)
Child axis If the input node is such that node of the nodes is the descendant of another, draft:child will produce the result in distinct document order In the general case, the implementation for child axis is more complicated, since it must provide the correct ordering
(define (ddo:child test-pred? . num-ancestors) (let ((num-anc (if (null? num-ancestors) 0 (car num-ancestors))) (child (sxml:child sxml:node?))) (letrec ((child4this ; Arguments ; curr-node - current node (or context) to process ; src - the remaining nodes of the input node-set ; Returns: (values res src) (lambda (curr-node src) (let iter-attrs ((src src) (res '())) (cond ((null? src) ; the zoo is completely over (values (append res ((draft:child test-pred? num-anc) curr-node)) src ; null )) ((memq (sxml:context->node (car src)) (sxml:attr-list (sxml:context->node curr-node))) ; next in src is the attribute of the curr-node (iter-attrs (cdr src) (append res ((draft:child test-pred? num-anc) (car src))))) (else ; normal behaviour (let ((res-ancestors (sxml:context->content curr-node))) (let iter-cands ((res-candidates (child (sxml:context->node curr-node))) (src src) (res res)) (cond ((null? src) ; this zoo is over (values (append res (draft:siblings->context-set ((sxml:filter test-pred?) res-candidates) (draft:list-head res-ancestors num-anc))) src ; always null )) ((null? res-candidates) (values res src)) (else ; processing the current res-candidate (let rpt ((more (list (car res-candidates))) (next (sxml:context->node (car src))) (src src) (res (if (test-pred? (car res-candidates)) (append res (list (draft:smart-make-context (car res-candidates) res-ancestors num-anc))) res))) (cond ((null? more) ; no more src members (iter-cands (cdr res-candidates) src res)) ((eq? (car more) next) ; next node is a descendant-or-self candidate ; or the attribute of its descendants (call-with-values (lambda () (child4this (car src) (cdr src))) (lambda (add-res new-src) (if (null? new-src) (iter-cands ; will exit there (cdr res-candidates) new-src (append res add-res)) (rpt (cdr more) ; kids processed by recursive (sxml:context->node (car new-src)) new-src (append res add-res)))))) (else (rpt (append (ddo:attr-child (car more)) (cdr more)) next src res)))))))))))))) (lambda (node) ; node or nodeset (if (nodeset? node) (let iter ((nset node) (res '())) (if (null? nset) res (call-with-values (lambda () (child4this (car nset) (cdr nset))) (lambda (add-res new-nset) (iter new-nset (append res add-res)))))) ((draft:child test-pred? num-anc) node))))))
Descendant axis We should take into account that one node in the input node set may be the descendant of the other node in the input node-set. Evaluation of descendant axis should not take the former node into account then, since its descendants won't add any new nodes to the result with respects to descendants of the latter node. Note that if the input node is such that node of the nodes is the descendant of another, draft:descendant will produce the result in distinct document order
(define (ddo:descendant test-pred? . num-ancestors) (let* ((num-anc (if (null? num-ancestors) 0 (car num-ancestors))) (child (sxml:child sxml:node?)) (desc (draft:descendant test-pred? num-anc))) (lambda (node) ; node or nodeset (let loop ((src (as-nodeset node)) (next-node #f) (content-to-scan '()) (res '())) (if (null? content-to-scan) (cond ((null? src) ; everyone processed (reverse res)) ((null? (cdr src)) ; of length 1 => never produces duplicates (append (reverse res) (desc (car src)))) (else (loop (cdr src) (sxml:context->node (cadr src)) (let ((cntnt (sxml:context->content (car src)))) (map (lambda (c) (cons c cntnt)) (child (sxml:context->node (car src))))) res))) (let ((curr-cntnt (car content-to-scan))) (call-with-values (lambda () (if ; next input node should be removed from consideration (eq? (car curr-cntnt) next-node) (values (cdr src) (if (null? (cdr src)) ; no next node #f (sxml:context->node (cadr src)))) (values src next-node))) (lambda (new-src new-next) (loop new-src new-next (append (map (lambda (c) (cons c curr-cntnt)) (child (car curr-cntnt))) (cdr content-to-scan)) (if (test-pred? (car curr-cntnt)) ; satisfies the node test (cons (draft:smart-make-context (car curr-cntnt) (cdr curr-cntnt) num-anc) res) res))))))))))
Descendant-or-self axis See the comment for ddo:descendant Note that if the input node is such that node of the nodes is the descendant of another, draft:descendant-or-self will produce the result in distinct document order
(define (ddo:descendant-or-self test-pred? . num-ancestors) (let* ((num-anc (if (null? num-ancestors) 0 (car num-ancestors))) (child (sxml:child sxml:node?)) (desc-os (draft:descendant-or-self test-pred? num-anc))) (lambda (node) ; node or nodeset (let loop ((src (as-nodeset node)) (next-node #f) (content-to-scan '()) (res '())) (if (null? content-to-scan) (cond ((null? src) ; everyone processed (reverse res)) ((null? (cdr src)) ; of length 1 => never produces duplicates (append (reverse res) (desc-os (car src)))) (else (loop (cdr src) (sxml:context->node (cadr src)) (list (sxml:context->content (car src))) res))) (let ((curr-cntnt (car content-to-scan))) (call-with-values (lambda () (if ; next input node should be removed from consideration (eq? (car curr-cntnt) next-node) (values (cdr src) (if (null? (cdr src)) ; no next node #f (sxml:context->node (cadr src)))) (values src next-node))) (lambda (new-src new-next) (loop new-src new-next (append (map (lambda (c) (cons c curr-cntnt)) (child (car curr-cntnt))) (cdr content-to-scan)) (if (test-pred? (car curr-cntnt)) ; satisfies the node test (cons (draft:smart-make-context (car curr-cntnt) (cdr curr-cntnt) num-anc) res) res))))))))))
Following axis The implementation exploits the idea expressed in http://pi3.informatik.uni-mannheim.de/publications/TR-02-011.pdf, that is, it is sufficient to calculate following for the first_dmax member of the input nodeset
(define (ddo:following test-pred? . num-ancestors) (let ((child (sxml:child sxml:node?)) (foll (apply draft:following (cons test-pred? num-ancestors)))) (lambda (node) ; node or nodeset (cond ((null? node) ; empty nodeset - nothing to do '()) ((and (pair? node) (not (symbol? (car node)))) ; non-empty nodeset (if (null? (cdr node)) ; a singleton nodeset (foll (car node)) (let loop ((candidate (car node)) (next (sxml:context->node (cadr node))) (more (cdr node)) (descendants (list (sxml:context->node (car node))))) (cond ((null? descendants) ; none of the node-set members are descendants of the candidate ; => apply following axis (foll candidate)) ((eq? (car descendants) next) ; the next node is the new candidate (if (null? (cdr more)) ; the next node is the final candidate (foll (car more)) (loop (car more) (sxml:context->node (cadr more)) (cdr more) (list next)))) ((memq next (ddo:attrs-and-values (car descendants))) ; next node in src is an attribute node or attribute value node (foll (car more))) (else ; proceed deeper in a tree (loop candidate next more (append (child (car descendants)) (cdr descendants)))))))) (else ; a single node (foll node))))))
Following-sibling axis
(define (ddo:following-sibling test-pred? . num-ancestors) (let ((num-anc (if (null? num-ancestors) 0 (car num-ancestors))) (child (sxml:child sxml:node?)) (all-following-siblings (lambda (node) ; not a nodeset (if (and (sxml:context? node) (not (null? (sxml:context->ancestors-u node)))) (cond ((memq (sxml:context->node-u node) (cdr ; parent is an element => cdr gives its children (car (sxml:context->ancestors-u node)))) => (lambda (x) x)) (else ; no following siblings '())) '() ; no parent => no siblings )))) (letrec ((reordering ; Arguments ; res-candidates = (listof node) - candidates for the result, not ; yet filtered with a node test ; res-ancestors - ancestors of res-candidates ; src - the remaining nodes of the input node-set ; Returns: (values res src) (lambda (res-candidates res-ancestors src) (let loop ((res-candidates res-candidates) (src src) (res '()) (nonself? #f)) (cond ((null? res-candidates) (values res src)) ((null? src) ; this zoo is over (values (append res (draft:siblings->context-set ((sxml:filter test-pred?) (if nonself? res-candidates (cdr res-candidates))) (draft:list-head res-ancestors num-anc))) src ; always null )) ((eq? (car res-candidates) (sxml:context->node (car src))) (loop res-candidates (cdr src) res nonself?)) (else ; processing the current res-candidate (let ((res-candidate (car res-candidates))) (let rpt ((more (list res-candidate)) (next (sxml:context->node (car src))) (src src) (res (if (and nonself? (test-pred? res-candidate)) (append res (list (draft:smart-make-context res-candidate res-ancestors num-anc))) res))) (cond ((null? more) ; no more src members among res-candidate descendants (loop (cdr res-candidates) src res #t)) ((eq? (car more) next) ; next node is a descendant-or-self of res-candidate (call-with-values (lambda () (reordering (all-following-siblings (car src)) (sxml:context->ancestors (car src)) (cdr src))) (lambda (add-res new-src) (if (null? new-src) (loop (cdr res-candidates) new-src (append res add-res) #t) (rpt (cdr more) ; kids processed by recursive (sxml:context->node (car new-src)) new-src (append res add-res)))))) ((memq next (ddo:attrs-and-values (car more))) ; the next node is the attribute node or ; attribute value node => it has no siblings (if (null? (cdr src)) (loop (cdr res-candidates) (cdr src) ; null res #t) (rpt more ; check for the other attributes (sxml:context->node (car src)) (cdr src) res))) (else (rpt (append (child (car more)) (cdr more)) next src res))))))))))) (lambda (node) ; node or nodeset (if (nodeset? node) (let iter ((nset node) (res '())) (if (null? nset) res (call-with-values (lambda () (reordering (all-following-siblings (car nset)) (sxml:context->ancestors (car nset)) (cdr nset))) (lambda (add-res new-nset) (iter new-nset (append res add-res)))))) ((draft:following-sibling test-pred? num-anc) node))))))
Namespace axis The alias for drart:namespace, since no reordering or duplicate elimination is required
(define ddo:namespace draft:namespace)
Parent axis When locating a parent, the thing we should care about is that several nodes in the input node-set may have the same parent node
(define (ddo:parent test-pred? . num-ancestors) (let ((num-anc (if (null? num-ancestors) 0 (car num-ancestors)))) (lambda (node) ; node or nodeset (let loop ((src (as-nodeset node)) (prev-parents '()) (res '())) (if (null? src) (reverse res) (let ((curr (car src))) (if (and (sxml:context? curr) (not (null? (sxml:context->ancestors-u curr)))) (let ((curr-parent (car (sxml:context->ancestors-u curr)))) (if (memq curr-parent prev-parents) ; a duplicate node ; this node is already in the result (loop (cdr src) prev-parents res) (loop (cdr src) (cons curr-parent prev-parents) (if (test-pred? curr-parent) (cons (draft:smart-make-context curr-parent (cdr (sxml:context->ancestors-u curr)) num-anc) res) res)))) ; no parent (loop (cdr src) prev-parents res))))))))
Preceding axis The implementation exploits the idea expressed in http://pi3.informatik.uni-mannheim.de/publications/TR-02-011.pdf, that is, it is sufficient to calculate preceding for the last_dmin member of the input nodeset
(define (ddo:preceding test-pred? . num-ancestors) (let ((prec (apply draft:preceding (cons test-pred? num-ancestors)))) (lambda (node) ; node or nodeset (cond ((null? node) ; empty nodeset - nothing to do '()) ((and (pair? node) (not (symbol? (car node)))) ; non-empty nodeset (if (null? (cdr node)) ; a singleton nodeset (prec (car node)) (let ((node (reverse node))) (let loop ((candidate (car node)) (next (sxml:context->node (cadr node))) (more (cdr node)) (descendants (reverse (ddo:attr-child (sxml:context->node (car node)))))) (cond ((null? descendants) ; none of the node-set members are descendants of the candidate ; => apply following axis (reverse (prec candidate))) ((eq? (car descendants) next) ; the next node is the new candidate (if (null? (cdr more)) ; the next node is the final candidate (reverse (prec (car more))) (loop (car more) (sxml:context->node (cadr more)) (cdr more) (reverse (ddo:attr-child next))))) (else ; proceed deeper in a tree (loop candidate next more (append (reverse (ddo:attr-child (car descendants))) (cdr descendants))))))))) (else ; a single node (reverse (prec node)))))))
Preceding-sibling axis
(define (ddo:preceding-sibling test-pred? . num-ancestors) (let ((num-anc (if (null? num-ancestors) 0 (car num-ancestors))) (child (sxml:child sxml:node?)) (all-preceding-siblings ; Selects preceding siblings of the node (should be context) (lambda (node) ; not a nodeset (if (and (sxml:context? node) (not (null? (sxml:context->ancestors-u node)))) (cond ((memq (sxml:context->node-u node) (reverse (cdr ; parent is an element => cdr gives its children (car (sxml:context->ancestors-u node))))) => cdr) (else ; no preceding siblings '())) '() ; no parent => no siblings )))) (letrec ((reordering ; Arguments ; res-candidates = (listof node) - candidates for the result, not ; yet filtered with a node test ; res-ancestors - ancestors of res-candidates ; src - the remaining nodes of the input node-set ; Returns: (values res src) (lambda (res-candidates res-ancestors src) (let loop ((res-candidates res-candidates) (src src) (res '())) (cond ((null? res-candidates) (values res src)) ((null? src) ; this zoo is over (values (append res (draft:siblings->context-set ((sxml:filter test-pred?) res-candidates) (draft:list-head res-ancestors num-anc))) src ; always null )) ((eq? (car res-candidates) (sxml:context->node (car src))) (loop res-candidates (cdr src) res)) (else ; processing the current res-candidate (let ((res-candidate (car res-candidates))) (let rpt ((more (reverse (child res-candidate))) (next (sxml:context->node (car src))) (src src) (res res)) (cond ((null? more) ; no more src members among res-candidate descendants (loop (cdr res-candidates) src (if (test-pred? res-candidate) (append res (list (draft:smart-make-context res-candidate res-ancestors num-anc))) res))) ((eq? (car more) next) ; next node is a descendant-or-self of res-candidate (call-with-values (lambda () (reordering (all-preceding-siblings (car src)) (sxml:context->ancestors (car src)) (cdr src))) (lambda (add-res new-src) (let ((new-src (cond ((null? new-src) new-src) ((eq? res-candidate (sxml:context->node (car new-src))) (cdr new-src)) (else new-src)))) (if (null? new-src) (loop (cdr res-candidates) new-src (if (test-pred? res-candidate) (append res add-res (list (draft:smart-make-context res-candidate res-ancestors num-anc))) (append res add-res))) (rpt (cdr more) ; kids processed by recursive (sxml:context->node (car new-src)) new-src (append res add-res))))))) (else (rpt (append (reverse (child (car more))) (cdr more)) next src res))))))))))) (lambda (node) ; node or nodeset (if (nodeset? node) (let iter ((nset (reverse node)) (res '())) (if (null? nset) (reverse res) (call-with-values (lambda () (reordering (all-preceding-siblings (car nset)) (sxml:context->ancestors (car nset)) (cdr nset))) (lambda (add-res new-nset) (iter new-nset (append res add-res)))))) ((draft:following-sibling test-pred? num-anc) node))))))
Self axis The alias for drart:self, since no reordering or duplicate elimination is required num-ancestors is not used here
(define ddo:self draft:self)
Ancestor axis, for position-based filtering
(define (ddo:ancestor-pos test-pred? . num-ancestors) (let ((num-anc (if (null? num-ancestors) 0 (car num-ancestors)))) (letrec (; A hybrid of assq and memq (assmemq (lambda (key lst) (cond ((null? lst) #f) ((eq? key (caar lst)) lst) (else (assmemq key (cdr lst))))))) (lambda (node) ; node or nodeset (let loop ((src (as-nodeset node)) (prev-ancestors '()) (ancs-alist '()) (pos-res '()) (vacant-num 1)) ; ancs-alist ::= (listof (cons node pos-nodeset)) (if (null? src) ; everyone processed pos-res (let ((curr (car src))) (cond ((or (not (sxml:context? curr)) (null? (sxml:context->ancestors-u curr))) ; no ancestors for this node (loop (cdr src) prev-ancestors ancs-alist pos-res vacant-num)) ((and (not (null? prev-ancestors)) (eq? (car (sxml:context->ancestors-u curr)) (car prev-ancestors))) ; The common case of removing (some) duplicate result node-sets ; from consideration. (loop (cdr src) prev-ancestors ancs-alist pos-res vacant-num)) (else (let rpt ((curr-ancs (sxml:context->ancestors-u curr)) (new-content '())) ; new content - that didn't repeat with the previous ; ancestors (cond ((or (null? curr-ancs) ; all ancestors are new ; the first repeated found (memq (car curr-ancs) prev-ancestors)) => (lambda (prev-tail) (call-with-values (lambda() (if (pair? prev-tail) (let ((t (assmemq (car prev-tail) ancs-alist))) (values prev-tail t (cdar t))) (values '() '() '()))) (lambda (prev-ancestors ancs-alist this-nset) (let creat ((prev-ancestors prev-ancestors) (ancs-alist ancs-alist) (vacant-num vacant-num) (this-nset this-nset) (new-content new-content)) (if (null? new-content) ; everyone processed (loop (cdr src) prev-ancestors ancs-alist (cons this-nset pos-res) vacant-num) (let ((new-this-nset (if (test-pred? (caar new-content)) ; add to the result (cons (cons (draft:smart-make-context (caar new-content) (cdar new-content) num-anc) vacant-num) this-nset) this-nset))) (creat (car new-content) (cons (cons (caar new-content) new-this-nset) ancs-alist) (+ vacant-num 1) new-this-nset (cdr new-content))))))))) (else (rpt (cdr curr-ancs) (cons curr-ancs new-content))))))))))))))
Ancestor-or-self axis, for position-based filtering
(define (ddo:ancestor-or-self-pos test-pred? . num-ancestors) (let ((num-anc (if (null? num-ancestors) 0 (car num-ancestors)))) (letrec (; A hybrid of assq and memq (assmemq (lambda (key lst) (cond ((null? lst) #f) ((eq? key (caar lst)) lst) (else (assmemq key (cdr lst))))))) (lambda (node) ; node or nodeset (let loop ((src (as-nodeset node)) (prev-ancestors '()) (ancs-alist '()) (pos-res '()) (vacant-num 1)) ; ancs-alist ::= (listof (cons node pos-nodeset)) (if (null? src) ; everyone processed pos-res (let rpt ((curr-ancs (sxml:context->content (car src))) (new-content '())) ; new content - that didn't repeat with the previous ; ancestors (cond ((or (null? curr-ancs) ; all ancestors are new ; or the first repeated found (memq (car curr-ancs) prev-ancestors)) => (lambda (prev-tail) (call-with-values (lambda () (if (pair? prev-tail) (let ((t (assmemq (car prev-tail) ancs-alist))) (values prev-tail t (cdar t))) (values '() '() '()))) (lambda (prev-ancestors ancs-alist this-nset) (let creat ((prev-ancestors prev-ancestors) (ancs-alist ancs-alist) (vacant-num vacant-num) (this-nset this-nset) (new-content new-content)) (if (null? new-content) ; everyone processed (loop (cdr src) prev-ancestors ancs-alist (cons this-nset pos-res) vacant-num) (let ((new-this-nset (if (test-pred? (caar new-content)) ; add to the result (cons (cons (draft:smart-make-context (caar new-content) (cdar new-content) num-anc) vacant-num) this-nset) this-nset))) (creat (car new-content) (cons (cons (caar new-content) new-this-nset) ancs-alist) (+ vacant-num 1) new-this-nset (cdr new-content))))))))) (else (rpt (cdr curr-ancs) (cons curr-ancs new-content)))))))))))
Child axis, for position-based filtering
(define (ddo:child-pos test-pred? . num-ancestors) (let ((num-anc (if (null? num-ancestors) 0 (car num-ancestors))) (child (sxml:child sxml:node?))) (letrec (; Creates a pos-nodeset (create-pos-nset (lambda (nset ancestors vacant-num) (if (null? nset) '() (cons (cons (if (null? ancestors) (car nset) (draft:make-context (car nset) ancestors)) vacant-num) (create-pos-nset (cdr nset) ancestors (+ vacant-num 1)))))) (src-walk ; curr-node - current input node (probably context) ; src - the remaining nodes in the input nodeset ; order-num - the order number of the current result node ; Returns: (values pos-result new-src new-order-num) (lambda (curr-node src order-num) (let ((curr-children (child (sxml:context->node curr-node)))) (if (null? curr-children) ; nothing to do for this curr-node (values '() src order-num) (let ((curr-ancestors (draft:list-head (sxml:context->content curr-node) num-anc))) (if (null? src) ; no searching for descendants required (values (list (create-pos-nset ((sxml:filter test-pred?) curr-children) curr-ancestors order-num)) src ; always null #f ; nobody cares of order-num anymore ) (let loop ((src src) (next-node (sxml:context->node (car src))) (curr-children (cdr curr-children)) (desc-to-scan (list (car curr-children))) (this-res (if (test-pred? (car curr-children)) (list (cons (if (null? curr-ancestors) (car curr-children) (draft:make-context (car curr-children) curr-ancestors)) order-num)) '())) (pos-result '()) (order-num (+ order-num 1))) (cond ((null? desc-to-scan) ; we can proceed to next curr-children (if (null? curr-children) (values (cons (reverse this-res) pos-result) src order-num) (loop src next-node (cdr curr-children) (list (car curr-children)) (if (test-pred? (car curr-children)) (cons (cons (if (null? curr-ancestors) (car curr-children) (draft:make-context (car curr-children) curr-ancestors)) order-num) this-res) this-res) pos-result (+ order-num 1)))) ; There are descendants to be scanned ((eq? (car desc-to-scan) next-node) (call-with-values (lambda () (src-walk (car src) (cdr src) order-num)) (lambda (new-pos-res new-src new-order-num) (if (null? new-src) ; no more nodes in src nodeset (values (cons (append (reverse this-res) (create-pos-nset ((sxml:filter test-pred?) curr-children) curr-ancestors order-num)) (append pos-result new-pos-res)) new-src ; always null #f ; nobody cares of this number anymore ) (loop new-src (sxml:context->node (car new-src)) curr-children (cdr desc-to-scan) ; descendants processed this-res (append pos-result new-pos-res) new-order-num))))) (else ; proceed to the next descendant (loop src next-node curr-children (append ; content-to-scan (ddo:attr-child (car desc-to-scan)) (cdr desc-to-scan)) this-res pos-result order-num))))))))))) (lambda (node) ; node or nodeset (let rpt ((src (as-nodeset node)) (pos-result '()) (order-num 1)) (if (null? src) ; all processed (filter ; removing empty result nodesets (lambda (x) (not (null? x))) pos-result) (call-with-values (lambda () (src-walk (car src) (cdr src) order-num)) (lambda (new-pos-res new-src new-order-num) (rpt new-src (append pos-result new-pos-res) new-order-num)))))))))
Descendant axis, for position-based filtering When no node in the input node-set is a descendant of another node in the input node-set, the ordinary draft:descendant function can be used
(define (ddo:descendant-pos test-pred? . num-ancestors) (let* ((num-anc (if (null? num-ancestors) 0 (car num-ancestors))) (child (sxml:child sxml:node?)) (desc (draft:descendant test-pred? num-anc))) (letrec ((src-walk ; curr-node - current input node (probably context) ; src - the remaining nodes in the input nodeset ; order-num - the order number of the current result node ; Returns: (values pos-result new-src new-order-num) (lambda (curr-node src order-num) (let loop ((src src) (next-node (if (null? src) #f (sxml:context->node (car src)))) (content-to-scan (let ((cntnt (sxml:context->content curr-node))) (map (lambda (c) (cons c cntnt)) (child (sxml:context->node curr-node))))) (this-res '()) (pos-result '()) (order-num order-num)) (if (null? content-to-scan) (values (cons (reverse this-res) pos-result) src (+ order-num 1)) (let ((curr-cntnt (car content-to-scan))) (if (eq? (car curr-cntnt) next-node) (call-with-values (lambda () (src-walk (car src) (cdr src) (+ order-num 1))) (lambda (new-pos-res new-src new-order-num) (loop new-src (if (null? new-src) #f (sxml:context->node (car new-src))) (cdr content-to-scan) ; descendants processed (append (reverse (car new-pos-res)) (if ; this res (test-pred? (car curr-cntnt)) (cons (cons (draft:smart-make-context (car curr-cntnt) (cdr curr-cntnt) num-anc) order-num) this-res) this-res)) (append pos-result new-pos-res) new-order-num))) (loop src next-node (append ; content-to-scan (map (lambda (c) (cons c curr-cntnt)) (child (car curr-cntnt))) (cdr content-to-scan)) (if ; this res (test-pred? (car curr-cntnt)) ; satisfies the node test (cons (cons (draft:smart-make-context (car curr-cntnt) (cdr curr-cntnt) num-anc) order-num) this-res) this-res) pos-result (+ order-num 1))))))))) (lambda (node) ; node or nodeset (let rpt ((src (as-nodeset node)) (pos-result '()) (order-num 1)) (if (null? src) ; all processed (filter ; removing empty result nodesets (lambda (x) (not (null? x))) pos-result) (call-with-values (lambda () (src-walk (car src) (cdr src) order-num)) (lambda (new-pos-res new-src new-order-num) (rpt new-src (append pos-result new-pos-res) new-order-num)))))))))
Descendant-or-selt axis, for position-based filtering When no node in the input node-set is a descendant of another node in the input node-set, the ordinary draft:descendant function can be used
(define (ddo:descendant-or-self-pos test-pred? . num-ancestors) (let* ((num-anc (if (null? num-ancestors) 0 (car num-ancestors))) (child (sxml:child sxml:node?))) (letrec ((src-walk ; curr-node - current input node (probably context) ; src - the remaining nodes in the input nodeset ; order-num - the order number of the current result node ; Returns: (values pos-result new-src new-order-num) (lambda (curr-node src order-num) (let loop ((src src) (next-node (if (null? src) #f (sxml:context->node (car src)))) (content-to-scan (list (sxml:context->content curr-node))) (this-res '()) (pos-result '()) (order-num order-num)) (if (null? content-to-scan) (values (cons (reverse this-res) pos-result) src (+ order-num 1)) (let ((curr-cntnt (car content-to-scan))) (if (eq? (car curr-cntnt) next-node) (call-with-values (lambda () (src-walk (car src) (cdr src) order-num)) (lambda (new-pos-res new-src new-order-num) (loop new-src (if (null? new-src) #f (sxml:context->node (car new-src))) (cdr content-to-scan) ; descendants processed (append (reverse (car new-pos-res)) this-res) (append pos-result new-pos-res) new-order-num))) (loop src next-node (append ; content-to-scan (map (lambda (c) (cons c curr-cntnt)) (child (car curr-cntnt))) (cdr content-to-scan)) (if ; this res (test-pred? (car curr-cntnt)) ; satisfies the node test (cons (cons (draft:smart-make-context (car curr-cntnt) (cdr curr-cntnt) num-anc) order-num) this-res) this-res) pos-result (+ order-num 1))))))))) (lambda (node) ; node or nodeset (let rpt ((src (as-nodeset node)) (pos-result '()) (order-num 1)) (if (null? src) ; all processed (filter ; removing empty result nodesets (lambda (x) (not (null? x))) pos-result) (call-with-values (lambda () (src-walk (car src) (cdr src) order-num)) (lambda (new-pos-res new-src new-order-num) (rpt new-src (append pos-result new-pos-res) new-order-num)))))))))
Following-sibling axis, for position-based filtering
(define (ddo:following-sibling-pos test-pred? . num-ancestors) (let ((num-anc (if (null? num-ancestors) 0 (car num-ancestors))) (child (sxml:child sxml:node?))) (letrec ((associate-num (lambda (nset ancestors vacant-num) (if (null? nset) nset (cons (cons (if (null? ancestors) (car nset) (draft:make-context (car nset) ancestors)) vacant-num) (associate-num (cdr nset) ancestors (+ vacant-num 1)))))) ; curr - current context to be processed ; src - remaining source contexts ; vacant-num - order number for the result node ; Returns: (values pos-result new-src new-vacant-num) (process-single (lambda (curr src vacant-num) (if (or (not (sxml:context? curr)) (null? (sxml:context->ancestors-u curr))) ; Siblings cannot be identified (values '() src vacant-num) (cond ((memq (sxml:context->node-u curr) (cdr ; parent is an element => cdr gives its children (car (sxml:context->ancestors-u curr)))) => (lambda (foll-siblings) (let ((ancestors (draft:list-head (sxml:context->ancestors-u curr) num-anc))) ; Scanning descendants of the context node (let loop ((foll-siblings (cdr foll-siblings)) (descs (child (car foll-siblings))) (src (ddo:discard-attributes (car foll-siblings) src)) (vacant-num vacant-num) (res '()) (pos-res '())) (cond ((null? src) (values (cons (append (reverse res) (associate-num foll-siblings ancestors vacant-num)) pos-res) src ; always null #f ; nobody cares of this number anymore )) ((null? descs) ; descendants of current foll-sibling (if (null? foll-siblings) ; that stuff is over (values (cons (reverse res) pos-res) src vacant-num) (let ((new-res (if (test-pred? (car foll-siblings)) (cons (cons (if (null? ancestors) (car foll-siblings) (draft:make-context (car foll-siblings) ancestors)) vacant-num) res) res))) (if (eq? (car foll-siblings) (sxml:context->node (car src))) (call-with-values (lambda () (process-single (car src) (cdr src) (+ vacant-num 1))) (lambda (new-pos-res new-src new-vacant) (values (cons (append (reverse new-res) (if (null? new-pos-res) '() (car new-pos-res))) (append pos-res new-pos-res)) new-src new-vacant))) (loop (cdr foll-siblings) (ddo:attr-child (car foll-siblings)) (ddo:discard-attributes (car foll-siblings) src) (+ vacant-num 1) new-res pos-res))))) ((eq? (car descs) (sxml:context->node (car src))) ; His siblings are on the way (call-with-values (lambda () (process-single (car src) (cdr src) vacant-num)) (lambda (new-pos-res new-src new-vacant) (loop foll-siblings (cdr descs) ; descendants processed new-src new-vacant res (cons pos-res new-pos-res))))) (else (loop foll-siblings (append (child (car descs)) (cdr descs)) (ddo:discard-attributes (car descs) src) vacant-num res pos-res))))))) (else (values '() src vacant-num))))))) (lambda (node) ; node or nodeset (if (nodeset? node) (let iter ((src node) (pos-res '()) (vacant-num 1)) (if (null? src) (filter ; removing empty result nodesets (lambda (x) (not (null? x))) pos-res) (call-with-values (lambda () (process-single (car src) (cdr src) vacant-num)) (lambda (new-pos-res new-src new-vacant) (iter new-src (append pos-res new-pos-res) new-vacant))))))))))
Parent axis, for position-based filtering We won't reinvent the wheel here. We'll use ddo:parent and apply the fact that for every single input node the parent axis produces no more than a single result node
(define (ddo:parent-pos test-pred? . num-ancestors) (let ((parent (apply ddo:parent (cons test-pred? num-ancestors)))) (letrec ((add-order-num (lambda (num nset) (if (null? nset) nset (cons (list (cons (car nset) num)) (add-order-num (+ num 1) (cdr nset))))))) (lambda (node) ; node or nodeset (add-order-num 1 (parent node))))))
Preceding-sibling axis, for position-based filtering
(define (ddo:preceding-sibling-pos test-pred? . num-ancestors) (let ((num-anc (if (null? num-ancestors) 0 (car num-ancestors))) (child (sxml:child sxml:node?)) (reverse-desc ; reverse descendants of node (lambda (node) (let scan ((more (ddo:attr-child node)) (res '())) (if (null? more) ; result formed res (scan (append (ddo:attr-child (car more)) (cdr more)) (cons (car more) res))))))) (letrec ((associate-num (lambda (nset ancestors vacant-num) (if (null? nset) nset (cons (cons (if (null? ancestors) (car nset) (draft:make-context (car nset) ancestors)) vacant-num) (associate-num (cdr nset) ancestors (- vacant-num 1)))))) ; curr - current context to be processed ; src - remaining source contexts ; vacant-num - order number for the result node ; Returns: (values pos-result new-src new-vacant-num) (process-single (lambda (curr src vacant-num) (if (or (not (sxml:context? curr)) (null? (sxml:context->ancestors-u curr))) ; Siblings cannot be identified (values '() src vacant-num) (cond ((memq (sxml:context->node-u curr) (reverse (cdr ; parent is an element => cdr gives its children (car (sxml:context->ancestors-u curr))))) => (lambda (prec-siblings) ; prec-siblings + self (if (null? (cdr prec-siblings)) ; no preceding siblings (values '() src vacant-num) (let ((ancestors (draft:list-head (sxml:context->ancestors-u curr) num-anc))) ; Scanning descendants of the context node (let loop ((prec-siblings (cdr prec-siblings)) (descs (reverse-desc (cadr prec-siblings))) (src src) (vacant-num vacant-num) (res '()) (pos-res '())) (cond ((null? src) (values (cons (append (reverse res) (associate-num ; DL: was: (if nonself? prec-siblings (cdr prec-siblings)) prec-siblings ancestors vacant-num)) pos-res) src ; always null #f ; nobody cares of this number anymore )) ((null? descs) ; descendants of current prec-sibling (let ((new-res (if (test-pred? (car prec-siblings)) (cons (cons (if (null? ancestors) (car prec-siblings) (draft:make-context (car prec-siblings) ancestors)) vacant-num) res) res))) (cond ((eq? (car prec-siblings) ; to be now added (sxml:context->node (car src))) (call-with-values (lambda () (process-single (car src) (cdr src) (- vacant-num 1))) (lambda (new-pos-res new-src new-vacant) (values (cons (append (reverse new-res) (if (null? new-pos-res) '() (car new-pos-res))) (append pos-res new-pos-res)) new-src new-vacant)))) ((null? (cdr prec-siblings)) ; that stuff is over (values (cons (reverse new-res) pos-res) src vacant-num)) (else (loop (cdr prec-siblings) (reverse-desc (cadr prec-siblings)) src (- vacant-num 1) new-res pos-res))))) ((eq? (car descs) (sxml:context->node (car src))) ; His siblings are on the way (call-with-values (lambda () (process-single (car src) (cdr src) vacant-num)) (lambda (new-pos-res new-src new-vacant) (loop prec-siblings (cdr descs) ; descendants processed new-src new-vacant res (append pos-res new-pos-res))))) (else (loop prec-siblings (cdr descs) src vacant-num res pos-res)))))))) (else (values '() src vacant-num))))))) (lambda (node) ; node or nodeset (if (nodeset? node) (let iter ((src (reverse node)) (pos-res '()) (vacant-num -1)) (if (null? src) (filter ; removing empty result nodesets (lambda (x) (not (null? x))) pos-res) (call-with-values (lambda () (process-single (car src) (cdr src) vacant-num)) (lambda (new-pos-res new-src new-vacant) (iter new-src (append new-pos-res pos-res) new-vacant))))))))))
Following axis for special case According to http://pi3.informatik.uni-mannheim.de/publications/TR-02-011.pdf, it is sufficient to calculate following for the first member of the input nodeset
(define (ddo:following-single-level test-pred? . num-ancestors) (let ((foll (apply draft:following (cons test-pred? num-ancestors)))) (lambda (node) ; node or nodeset (cond ((null? node) ; empty nodeset - nothing to do '()) ((and (pair? node) (not (symbol? (car node)))) ; non-empty nodeset (foll (car node))) (else ; a single node (foll node))))))
Following-sibling axis for the special case We need only to care of duplicates removal, and ordering would be achieved automatically
(define (ddo:following-sibling-single-level test-pred? . num-ancestors) (let ((num-anc (if (null? num-ancestors) 0 (car num-ancestors)))) (lambda (node) ; node or nodeset (let loop ((src (as-nodeset node)) (res '())) (if (null? src) ; everyone processed (reverse res) (let ((curr (car src))) (if (and (sxml:context? curr) (not (null? (sxml:context->ancestors-u curr)))) (cond ((memq (sxml:context->node-u curr) (cdr ; parent is an element => cdr gives its children (car (sxml:context->ancestors-u curr)))) => (lambda (foll-siblings) (let rpt ((foll-siblings (cdr foll-siblings)) (src (cdr src)) (res res)) (cond ((null? foll-siblings) (loop src res)) ((null? src) ; no more source nodes in document order (append (reverse res) (draft:siblings->context-set ((sxml:filter test-pred?) foll-siblings) (draft:list-head (sxml:context->ancestors-u curr) num-anc)))) (else (rpt (cdr foll-siblings) (if (eq? (car foll-siblings) (sxml:context->node (car src))) (cdr src) ; remove the first source node src) (if (test-pred? (car foll-siblings)) (cons (draft:smart-make-context (car foll-siblings) (sxml:context->ancestors-u curr) num-anc) res) res))))))) (else ; no following siblings (loop (cdr src) res))) (loop (cdr src) res) ; no parent => no siblings )))))))
Parent axis for the case when all nodes in the input node-set are located on the same level of hierarchy within a document In this case the parent axis can be computed with the O(n) complexity, n is the number of nodes in the document, compared to O(n^2) complexity for ddo:parent
(define (ddo:parent-single-level test-pred? . num-ancestors) (let ((num-anc (if (null? num-ancestors) 0 (car num-ancestors)))) (lambda (node) ; node or nodeset (let loop ((src (as-nodeset node)) (prev-parent #f) (res '())) (if (null? src) (reverse res) (let ((curr (car src))) (if (and (sxml:context? curr) (not (null? (sxml:context->ancestors-u curr)))) (let ((curr-parent (car (sxml:context->ancestors-u curr)))) (if ; this condition would never evaluate to #t when prev-parent=#f (eq? curr-parent prev-parent) ; a duplicate node ; this node is already in the result (loop (cdr src) prev-parent res) (loop (cdr src) curr-parent (if (test-pred? curr-parent) (cons (draft:smart-make-context curr-parent (cdr (sxml:context->ancestors-u curr)) num-anc) res) res)))) ; no parent (loop (cdr src) prev-parent res))))))))
Preceding axis for the special case The implementation exploits the idea expressed in http://pi3.informatik.uni-mannheim.de/publications/TR-02-011.pdf, that is, it is sufficient to calculate preceding for the last member of the input nodeset
(define (ddo:preceding-single-level test-pred? . num-ancestors) (let ((prec (apply draft:preceding (cons test-pred? num-ancestors)))) (lambda (node) ; node or nodeset (cond ((null? node) ; empty nodeset - nothing to do '()) ((and (pair? node) (not (symbol? (car node)))) ; non-empty nodeset (reverse ; restore document order (prec (ddo:list-last node)))) (else ; a single node (reverse (prec node)))))))
Preceding-sibling axis for the special case
(define (ddo:preceding-sibling-single-level test-pred? . num-ancestors) (let ((num-anc (if (null? num-ancestors) 0 (car num-ancestors)))) (lambda (node) ; node or nodeset (let loop ((src (reverse (as-nodeset node))) (res '())) (if (null? src) ; everyone processed res (let ((curr (car src))) (if (and (sxml:context? curr) (not (null? (sxml:context->ancestors-u curr)))) (cond ((memq (sxml:context->node-u curr) (reverse (cdr ; parent is an element => cdr gives its children (car (sxml:context->ancestors-u curr))))) => (lambda (prec-siblings) (let rpt ((prec-siblings (cdr prec-siblings)) (src (cdr src)) (res res)) (cond ((null? prec-siblings) (loop src res)) ((null? src) ; no more source nodes (append (reverse (draft:siblings->context-set ((sxml:filter test-pred?) prec-siblings) (draft:list-head (sxml:context->ancestors-u curr) num-anc))) res)) (else (rpt (cdr prec-siblings) (if (eq? (car prec-siblings) (sxml:context->node (car src))) (cdr src) ; remove the first source node src) (if (test-pred? (car prec-siblings)) (cons (draft:smart-make-context (car prec-siblings) (sxml:context->ancestors-u curr) num-anc) res) res))))))) (else ; no preceding siblings (loop (cdr src) res))) (loop (cdr src) res) ; no parent => no siblings )))))))
Following axis for the special case
(define (ddo:following-single-level-pos test-pred? . num-ancestors) (let* ((num-anc (if (null? num-ancestors) 0 (car num-ancestors))) (descend (draft:descendant-or-self test-pred? num-anc)) (follow (draft:following test-pred? num-anc))) (letrec (; curr - current context to be processed ; src - remaining source contexts ; vacant-num - order number for the result node ; Returns: pos-result (process-single (lambda (curr src vacant-num) (cond ((null? src) ; no more nodes (let add-labels ((to-scan (follow curr)) (res '()) (vacant-num vacant-num)) (if (null? to-scan) (list (reverse res)) (add-labels (cdr to-scan) (cons (cons (car to-scan) vacant-num) res) (+ vacant-num 1))))) ((not (sxml:context? curr)) ; can't find following nodes (cons '() (process-single (car src) (cdr src) vacant-num))) (else (let ((next (sxml:context->node (car src)))) (let loop ((this-level (sxml:context->node-u curr)) (ancs-to-view (sxml:context->ancestors-u curr)) (content-set '()) (pos-nset '()) (vacant-num vacant-num)) (cond ((null? content-set) ; no one to scan at this level (cond ((null? ancs-to-view) (cons (reverse pos-nset) (process-single (car src) (cdr src) vacant-num))) ((memq next (sxml:attr-list (car ancs-to-view))) ; next is an attribute (let ((pos-result (process-single (car src) (cdr src) vacant-num))) (cons (append (reverse pos-nset) (car pos-result)) pos-result))) (else ; go to the next level (loop (car ancs-to-view) (cdr ancs-to-view) (map (lambda (n) (cons n (cdr ancs-to-view))) (cond ((memq this-level (cdr ; parent is an element => children (car ancs-to-view))) => cdr) (else ; curr-node is an attribute node ((select-kids sxml:node?) (car ancs-to-view))))) pos-nset vacant-num)))) ((memq next (sxml:attr-list (caar ancs-to-view))) ; next node is an attribute of currently scanned node (let ((pos-result (process-single (car src) (cdr src) vacant-num))) (cons (append (reverse pos-nset) (car pos-result)) pos-result))) ((eq? (caar content-set) next) ; current node is eq to the next one in src (let add-desc ((to-scan (descend (draft:smart-make-context (caar content-set) (cdar content-set) num-anc))) (pos-nset pos-nset) (vacant-num vacant-num)) (if (null? to-scan) (let ((pos-result (process-single (car src) (cdr src) vacant-num))) (cons (append (reverse pos-nset) (car pos-result)) pos-result)) (add-desc (cdr to-scan) (cons (cons (car to-scan) vacant-num) pos-nset) (+ vacant-num 1))))) (else ; go on to scan the next node (loop this-level ancs-to-view (append (map (lambda (n) (cons n (car content-set))) ((sxml:child sxml:node?) (caar content-set))) (cdr content-set)) (if (test-pred? (caar content-set)) (cons (cons (draft:smart-make-context (caar content-set) (cdar content-set) num-anc) vacant-num) pos-nset) pos-nset) (+ vacant-num 1))))))))))) (lambda (node) ; node or nodeset (let ((nset (as-nodeset node))) (if (null? nset) ; nothing to be done nset (filter ; removing empty result nodesets (lambda (x) (not (null? x))) (process-single (car nset) (cdr nset) 1))))))))
Following-sibling axis for the special case
(define (ddo:following-sibling-single-level-pos test-pred? . num-ancestors) (let ((num-anc (if (null? num-ancestors) 0 (car num-ancestors)))) (letrec (; curr - current context to be processed ; src - remaining source contexts ; vacant-num - order number for the result node ; Returns: pos-result (process-single (lambda (curr src vacant-num) (if (or (not (sxml:context? curr)) (null? (sxml:context->ancestors-u curr))) ; Siblings cannot be identified (if (null? src) ; recursion is over '() (process-single (car src) (cdr src) vacant-num)) (cond ((memq (sxml:context->node-u curr) (cdr ; parent is an element => cdr gives its children (car (sxml:context->ancestors-u curr)))) => (lambda (foll-siblings) (let ((ancestors (draft:list-head (sxml:context->ancestors-u curr) num-anc))) (if (null? src) ; no more nodes (let no-more ((foll-siblings (cdr foll-siblings)) (res '()) (vacant-num vacant-num)) (if (null? foll-siblings) ; everyone processed (list (reverse res)) (no-more (cdr foll-siblings) (if (test-pred? (car foll-siblings)) (cons (cons (if (null? ancestors) (car foll-siblings) (draft:make-context (car foll-siblings) ancestors)) vacant-num) res) res) (+ vacant-num 1)))) ; else there are more nodes in src (let ((next (sxml:context->node (car src)))) (let more ((foll-siblings (cdr foll-siblings)) (res '()) (vacant-num vacant-num)) (if (null? foll-siblings) ; everyone processed (cons (reverse res) (process-single (car src) (cdr src) vacant-num)) (let ((new-res (if (test-pred? (car foll-siblings)) (cons (cons (if (null? ancestors) (car foll-siblings) (draft:make-context (car foll-siblings) ancestors)) vacant-num) res) res))) (if (eq? (car foll-siblings) next) ; recursion (let ((pos-res (process-single (car src) (cdr src) (+ vacant-num 1)))) (if (null? pos-res) ; this shouldn't occur (list (reverse new-res)) (cons (append (reverse new-res) (car pos-res)) pos-res))) (more (cdr foll-siblings) new-res (+ vacant-num 1))))))))))) (else ; no following siblings (if (null? src) ; recursion is over '() (process-single (car src) (cdr src) vacant-num)))))))) (lambda (node) ; node or nodeset (let ((nset (as-nodeset node))) (if (null? nset) ; nothing to be done nset (filter ; removing empty result nodesets (lambda (x) (not (null? x))) (process-single (car nset) (cdr nset) 1))))))))
Parent axis, for position-based filtering This function has very much the same with ddo:parent-pos. In future, we should use a meta-function for paremetrization of these two
(define (ddo:parent-single-level-pos test-pred? . num-ancestors) (let ((parent (apply ddo:parent-single-level (cons test-pred? num-ancestors)))) (letrec ((add-order-num (lambda (num nset) (if (null? nset) nset (cons (list (cons (car nset) num)) (add-order-num (+ num 1) (cdr nset))))))) (lambda (node) ; node or nodeset (add-order-num 1 (parent node))))))
Preceding axis for the special case
(define (ddo:preceding-single-level-pos test-pred? . num-ancestors) (let* ((num-anc (if (null? num-ancestors) 0 (car num-ancestors))) (descend (draft:descendant-or-self test-pred? num-anc)) (precede (draft:preceding test-pred? num-anc))) (letrec (; curr - current context to be processed ; src - remaining source contexts ; vacant-num - order number for the result node ; Returns: pos-result (process-single (lambda (curr src vacant-num) (cond ((null? src) ; no more nodes (let add-labels ((to-scan (precede curr)) (res '()) (vacant-num vacant-num)) (if (null? to-scan) (list (reverse res)) (add-labels (cdr to-scan) (cons (cons (car to-scan) vacant-num) res) (- vacant-num 1))))) ((not (sxml:context? curr)) ; can't find following nodes (cons '() (process-single (car src) (cdr src) vacant-num))) (else (let ((next (sxml:context->node (car src)))) (let loop ((this-level (sxml:context->node-u curr)) (ancs-to-view (sxml:context->ancestors-u curr)) (content-set '()) (pos-nset '()) (vacant-num vacant-num)) (cond ((null? content-set) ; no one to scan at this level (if (null? ancs-to-view) (cons (reverse pos-nset) (process-single (car src) (cdr src) vacant-num)) (loop (car ancs-to-view) (cdr ancs-to-view) (reverse (map sxml:context->content (descend (map (lambda (n) (draft:smart-make-context n (cdr ancs-to-view) num-anc)) (cond ((memq this-level (reverse ((select-kids sxml:node?) (car ancs-to-view)))) => (lambda (nset) (reverse (cdr nset)))) (else ; curr-node is an attribute node '())))))) pos-nset vacant-num))) ((eq? (caar content-set) next) ; current node is eq to the next one in src (let ((pos-result (process-single (car src) (cdr src) (- vacant-num 1)))) (cons (append (reverse (if (test-pred? (caar content-set)) (cons (cons (draft:smart-make-context (caar content-set) (cdar content-set) num-anc) vacant-num) pos-nset) pos-nset)) (car pos-result)) pos-result))) (else ; go on to scan the next node (loop this-level ancs-to-view (cdr content-set) (if (test-pred? (caar content-set)) (cons (cons (draft:smart-make-context (caar content-set) (cdar content-set) num-anc) vacant-num) pos-nset) pos-nset) (- vacant-num 1))))))))))) (lambda (node) ; node or nodeset (let ((nset (reverse (as-nodeset node)))) (if (null? nset) ; nothing to be done nset (filter ; removing empty result nodesets (lambda (x) (not (null? x))) (process-single (car nset) (cdr nset) -1))))))))
Preceding-sibling axis for the special case
(define (ddo:preceding-sibling-single-level-pos test-pred? . num-ancestors) (let ((num-anc (if (null? num-ancestors) 0 (car num-ancestors)))) (letrec (; curr - current context to be processed ; src - remaining source contexts ; vacant-num - order number for the result node ; Returns: pos-result (process-single (lambda (curr src vacant-num) (if (or (not (sxml:context? curr)) (null? (sxml:context->ancestors-u curr))) ; Siblings cannot be identified (if (null? src) ; recursion is over '() (process-single (car src) (cdr src) vacant-num)) (cond ((memq (sxml:context->node-u curr) (reverse (cdr ; parent is an element => cdr gives its children (car (sxml:context->ancestors-u curr))))) => (lambda (prec-siblings) (let ((ancestors (draft:list-head (sxml:context->ancestors-u curr) num-anc))) (if (null? src) ; no more nodes (let no-more ((prec-siblings (cdr prec-siblings)) (res '()) (vacant-num vacant-num)) (if (null? prec-siblings) ; everyone processed (list (reverse res)) (no-more (cdr prec-siblings) (if (test-pred? (car prec-siblings)) (cons (cons (if (null? ancestors) (car prec-siblings) (draft:make-context (car prec-siblings) ancestors)) vacant-num) res) res) (- vacant-num 1)))) ; else there are more nodes in src (let ((next (sxml:context->node (car src)))) (let more ((prec-siblings (cdr prec-siblings)) (res '()) (vacant-num vacant-num)) (if (null? prec-siblings) ; everyone processed (cons (reverse res) (process-single (car src) (cdr src) vacant-num)) (let ((new-res (if (test-pred? (car prec-siblings)) (cons (cons (if (null? ancestors) (car prec-siblings) (draft:make-context (car prec-siblings) ancestors)) vacant-num) res) res))) (if (eq? (car prec-siblings) next) ; recursion (let ((pos-res (process-single (car src) (cdr src) (- vacant-num 1)))) (if (null? pos-res) ; this shouldn't occur (list (reverse new-res)) (cons (append (reverse new-res) (car pos-res)) pos-res))) (more (cdr prec-siblings) new-res (- vacant-num 1))))))))))) (else ; no preceding siblings (if (null? src) ; recursion is over '() (process-single (car src) (cdr src) vacant-num)))))))) (lambda (node) ; node or nodeset (let ((nset (reverse (as-nodeset node)))) (if (null? nset) ; nothing to be done nset (reverse (filter ; removing empty result nodesets (lambda (x) (not (null? x))) (process-single (car nset) (cdr nset) -1)))))))))


|
PolyTycoon
1
UnityTransportTycoontypegame.
|
Public Member Functions | |
| override Path | FindPath (PathFindingNode startNode, PathFindingNode endNode) |
| Calculates the shortest Path from the startNode to the endNode. More... | |
Additional Inherited Members | |
| Protected Member Functions inherited from NetworkAStarPathFinding | |
| virtual Path | RetracePath (PathFindingNode fromNode, NetworkNode toNetworkNode) |
| Extracts the actual Path from the found NetworkNode. More... | |
| WayPoint | CalculateTraversalVectors (NetworkNode lastNetworkNode, NetworkNode currentNetworkNode) |
| Returns the Traversal Vectors as a WayPoint Object from a given set of PathfindingNodes. These are used to make vehicles like trucks move on the right side of the road and make smooth turns. More... | |
| Protected Member Functions inherited from AbstractPathFindingAlgorithm | |
| int | GetDistance (PathFindingNode nodeA, PathFindingNode nodeB) |
| This function calculates the distance between two Nodes. More... | |
|
virtual |
Calculates the shortest Path from the startNode to the endNode.
| startNode | The node this path is supposed to start on |
| endNode | The node this path is supposed to end on |
Reimplemented from NetworkAStarPathFinding.


About Command line
- echo - whatever is typed, the computer says back
- cd - change directory - choose which folder you wnat to use
- dir - directory listing - lists the files on the folder
- cp - copy - copies a document and allows to change name
what is Git?
track changes
coordinate work
manage a project
what do these commands do?
- init - initialise
- status - check state of working directory
- add - add files to directory
- commit - records change to repository
- push - push commits made on your local branch to a remote repository
- pull - download changed files from github


NWC gives new December deadline to complete Ferry pipeline project
The National Water Commission (NWC) now says it expects to complete the Ferry pipeline project in December.
This means that although water storage systems across the island have increased significantly some people in the corporate area will be without consistent supplies leading up to Christmas.
The NWC had set an April timeline to install a new 18-inch main to transport water from St Catherine to Kingston.
It later revised the deadline to July and then to November.
READ: NWC says Ferry pipeline to be operational by July
Speaking on the Morning Agenda on Power 106FM, NWC president Mark Barnett said a series of issues contributed to the delay.
Among them, he said, were delays in the importation of materials.
He said, too, that there have been changes to the initial route for the pipes.
"These are not abnormal in a construction project,” said Barnett but noted that the situation is more critical because it involves the prime commodity of water.
Barnett said, with the Hermitage Dam now at 100 per cent of capacity and the Mona Reservoir at 98 per cent, the NWC has been redistributing water to areas impacted by the prolonged delay in restoring the Ferry distribution system.
In the meantime, places like Molynes Road and Seaward Drive will continue to see disruptions in their water supply systems.


swine African ASFV fever virus :â€". (). al.. viral infection Ornithodoros Virol. pigs ticks wild infected ASF soft Vet replication proteins Res. boar detection protein Dis. Swine domestic transmission Virus gene virus. Emerg cell tick Continuing antibodies genotype virulent {border-style â€" disease DNA px;} #ffffff;} early entry erraticus ./j.virusres... Republic high including role sensitivity ./JVI...-. Microbiol. PCR assay samples significant using Africa Transbound genes serological ./tbed. //, OIE cells clinical control demonstrated host important moubata outbreaks spread vaccine assays diagnostic highly qPCR reported strain strains warthogs ./JVI.- ELISA Europe Resolved Swine, associated involved isolate isolates late portable shown (â€"). ASFV-specific Africa, Europe, Figure September Virology. animal antibody antigens capable challenge detecting diagnosis envelope include multiple observed porcinus pork recombinant responses tests â€"). Arch Gen Infect People's Russian countries current cycle enhancement essential genome indirect mortality protection required structural use virulence ./S-()- ./eid. ./s--- :e. Caucasus Democratic Entomol. European However, Med Transmission amplification animals antigen argasid attenuated compared complex days development endemic expression field immune likely potential px; research studies study sylvatic used years {font-family (Pt ./j.vetmic... CDv Clin Detection Experimental Fever Iberian United Vero WAHIS contact core distribution flow font-size global laboratory lateral levels maintained mechanisms need new pig rates real-time showed specificity swine, testing virus, (ASF) ):â€". ./j.virol... ./journal.pone. ASFV, ASFV-infected Disease Federation Georgia MGF ONE. Veterinary Wild assembly attachment capsid cells. cellular collected detected direct does double; emerged endosomal endosomes experimentally feeding increased known major multigene number occurs polymerase positive post-infection products protective recommended region samples. sites situation specific test ticks. titers vectors virion â€", (Acari: (Sus ./BF ./jmedent/.. ./vir..- Asia, Central China, Department Development FAO IFAT LAMP Methods. Republic, Res South Virol available based blood border-color border-width commercial culling derived detect events experimental factories factors family following identified infection. isolated isothermal lack large level low method molecular needed oral outbreak pigs. play presence primarily produce provinces replicate replication, results scrofa sensitive solid; species takes targeting ticks, time typically vector viremic vitro {font-style {font-weight (Phacochoerus (e.g., ./---- ./JCM...-. ./S ./j.-...x ./j.vaccine... Africa. Argasidae). Asia August Biol China Congo, Deletion Domestic Early Eastern Epidemiol Eurasian Europe. Fc-receptor February IPT Infect. Interface, Korea Molecular OIE-recommended Portugal RNA Sci Sci. Vaccine. Vaccines. West [(, affect affected analysis areas binding bold comparable confirmatory considered continued courier; cycle, depending developed different em; encodes epidemic especially established extraction feral fever,â€� fever. fluorescent formats future genotypes identification immunity immunization induction infectivity information, interferon internal limited lines little live long lower macrophage macropinocytosis marocanus mediate mediated midgut movement natural novel outer pER parental persistence pigs, poor porcine possess previously primary produced provide pt;} reactivity receptor receptors remains resistance response routes sera serum strategies subsequently survival susceptible thermocycler tick, transport type update, uses variable variety viremia virions virus:


import numpy
import six
from chainer import cuda
from chainer.functions.array import concat
from chainer.functions.pooling import max_pooling_2d
from chainer.functions.pooling import pooling_2d
class SpatialPyramidPooling2D(pooling_2d.Pooling2D):
"""Spatial pyramid pooling over a set of 2d planes."""
def __init__(self, x_shape, pyramid_height, pooling_class, use_cudnn=True):
bottom_c, bottom_h, bottom_w = x_shape
self.pyramid_height = pyramid_height
# create pooling functions for different pyramid levels
out_dim = 0
self.split_inds = []
self.poolers = []
for pyramid_level in six.moves.range(pyramid_height):
num_bins = int(2 ** pyramid_level)
ksize_h = int(numpy.ceil(bottom_h / (float(num_bins))))
remainder_h = ksize_h * num_bins - bottom_h
pad_h = remainder_h // 2
ksize_w = int(numpy.ceil(bottom_w / (float(num_bins))))
remainder_w = ksize_w * num_bins - bottom_w
pad_w = remainder_w // 2
ksize = (ksize_h, ksize_w)
pad = (pad_h, pad_w)
if pooling_class is max_pooling_2d.MaxPooling2D:
pooler = pooling_class(ksize=ksize, stride=None, pad=pad,
cover_all=True, use_cudnn=use_cudnn)
self.poolers.append(pooler)
else:
raise NotImplementedError()
out_dim += bottom_c * (num_bins ** 2)
if pyramid_level < pyramid_height - 1:
self.split_inds.append(out_dim)
def forward(self, x):
self.ys = []
for pooler in self.poolers:
y = pooler.forward(x)[0]
n, c, h, w = pooler.out_shape = y.shape
self.ys.append(y.reshape((n, c * h * w, 1, 1)))
return concat.Concat(axis=1).forward(self.ys)
def backward(self, x, gy):
xp = cuda.get_array_module(*x)
gx = xp.zeros_like(x[0])
gys = xp.split(gy[0], self.split_inds, axis=1)
for pooler, gy in zip(self.poolers, gys):
gy = gy.reshape(pooler.out_shape)
gx += pooler.backward(x, (gy,))[0]
return gx,
[docs]def spatial_pyramid_pooling_2d(x, pyramid_height, pooling_class,
use_cudnn=True):
"""Spatial pyramid pooling function.
It outputs a fixed-length vector regardless of input feature map size.
It performs pooling operation to the input 4D-array ``x`` with different
kernel sizes and padding sizes, and then flattens all dimensions except
first dimension of all pooling results, and finally concatenates them along
second dimension.
At :math:`i`-th pyramid level, the kernel size
:math:`(k_h^{(i)}, k_w^{(i)})` and padding size
:math:`(p_h^{(i)}, p_w^{(i)})` of pooling operation are calculated as
below:
.. math::
k_h^{(i)} &= \\lceil b_h / 2^i \\rceil, \\\\
k_w^{(i)} &= \\lceil b_w / 2^i \\rceil, \\\\
p_h^{(i)} &= (2^i k_h^{(i)} - b_h) / 2, \\\\
p_w^{(i)} &= (2^i k_w^{(i)} - b_w) / 2,
where :math:`\\lceil \\cdot \\rceil` denotes the ceiling function, and
:math:`b_h, b_w` are height and width of input variable ``x``,
respectively. Note that index of pyramid level :math:`i` is zero-based.
See detail in paper: `Spatial Pyramid Pooling in Deep Convolutional \
Networks for Visual Recognition \
<http://arxiv.org/abs/1406.4729>`_.
Args:
x (~chainer.Variable): Input variable. The shape of ``x`` should be
``(batchsize, # of channels, height, width)``.
pyramid_height (int): the number of pyramid levels
pooling_class (MaxPooling2D or AveragePooling2D):
Only MaxPooling2D class can be available for now.
use_cudnn (bool): If ``True`` and cuDNN is enabled, then this function
uses cuDNN as the core implementation.
Returns:
~chainer.Variable: Output variable. The shape of the output variable
will be :math:`(batchsize, c \\sum_{h=0}^{H-1} 2^{2h}, 1, 1)`,
where :math:`c` is the number of channels of input variable ``x``
and :math:`H` is the number of pyramid levels.
.. note::
This function uses some pooling classes as components to perform
spatial pyramid pooling. Now it supports only
:class:`~functions.MaxPooling2D` as elemental pooling operator so far.
"""
return SpatialPyramidPooling2D(x.data.shape[1:], pyramid_height,
pooling_class, use_cudnn=use_cudnn)(x)


The driving motivation for this class is our need to read a document's CAP Alert XMLNS prior to actually parsing the document.
Call reset() in-between uses. There is no need to close the encapsulated streams: since they are already cached, they will simply be garbage collected when they're no longer needed.
| Modifier and Type | Method and Description |
|---|---|
| void | reset()
Resets streams to their initial positions.
|


Notices
This page is dedicated to notice related to new announcements.Here you will find all updates related to our college.
Table Search
| DATE | TYPE | NOTICES |
|---|---|---|
| 22/09/10 | academics | CSE time table |
| 22/09/2018 | Financial | SBI fee link |
| 23/08/2018 | Schlorship | Post-matric Scholarship for Students with Disabilities |
| 24/08/2018 | Scholarship | Notice-MERIT CUM MEANS BASED SCHOLARSHIP |
| 24/08/2018 | Announcement | Result For Walk-in-Interview held on Aug 27-28 2018 |
| 24/08/2018 | Schlorship | PRIME MINISTER�S SCHOLARSHIP SCHEME for RPF |
| 25/08/2018 | time-table | Sessional Exam-Intimation for back paper |
| 24/05/2018 | event | Inceptum |
| 24/06/2018 | workshop | python workshop |


{% extends 'layout.html' %} {% block title %}subscribe{% endblock %} {% block content %}
Every wednesday morning you will receive few instagram photos picked specifically for you.
Instagram doesn't let us access your email, please enter it to subscribe.
{% endblock %}


UGA Photographer Speaks Out After Being KO’d During Auburn-Georgia Game (TWEET)
by Darrelle LincolnChamberlain Smith, who was the Georgia photographer injured on the sideline at Auburn, has released a statement following her injury that scared everybody watching when she was ran over by Georgia RB Brian Herrien.
Smith was knocked unconscious as Herrien was pushed out of bounds near the goal line.
“I’m so glad to be walking away with nothing more than a concussion and some bruises,” she wrote on a Twitter post. “I will be home resting and recovering for the next several days, but look forward to being back on the sidelines soon!”
Smith was taken to East Alabama Medical Center for treatment after she left the field on a stretcher once she woke up from the hit.


OpenGL Mathematics (GLM) is a C++ mathematics library for 3D applications based on the OpenGL Shading Language (GLSL) specification.
GLM provides 3D programmers with math classes and functions that are similar to GLSL or any high level GPU programming language. The idea is to have a library that has identical naming conventions and functionalities than GLSL so that when developers know GLSL, they know how to use GLM.
However, this project isn't limited by GLSL features. An extension system, based on the GLSL extension conventions, allows extended capabilities.
This library can be used with OpenGL but also for software rendering (Raytracing / Rasterisation), image processing and as much contexts as a simple math library could be used for.
GLM is written as a platform independent library and supports the following compilers:
The source code is under the MIT licence.
Any feedback is welcome and can be sent to glm@g-truc.net.


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Silent Key
Frank Irish KA7LEB Missoula, MT February 24, 2014
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Silent Key
Bob Phillips W7LMA Moyie Springs, ID February 17, 2014
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Silent Key
KJ7Z Phillip C. Barnett threw his final pitch on this earth Sunday March 25th 2012 at the age of 62. Phil was born February 1st 1950 the third of three sons of Melvin Barnett and Willie Estelle Malaney in Fort Worth, Texas. He moved to sunny beaches of southern California at the age of 2 where he learned to surf the waves and began his deep passion for the game of baseball. When Phil was playing little league baseball, he made the all star team 5 straight years, in the district tournament he pitched a no hitter , when he played baseball for Lakewood High School also pitched 2 no hitters and had many double strike out games and a 17 strike game, he was also hitting over 400. Pro scouts talking to him and visiting with his parents but he joined the army instead. There are a lot of people who can play of the few. He entered the army in June 1958 and while stationed in Fort Lewis Washington as a Hercules Missile Specialist met his first wife Chelly Bates the mother of his two children Natalie and Wade. After the death of his father in 1970, she brought Phil to theand Chelly divorced in 1994 and he found love again and married Wilma Kampka in May 2001. Phil retired from the US Forest and where he worked as a Sales Administrator, Law Enforcement Officer and was certified as an Advanced Log Scaler. He was an extra class ham operator and proudly carried the call sign KJ7Z, the �Big Nasty� He taught many classes on the art of Morris Code and spent many a weekend climbing his tower, administering a test, and helping fellow ham operators set up their ham station. His passion ran so deep he helped his daughter receive her license at the age of 8 and recently many a weekend Phil was the voice of the local swap meet. He loved to gab with anyone and had many a joke to share and tale to tell. �Bean the first three in head� was a favorite that Phil told new many different a capacities with the Bitterroot Bucs , The Red Sox, local T-ball league thru American Legion and softball teams as well played on several softball teams including one with his colleagues of the Bitterroot National Forest. He umpired for several years as well. He never missed a World Series and if there was a game he was watching. His passion for coaching continues thru both of his children�s interest in coaching local youth. Phil is survived by his wife Wilma, daughter Natalie Hinther and her husband Brian and their three sons Stone, Garrison and Marshall, his son Wade and his fianc� Vanessa, her children Logan and Jyllian and Wade�s children Autumn and Drake, his brother Lewis Barnett of Stevensville and Clayton Barnett of Huntington Beach, California and many nieces and nephews. Phil asked for no formal services.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Silent Key
Everyone waited for George to talk and would talk to him even if they didn't want to talk that day. . All of us looked forward to talking to him when we heard his voice on the air. He will be missed and thought of often. Donnie W7XY
In Memory of KA7VQV
-George Peterson
When we hear the call sign one last time
We�ll remember the man who was very fine
A role model, a mentor, a friend
Someone to look up to, until the end.
Now the radio is silent and covered with dust
We�ve lost a good man, someone who had our trust.
The contacts, the nets, the friends he made
No-one who knew him would ever trade
The world will now be a dimmer place
Without George�s bright smiling face.
One day we�ll meet, my friend
When our time on earth is at an end
You were a wonderful man who many aspire to be
And now my friend, you are a Silent Key.
You may be gone, but never forgotten
A brighter star, heaven has never gotten
So until we meet again
�73 my friend.
--Carla Stafford, KE7SFX
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
These pictures were taken in 2005 at the Butler Repeater site. Bill, K7MT is the one on the tower. The other two are Larry, N7YET and Steve, NO7V. They where sent to me by W7PUG Bob and W7AVG Bill sent them to him.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
W7AVG (Bill Koler) at the Dillon repeater site atop 9200 ft. Maurer Mountain
20 miles SE of Dillon. Bill is seen in the picture repairing the 146.7600 MHz repeater
antenna ground and tightening the lead in cable. Bill works closely with Todd (AE7V)
and the DES here in Beaverhead County. Keeps all the amature radio operators here
in Dillon up to date on emergency services. He is also a mentor to new hams,
such as myself. 73 Bob (KB7FPZ)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Here is a picture of crew helping repair antenna's for K7PTO John
Nice motorcycle belongs to �Yogi Bear�, K7YB.
Left to right: WB7OTC, Bruce---K7YB, Bob---WV7Z, Mike---K7PTO, John. Not pictured: urs trooly.
Jerry, KB7QQ Thanks Jerry
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
We want to say Thank You to KD7HWV Jack for all the years of service running the Montana Traffic Net.
It is not an easy task keeping things running smoothly and taking the Flak and everybody wanting it perfect.
We will miss you. Now you can sit back and let somebody else count.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Todd on tower. AE7V
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Below the article listed below is an article related to the story by N7VLC
Thanks Ron.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Hi Donnie -
Here is a bit of Missoula Ham history relating to the new check-in to the MTN tonight - K7CPJ - of Soda Springs, ID. In 1958 I started school at UM (Montana State University in those days) and stayed in Dunaway Hall mens dorm. About the second week of school I discovered what appeared to be a long wire antenna strung between one wing of Craig Hall and Dunaway Hall. Being curious, I traced the wire to a window in Craig - counted the windows from one end -then went to that hall and counted doors and knocked. Lo-and-behold there WAS a ham living there and his name was Darrel and his call was K7CPJ. We struck up a friendship that lasted for a long time, but we lost track until I heard him check into the Farm net some time back and called him by land line to re-connect..
In the dorm he had a Heathkit CW transmitter (either DX 35 or DX 65 - don't remember) He had recently up-graded his Novice to a General and was anxious to get on phone. I gathered up some junk and built him a one tube 6L6 Heising modulator (often referred to as "choke" modulation) and drove it with the high impedance audio output of an Allied Radio tape recorder that I had. Darrel didn't think it could possibly work, but we but hooked it into the B+ line to the final amp via a plug already built into the Heathkit backside for similar purposes. Other voltages were available there for the 6L6 tube, so hook-up was relatively simple. We called George, W7IOJ, on the phone and we got on the air on - guess where ??? (3910) and carried on a good QSO with a good audio report from George. Darrel continued to use that get-up for a couple years while he was at school, making contacts all over the country.
I haven't talked to him since I got my general, so am looking forward to connecting sometime when conditions are compatable. I've listened to the Farm net lots of times, but never found good conditions between Soda Springs and Plains.
In case you aren't familiar with Soda Springs - it is located in the very southeast corner of Idaho east of the place where that ham radio outlet is located (don't remember the name of the town or the store - it's hell to be getting old Hi!)
Take Care 73, Ron W. N7VLC
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
Thanks Jerry and Mike for this one.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Letter in the Missoulian written by N7TAE (Now a Silent Key)
Letters for Tuesday, June 15, 2004
Communications
Internet idea would jam short wave
The communication industry would like to use the electric power network of
distribution wires to carry, along with power for your toaster and vacuum,
very high frequency signals that could be picked up and used by your personal
computer. This would replace your use of telephone lines to reach the
Internet. All these power line wires already function as radio transmitting
antennas, but the 60-cycle per second radio energy does not interfere with
broadcast or short wave radio.
BPL (Broadcast by Power Line) use would insert huge numbers of signals at all
of the so-called "short wave" frequencies onto the lines, superimposed on the
60-cycle power current. The result would be a jumble of transmissions all
across the short-wave band. To a receiver listening at any one frequency the
result is a steady hissing noise strong enough to override any ordinary
message being sent at that frequency.
Proponents of the system say it will occupy all frequencies from 1800
kilohertz to about 80,000 kilohertz. KGVO uses a frequency of 1290 kilohertz.
Within the part of the spectrum are found stations from around the world
(England, Berlin, Moscow, etc.), and many radio systems used by police, fire,
marine and other services. Amateur radio operators use this band heavily to
provide emergency service when disasters interrupt commercial communication
systems.
class="detailstory" A good analogy: Imagine a back-fence conversation
with an air raid siren running steadily on a 50-foot pole at each end of every
alley.
At least six important nations (e.g. Holland, Japan) have rejected this
system. We should also. Our FCC has not taken a stance.
Wayne P. Van Meter, ( Wayne is now a Silent Key but
while he was on this earth he worked very hard in the Hobby to make it
better. )
2224 1/2 Rattlesnake Drive, Missoula
============================================
Wayne Van Meter Bob Leo
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


---
layout: post
title: End credits
date: '2016-03-14T18:30:46+01:00'
categories:
- Graphic Design
- Title Design
picture_url: https://film-Storyboards.tumblr.com/post/141057109583/small-graphic-design-job-end-credits-for-a-short
---
Small graphic design job: end credits for a short film.


Christmas in Peru
It starts as a passing word mentioned by a coworker, quickly spreading to local billboards and radio stations, and finally, you know its that time of year when you hear the jingle jingle outside every supermarket, Christmas is coming. As “the most wonderful time of the year”, its no wonder families around the world choose to celebrate this festive occasion with their loved ones. Here we will go over a few of the differences Santa might see as he visits the country of Peru each year.
Summer Santa
For most of Peru, there is no such thing as a “White Christmas”, as Christmas arrives only a few days after celebrating the first day of summer. Children in Peru can enjoy their gifts all day every day without hindrance as Santa arrives each year during the school seasons summer break.
Trees are coming to town
When you think of Christmas, one of the first things that come to mind are Christmas Trees, housing a years worth of good deeds under their branches. While not traditionally a staple of the years festivities, the Christmas Tree has been increasing in popularity as a popular part of the season due to influence from countries such as the United States or Europe. Expect a brightly colored assortment of hand crafted decorations vibrant in local culture.
On the night before Christmas
Traditionally December 25th is the big day when it comes to old Saint Nicks time to shine, in Peru the big day(or night in this case), is Christmas Eve. At 10pm Peruvians attend a church service known as a Rooster Mass, named as such to depict the Rooster said to have crowed the night Jesus was born. Families then return home to share in a giant dinner complete with turkey and tamales and start opening their presents.
And now for a not so silent night
Once all the impressive fireworks displays have ended and the presents are opened, its time for the kids to go to bed, as Christmas eve is a time to get your groove on since many Peruvian adult family members tend to keep the party going until early hours in the morning. In Peru, December 25th is spent as a day enjoying family and newly opened presents, not to mention recovering from the nights festivities.
And now for a not so silent night
Christmas cheer can be found throughout the country of Peru, but there are a few places that go above and beyond. In the city of Cusco, in effort to provide some love to those less fortunate, the locals set up stands all across the city providing Hot Chocolate to anyone looking for something hot and delicious to sip on. For those not enjoying the crowds found in Cusco, expect a slightly more laid back cultural vibe in Arequipa, where you can view the many parades or join in on the many parties or events you will find around town.


{# inserts scripts specific to webpage and pass relevant variables to javascript #} {% block scripts %}{% endblock %}


You can use the ::first-letter pseudo-element to add a special effect to the first character and line of a text!
Select some text!
Note: Firefox supports an alternative, the ::-moz-selection property.


Epidemiological exercises in R
Prerequisites
1
Exercise 4
1.1
Load packages
1.2
Import data
1.3
First mixed model
1.3.1
Fit the model
1.3.2
Diagnostic plots
1.4
Second mixed model
1.4.1
Fit the model
1.4.2
Plot observed versus predicted model values
2
Exercise 9.4
2.1
Load packages
2.2
Data
2.3
Autocorrelation statistics
2.4
First variogram
2.5
Second variogram
2.6
Variogram model selection
3
Exercise 9.5
3.1
Load packages
3.2
Data
3.3
Autocorrelation statistics
3.4
First variogram
3.5
Second variogram
3.6
Variogram model selection
4
Yield loss
4.1
Load packages
4.2
Data
4.3
Mixed model for response variable DS
4.3.1
Diagnostic plots
4.4
Mixed model for response variable YIELD
4.4.1
Diagnostic plots
4.5
Linear regression between YIELD and DS
4.5.1
Linear regression between RY1 and DS
4.5.2
Transform dataset a
4.6
Mixed model for RY2
4.7
Linear regression between RY2 and CDS
(Appendix) Appendix
5
SAS code
5.1
Exercise 9.4
Published with bookdown
Epidemiological exercises in R
(Appendix) Appendix


CLASSES
IOSD MAIT is largest technical society of MAIT with around 400+ members registered in MAIT. We Teach, We make and We learn. Together. We are confident that our efforts of sharing our knowledge will help our students in their future and we could continue this further.
'' MIND IS A TERRIBLE THING TO WASTE ''


---
layout: archive
title: "Research"
permalink: /research/
author_profile: true
---
{% include base_path %}
Publications
T. Liu, N. D. Truong, A. Nikpour, L. Zhou, and O. Kavehei, "Epileptic Seizure Classification With Symmetric and Hybrid Bilinear Models ", IEEE Journal of Biomedical and Health Informatics, 2020
Download paper here
J. Niu, D. Liu, R. Liu, and T. Liu, "The Impact of the New Cooperative Medical Scheme in Sangzhi County, Hunan Province", Chinese Journal of Population Resources and Environment, vol. 11, no. 2, pp. 174–179, 2013
Download paper here
You can also find my articles on my Google Scholar profile.
Research Projects
{% for post in site.portfolio %}
{% include archive-single.html %}
{% endfor %}


Which takes you to the Entry Edit form:
If the description of an entry begins with "<wiki>" then RAMADDA uses the description text as a wiki page when displaying the entry in the default HTML view. See here for more information on wiki text in RAMADDA.
Clicking on the "Edit Menu -> Add Properties" link takes you to the Add Properties form where you can select the type of properties to add. e.g., Tag:
Select the type of properties to add, e.g., "Tag": You can upload a file as an attachment to an entry: If you create a "thumbnail" attachment that is an image it will be displayed when the entry is listed:Note: In RAMADDA when there is a collection of checkboxes in a form selecting one and then selecting another with a Shift-Click toggles the range of checkboxes between the first the second checkbox clicked. Doing a Control-Click on a checkbox toggles all of them on or off.
The "Add selected to parent folder" button allows you to select some properties and copy them into the parent folder. For example, you may have a large number of data files one or more of which have properties (see Automatic Properties Harvesting for more information). Instead of laboriously adding properties to the parent folder you can just copy it from one of the children data entries.
If there is a data file that RAMADDA can open using the NetCDF/CDM library (e.g., gridded data, point data, radar, etc.) then there will be a "CDL" view link in the View menu for that entry. On that page there will be a "Add short properties" and "Add full properties" links shown. Adding short properties will just try to determine the geospatial bounds and the time range of the data file and set those properties. Adding full properties will also add as properties elements the netcdf varbiables and all of the netcdf global attributes found.For Folders you can recurse down the entry hierarchy and set the spatial and/or temporal bounds of each entry as the union of its children entry metadata.
The Generate File Listing will provide a summary of all of the files in the hierarchy. You can choose to only list entries that have a file that is missing or only list entries that are OK.
The entry type of the entry you are editing can be changed. Note: for entries that have special attributes (e.g., Project, Point Data) when you change the type to a different type the special attributes will be deleted.
You can also recurse down the folder tree and change the type of all entries that match the specified original entry type and/or a pattern that is matched on the name or the filename of the entry. Note: the pattern is a regular expression.
So, for example, you might have a folder that contains a set of plain File entries that you want to change to be a certain data type (e.g., Landsat Satellite Data). You would select "File" as the Old Type, Landsat Satellite data as the new type. If you had a number of File entries but not all are to be changed you can use the pattern (e.g., ".*.hdf") to match on the File entries that you want to change.


Mercury robot challenge 2016¶
Voyager Technical Document
Team
- Julio Cesar Castellanos -<EMAIL_ADDRESS>- Ivan Dario -<EMAIL_ADDRESS>- Rafael Vergara -<EMAIL_ADDRESS>- Luis Villadiego -<EMAIL_ADDRESS>Summary¶
This technical document describes the creation and specs of a remotely controlled robot. The Robot “Voyager” was designed and built to meet the requirements of the Oklahoma State University Mercury Robotics competition for 2016 in Bogota, Colombia.
Highlevel block diagram¶
Communication¶
The microcontroller will be conecte via serial to the raspberry pi, on the raspberry we use a Nodejs library in order to expose a real time socket web based server. For handle browser events we use jQuery and keypress in order to detect when a key is pressed then and do a socket emit.
Main board¶
The robot uses the Raspberri pi B+ as the principal board, this board allow the commnincation to a higer level user application using a Sockect TCP server. It is attached direclty to the microcontroller via serial USB port.
Video feedback¶
The robot has a camera module attached to the raspberry pi, we expose this camera thougth a UDP video stream server.
Cotroller interface¶
We have a web based interface using HTML,CSS and Javascript to handle browser events.
Drive train¶
The robot has one motor per side, each running a tread through a gearbox with an encoder.
Subsystems¶
The robot has two Ultrasonic sensors......
Power¶
The robot has a 7.2[V] standard 3000[mAh] NiMH battery.


Internal Server Error
We are experiencing an internal server problem, please try back later.
Back to Home


Issue: READ-MODIFY-WRITE-EVALUATION-ORDERReferences: DEFINE-MODIFY-MACRO
DECF, INCF, POP, PUSH, PUSHNEW, REMF
Related issues: Issue SETF-SUB-METHODS
Issue PUSH-EVALUATION-ORDER
Category: Clarification, change
Edit history: v1, 17 Dec 1990, Sandra Loosemore
v2, 19 Feb 1991, Sandra Loosemore
Problem description:
Proposal SETF-SUB-METHODS:DELAYED-ACCESS-STORES states that "reading
the value" of a generalized variable reference is not part of the
series of evaluations that must be done in left-to-right order. That
issue only addressed the problem in the context of SETF places such
as GETF, LDB, and MASK-FIELD whose SETF methods include an implicit
read-modify-write operation on a nested place form.
There is a similar order-of-evaluation issue for explicit
read-modify-write macros such as INCF and those defined with
DEFINE-MODIFY-MACRO: if the access to the place is performed before
other arguments to the macro are evaluated, any side-effects of those
evaluations on the value of the place are lost.
In the case of SETF of GETF and friends, issue SETF-SUB-METHODS placed
constraints on the order of evaluation of subforms within the values
returned by GET-SETF-METHOD. In the case of INCF and friends, the
question is the order of evaluation in the expansion of the
read-modify-write macro.
Proposal READ-MODIFY-WRITE-EVALUATION-ORDER:DELAYED-ACCESS-STORES:
Clarify that the exception of "reading the value" of a generalized
variable reference from the series of evaluations that must be done in
left-to-right order applies to the read-modify-write macros DECF,
INCF, POP, PUSH, PUSHNEW, REMF, SHIFTF and all macros defined with
Specifically:
For DECF, INCF, POP, REMF, and all macros defined with
DEFINE-MODIFY-MACRO:
These macros are of the form
(<operator> <place> . <other-arguments>)
The order of evaluation should be:
- all subforms of the <place>, in the order specified by the second
value of GET-SETF-METHOD for that <place>
- the <other-arguments>, in left-to-right order
- the access to <place>
- the computation of the new value to be stored
- the store into <place>
For PUSH and PUSHNEW:
These macros are of the form
(<operator> <object> <place> . <other-arguments>)
The order of evaluation should be:
- the <object>
- all subforms of the <place>, in the order specified by the second
value of GET-SETF-METHOD for that <place>
- the <other-arguments>, in left-to-right order
- the access to <place>
- the computation of the new value to be stored
- the store into <place>
In other words, the subforms of the <place> argument and any other
argument subforms should be evaluated in left-to-right order, but the
actual access of the <place> happens after all of the subform evaluations
and just before the computation and store of the new value.
Examples:
These two examples parallel examples 6 and 7 (respectively) from
issue SETF-SUB-METHODS.
1. (setq r (list 'a 1 'b 2 'c 3))
(setf (getf r 'b) (progn (setq r nil) 6))
r => (b 6)
(setq r 5)
r => 1
In both cases, the place form that is the target of the read-modify-write
operation is the variable R. The access of this place is delayed until
the other subforms have been evaluated, so the value of R that is
read as part of the read-modify-write operation reflects the SETQ.
2. (setq s (setq r (list (list 'a 1 'b 2 'c 3))))
r => nil
s => ((A 1 B 6 C 3))
(incf (car r) (progn (setq r (list 0)) 1))
r => (0)
s => (6)
In both cases, the nested place form is the value of (CAR R). Note that
the SETQ does not affect the read-modify-write operation because the
value of R has already been saved in a temporary variable as part of
evaluating the subforms of the nested place form. The read-modify-write
operation applies to the CAR of this value.
Rationale:
This makes the rules for conceptual "read-modify-write" operations
consistent, regardless of whether or not the operation is specified by
a special-case SETF place (such as GETF) or a macro such as those
defined by DEFINE-MODIFY-MACRO.
Current Practice:
Neither Lucid CL nor Allegro CL implement this proposal. In both
implementations, the access to the place subform apparently happens in
its normal left-to-right order.
Cost to Implementors:
Small.
Cost to Users:
Hard to say. Some programs that depend on the strict left-to-right
order of evaluation now supported in some implementations may break,
but probably such programs are no more common than those that were
broken by the adoption of proposal SETF-SUB-METHODS:DELAYED-ACCESS-STORES.
Cost of non-adoption:
Read-modify-write macros such as INCF and macros defined with
DEFINE-MODIFY-MACRO continue to have the same problems with losing
multiple updates to the place that were solved for SETF of GETF by
adoption of SETF-SUB-METHODS:DELAYED-ACCESS-STORES.
Performance impact:
Probably not applicable.
Benefits:
The cost of non-adoption is avoided.
Esthetics:
Specifying the same order of evaluation rules for all conceptual
read-modify-write operations is better than arbitrarily having a
difference between those defined as special-case SETF places (like GETF)
and those defined as macros.
Discussion:
This proposal does not change the order of evaluation for the macros
ROTATEF, SHIFTF, ASSERT, CHECK-TYPE, CTYPECASE, and CCASE. These
macros all have their own peculiar order-of-evaluation rules already.