http://www.zorba-xquery.com/modules/node-position ZC

Module Description
Before using any of the functions below please remember to import the module namespace:
import module namespace np = "http://www.zorba-xquery.com/modules/node-position";

This module provides a function (np:node-position) that, given a node, returns positional information about the node in the form of an xs:anyURI item. The module also defines functions that use such positional information to determine: (1) positional relationships between two nodes (e.g. if one is the ancestor of another) and (2) positional properties of a single node (e.g. its level in the tree). Within this module, the term "node position" will be used to refer to an xs:anyURI item that is returned by the np:node-position function.

Author:

Federico Cavalieri, Markos Zaharioudakis

XQuery version and encoding for this module:

xquery version "1.0" encoding "utf-8";

Zorba version for this module:

The latest version of this module is 2.0. For more information about module versioning in Zorba please check out this resource.

Module Resources
Namespaces
np http://www.zorba-xquery.com/modules/node-position
ver http://www.zorba-xquery.com/options/versioning
Function Summary
External ancestor-of ( $pos1 as xs:anyURI, $pos2 as xs:anyURI ) as xs:boolean external
Determines whether the node position given as second argument is an ancestor of the node position given as first argument.
External attribute-of ( $n-pos1 as xs:anyURI, $n-pos2 as xs:anyURI ) as xs:boolean external
Determines whether the node position given as second argument is an attribute of the node position given as first argument.
External child-of ( $n-pos1 as xs:anyURI, $n-pos2 as xs:anyURI ) as xs:boolean external
Determines whether the node position given as second argument is a child of the node position given as first argument.
External descendant-of ( $n-pos1 as xs:anyURI, $n-pos2 as xs:anyURI ) as xs:boolean external
Determines whether the node position given as second argument is a descendant of the node position given as first argument.
External following-in-document-order-of ( $n-pos1 as xs:anyURI, $n-pos2 as xs:anyURI ) as xs:boolean external
Determines whether the node position given as second argument is following in document order the node position given as first argument.
External following-of ( $n-pos1 as xs:anyURI, $n-pos2 as xs:anyURI ) as xs:boolean external
Determines whether the node position given as second argument is following the node position given as first argument.
External following-sibling-of ( $n-pos1 as xs:anyURI, $n-pos2 as xs:anyURI ) as xs:boolean external
Determines whether the node position given as second argument is a following-sibling of the node position given as first argument.
External in-collection ( $n-pos as xs:anyURI ) as xs:boolean external
Determines whether a node position belongs to a collection.
External in-same-collection-of ( $n-pos1 as xs:anyURI, $n-pos2 as xs:anyURI ) as xs:boolean external
Determines whether two node positions belong to the same collection.
External in-same-tree-of ( $n-pos1 as xs:anyURI, $n-pos2 as xs:anyURI ) as xs:boolean external
Determines whether two node positions belong to the same tree.
External in-subtree-of ( $n-pos1 as xs:anyURI, $n-pos2 as xs:anyURI ) as xs:boolean external
Determines whether the node position given as second argument belongs to the subtree rooted at the node position given as first argument.
External is-attribute ( $n-pos1 as xs:anyURI ) as xs:boolean external
Determines whether a node position corresponds to an attribute node.
External is-comment ( $n-pos1 as xs:anyURI ) as xs:boolean external
Determines whether a node position corresponds to a comment node.
External is-document ( $n-pos1 as xs:anyURI ) as xs:boolean external
Determines whether a node position corresponds to a document node.
External is-element ( $n-pos1 as xs:anyURI ) as xs:boolean external
Determines whether a node position corresponds to an element node.
External is-processing-instruction ( $n-pos1 as xs:anyURI ) as xs:boolean external
Determines whether a node position corresponds to an processing-instruction node.
External is-text ( $n-pos1 as xs:anyURI ) as xs:boolean external
Determines whether a node position corresponds to a text node.
External level ( $n-pos as xs:anyURI ) as xs:integer external
Computes the level of a node position in its tree.
External node-position ( $arg as node() ) as xs:anyURI external
Return a URI item containing positional information for a given node.
External parent-of ( $n-pos1 as xs:anyURI, $n-pos2 as xs:anyURI ) as xs:boolean external
Determines whether the node position given as second argument is the parent of the node position given as first argument.
External preceding-in-document-order-of ( $n-pos1 as xs:anyURI, $n-pos2 as xs:anyURI ) as xs:boolean external
Determines whether the node position given as second argument is preceding in document order the node position given as first argument.
External preceding-of ( $n-pos1 as xs:anyURI, $n-pos2 as xs:anyURI ) as xs:boolean external
Determines whether the node position given as second argument is preceding the node position given as first argument.
External preceding-sibling-of ( $n-pos1 as xs:anyURI, $n-pos2 as xs:anyURI ) as xs:boolean external
Determines whether the node position given as second argument is a preceding-sibling of the node position given as first argument.
External sibling-of ( $n-pos1 as xs:anyURI, $n-pos2 as xs:anyURI ) as xs:boolean external
Determines whether two node positions are siblings.
Functions
External ancestor-of back to 'Function Summary'
declare function np:ancestor-of (
            $pos1 as xs:anyURI, 
            $pos2 as xs:anyURI 
 ) as xs:boolean external

Determines whether the node position given as second argument is an ancestor of the node position given as first argument. If the two positions were obtained within the same snapshot S, then the result of the function applies to the corresponding nodes as well, that is, within snapshot S, the second node is an ancestor of the first. Otherwise, the result of the function does not imply anything about the positional relationship of the two nodes.

Parameters:
Returns:
Errors:

External attribute-of back to 'Function Summary'
declare function np:attribute-of (
            $n-pos1 as xs:anyURI, 
            $n-pos2 as xs:anyURI 
 ) as xs:boolean external

Determines whether the node position given as second argument is an attribute of the node position given as first argument. If the two positions were obtained within the same snapshot S, then the result of the function applies to the corresponding nodes as well, that is, within snapshot S, the second node is an attribute of the first. Otherwise, the result of the function does not imply anything about the positional relationship of the two nodes.

Parameters:
Returns:
Errors:

External child-of back to 'Function Summary'
declare function np:child-of (
            $n-pos1 as xs:anyURI, 
            $n-pos2 as xs:anyURI 
 ) as xs:boolean external

Determines whether the node position given as second argument is a child of the node position given as first argument. If the two positions were obtained within the same snapshot S, then the result of the function applies to the corresponding nodes as well, that is, within snapshot S, the second node is a child of the first. Otherwise, the result of the function does not imply anything about the positional relationship of the two nodes.

Parameters:
Returns:
Errors:

External descendant-of back to 'Function Summary'
declare function np:descendant-of (
            $n-pos1 as xs:anyURI, 
            $n-pos2 as xs:anyURI 
 ) as xs:boolean external

Determines whether the node position given as second argument is a descendant of the node position given as first argument. If the two positions were obtained within the same snapshot S, then the result of the function applies to the corresponding nodes as well, that is, within snapshot S, the second node is a descendant of the first. Otherwise, the result of the function does not imply anything about the positional relationship of the two nodes.

Parameters:
Returns:
Errors:

External following-in-document-order-of back to 'Function Summary'
declare function np:following-in-document-order-of (
            $n-pos1 as xs:anyURI, 
            $n-pos2 as xs:anyURI 
 ) as xs:boolean external

Determines whether the node position given as second argument is following in document order the node position given as first argument. If the two positions were obtained within the same snapshot S, then the result of the function applies to the corresponding nodes as well, that is, within snapshot S, the second node is following in document order the first. Otherwise, the result of the function does not imply anything about the positional relationship of the two nodes.

Parameters:
Returns:
Errors:

External following-of back to 'Function Summary'
declare function np:following-of (
            $n-pos1 as xs:anyURI, 
            $n-pos2 as xs:anyURI 
 ) as xs:boolean external

Determines whether the node position given as second argument is following the node position given as first argument. If the two positions were obtained within the same snapshot S, then the result of the function applies to the corresponding nodes as well, that is, within snapshot S, the second node is following the first. Otherwise, the result of the function does not imply anything about the positional relationship of the two nodes.

Parameters:
Returns:
Errors:

External following-sibling-of back to 'Function Summary'
declare function np:following-sibling-of (
            $n-pos1 as xs:anyURI, 
            $n-pos2 as xs:anyURI 
 ) as xs:boolean external

Determines whether the node position given as second argument is a following-sibling of the node position given as first argument. If the two positions were obtained within the same snapshot S, then the result of the function applies to the corresponding nodes as well, that is, within snapshot S, the second node is a following-sibling of the first. Otherwise, the result of the function does not imply anything about the positional relationship of the two nodes.

Parameters:
Returns:
Errors:

External in-collection back to 'Function Summary'
declare function np:in-collection (
            $n-pos as xs:anyURI 
 ) as xs:boolean external

Determines whether a node position belongs to a collection.

Parameters:
Returns:
Errors:

External in-same-collection-of back to 'Function Summary'
declare function np:in-same-collection-of (
            $n-pos1 as xs:anyURI, 
            $n-pos2 as xs:anyURI 
 ) as xs:boolean external

Determines whether two node positions belong to the same collection. If the two positions were obtained within the same snapshot S, then the result of the function applies to the corresponding nodes as well, that is, within snapshot S, the two nodes belong to the same collection. Otherwise, the result of the function does not imply anything about the positional relationship of the two nodes.

Parameters:
Returns:
Errors:

External in-same-tree-of back to 'Function Summary'
declare function np:in-same-tree-of (
            $n-pos1 as xs:anyURI, 
            $n-pos2 as xs:anyURI 
 ) as xs:boolean external

Determines whether two node positions belong to the same tree. If the two positions were obtained within the same snapshot S, then the result of the function applies to the corresponding nodes as well, that is, within snapshot S, the two nodes belong to the same tree. Otherwise, the result of the function does not imply anything about the positional relationship of the two nodes.

Parameters:
Returns:
Errors:

External in-subtree-of back to 'Function Summary'
declare function np:in-subtree-of (
            $n-pos1 as xs:anyURI, 
            $n-pos2 as xs:anyURI 
 ) as xs:boolean external

Determines whether the node position given as second argument belongs to the subtree rooted at the node position given as first argument. If the two positions were obtained within the same snapshot S, then the result of the function applies to the corresponding nodes as well, that is, within snapshot S, the second node belongs to the subtree rooted at the first. Otherwise, the result of the function does not imply anything about the positional relationship of the two nodes. This function differs from np:descendant-of in the way it treats attribute nodes. np:descendant-of follows the XQuery/XPath specification for the descendant axis, and as a result, it does not consider attributes as descendants of any nodes; it will always return false if $n-pos2 was obtained from an attribute node.In contrast, np:in-subtree-of will return true if $n-pos2 was obtained from an attribute node that appeared in the subtree of the node that $n-pos1 was obtained from.

Parameters:
Returns:
Errors:

External is-attribute back to 'Function Summary'
declare function np:is-attribute (
            $n-pos1 as xs:anyURI 
 ) as xs:boolean external

Determines whether a node position corresponds to an attribute node.

Parameters:
Returns:
Errors:

External is-comment back to 'Function Summary'
declare function np:is-comment (
            $n-pos1 as xs:anyURI 
 ) as xs:boolean external

Determines whether a node position corresponds to a comment node.

Parameters:
Returns:
Errors:

External is-document back to 'Function Summary'
declare function np:is-document (
            $n-pos1 as xs:anyURI 
 ) as xs:boolean external

Determines whether a node position corresponds to a document node.

Parameters:
Returns:
Errors:

External is-element back to 'Function Summary'
declare function np:is-element (
            $n-pos1 as xs:anyURI 
 ) as xs:boolean external

Determines whether a node position corresponds to an element node.

Parameters:
Returns:
Errors:

External is-processing-instruction back to 'Function Summary'
declare function np:is-processing-instruction (
            $n-pos1 as xs:anyURI 
 ) as xs:boolean external

Determines whether a node position corresponds to an processing-instruction node.

Parameters:
Returns:
Errors:

External is-text back to 'Function Summary'
declare function np:is-text (
            $n-pos1 as xs:anyURI 
 ) as xs:boolean external

Determines whether a node position corresponds to a text node.

Parameters:
Returns:
Errors:

External level back to 'Function Summary'
declare function np:level (
            $n-pos as xs:anyURI 
 ) as xs:integer external

Computes the level of a node position in its tree. Note: The root node of a tree is at level one. The result of the function applies to the corresponding node as well, that is, within the snapshot in which the position was computed, the node level is the returned one. The result of the function does not imply anything about the node level in other snapshots.

Parameters:
Returns:
Errors:

External node-position back to 'Function Summary'
declare function np:node-position (
            $arg as node() 
 ) as xs:anyURI external

Return a URI item containing positional information for a given node.

Within a snapshot, each has a different positional URI. However, different nodes in different snapshots might have the same URI.

Parameters:
Returns:

External parent-of back to 'Function Summary'
declare function np:parent-of (
            $n-pos1 as xs:anyURI, 
            $n-pos2 as xs:anyURI 
 ) as xs:boolean external

Determines whether the node position given as second argument is the parent of the node position given as first argument. If the two positions were obtained within the same snapshot S, then the result of the function applies to the corresponding nodes as well, that is, within snapshot S, the second node is the parent of the first. Otherwise, the result of the function does not imply anything about the positional relationship of the two nodes.

Parameters:
Returns:
Errors:

External preceding-in-document-order-of back to 'Function Summary'
declare function np:preceding-in-document-order-of (
            $n-pos1 as xs:anyURI, 
            $n-pos2 as xs:anyURI 
 ) as xs:boolean external

Determines whether the node position given as second argument is preceding in document order the node position given as first argument. If the two positions were obtained within the same snapshot S, then the result of the function applies to the corresponding nodes as well, that is, within snapshot S, the second node is preceding in document order the first. Otherwise, the result of the function does not imply anything about the positional relationship of the two nodes.

Parameters:
Returns:
Errors:

External preceding-of back to 'Function Summary'
declare function np:preceding-of (
            $n-pos1 as xs:anyURI, 
            $n-pos2 as xs:anyURI 
 ) as xs:boolean external

Determines whether the node position given as second argument is preceding the node position given as first argument. If the two positions were obtained within the same snapshot S, then the result of the function applies to the corresponding nodes as well, that is, within snapshot S, the second node is preceding the first. Otherwise, the result of the function does not imply anything about the positional relationship of the two nodes.

Parameters:
Returns:
Errors:

External preceding-sibling-of back to 'Function Summary'
declare function np:preceding-sibling-of (
            $n-pos1 as xs:anyURI, 
            $n-pos2 as xs:anyURI 
 ) as xs:boolean external

Determines whether the node position given as second argument is a preceding-sibling of the node position given as first argument. If the two positions were obtained within the same snapshot S, then the result of the function applies to the corresponding nodes as well, that is, within snapshot S, the second node is a preceding-sibling of the first. Otherwise, the result of the function does not imply anything about the positional relationship of the two nodes.

Parameters:
Returns:
Errors:

External sibling-of back to 'Function Summary'
declare function np:sibling-of (
            $n-pos1 as xs:anyURI, 
            $n-pos2 as xs:anyURI 
 ) as xs:boolean external

Determines whether two node positions are siblings. If the two positions were obtained within the same snapshot S, then the result of the function applies to the corresponding nodes as well, that is, within snapshot S, the second node is a sibling of the first. Otherwise, the result of the function does not imply anything about the positional relationship of the two nodes.

Parameters:
Returns:
Errors:

blog comments powered by Disqus