UnionSelected (XmlNodelist function)
Union of XmlNodelist and selected nodes (XmlNodelist class)
UnionSelected creates an XmlNodelist that is the union of (that is, it merges) an XmlNodelist and the nodelist result of an XPath expression.
Syntax
%unionNodl = nodl:UnionSelected( nr, [xpath]) Throws XPathError
Syntax terms
%unionNodl | An XmlNodelist pointing to the nodelist that is created. |
---|---|
nodl | An XmlNodelist whose nodes are merged with the xpath result nodelist. |
nr | An XmlDoc or XmlNode, used as the context node for the xpath expression. |
xpath | A Unicode string that is an Xpath expression that results in a nodelist. This is an optional argument whose default is a period (.), that is, the node referenced by the method object (nr). Prior to Sirius Mods Version 7.6, this argument is an EBCDIC string. |
Usage notes
- The XmlDoc associated with nodl and nr must be the same.
- If the result of the argument XPath expression (xpath) is empty, a copy of nodl is returned.
Examples
In the following example, the UnionSelected method adds a "b" node to a nodelist of two "a" nodes:
begin %doc is object xmlDoc %nl1 is object xmlNodelist %nl2 is object xmlNodelist %i is float %doc = new %doc:loadXml('<top><a><b>05</b><b></b></a><a>55</a></top>') %doc:print %nl1 = %doc:selectNodes('*/a') skip 1 line print "Nodes in nodelist %nl1 (as always, nodelist items are in document order):" for %i from 1 to %nl1:count print %nl1(%i):serial(, 'EBCDIC') end for %nl2 = %nl1:unionSelected(%doc, '*/a/b[1]') skip 1 line print "Nodes in the merged nodelist (comparable to XPath '*/a | */a/b[1]'):" for %i from 1 to %nl2:count print %nl2(%i):serial(, 'EBCDIC') end for end
The example results follow:
<top> <a> <b>05</b> <b/> </a> <a>55</a> </top> Nodes in nodelist %nl1 (as always, nodelist items are in document order): <a><b>05</b><b/></a> <a>55</a> Nodes in the merged nodelist (comparable to XPath '*/a | */a/b[1]'): <a><b>05</b><b/></a> <b>05</b> <a>55</a>
Request-cancellation errors
This list is not exhaustive: it does not include all the errors that are request cancelling.
- The XmlDocs associated with nodl and nr are not the same.
- xpath expression is invalid.
- Insufficient free space exists in CCATEMP.
See also
- For more information about using XPath expressions, see XPath.