- aug-defnode a name expr valueprocedure
If the node at EXPR does not exist, creates a node at EXPR with value VALUE, storing the node in variable NAME. This is like using defvar followed by aug-set!.
If the node or nodes at EXPR do exist, stores the corresponding nodeset in variable NAME. The node values are not modified and VALUE is ignored.
Returns two values: the integer number of nodes in the nodeset, and a boolean indicating whether a node was created or not.
A typical use is with the XPath predicate [last()+1] to append a node to a list of nodes that all have the same name, and keep a reference to the new node.
Example:
;; First create a new node with a value and assign it to a variable; ;; then assign the same node to a second variable (value is ignored). (aug-defnode a "myalias" "/files/etc/hosts/1/alias[last()+1]" "crichton") ;=> values: 1 #t (aug-defnode a "myalias1" "/files/etc/hosts/1/alias[last()]" "crichton2") ;=> values: 1 #f (aug-get a "$myalias") ;=> "crichton" (aug-get a "$myalias1") ;=> "crichton"