Evaluate() private method

private Evaluate ( ActionFrame context, int key ) : object
context ActionFrame
key int
return object
コード例 #1
0
        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 (this.valueKey != Compiler.InvalidQueryKey) {
                    list.Add(SimplifyValue(processor.Evaluate(frame, this.valueKey)));
                }
                else if (this.level == "any") {
                    int number = numberAny(processor, frame);
                    if (number != 0) {
                        list.Add(number);
                    }
                }
                else {
                    bool multiple = (this.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,
                    this.formatAvt       == null ? this.formatTokens : ParseFormat(this.formatAvt.Evaluate(processor, frame)),
                    this.langAvt         == null ? this.lang         : this.langAvt        .Evaluate(processor, frame),
                    this.letterAvt       == null ? this.letter       : ParseLetter(this.letterAvt.Evaluate(processor, frame)),
                    this.groupingSepAvt  == null ? this.groupingSep  : this.groupingSepAvt .Evaluate(processor, frame),
                    this.groupingSizeAvt == null ? this.groupingSize : this.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;
            }
        }
コード例 #2
0
        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;
            }
        }