public class XPathLocationStep { String Axis; String NodeTest; Array of XPathResults OutputNodeSet; String FunctionName; String Predicate; DOM_Document XML_DOM; //constructor XPathLocationStep(String XPathLocationStepString, DOM_Document XML_DOM_Document) { Resolve the XPathLocationStepString into FunctionName, Axis, NodeTest, and Predicate; XML_DOM = XML_DOM_Document; }//constructor Array of XPathResults getResult(Array of Nodes ContextNodeSet) { OutputNodeSet = new Array of XPathResults; Integer NodeCount = Number of nodes in ContextNodeSet; if (Axis is equal to "child" or "descendant") { Repeat NodeCount times for i = 0 to NodeCount-1 { Node node = ContextNodeSet[i]; Integer ChildCount = Number of node's children; Repeat ChildCount times for j = 0 to ChildCount-1 { Node ChildNode = node.getChildElement(j); String ChldName = Name of the ChildNode; if (NodeTest is equal to ChildName) Add ChildNode to OutputNodeSet; if (Axis is equal to "descendant") { Array of Nodes Descendants = getMatchingDescendants(ChildNode); Add MatchingDescendants to OutputNodeSet; }//if (Axis is equal to "descendant") }//Repeat ChildCount times for j = 0 to ChildCount-1 }//Repeat NodeCount times for i = 0 to n-1 }//if (Axis is equal to "child" or "descendant") /* Other Axes */ Predicate predicateEvaluator = new Predicate(OutputNodeSet, XML_DOM); OutputNodeSet = predicateEvaluator.getResult(); return OutputNodeSet; }//getResult() // This is recursive. private Array of Nodes getMatchingDescendants(Node node) { Array of Nodes MatchingDescendants; Integer ChildCount = Number of node's children; Repeat NodeCount times for j = 0 to ChildCount-1 { Node ChildNode = node.getChildElement(j); String ChildName = Name of the ChildNode; if (NodeTest is equal to ChildName) Add ChildNode to MatchingDescendants; //recursive!! Array of Nodes MoreDescendants = getMatchingDescendants(ChildNode); Add MoreDescendants to MatchingDescendnts; }//Repeat NodeCount times for j = 0 to ChildCount-1 return MatchingDescendants; }//getMatchingDescendants }//class