Evaluate() private method

private Evaluate ( Processor processor, ActionFrame frame ) : string
processor Processor
frame ActionFrame
return string
 // For perf reason we precalculating AVTs at compile time.
 // If we can do this we set original AVT to null
 internal static string PrecalculateAvt(ref Avt avt) {
     string result = null;
     if(avt != null && avt.IsConstant) {
         result = avt.Evaluate(null, null);
         avt = null;
     }
     return result;
 }
Example #2
0
        internal override void Execute(Processor processor, ActionFrame frame)
        {
            Debug.Assert(processor != null && frame != null);

            switch (frame.State)
            {
            case Initialized:
                if (_qname != null)
                {
                    frame.CalulatedName = _qname;
                }
                else
                {
                    frame.CalulatedName = CreateElementQName(
                        _nameAvt == null ? _name : _nameAvt.Evaluate(processor, frame),
                        _nsAvt == null ? _nsUri : _nsAvt.Evaluate(processor, frame),
                        _manager
                        );
                }
                goto case NameDone;

            case NameDone:
            {
                PrefixQName qname = frame.CalulatedName;
                if (processor.BeginEvent(XPathNodeType.Element, qname.Prefix, qname.Name, qname.Namespace, _empty) == false)
                {
                    // Come back later
                    frame.State = NameDone;
                    break;
                }

                if (!_empty)
                {
                    processor.PushActionFrame(frame);
                    frame.State = ProcessingChildren;
                    break;                                      // Allow children to run
                }
                else
                {
                    goto case ProcessingChildren;
                }
            }

            case ProcessingChildren:
                if (processor.EndEvent(XPathNodeType.Element) == false)
                {
                    frame.State = ProcessingChildren;
                    break;
                }
                frame.Finished();
                break;

            default:
                Debug.Fail("Invalid ElementAction execution state");
                break;
            }
        }
Example #3
0
        // For perf reason we precalculating AVTs at compile time.
        // If we can do this we set original AVT to null
        internal static string PrecalculateAvt(ref Avt avt)
        {
            string result = null;

            if (avt != null && avt.IsConstant)
            {
                result = avt.Evaluate(null, null);
                avt    = null;
            }
            return(result);
        }
        internal override void Compile(Compiler compiler)
        {
            CompileAttributes(compiler);
            CheckRequiredAttribute(compiler, _nameAvt, "name");

            if (_nameAvt.IsConstant)
            {
                _name    = _nameAvt.Evaluate(null, null);
                _nameAvt = null;
                if (!IsProcessingInstructionName(_name))
                {
                    // For Now: set to null to ignore action late;
                    _name = null;
                }
            }

            if (compiler.Recurse())
            {
                CompileTemplate(compiler);
                compiler.ToParent();
            }
        }
Example #5
0
        internal override void Execute(Processor processor, ActionFrame frame)
        {
            Debug.Assert(processor != null && frame != null);
            Debug.Assert(frame.State == Initialized);

            processor.AddSort(_sort != null ?
                              _sort :
                              new Sort(
                                  _selectKey,
                                  _langAvt == null ? _lang : ParseLang(_langAvt.Evaluate(processor, frame)),
                                  _dataTypeAvt == null ? _dataType : ParseDataType(_dataTypeAvt.Evaluate(processor, frame), _manager),
                                  _orderAvt == null ? _order : ParseOrder(_orderAvt.Evaluate(processor, frame)),
                                  _caseOrderAvt == null ? _caseOrder : ParseCaseOrder(_caseOrderAvt.Evaluate(processor, frame))
                                  )
                              );
            frame.Finished();
        }
        internal override void Execute(Processor processor, ActionFrame frame)
        {
            Debug.Assert(processor != null && frame != null);
            ArrayList list = processor.NumberList;

            switch (frame.State)
            {
            case Initialized:
                Debug.Assert(frame != null);
                Debug.Assert(frame.NodeSet != null);
                list.Clear();
                if (_valueKey != Compiler.InvalidQueryKey)
                {
                    list.Add(SimplifyValue(processor.Evaluate(frame, _valueKey)));
                }
                else if (_level == "any")
                {
                    int number = numberAny(processor, frame);
                    if (number != 0)
                    {
                        list.Add(number);
                    }
                }
                else
                {
                    bool           multiple    = (_level == "multiple");
                    XPathNavigator contextNode = frame.Node;           // context of xsl:number element. We using this node in MatchCountKey()
                    XPathNavigator countNode   = frame.Node.Clone();   // node we count for
                    if (countNode.NodeType == XPathNodeType.Attribute || countNode.NodeType == XPathNodeType.Namespace)
                    {
                        countNode.MoveToParent();
                    }
                    while (moveToCount(countNode, processor, contextNode))
                    {
                        list.Insert(0, numberCount(countNode, processor, contextNode));
                        if (!multiple || !countNode.MoveToParent())
                        {
                            break;
                        }
                    }
                    if (!checkFrom(processor, countNode))
                    {
                        list.Clear();
                    }
                }

                /*CalculatingFormat:*/
                frame.StoredOutput = Format(list,
                                            _formatAvt == null ? _formatTokens : ParseFormat(_formatAvt.Evaluate(processor, frame)),
                                            _langAvt == null ? _lang : _langAvt.Evaluate(processor, frame),
                                            _letterAvt == null ? _letter : ParseLetter(_letterAvt.Evaluate(processor, frame)),
                                            _groupingSepAvt == null ? _groupingSep : _groupingSepAvt.Evaluate(processor, frame),
                                            _groupingSizeAvt == null ? _groupingSize : _groupingSizeAvt.Evaluate(processor, frame)
                                            );
                goto case OutputNumber;

            case OutputNumber:
                Debug.Assert(frame.StoredOutput != null);
                if (!processor.TextEvent(frame.StoredOutput))
                {
                    frame.State = OutputNumber;
                    break;
                }
                frame.Finished();
                break;

            default:
                Debug.Fail("Invalid Number Action execution state");
                break;
            }
        }