Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        /// <summary>
        ///  Evaluates the current step in the path. If the path represented by the step does not
        ///  exist, NULL is returned. Otherwise, the node found is returned unless the special adk:X()
        ///  marker function is contained in the predicate expression, which signals that the specified
        /// repeatable element should always be created
        /// </summary>
        /// <param name="navigator"></param>
        /// <param name="parentPath"></param>
        /// <param name="currentStep"></param>
        /// <returns></returns>
        private INodePointer FindChild(XPathNavigator navigator, StringBuilder parentPath, AdkXPathStep currentStep)
        {
            String currentStepxPath = currentStep.ToString();

            if (currentStep.IsContextDependent())
            {
                // If the special 'adk:x()' function is present, that means to always
                // create the element, therefore, return null as if it were not found
                if (currentStepxPath.IndexOf("adk:x") > -1)
                {
                    return(null);
                }
            }

            navigator.MoveToRoot();
            SifXPathNavigator sifNav =
                (SifXPathNavigator)navigator.SelectSingleNode(parentPath + "/" + currentStepxPath);

            if (sifNav != null)
            {
                return(sifNav.UnderlyingPointer);
            }
            return(null);
        }