Esempio n. 1
0
 internal override void setContext(XPathNavigator context)
 {
     if (_Opnd != null)
     {
         _Opnd.setContext(context);
     }
 }
Esempio n. 2
0
 public XPathSelectionIterator(XPathNavigator nav, string xpath) {
     this.nav = nav;
     query = new QueryBuilder().Build( xpath, /*allowVar:*/true, /*allowKey:*/true );
     if (query.ReturnType() != XPathResultType.NodeSet) {
         throw new XPathException(Res.Xp_NodeSetExpected);
     }
     query.setContext(nav.Clone());
 }
Esempio n. 3
0
 public XPathSelectionIterator(XPathNavigator nav, XPathExpression expr) {
     this.nav = nav.Clone();
     query = ((CompiledXpathExpr) expr).QueryTree;
     if (query.ReturnType() != XPathResultType.NodeSet) {
         throw new XPathException(Res.Xp_NodeSetExpected);
     }
     query.setContext(nav.Clone());
 }
Esempio n. 4
0
 internal Boolean toBoolean(XPathNavigator qyContext, XPathNodeIterator iterator)
 {
     if (_qy.ReturnType() == XPathResultType.NodeSet)
     {
         _qy.setContext(qyContext.Clone());
         XPathNavigator value = _qy.advance();
         if (value != null)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else if (_qy.ReturnType() == XPathResultType.String)
     {
         object result = _qy.getValue(qyContext, iterator);
         if (result.ToString().Length > 0)
         {
             return(true);
         }
         else
         {
             if (result is string)
             {
                 return(false);
             }
             else
             {
                 Debug.Assert(result is XPathNavigator);
                 return(true);              // RTF can't be empty ?
             }
         }
     }
     else if (_qy.ReturnType() == XPathResultType.Boolean)
     {
         return(Convert.ToBoolean(_qy.getValue(qyContext, iterator)));
     }
     else if (_qy.ReturnType() == XPathResultType.Number)
     {
         return(toBoolean(XmlConvert.ToXPathDouble(_qy.getValue(qyContext, iterator))));
     }
     return(false);
 } // toBoolean
 public XPathSelectionIterator(XPathNavigator nav, XPathExpression expr)
 {
     this.nav = nav.Clone();
     query    = ((CompiledXpathExpr)expr).QueryTree;
     if (query.ReturnType() != XPathResultType.NodeSet)
     {
         throw new XPathException(Res.Xp_NodeSetExpected);
     }
     query.setContext(nav.Clone());
 }
 public XPathSelectionIterator(XPathNavigator nav, string xpath)
 {
     this.nav = nav;
     query    = new QueryBuilder().Build(xpath, /*allowVar:*/ true, /*allowKey:*/ true);
     if (query.ReturnType() != XPathResultType.NodeSet)
     {
         throw new XPathException(Res.Xp_NodeSetExpected);
     }
     query.setContext(nav.Clone());
 }
 private double Number(XPathNavigator qyContext, XPathNodeIterator iterator)
 {
     if (_qy != null)
     {
         if (_qy.ReturnType() == XPathResultType.NodeSet)
         {
             _qy.setContext(qyContext.Clone());
             XPathNavigator value = _qy.advance();
             if (value != null)
             {
                 return(Number(value.Value));
             }
             else
             {
                 return(double.NaN);
             }
         }
         else
         if (_qy.ReturnType() == XPathResultType.String)
         {
             return(Number(_qy.getValue(qyContext, iterator).ToString()));
         }
         else
         if (_qy.ReturnType() == XPathResultType.Boolean)
         {
             return(Number(Convert.ToBoolean(_qy.getValue(qyContext, iterator))));
         }
         else
         {
             return(XmlConvert.ToXPathDouble(_qy.getValue(qyContext, iterator)));
         }
     }
     else
     if (qyContext != null)
     {
         return(XmlConvert.ToXPathDouble(qyContext.Value));
     }
     else
     {
         return(double.NaN);
     }
 }
Esempio n. 8
0
        internal bool matches(IQuery e, XPathNavigator context)
        {
            if (_opnd == null)
            {
                return(false);
            }
            XPathResultType resultType = _opnd.ReturnType();

            if (resultType == XPathResultType.Number)
            {
                double i = XmlConvert.ToXPathDouble(_opnd.getValue(e));
                return(i == e.Position);
            }
            if (resultType == XPathResultType.NodeSet)
            {
                _opnd.setContext(context);
                if (_opnd.advance() != null)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            if (resultType == XPathResultType.Boolean)
            {
                return(Convert.ToBoolean(_opnd.getValue(e)));
            }
            if (resultType == XPathResultType.String)
            {
                if (_opnd.getValue(context, null).ToString().Length > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            return(false);
        }
Esempio n. 9
0
 internal override void setContext(XPathNavigator e)
 {
     reset();
     if (m_qyInput == null)
     {
         if (e == null)
         {
             return;
         }
         m_qyInput = new XPathSelfQuery(e);
     }
     else
     {
         m_qyInput.setContext(e);
     }
 }
Esempio n. 10
0
        private String toString(XPathNavigator qyContext, XPathNodeIterator iterator)
        {
            if (_ArgList != null && _ArgList.Count > 0)
            {
                IQuery _qy = (IQuery)_ArgList[0];

                if (_qy.ReturnType() == XPathResultType.NodeSet)
                {
                    _qy.setContext(qyContext.Clone());

                    XPathNavigator value = _qy.advance();

                    if (value != null)
                    {
                        return(value.Value);
                    }
                    else
                    {
                        return(String.Empty);
                    }
                }
                else if (_qy.ReturnType() == XPathResultType.String)
                {
                    return(_qy.getValue(qyContext, iterator).ToString());
                }
                else if (_qy.ReturnType() == XPathResultType.Boolean)
                {
                    return(Convert.ToBoolean(_qy.getValue(qyContext, iterator)) ? "true" : "false");
                }
                else
                {
                    return(toString(XmlConvert.ToXPathDouble(_qy.getValue(qyContext, iterator))));
                }
            }
            else if (qyContext != null)
            {
                return(qyContext.Value);
            }
            else
            {
                return(String.Empty);
            }
        }
Esempio n. 11
0
        private String toString(IQuery qyContext)
        {
            XPathNavigator value = null;

            if (_ArgList != null && _ArgList.Count > 0)
            {
                IQuery _qy = (IQuery)_ArgList[0];

                if (_qy.ReturnType() == XPathResultType.NodeSet)
                {
                    _qy.setContext(qyContext.peekElement().Clone());

                    value = _qy.advance();
                    if (value != null)
                    {
                        return(value.Value);
                    }
                    else
                    {
                        return(String.Empty);
                    }
                }
                else if (_qy.ReturnType() == XPathResultType.String)
                {
                    return(_qy.getValue(qyContext).ToString());
                }
                else if (_qy.ReturnType() == XPathResultType.Boolean)
                {
                    return(toString(Convert.ToBoolean(_qy.getValue(qyContext))));
                }
                return(toString(XmlConvert.ToXPathDouble(_qy.getValue(qyContext))));
            }
            else
            if ((value = qyContext.peekElement()) != null)
            {
                return(value.Value);
            }
            else
            {
                return(String.Empty);
            }
        }
Esempio n. 12
0
 internal void FillList()
 {
     _elementList = new ArrayList();
     while (true)
     {
         if (_getInput1)
         {
             _getInput1 = false;
             if ((m_eNext = m_qyInput.advance()) == null)
             {
                 _top = _elementList.Count;
                 return;
             }
             _child.setContext(m_eNext);
         }
         while ((m_eNext = _child.advance()) != null)
         {
             //if ( matches( _child, m_eNext) ) {
             NotVisited(m_eNext);
             //}
         }
         _getInput1 = true;
     }
 }
Esempio n. 13
0
        static bool compareQueryQuery1(
                                      IQuery opnd1,
                                      IQuery opnd2,
                                      IQuery qyContext,
                                      Operator.Op op) {
            XPathNavigator val1, val2; 
            String str1,str2;  
            opnd1.setContext(qyContext.peekElement().Clone()); 
            opnd2.setContext(qyContext.peekElement().Clone());
            while (true) {
                val1 = opnd1.advance();
                if (val1 != null)
                    str1 = val1.Value;
                else
                    return false;

                val2 = opnd2.advance();

                if (val2 != null)
                    str2 = val2.Value;
                else
                    return false;

                while (true) {
                    switch (op) {
                        case Operator.Op.EQ :
                            if (str1 == str2)
                                return true;
                            break;
                        case Operator.Op.NE :
                            if (str1 != str2)
                                return true;
			                break;
                    }
                    val2 = opnd2.advance();
                    if (val2 != null)
                        str2 = val2.Value;
                    else {
                        opnd2.reset();    
                        break;
                    }           
                }
            }
        }
Esempio n. 14
0
        static bool compareQueryQuery2(
                                      IQuery opnd1,
                                      IQuery opnd2,
                                      IQuery qyContext,
                                      Operator.Op op) {
            XPathNavigator val1, val2;
            double n1,n2;   
            opnd1.setContext(qyContext.peekElement().Clone()); 
            opnd2.setContext(qyContext.peekElement().Clone());
            while (true) {
                val1 = opnd1.advance();
                if (val1 != null)
                    n1 = NumberFunctions.Number(val1.Value);
                else
                    return false;
                val2 = opnd2.advance();

                if (val2 != null)
                    n2 = NumberFunctions.Number(val2.Value);
                else
                    return false;
                while (true) {

                    switch (op) {
                        case Operator.Op.LT : if (n1 < n2) return true;
                            break;
                        case Operator.Op.GT : if (n1 > n2) return true;
                            break;
                        case Operator.Op.LE : if (n1 <= n2) return true;
                            break;
                        case Operator.Op.GE : if (n1 >= n2) return true;
                            break;
                        case Operator.Op.EQ : if (n1 == n2) return true;
                            break;
		        case Operator.Op.NE : if (n1 != n2) return true;
			    break;
                    }
                    val2 = opnd2.advance();
                    if (val2 != null)
                        n2 = NumberFunctions.Number(val2.Value);
                    else {
                        opnd2.reset();    
                        break;
                    }

                }
            }

        }
Esempio n. 15
0
 static bool compareQueryString1(IQuery opnd1, IQuery opnd2, XPathNavigator qyContext, Operator.Op op, XPathNodeIterator iterator) {
     XPathNavigator val1;
     opnd1.setContext(qyContext.Clone()); 
     String n2 = XmlConvert.ToXPathString(opnd2.getValue(qyContext, iterator));
     while ((val1 = opnd1.advance()) != null) {
         if (op == Operator.Op.EQ) {
             if (val1.Value == n2) return true;
         }
         else if (val1.Value != n2) return true;
     }
     return false;
 }
Esempio n. 16
0
       static bool compareQueryString2(IQuery opnd1, IQuery opnd2, IQuery qyContext, Operator.Op op) {

            XPathNavigator val1;
            opnd1.setContext(qyContext.peekElement().Clone()); 
            double n1, n2 = NumberFunctions.Number(XmlConvert.ToXPathString(opnd2.getValue(qyContext)));

            while (true) {
                val1 = opnd1.advance();
                if (val1 != null)
                    n1 = NumberFunctions.Number(val1.Value);
                else
                    return false;

                switch (op) {
                    
                    case Operator.Op.LT :if (n1 <  n2) return true;
                        break;
                    case Operator.Op.GT :if (n1 >  n2) return true;
                        break;
                    case Operator.Op.LE :if (n1 <= n2) return true;
                        break;
                    case Operator.Op.GE :if (n1 >= n2)  return true;
                        break;
                    case Operator.Op.EQ :if (n1 == n2) return true;
                        break;
                    case Operator.Op.NE :if (n1 != n2) return true;
                        break;
                }
            }
        }
Esempio n. 17
0
        static bool compareQueryBool1(IQuery opnd1, IQuery opnd2, IQuery qyContext, Operator.Op op) {
            XPathNavigator val1;
            opnd1.setContext(qyContext.peekElement().Clone()); 
            Boolean n1 = false, n2 = Convert.ToBoolean(opnd2.getValue(qyContext));

                val1 = opnd1.advance();
                if (val1 != null) {
                    n1 = true;
                }
                else {
                    if (op ==  Operator.Op.EQ ) {
                        return (n2 == n1);
                    }
                    return (n2 != n1);
                }

                switch (op) {
                    
                    case Operator.Op.EQ : return (n1 == n2)  ;
                    case Operator.Op.NE : return (n1 != n2) ;
                }
                return false;

        }
Esempio n. 18
0
 internal override void setContext(XPathNavigator e)
 {
     reset();
     qy1.setContext(e.Clone());
     qy2.setContext(e.Clone());
 }
Esempio n. 19
0
        static bool compareStringQuery1(IQuery opnd1, IQuery opnd2, XPathNavigator qyContext, Operator.Op op , XPathNodeIterator iterator) {
            XPathNavigator val1;
            opnd2.setContext(qyContext.Clone()); 
            String n2, n1 = XmlConvert.ToXPathString(opnd1.getValue(qyContext, iterator));

            while (true) {
                val1 = opnd2.advance();
                if (val1 != null)
                    n2 = val1.Value;
                else
                    return false;

                switch (op) {
                    
                    case Operator.Op.EQ : if (n1 == n2) return true ;
                        break;
                    case Operator.Op.NE : if (n1 != n2) return true ;
                        break;
                }

            }
        }
Esempio n. 20
0
        static bool compareBoolQuery2(IQuery opnd1, IQuery opnd2, XPathNavigator qyContext, Operator.Op op, XPathNodeIterator iterator) {
            XPathNavigator val1;
            opnd2.setContext(qyContext.Clone()); 
            double n2, n1 = NumberFunctions.Number(Convert.ToBoolean(opnd1.getValue(qyContext, iterator)));

                val1 = opnd2.advance();
                if (val1 != null)
                    n2 = 1.0;
                else {
                    n2 = 0;
                    switch (op) {                    
                        case Operator.Op.LT : return (n1 <  n2) ;
                        case Operator.Op.GT : return (n1 >  n2) ;
                        case Operator.Op.LE : return (n1 <= n2) ;
                        case Operator.Op.GE : return (n1 >= n2) ;

                    }
                }

                switch (op) {
                    
                    case Operator.Op.LT : return (n1 <  n2)  ;
                    case Operator.Op.GT : return (n1 >  n2)  ;
                    case Operator.Op.LE : return (n1 <= n2) ;
                    case Operator.Op.GE : return (n1 >= n2)   ;
                }
                return false;

        }
Esempio n. 21
0
      static bool compareBoolQuery1(IQuery opnd1, IQuery opnd2, XPathNavigator qyContext, Operator.Op op, XPathNodeIterator iterator) {
            XPathNavigator val1;
            opnd2.setContext(qyContext.Clone()); 
            Boolean n2 = false, n1 = Convert.ToBoolean(opnd1.getValue(qyContext, iterator));

                val1 = opnd2.advance();
                if (val1 != null)
                    n2 = true;
                else {
                    if (op ==  Operator.Op.EQ ) {
                        return (n2 == n1);
                    }
                    return (n2 != n1);
                }

                switch (op) {
                    
                    case Operator.Op.EQ : return (n1 == n2) ;
                    case Operator.Op.NE : return (n1 != n2) ;
                }
                return false;

        }
Esempio n. 22
0
        static bool compareQueryBool2(IQuery opnd1, IQuery opnd2, IQuery qyContext, Operator.Op op) {
            XPathNavigator val1;
            opnd1.setContext(qyContext.peekElement().Clone()); 
            double n1, n2 = NumberFunctions.Number(Convert.ToBoolean(opnd2.getValue(qyContext)));

                val1 = opnd1.advance();
                if (val1 != null)
                    n1 = 1.0;
                else {
                    n1 = 0;
                    switch (op) {                    
                        case Operator.Op.LT : return (n1 <  n2) ;
                        case Operator.Op.GT : return (n1 >  n2) ;
                        case Operator.Op.LE : return (n1 <= n2) ;
                        case Operator.Op.GE : return (n1 >= n2) ;

                    }
                }

                switch (op) {
                    
                    case Operator.Op.LT : return (n1 <  n2) ;
                    case Operator.Op.GT : return (n1 >  n2) ;
                    case Operator.Op.LE : return (n1 <= n2) ;
                    case Operator.Op.GE : return (n1 >= n2) ;

                }
                return false;

        }
Esempio n. 23
0
 internal override void setContext(XPathNavigator e)
 {
     reset();
     _qyInput.setContext(e);
 }
Esempio n. 24
0
      static bool compareStringQuery2(IQuery opnd1, IQuery opnd2, XPathNavigator qyContext, Operator.Op op, XPathNodeIterator iterator) {
            XPathNavigator val1;
            opnd2.setContext(qyContext.Clone()); 
            double n2, n1 = NumberFunctions.Number(XmlConvert.ToXPathString(opnd1.getValue(qyContext, iterator)));

            while (true) {
                val1 = opnd2.advance();
                if (val1 != null)
                    n2 = NumberFunctions.Number(val1.Value);
                else
                    return false;

                switch (op) {
                    
                    case Operator.Op.LT :if (n1 <  n2) return true ;
                        break;
                    case Operator.Op.GT :if (n1 >  n2) return true ;
                        break;
                    case Operator.Op.LE :if (n1 <= n2) return true ;
                        break;
                    case Operator.Op.GE :if (n1 >= n2) return true ;
                        break;
                    case Operator.Op.EQ :if (n1 == n2) return true ;
                        break;
                    case Operator.Op.NE :if (n1 != n2) return true ;
                        break;

                }

            }
        }