Example #1
0
        /// <summary>
        /// Implements an optimized algorithm for the following function 
        ///    node-set difference(node-set, node-set) 
        /// Uses document identification and binary search,
        /// based on the fact that a node-set is always in document order.
        /// </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>
        /// <author>Dimitre Novatchev</author>
		
        private XPathNodeIterator difference2(XPathNodeIterator nodeset1, XPathNodeIterator nodeset2)
        {
            ArrayList arDocs = new ArrayList();

            ArrayList arNodes2 = new ArrayList(nodeset2.Count);

            while(nodeset2.MoveNext())
            {
                arNodes2.Add(nodeset2.Current.Clone());
            }


            auxEXSLT.findDocs(arNodes2, arDocs);

            ExsltNodeList enlResult = new ExsltNodeList();

            while(nodeset1.MoveNext())
            {
                XPathNavigator currNode = nodeset1.Current; 
				
                if(!auxEXSLT.findNode(arNodes2, arDocs, currNode) )
                    enlResult.Add(currNode.Clone());
            }

            return ExsltCommon.ExsltNodeListToXPathNodeIterator(enlResult); 
        }
Example #2
0
        /// <summary>
        /// Implements the following function
        ///		node-set trailing(node-set, node-set)
        /// </summary>
        /// <param name="nodeset1"></param>
        /// <param name="nodeset2"></param>
        /// <returns>returns the nodes in the node set passed as the
        /// first argument that follow, in document order, the first node
        /// in the node set passed as the second argument</returns>
        public XPathNodeIterator trailing(XPathNodeIterator nodeset1, XPathNodeIterator nodeset2)
        {
            XPathNavigator leader = null;

            if (nodeset2.MoveNext())
            {
                leader = nodeset2.Current;
            }
            else
            {
                return(nodeset1);
            }

            ExsltNodeList nodelist1 = new ExsltNodeList();

            while (nodeset1.MoveNext())
            {
                if (nodeset1.Current.ComparePosition(leader) == XmlNodeOrder.After)
                {
                    nodelist1.Add(nodeset1.Current.Clone());
                }
            }

            return(ExsltCommon.ExsltNodeListToXPathNodeIterator(nodelist1));
        }
Example #3
0
        /// <summary>
        /// Implements an optimized algorithm for the following function
        ///    node-set difference(node-set, node-set)
        /// Uses document identification and binary search,
        /// based on the fact that a node-set is always in document order.
        /// </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>
        /// <author>Dimitre Novatchev</author>

        private XPathNodeIterator difference2(XPathNodeIterator nodeset1, XPathNodeIterator nodeset2)
        {
            ArrayList arDocs = new ArrayList();

            ArrayList arNodes2 = new ArrayList(nodeset2.Count);

            while (nodeset2.MoveNext())
            {
                arNodes2.Add(nodeset2.Current.Clone());
            }


            auxEXSLT.findDocs(arNodes2, arDocs);

            ExsltNodeList enlResult = new ExsltNodeList();

            while (nodeset1.MoveNext())
            {
                XPathNavigator currNode = nodeset1.Current;

                if (!auxEXSLT.findNode(arNodes2, arDocs, currNode))
                {
                    enlResult.Add(currNode.Clone());
                }
            }

            return(ExsltCommon.ExsltNodeListToXPathNodeIterator(enlResult));
        }
Example #4
0
/// <summary>
/// This method converts an ExsltNodeList to an XPathNodeIterator over the nodes in the list.
/// </summary>
/// <param name="list">The list to convert</param>
/// <returns>An XPathNodeIterator over the nodes in the original list</returns>
/// <remarks>Known Issues: A node list containing multiple instances of an attribute
/// with the same namespace name and local name will cause an error.</remarks>
        internal static XPathNodeIterator ExsltNodeListToXPathNodeIterator(ExsltNodeList list)
        {
            Assembly systemXml         = typeof(XPathNodeIterator).Assembly;
            Type     arrayIteratorType = systemXml.GetType("System.Xml.XPath.XPathArrayIterator");

            return((XPathNodeIterator)Activator.CreateInstance(arrayIteratorType,
                                                               BindingFlags.Instance | BindingFlags.Public |
                                                               BindingFlags.CreateInstance, null, new object[] { list.innerList }, null));
        }
Example #5
0
        /// <summary>
        /// Implements the following function
        ///    node-set distinct(node-set)
        /// </summary>
        /// <param name="nodeset">The input nodeset</param>
        /// <returns>Returns the nodes in the nodeset whose string value is
        /// distinct</returns>
        public XPathNodeIterator distinct(XPathNodeIterator nodeset)
        {
            if (nodeset.Count > 15)
            {
                return(distinct2(nodeset));
            }
            //else
            ExsltNodeList nodelist = new ExsltNodeList();

            while (nodeset.MoveNext())
            {
                if (!nodelist.ContainsValue(nodeset.Current.Value))
                {
                    nodelist.Add(nodeset.Current.Clone());
                }
            }

            return(ExsltCommon.ExsltNodeListToXPathNodeIterator(nodelist));
        }
Example #6
0
		/// <summary>
		/// Implements the following function 
		///    boolean 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 bool subset(XPathNodeIterator nodeset1, XPathNodeIterator nodeset2)
		{
			if(nodeset1.Count > 125 || nodeset2.Count > 125)
				return subset2(nodeset1, nodeset2);
			//else
			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; 
		} 
Example #7
0
        /// <summary>
        /// Implements the following function
        /// node-set distinct2(node-set)
        ///
        /// This implements an optimized algorithm
        /// using a Hashtable
        ///
        /// </summary>
        /// <param name="nodeset">The input nodeset</param>
        /// <returns>Returns the nodes in the nodeset whose string value is
        /// distinct</returns>
        /// <author>Dimitre Novatchev</author>
        private XPathNodeIterator distinct2(XPathNodeIterator nodeset)
        {
            ExsltNodeList nodelist = new ExsltNodeList();

            Hashtable ht = new Hashtable(nodeset.Count / 3);

            while (nodeset.MoveNext())
            {
                string strVal = nodeset.Current.Value;

                if (!ht.ContainsKey(strVal))
                {
                    ht.Add(strVal, "");

                    nodelist.Add(nodeset.Current.Clone());
                }
            }

            return(ExsltCommon.ExsltNodeListToXPathNodeIterator(nodelist));
        }
Example #8
0
        /// <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 bool hasSameNode(XPathNodeIterator nodeset1, XPathNodeIterator nodeset2)
        {
            if (nodeset1.Count >= 250 || nodeset2.Count >= 250)
            {
                return(hasSameNode2(nodeset1, nodeset2));
            }
            //else

            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);
        }
Example #9
0
        /// <summary>
        /// Implements the following function
        ///    boolean 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 bool subset(XPathNodeIterator nodeset1, XPathNodeIterator nodeset2)
        {
            if (nodeset1.Count > 125 || nodeset2.Count > 125)
            {
                return(subset2(nodeset1, nodeset2));
            }
            //else
            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);
        }
Example #10
0
        /// <summary>
        /// Implements the following function
        ///    node-set highest(node-set)
        /// </summary>
        /// <param name="iterator">The input nodeset</param>
        /// <returns>All the nodes that contain the max value in the nodeset</returns>
        public XPathNodeIterator highest(XPathNodeIterator iterator)
        {
            ExsltNodeList newList = new ExsltNodeList();
            double        max, t;

            if (iterator.Count == 0)
            {
                return(ExsltCommon.ExsltNodeListToXPathNodeIterator(newList));
            }


            try{
                iterator.MoveNext();
                max = XmlConvert.ToDouble(iterator.Current.Value);
                newList.Add(iterator.Current.Clone());

                while (iterator.MoveNext())
                {
                    t = XmlConvert.ToDouble(iterator.Current.Value);

                    if (t > max)
                    {
                        max = t;
                        newList.Clear();
                        newList.Add(iterator.Current.Clone());
                    }
                    else if (t == max)
                    {
                        newList.Add(iterator.Current.Clone());
                    }
                }
            }catch (Exception) {           //return empty node set
                newList.Clear();
                return(ExsltCommon.ExsltNodeListToXPathNodeIterator(newList));
            }

            return(ExsltCommon.ExsltNodeListToXPathNodeIterator(newList));
        }
Example #11
0
        /// <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 XPathNodeIterator difference(XPathNodeIterator nodeset1, XPathNodeIterator nodeset2)
        {
            if(nodeset2.Count > 166)
                return difference2(nodeset1, nodeset2);
            //else
            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); 
        }
Example #12
0
        /// <summary>
        ///   Implements the following function
        ///   node-set intersection3(node-set, node-set)
        ///
        ///   This is an optimisation of the initial implementation
        ///   of intersection(). It uses a document identification
        ///   and a binary search algorithm, based on the fact
        ///   that a node-set is always in document order.
        /// </summary>
        /// <param name="nodeset1">The first node-set</param>
        /// <param name="nodeset2">The second node-set</param>
        /// <returns>The node-set, which is the intersection
        ///          of nodeset1 and nodeset2
        /// </returns>
        /// <author>Dimitre Novatchev</author>

        private XPathNodeIterator intersection3(XPathNodeIterator nodeset1,
                                                XPathNodeIterator nodeset2)
        {
            XPathNodeIterator it1 =
                (nodeset1.Count > nodeset2.Count) ? nodeset1
                : nodeset2;

            XPathNodeIterator it2 =
                (nodeset1.Count > nodeset2.Count) ? nodeset2
                : nodeset1;

            ArrayList arDocs = new ArrayList();

            ArrayList arNodes1 = new ArrayList(it1.Count);

            while (it1.MoveNext())
            {
                arNodes1.Add(it1.Current.Clone());
            }


            auxEXSLT.findDocs(arNodes1, arDocs);

            ExsltNodeList enlResult = new ExsltNodeList();

            while (it2.MoveNext())
            {
                XPathNavigator currNode = it2.Current;

                if (auxEXSLT.findNode(arNodes1, arDocs, currNode))
                {
                    enlResult.Add(currNode.Clone());
                }
            }

            return(ExsltCommon.ExsltNodeListToXPathNodeIterator(enlResult));
        }
Example #13
0
        /// <summary>
        /// Implements
        ///    boolean hassamenode2(node-set, node-set)
        ///
        /// Optimized by using a document identification and
        /// binary search algorithm
        /// </summary>
        /// <param name="nodeset1">The first nodeset</param>
        /// <param name="nodeset2">The second nodeset</param>
        /// <returns>true if both nodeset contain
        /// at least one of the same node</returns>
        /// <author>Dimitre Novatchev</author>
        private bool hasSameNode2(XPathNodeIterator nodeset1, XPathNodeIterator nodeset2)
        {
            XPathNodeIterator it1 =
                (nodeset1.Count > nodeset2.Count) ? nodeset1
                : nodeset2;

            XPathNodeIterator it2 =
                (nodeset1.Count > nodeset2.Count) ? nodeset2
                : nodeset1;

            ArrayList arDocs = new ArrayList();

            ArrayList arNodes1 = new ArrayList(it1.Count);

            while (it1.MoveNext())
            {
                arNodes1.Add(it1.Current.Clone());
            }


            auxEXSLT.findDocs(arNodes1, arDocs);

            ExsltNodeList enlResult = new ExsltNodeList();

            while (it2.MoveNext())
            {
                XPathNavigator currNode = it2.Current;

                if (auxEXSLT.findNode(arNodes1, arDocs, currNode))
                {
                    return(true);
                }
            }

            return(false);
        }
Example #14
0
        /// <summary>
        /// Implements the following function
        ///   node-set intersection(node-set, node-set)
        /// </summary>
        /// <param name="nodeset1">The first node-set</param>
        /// <param name="nodeset2">The second node-set</param>
        /// <returns>The node-set, which is the intersection
        ///          of nodeset1 and nodeset2
        /// </returns>
        public XPathNodeIterator intersection(XPathNodeIterator nodeset1, XPathNodeIterator nodeset2)
        {
            if (nodeset1.Count >= 500 || nodeset2.Count >= 500)
            {
                return(intersection3(nodeset1, nodeset2));
            }
            //else
            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));
        }
Example #15
0
        /// <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 XPathNodeIterator difference(XPathNodeIterator nodeset1, XPathNodeIterator nodeset2)
        {
            if (nodeset2.Count > 166)
            {
                return(difference2(nodeset1, nodeset2));
            }
            //else
            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));
        }
Example #16
0
        /// <summary>
        /// Implements the following function 
        ///		node-set trailing(node-set, node-set)
        /// </summary>
        /// <param name="nodeset1"></param>
        /// <param name="nodeset2"></param>
        /// <returns>returns the nodes in the node set passed as the 
        /// first argument that follow, in document order, the first node 
        /// in the node set passed as the second argument</returns>
        public XPathNodeIterator trailing(XPathNodeIterator nodeset1, XPathNodeIterator nodeset2)
        {
				
            XPathNavigator leader = null; 
					
            if(nodeset2.MoveNext())
            {
                leader = nodeset2.Current; 
            }
            else
            { 
                return nodeset1; 
            }

            ExsltNodeList nodelist1 = new ExsltNodeList();

            while(nodeset1.MoveNext())
            {
                if(nodeset1.Current.ComparePosition(leader) == XmlNodeOrder.After)
                {
                    nodelist1.Add(nodeset1.Current.Clone()); 
                }					
            }

            return ExsltCommon.ExsltNodeListToXPathNodeIterator(nodelist1);  
        }
Example #17
0
        /// <summary>
        ///   Implements the following function 
        ///   node-set intersection3(node-set, node-set)
        ///
        ///   This is an optimisation of the initial implementation
        ///   of intersection(). It uses a document identification
        ///   and a binary search algorithm, based on the fact
        ///   that a node-set is always in document order.
        /// </summary>
        /// <param name="nodeset1">The first node-set</param>
        /// <param name="nodeset2">The second node-set</param>
        /// <returns>The node-set, which is the intersection
        ///          of nodeset1 and nodeset2
        /// </returns>
        /// <author>Dimitre Novatchev</author>				

        private XPathNodeIterator intersection3(XPathNodeIterator nodeset1, 
            XPathNodeIterator nodeset2)
        {
            XPathNodeIterator it1 = 
                (nodeset1.Count > nodeset2.Count) ? nodeset1
                : nodeset2;

            XPathNodeIterator it2 = 
                (nodeset1.Count > nodeset2.Count) ? nodeset2
                : nodeset1;

            ArrayList arDocs = new ArrayList();

            ArrayList arNodes1 = new ArrayList(it1.Count);

            while(it1.MoveNext())
            {
                arNodes1.Add(it1.Current.Clone());
            }


            auxEXSLT.findDocs(arNodes1, arDocs);

            ExsltNodeList enlResult = new ExsltNodeList();

            while(it2.MoveNext())
            {
                XPathNavigator currNode = it2.Current; 
				
                if(auxEXSLT.findNode(arNodes1, arDocs, currNode) )
                    enlResult.Add(currNode.Clone());
            }

            return ExsltCommon.ExsltNodeListToXPathNodeIterator(enlResult); 
        }
Example #18
0
        /// <summary>
        /// Implements the following function 
        ///   node-set intersection(node-set, node-set)
        /// </summary>
        /// <param name="nodeset1">The first node-set</param>
        /// <param name="nodeset2">The second node-set</param>
        /// <returns>The node-set, which is the intersection
        ///          of nodeset1 and nodeset2
        /// </returns>
        public XPathNodeIterator intersection(XPathNodeIterator nodeset1, XPathNodeIterator nodeset2)
        {
				
            if(nodeset1.Count >= 500 || nodeset2.Count >= 500)
                return intersection3(nodeset1, nodeset2);
            //else
            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); 

        }
Example #19
0
        /// <summary>
        /// Implements 
        ///    boolean hassamenode2(node-set, node-set)
        ///    
        /// Optimized by using a document identification and
        /// binary search algorithm
        /// </summary>
        /// <param name="nodeset1">The first nodeset</param>
        /// <param name="nodeset2">The second nodeset</param>
        /// <returns>true if both nodeset contain 
        /// at least one of the same node</returns>
        /// <author>Dimitre Novatchev</author>
        private bool hasSameNode2(XPathNodeIterator nodeset1, XPathNodeIterator nodeset2)
        {
            XPathNodeIterator it1 = 
                (nodeset1.Count > nodeset2.Count) ? nodeset1
                : nodeset2;

            XPathNodeIterator it2 = 
                (nodeset1.Count > nodeset2.Count) ? nodeset2
                : nodeset1;

            ArrayList arDocs = new ArrayList();

            ArrayList arNodes1 = new ArrayList(it1.Count);

            while(it1.MoveNext())
            {
                arNodes1.Add(it1.Current.Clone());
            }


            auxEXSLT.findDocs(arNodes1, arDocs);

            ExsltNodeList enlResult = new ExsltNodeList();

            while(it2.MoveNext())
            {
                XPathNavigator currNode = it2.Current; 
				
                if(auxEXSLT.findNode(arNodes1, arDocs, currNode) )
                    return true;
            }

            return false; 
        }
Example #20
0
        /// <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 bool hasSameNode(XPathNodeIterator nodeset1, XPathNodeIterator nodeset2)
        {
            if(nodeset1.Count >= 250 || nodeset2.Count >= 250)
                return hasSameNode2(nodeset1, nodeset2);
            //else
				
            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; 
        }
Example #21
0
        /// <summary>
        /// Implements the following function 
        /// node-set distinct2(node-set)
        /// 
        /// This implements an optimized algorithm
        /// using a Hashtable
        ///    
        /// </summary>
        /// <param name="nodeset">The input nodeset</param>
        /// <returns>Returns the nodes in the nodeset whose string value is 
        /// distinct</returns>
        /// <author>Dimitre Novatchev</author>
        private XPathNodeIterator distinct2(XPathNodeIterator nodeset)
        {
				
            ExsltNodeList nodelist = new ExsltNodeList();

            Hashtable ht = new Hashtable(nodeset.Count / 3);

            while(nodeset.MoveNext())
            {
                string strVal = nodeset.Current.Value;

                if(! ht.ContainsKey(strVal) )
                {
                    ht.Add(strVal, "");

                    nodelist.Add(nodeset.Current.Clone()); 
                }					
            }
					 
            return ExsltCommon.ExsltNodeListToXPathNodeIterator(nodelist); 

        }
Example #22
0
        /// <summary>
        /// Implements the following function 
        ///    node-set distinct(node-set)
        /// </summary>
        /// <param name="nodeset">The input nodeset</param>
        /// <returns>Returns the nodes in the nodeset whose string value is 
        /// distinct</returns>
        public XPathNodeIterator distinct(XPathNodeIterator nodeset)
        {
            if(nodeset.Count > 15)
                return distinct2(nodeset);
            //else
            ExsltNodeList nodelist = new ExsltNodeList();

            while(nodeset.MoveNext())
            {
                if(!nodelist.ContainsValue(nodeset.Current.Value))
                {
                    nodelist.Add(nodeset.Current.Clone()); 
                }					
            }
					 
            return ExsltCommon.ExsltNodeListToXPathNodeIterator(nodelist); 

        }
Example #23
0
/// <summary>
/// This method converts an ExsltNodeList to an XPathNodeIterator over the nodes in the list.
/// </summary>
/// <param name="list">The list to convert</param>
/// <returns>An XPathNodeIterator over the nodes in the original list</returns>
/// <remarks>Known Issues: A node list containing multiple instances of an attribute 
/// with the same namespace name and local name will cause an error.</remarks>
		internal static XPathNodeIterator ExsltNodeListToXPathNodeIterator(ExsltNodeList list){
		

			Assembly systemXml = typeof(XPathNodeIterator).Assembly; 
			Type arrayIteratorType = systemXml.GetType("System.Xml.XPath.XPathArrayIterator"); 

			return (XPathNodeIterator) Activator.CreateInstance( arrayIteratorType, 
				BindingFlags.Instance | BindingFlags.Public | 
				BindingFlags.CreateInstance, null, new object[]{ list.innerList}, null ); 

		}
Example #24
0
		/// <summary>
		/// Implements the following function 
		///    node-set highest(node-set)
		/// </summary>
		/// <param name="iterator">The input nodeset</param>
		/// <returns>All the nodes that contain the max value in the nodeset</returns>		
		public XPathNodeIterator highest(XPathNodeIterator iterator){

			ExsltNodeList newList = new ExsltNodeList(); 
			double max, t; 

			if(iterator.Count == 0){
				return ExsltCommon.ExsltNodeListToXPathNodeIterator(newList);  
			}


			try{ 

				iterator.MoveNext(); 
				max = XmlConvert.ToDouble(iterator.Current.Value);
				newList.Add(iterator.Current.Clone()); 

				while (iterator.MoveNext()){
					t = XmlConvert.ToDouble(iterator.Current.Value);
				
					if(t > max){
						max =  t;
						newList.Clear(); 
						newList.Add(iterator.Current.Clone()); 
					}else if( t == max){
						newList.Add(iterator.Current.Clone()); 
					}
				}
				
			}catch(Exception){ //return empty node set
				newList.Clear(); 
				return ExsltCommon.ExsltNodeListToXPathNodeIterator(newList);  
			}

			return ExsltCommon.ExsltNodeListToXPathNodeIterator(newList); 
		}