private static AdkXPathStep ParseStep(string nodeName) { AdkXPathStep step; if (nodeName.StartsWith("@")) { step = new AdkXPathStep(AdkAxisType.Attribute, new AdkNodeNameTest(nodeName.Substring(1))); } else { step = new AdkXPathStep(AdkAxisType.Child, new AdkNodeNameTest(nodeName)); } return(step); }
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); }
private static AdkExpression ParseSimplePredicate(Fragment predicateFragment) { Fragment[] predicateParts = predicateFragment.Split("="); if (predicateParts.Length != 2) { // This is a fragment type we don't support. Just return it as // a Custom function. return(ParseExtensionFunction(predicateFragment)); } String nodeName = predicateParts[0].ToString(); String comparedValue = predicateParts[1].ToString(); AdkStaticValue c = ParseConstant(comparedValue); AdkXPathStep step = ParseStep(nodeName); return(new AdkEqualOperation(new AdkLocPath(false, step), c)); }
/// <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; }