5.34.4 SET

The SET command is used to set the "current" node in the presently loaded XML document. The "current" node is the node to which further queries (using the QUERY command) are applied.

When the document is loaded using the LOAD command, the current node is the document node.  It is not mandatory to issue the SET command to change the current node.  Providing the XPath expressions used in queries are formulated appropriately, they can be executed against the document node, and in many cases this will be all that is needed.

However, in more complex applications of the XMLQueryService, the SET command may be used, perhaps iteratively, to process specific sections of an XML document. The generated XPath expressions returned by the QUERY command when the special *XPATH or *XPATH_CONCISE values are specified may be used with the SET command to iteratively process subsets of the document contents.

Syntax:

Command

Keyword

Value

Developer notes

SET

CURRENTNODE

 

The value of this keyword is used to set the current node in the loaded XML document as the node to which further queries (using the QUERY command) are applied.

*DOCUMENT

This value specifies that the document node is the current node – this is the default state immediately after loading an XML document with the LOAD command.

xpath expression

You may specify an appropriately formulated XPath expression that identifies a single node in the document that is to be the "current" node.

For more information about XPath expressions used with the XMLQueryService, refer to 5.34.8 Guide to XPath expressions for use with XMLQueryService.

 

Example

SET