/// <summary> /// Implements the following function /// node-set subset(node-set, node-set) /// </summary> /// <param name="nodeset1">An input nodeset</param> /// <param name="nodeset2">Another input nodeset</param> /// <returns>True if all the nodes in the first nodeset are contained /// in the second nodeset</returns> /// <remarks>THIS FUNCTION IS NOT PART OF EXSLT!!!</remarks> public static bool subset(XPathNodeIterator nodeset1, XPathNodeIterator nodeset2){ ExsltNodeList nodelist1 = new ExsltNodeList(nodeset1, true); ExsltNodeList nodelist2 = new ExsltNodeList(nodeset2, true); foreach(XPathNavigator nav in nodelist1){ if(!nodelist2.Contains(nav)){ return false; } } return true; }
/// <summary> /// Implements /// boolean hassamenode(node-set, node-set) /// </summary> /// <param name="nodeset1"></param> /// <param name="nodeset2"></param> /// <returns>true if both nodeset contain at least one of the same node</returns> public static bool hassamenode(XPathNodeIterator nodeset1, XPathNodeIterator nodeset2) { ExsltNodeList nodelist1 = new ExsltNodeList(nodeset1, true); ExsltNodeList nodelist2 = new ExsltNodeList(nodeset2, true); foreach (XPathNavigator nav in nodelist1) { if (nodelist2.Contains(nav)) { return(true); } } return(false); }
/// <summary> /// Implements the following function /// node-set difference(node-set, node-set) /// </summary> /// <param name="nodeset1">An input nodeset</param> /// <param name="nodeset2">Another input nodeset</param> /// <returns>The those nodes that are in the node set /// passed as the first argument that are not in the node set /// passed as the second argument.</returns> public static XPathNodeIterator difference(XPathNodeIterator nodeset1, XPathNodeIterator nodeset2){ ExsltNodeList nodelist1 = new ExsltNodeList(nodeset1, true); ExsltNodeList nodelist2 = new ExsltNodeList(nodeset2); for(int i = 0; i < nodelist1.Count; i++){ XPathNavigator nav = nodelist1[i]; if(nodelist2.Contains(nav)){ nodelist1.RemoveAt(i); i--; } } return ExsltCommon.ExsltNodeListToXPathNodeIterator(nodelist1); }
/// <summary> /// Implements the following function /// node-set difference(node-set, node-set) /// </summary> /// <param name="nodeset1">An input nodeset</param> /// <param name="nodeset2">Another input nodeset</param> /// <returns>The those nodes that are in the node set /// passed as the first argument that are not in the node set /// passed as the second argument.</returns> public static XPathNodeIterator difference(XPathNodeIterator nodeset1, XPathNodeIterator nodeset2) { ExsltNodeList nodelist1 = new ExsltNodeList(nodeset1, true); ExsltNodeList nodelist2 = new ExsltNodeList(nodeset2); for (int i = 0; i < nodelist1.Count; i++) { XPathNavigator nav = nodelist1[i]; if (nodelist2.Contains(nav)) { nodelist1.RemoveAt(i); i--; } } return(ExsltCommon.ExsltNodeListToXPathNodeIterator(nodelist1)); }