Exemplo n.º 1
0
 internal ChildrenQuery(
                       IQuery qyInput,
                       String name,
                       String prefix,
                       String urn,
                       XPathNodeType type) : base (qyInput, name, prefix, urn, type) {
 }
Exemplo n.º 2
0
//        private XsltContext _context;


        internal SortQuery(IQuery  qyParent) {
            System.Diagnostics.Debug.Assert(qyParent != null, "Sort Query needs an input query tree to work on");
            _qyInput = qyParent;
            _sortExpressions = new ArrayList();
            _comparers = new ArrayList();
            _Results = new SortedList(new XPathComparer(_comparers));
        }
Exemplo n.º 3
0
 internal XPathSelfQuery(
                        IQuery  qyInput,
                        String Name,
                        String Prefix,
                        String URN,
                        XPathNodeType Type) : base(qyInput, Name,  Prefix, URN,  Type) {
 }
Exemplo n.º 4
0
 private XPathSelectionIterator(XPathSelectionIterator it) {
     this.nav   = it.nav.Clone();
     this.query = it.query.Clone();
     for(position = 0; position < it.position; position ++) {
         this.query.advance();
     }
 }
Exemplo n.º 5
0
 internal override object getValue(IQuery qy) {
     switch (_FuncType) {
         case System.Xml.XPath.Function.FunctionType.FuncString :
             return toString(qy);
         case System.Xml.XPath.Function.FunctionType.FuncConcat :
             return Concat(qy);
         case System.Xml.XPath.Function.FunctionType.FuncStartsWith :
             return Startswith(qy);
         case System.Xml.XPath.Function.FunctionType.FuncContains :
             return Contains(qy);
         case System.Xml.XPath.Function.FunctionType.FuncSubstringBefore :
             return Substringbefore(qy);
         case System.Xml.XPath.Function.FunctionType.FuncSubstringAfter :
             return Substringafter(qy);
         case System.Xml.XPath.Function.FunctionType.FuncSubstring :
             return Substring(qy);
         case System.Xml.XPath.Function.FunctionType.FuncStringLength :
             return StringLength(qy);
         case System.Xml.XPath.Function.FunctionType.FuncNormalize :
             return Normalize(qy);
         case System.Xml.XPath.Function.FunctionType.FuncTranslate :
             return Translate(qy);
     }
     return String.Empty;
 }
Exemplo n.º 6
0
        internal MethodOperand(
                              IQuery opnd,
                              FT ftype) {
            _FType= ftype;
            _Opnd = opnd; 

        }
Exemplo n.º 7
0
 internal AttributeQuery(
                        IQuery qyParent,
                        String Name, 
                        String Prefix,
                        String URN,
                        XPathNodeType Type) : base(qyParent, Name, Prefix, URN, Type) {
 }
Exemplo 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;      
 }
Exemplo n.º 9
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());
 }
Exemplo n.º 10
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());
 }
Exemplo n.º 11
0
 internal FollSiblingQuery(
     IQuery qyInput,
     String name,
     String prefix,
     String urn,
     XPathNodeType type) : base (qyInput, name, prefix, urn, type)
 {
 }
Exemplo n.º 12
0
 internal XPathAncestorQuery(
                            IQuery  qyInput,
                            bool matchSelf,
                            String Name,
                            String Prefix,
                            String URN,
                            XPathNodeType Type) : base(qyInput, Name, Prefix, URN, Type) {
     _fMatchSelf = matchSelf;
 }
Exemplo n.º 13
0
 internal XPathDescendantQuery(
                              IQuery  qyParent,
                              bool matchSelf,
                              String Name,
                              String Prefix,
                              String URN,
                              XPathNodeType Type) : base(qyParent, Name, Prefix, URN, Type) {
     _fMatchSelf = matchSelf;
 }
Exemplo n.º 14
0
        internal SmartXPathDescendantQuery(
                                          IQuery  qyParent,
                                          bool matchSelf,
                                          String Name,
                                          String Prefix,
                                          String URN,
                                          XPathNodeType Type,
                                          bool abbrAxis) : base(qyParent,matchSelf, Name, Prefix, URN, Type, abbrAxis) {

        }
Exemplo n.º 15
0
 internal XPathDescendantQuery(
                              IQuery  qyParent,
                              bool matchSelf,
                              String Name,
                              String Prefix,
                              String URN,
                              XPathNodeType Type,
                              bool abbrAxis) : this(qyParent, matchSelf, Name, Prefix, URN, Type)
 {
     this.abbrAxis = abbrAxis;
 }
Exemplo n.º 16
0
 internal NumericExpr(Operator.Op op, IQuery  opnd1, IQuery  opnd2) {
     if ( opnd1 is VariableQuery || opnd1 is XsltFunction  || opnd1.ReturnType() != XPathResultType.Number)
         _opnd1= new NumberFunctions(opnd1);
     else
         _opnd1 = opnd1;
     if (opnd2 != null && (opnd2 is VariableQuery || opnd2 is XsltFunction ||   opnd2.ReturnType() != XPathResultType.Number))
         _opnd2= new NumberFunctions(opnd2);
     else
         _opnd2 = opnd2;
     _op= op;
 }
Exemplo n.º 17
0
        internal BaseAxisQuery(
                              IQuery qyInput,
                              String Name,
                              String Prefix,
                              String urn,
                              XPathNodeType Type) {
            m_Prefix = Prefix;
            m_URN = urn;
            m_qyInput = qyInput;
            m_Name = Name;
            m_Type = Type;
            _fMatchName = !m_Prefix.Equals(String.Empty) || !m_Name.Equals(String.Empty);

        }
Exemplo n.º 18
0
 internal override object getValue(IQuery qy) {
     switch (_FuncType) {
         case FT.FuncNumber:
             return Number(qy);
         case FT.FuncSum:
             return Sum(qy);
         case FT.FuncFloor:
             return Floor(qy);
         case FT.FuncCeiling:
             return Ceiling(qy);
         case FT.FuncRound:
             return Round(qy);
     }
     return null;
 }
Exemplo n.º 19
0
        internal SortQuery(SortQuery originalQuery) {
            this._qyInput = originalQuery._qyInput.Clone();
            int count = originalQuery._sortExpressions.Count;
            this._sortExpressions = new ArrayList(count);
            for (int i=0; i < count; i++) {
                IQuery query = originalQuery._sortExpressions[i] as IQuery;
                query = query.Clone();
                this._sortExpressions.Add(query);
            }
            this._comparers = new ArrayList(originalQuery._comparers);
            this._Results = new SortedList(new XPathComparer(_comparers));
            //            SetXsltContext(_context);


        }
Exemplo n.º 20
0
 internal override object getValue(IQuery qy) {
     switch (_FuncType) {
         case FT.FuncBoolean :
             return toBoolean(qy);
         case FT.FuncNot :
             return Not(qy);
         case FT.FuncTrue :
             return true;
         case FT.FuncFalse :
             return false;
         case FT.FuncLang :
             return Lang(qy);
     }
     return null;
 }
Exemplo n.º 21
0
        internal override void SetXsltContext(XsltContext context) {
            if (context == null) {
                throw new XPathException(Res.Xp_UndefinedXsltContext, Prefix, Name);            }

            if(xsltContextVariable == null) {
                xsltContextVariable = context.ResolveVariable(Prefix, Name);
                Debug.Assert(xsltContextVariable != null, "XSLT has to resolve it or throw exception");
            }
            else {
                Debug.Assert(xsltContextVariable == context.ResolveVariable(Prefix, Name), "ResolveVariable supposed to return the same VariableAction each time");
            }
            Object result = xsltContextVariable.Evaluate(context);
            if (result is double) {
                _VarQuery = new OperandQuery(result, XPathResultType.Number);
            }
            else if (result is String) {
                _VarQuery = new OperandQuery(result, XPathResultType.String);
            }
            else if (result is Boolean) {
                _VarQuery = new OperandQuery(result, XPathResultType.Boolean);
            }
            else if (result is XPathNavigator) {
                _VarQuery = new NavigatorQuery((XPathNavigator)result);
            }            
            else if (result is ResetableIterator) {
                ResetableIterator it = result as ResetableIterator;
                _VarQuery = new XmlIteratorQuery( (ResetableIterator) it.Clone() );
            }
            else if (result is XPathNodeIterator) {
                Debug.Assert(false, "Unexpected type of XPathNodeIterator");
                throw new NotSupportedException(Res.GetString(Res.XmlUnsupportedType, result.GetType().FullName));             
            }
            else if (result is int) {
                _VarQuery = new OperandQuery(XmlConvert.ToXPathDouble(result), XPathResultType.Number);
            }
            else {
                if (result == null) {
                    throw new XPathException(Res.Xslt_InvalidVariable, Name);
                }
                Debug.Assert(false, "Unexpected variable type");
                throw new NotSupportedException(Res.GetString(Res.XmlUnsupportedType, result.GetType().FullName));
            }
            Debug.Assert(_VarQuery != null);           
        }
Exemplo n.º 22
0
        internal override object getValue( IQuery  qyContext) {
            double n1=0,n2=0;

            //Debug.Assert(_opnd1 != null);
            //Debug.Assert((_opnd2 != null) || (OperandValue::NEGATE == _op));

            n1 = XmlConvert.ToXPathDouble(_opnd1.getValue(qyContext));
            if (_op != Operator.Op.NEGATE)
                n2 = XmlConvert.ToXPathDouble(_opnd2.getValue(qyContext));
            switch (_op) {
                case Operator.Op.PLUS   : return  n1 + n2;
                case Operator.Op.MINUS  : return  n1 - n2;
                case Operator.Op.MOD    : return  n1 % n2;
                case Operator.Op.DIV    : return  n1 / n2;
                case Operator.Op.MUL    : return  n1 * n2;               
                case Operator.Op.NEGATE : return -n1;
            }
            return null;
        }
Exemplo n.º 23
0
        public override void AddSort(object expr, IComparer comparer) {
            // sort makes sense only when we are dealing with a query that
            // returns a nodeset.
	    IQuery evalExpr;
             _allowSort = true;
            if (expr is String) {
                evalExpr = _builder.Build((String)expr, out _hasUnresolvedPrefix); // this will throw if expr is invalid
            }
            else if (expr is CompiledXpathExpr) {
		evalExpr = ((CompiledXpathExpr)expr).QueryTree;
	    }
            else {
                throw new XPathException(Res.Xp_BadQueryObject);
            }
            if (_sortQuery == null) {
                _sortQuery = new SortQuery(_compiledQuery);
                _compiledQuery = _sortQuery;
            }
            _sortQuery.AddSort(evalExpr, comparer);
        }
Exemplo n.º 24
0
 internal CacheQuery(IQuery qyParent) : base(qyParent){
 }
 private static void AddParameters(TypedParameter[] parameters, IQuery query)
 {
     foreach (TypedParameter parameter in parameters)
     {
         query.SetParameter(parameter.Name, parameter.Value,
                            parameter.IType);
     }
 }
Exemplo n.º 26
0
 internal IDQuery(IQuery qyInput)
 {
     m_qyInput = qyInput;
 }
Exemplo n.º 27
0
 internal CompiledXpathExpr(IQuery query, string expression, bool hasPrefix) {
     _compiledQuery = query;
     _expr = expression;
     _builder = new QueryBuilder();
     _hasUnresolvedPrefix = hasPrefix;
 }
Exemplo n.º 28
0
 internal ReversePositionQuery(IQuery qyParent) :base(qyParent){
 }
Exemplo n.º 29
0
 internal override Object getValue(IQuery qy) {
     InvokeFunction(qy.peekElement().Clone());
     return _ResultQuery.getValue(qy);
 } 
Exemplo n.º 30
0
        private void InvokeFunction(XPathNavigator qy) {
            IXsltContextFunction function = this.Function;

            // calculate arguments:
            Debug.Assert(_ArgArray != null && _ArgArray.Length == _ArgList.Count);
            for(int i = _ArgList.Count - 1; 0 <= i; i --) {
                IQuery arg = (IQuery) _ArgList[i];
                if (arg.ReturnType() == XPathResultType.NodeSet) {
                    _ArgArray[i] = new XPathQueryIterator(arg, qy.Clone());
                }
                else {
                    _ArgArray[i] = arg.getValue(qy, null);
                }
            }

            try {
                object result = function.Invoke(_XsltContext, _ArgArray, qy);

                if(result == null) {
                    _ResultQuery = new OperandQuery( String.Empty, XPathResultType.String );
                }
                else {
                    XPathResultType returnedType = function.ReturnType;
                    if(returnedType == XPathResultType.Any) {
                        // If function is untyped get returned type from real result
                        returnedType = XsltCompileContext.GetXPathType(result.GetType());
                    }
                    switch (returnedType) {
                    case XPathResultType.String :
                        // trick. As soon XPathResultType.Navigator will be distinct type rid of from it. 
                        //_ResultQuery = new OperandQuery( result, XPathResultType.String );
                        if(result is XPathNavigator) {
                            _ResultQuery = new NavigatorQuery((XPathNavigator)result);
                        }
                        else {
                            _ResultQuery = new OperandQuery( result, XPathResultType.String );
                        }
                        break;
                    case XPathResultType.Boolean :
                        _ResultQuery = new OperandQuery( result, XPathResultType.Boolean );
                        break;
                    case XPathResultType.Number :
                        _ResultQuery = new OperandQuery( XmlConvert.ToXPathDouble( result ), XPathResultType.Number );
                        break;
                    case XPathResultType.NodeSet :
                        if (result is ResetableIterator) {
                            _ResultQuery = new XmlIteratorQuery((ResetableIterator)result);
                        }
                        else {
                            Debug.Assert(false, "Unexpected type of XPathNodeIterator");
                            throw new NotSupportedException(Res.GetString(Res.XmlUnsupportedType, result.GetType().FullName)); 
                        }
                        break;
//                  case XPathResultType.Navigator :
//                      _ResultQuery = new NavigatorQuery((XPathNavigator)result);
//                      break;
                    default :
                        _ResultQuery = new OperandQuery( result.ToString(), XPathResultType.String );
                        break;
                    }
                }
            }
            catch(Exception ex) {
                string qname = _Prefix != string.Empty ? _Prefix + ":" + _Name : _Name;
                throw new XsltException(Res.Xslt_FunctionFailed, new string[] {qname}, ex);
            }
        }