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.
%unionNodl = nodl:UnionSelected( nr, [xpath]) Throws XPathError
|%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.|
- 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.
In the following example, the UnionSelected method adds a "b" node to a nodelist of two "a" nodes (in some cases, this can be a convenient workaround to Janus SOAP's lack of support of the '|' operator in XPath):
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') skip 1 line print "Nodes in the merged nodelist (comparable to XPath '*/a | */a/b'):" 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'): <a><b>05</b><b/></a> <b>05</b> <a>55</a>
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.
- For more information about using XPath expressions, see XPath.