summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2006-07-25 15:48:15 (EDT)
committer pelder2006-07-25 15:48:15 (EDT)
commitd64e6971e79fac361be43969c4f769fef09d17f5 (patch)
tree36a48704d48df0b64431c8053c93a1c030b297c8
parentb6ca588e73b40aa586e761d4459ee3b3cdf4e8e8 (diff)
downloadorg.eclipse.jet-d64e6971e79fac361be43969c4f769fef09d17f5.zip
org.eclipse.jet-d64e6971e79fac361be43969c4f769fef09d17f5.tar.gz
org.eclipse.jet-d64e6971e79fac361be43969c4f769fef09d17f5.tar.bz2
[151219] Correct spelling of 'descendant-or-self' axis.
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/xpath/ast/Axis.java12
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/xpath/parser/XPathParser.java6
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/AllTests.java1
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/DescendantOrSelfTests.java58
4 files changed, 68 insertions, 9 deletions
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/xpath/ast/Axis.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/xpath/ast/Axis.java
index 96e9a16..039ee9f 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/xpath/ast/Axis.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/xpath/ast/Axis.java
@@ -242,7 +242,7 @@ public abstract class Axis
}
- private static final class DescendentOrSelfAxis extends Axis
+ private static final class DescendantOrSelfAxis extends Axis
{
public NodeSet evaluate(NodeTest nodeTest, Context context)
@@ -273,7 +273,7 @@ public abstract class Axis
public String getAxisName()
{
- return "descendent-or-self"; //$NON-NLS-1$
+ return "descendant-or-self"; //$NON-NLS-1$
}
}
@@ -286,7 +286,7 @@ public abstract class Axis
private static final Axis selfAxis = new SelfAxis();
- private static final Axis descendentOrSelfAxis = new DescendentOrSelfAxis();
+ private static final Axis descendantOrSelfAxis = new DescendantOrSelfAxis();
private static final Map axisByNameMap = new HashMap(15);
static
@@ -295,7 +295,7 @@ public abstract class Axis
axisByNameMap.put(attributeAxis.getAxisName(), attributeAxis);
axisByNameMap.put(parentAxis.getAxisName(), parentAxis);
axisByNameMap.put(selfAxis.getAxisName(), selfAxis);
- axisByNameMap.put(descendentOrSelfAxis.getAxisName(), descendentOrSelfAxis);
+ axisByNameMap.put(descendantOrSelfAxis.getAxisName(), descendantOrSelfAxis);
}
/**
@@ -327,9 +327,9 @@ public abstract class Axis
return parentAxis;
}
- public static Axis descendentOfSelf()
+ public static Axis descendantOrSelf()
{
- return descendentOrSelfAxis;
+ return descendantOrSelfAxis;
}
public static Axis axisByName(String axisName)
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/xpath/parser/XPathParser.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/xpath/parser/XPathParser.java
index 2c2b90d..ba7ea53 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/xpath/parser/XPathParser.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/xpath/parser/XPathParser.java
@@ -363,7 +363,7 @@ public class XPathParser
else if (peekNext() == XPathTokens.SLASH_SLASH)
{
consumeToken();
- anchorNode = new Step(new Root(), Axis.descendentOfSelf(), NodeTest.allNodes());
+ anchorNode = new Step(new Root(), Axis.descendantOrSelf(), NodeTest.allNodes());
}
else
{
@@ -405,7 +405,7 @@ public class XPathParser
else if (peekNext() == XPathTokens.SLASH_SLASH)
{
consumeToken();
- result = step(new Step(result, Axis.descendentOfSelf(), NodeTest.allNodes()));
+ result = step(new Step(result, Axis.descendantOrSelf(), NodeTest.allNodes()));
}
else
{
@@ -431,7 +431,7 @@ public class XPathParser
{
// build a descendent-or-self axis
consumeToken();
- return relativeLocationPath(new Step(castToNodeSetExpr(filterExpr), Axis.descendentOfSelf(), NodeTest.allNodes()));
+ return relativeLocationPath(new Step(castToNodeSetExpr(filterExpr), Axis.descendantOrSelf(), NodeTest.allNodes()));
}
else
{
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/AllTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/AllTests.java
index 4d7e201..6d10fc7 100644
--- a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/AllTests.java
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/AllTests.java
@@ -15,6 +15,7 @@ public class AllTests {
suite.addTest(ResourceAttributeInspectorTests.suite());
suite.addTestSuite(SelfStepTests.class);
suite.addTestSuite(ParentStepTests.class);
+ suite.addTestSuite(DescendantOrSelfTests.class);
suite.addTestSuite(LogicalOpTests.class);
suite.addTestSuite(DOMInspectorTests.class);
suite.addTestSuite(ExpandedNameTests.class);
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/DescendantOrSelfTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/DescendantOrSelfTests.java
new file mode 100644
index 0000000..1b725ea
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/DescendantOrSelfTests.java
@@ -0,0 +1,58 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *
+ * </copyright>
+ *
+ * $Id$
+ */
+
+package org.eclipse.jet.tests.xpath;
+
+import java.util.Set;
+
+import org.eclipse.jet.internal.xpath.ast.Axis;
+import org.eclipse.jet.internal.xpath.ast.NodeTest;
+import org.eclipse.jet.internal.xpath.ast.Root;
+import org.eclipse.jet.internal.xpath.ast.Step;
+import org.eclipse.jet.xpath.Context;
+import org.eclipse.jet.xpath.inspector.ExpandedName;
+import org.eclipse.jet.xpath.inspector.INodeInspector.NodeKind;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Test the 'descendant-of-self' axis.
+ *
+ */
+public class DescendantOrSelfTests extends AbstractExprTest {
+
+ public void testEvalAsNodeSet_root_slash_slash_b() {
+ Step stepExpr = new Step(
+ new Step(new Root(), Axis.childAxis(),
+ NodeTest.nameTest(NodeKind.ELEMENT, new ExpandedName("root"))),
+ Axis.descendantOrSelf(),
+ NodeTest.nameTest(NodeKind.ELEMENT, new ExpandedName("b")));
+
+ Context context = new Context(document, null);
+
+ Set resultSet = stepExpr.evalAsNodeSet(context);
+
+ assertNotNull(resultSet);
+ assertEquals(2, resultSet.size());
+ Element elementA2 = (Element) rootElement.getElementsByTagName("a").item(1);
+ Node elementB2 = (Element) elementA2.getElementsByTagName("b").item(0);
+
+ assertTrue(resultSet.contains(elementB));
+ assertTrue(resultSet.contains(elementB2));
+
+ }
+}