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);
        }
Exemple #2
0
        private void AssertStep(AdkXPathStep step, String name, String singePredicateName, object singlePredicateValue)
        {
            Assert.AreEqual(name, ((AdkNodeNameTest)step.NodeTest).NodeName);
            Assert.IsNotNull(step.Predicates);
            Assert.AreEqual(1, step.Predicates.Length);
            Assert.IsInstanceOfType(typeof(AdkEqualOperation), step.Predicates[0]);

            AdkExpression[] components = ((AdkEqualOperation)step.Predicates[0]).Arguments;
            Assert.AreEqual(2, components.Length);
            Assert.IsInstanceOfType(typeof(AdkLocPath), components[0]);
            AdkLocPath lp = (AdkLocPath)components[0];

            AdkNodeNameTest attrName = (AdkNodeNameTest)lp.Steps[0].NodeTest;

            Assert.AreEqual(singePredicateName, attrName.NodeName);

            object value = components[1].ComputeValue(null);

            Assert.AreEqual(singlePredicateValue, value);
        }