Exemplo n.º 1
0
        private static AdkXPathStep ParseNextStep(Fragment stepFragment)
        {
            Fragment predicateFragment = stepFragment.FindBoundedFragment('[', ']');

            if (predicateFragment != null)
            {
                AdkExpression predicates = ParsePredicates(predicateFragment);
                String        stepName   = stepFragment.BeforeFragment(predicateFragment);

                return(new AdkXPathStep(AdkAxisType.Child, new AdkNodeNameTest(stepName), predicates));
            }
            else
            {
                return(ParseStep(stepFragment.ToString()));
            }
        }
Exemplo n.º 2
0
        private String Parenthesize(AdkExpression expression, bool left)
        {
            if (!(expression is AdkOperation))
            {
                return(expression.ToString());
            }
            AdkOperation op            = (AdkOperation)expression;
            int          myPrecedence  = Precedence;
            int          thePrecedence = op.Precedence;

            bool needParens = true;

            if (myPrecedence < thePrecedence)
            {
                needParens = false;
            }
            else if (myPrecedence == thePrecedence)
            {
                if (Symmetric)
                {
                    needParens = false;
                }
                else
                {
                    needParens = !left;
                }
            }

            if (needParens)
            {
                return("(" + expression.ToString() + ")");
            }
            else
            {
                return(expression.ToString());
            }
        }
Exemplo n.º 3
0
        private String Parenthesize( AdkExpression expression, bool left )
        {
            if ( !(expression is AdkOperation) )
            {
                return expression.ToString();
            }
            AdkOperation op = (AdkOperation) expression;
            int myPrecedence = Precedence;
            int thePrecedence = op.Precedence;

            bool needParens = true;
            if ( myPrecedence < thePrecedence )
            {
                needParens = false;
            }
            else if ( myPrecedence == thePrecedence )
            {
                if ( Symmetric )
                {
                    needParens = false;
                }
                else
                {
                    needParens = !left;
                }
            }

            if ( needParens )
            {
                return "(" + expression.ToString() + ")";
            }
            else
            {
                return expression.ToString();
            }
        }
Exemplo n.º 4
0
        private void CreatePredicateValues( INodePointer current, AdkExpression predicate, XsltContext evalContext )
        {
            if ( predicate is AdkEqualOperation )
            {
                AdkExpression[] components = ((AdkEqualOperation) predicate).Arguments;
                AdkLocPath lp = (AdkLocPath) components[0];
                AdkNodeNameTest attrName = (AdkNodeNameTest) lp.Steps[0].NodeTest;
                INodePointer attr = current.CreateAttribute( this, attrName.NodeName );
                Object value = components[1].ComputeValue( evalContext );
                attr.SetValue( value );
                return;
            }

            // This might be the 'adk:x()' function
            if ( predicate is AdkAndOperation )
            {
                foreach ( AdkExpression expr in ((AdkAndOperation) predicate).Arguments )
                {
                    if ( expr is AdkFunction && ((AdkFunction) expr).FunctionName.Equals( "adk:x" ) )
                    {
                        // This is the special marker function that tells the ADK to always
                        // create the parent repeatable element. Don't evaluate it.
                        continue;
                    }
                    else
                    {
                        CreatePredicateValues( current, expr, evalContext );
                    }
                }
                return;
            }

            // Unrecognized predicate
            throw new ArgumentException( "Cannot evaluate expression predicate: " + predicate );
        }
Exemplo n.º 5
0
 public AdkEqualOperation(AdkExpression arg1, AdkExpression arg2) : base(arg1, arg2)
 {
 }
Exemplo n.º 6
0
 public AdkEqualOperation( AdkExpression arg1, AdkExpression arg2 )
     : base(arg1, arg2)
 {
 }