aboutsummaryrefslogtreecommitdiff
path: root/libjava/classpath/gnu/xml/xpath
diff options
context:
space:
mode:
authorMark Wielaard <mark@gcc.gnu.org>2006-03-10 21:46:48 +0000
committerMark Wielaard <mark@gcc.gnu.org>2006-03-10 21:46:48 +0000
commit8aa540d2f783474d1d2e06f16744bf67b9c1facc (patch)
treeea38c56431c5d4528fb54254c3f8e50f517bede3 /libjava/classpath/gnu/xml/xpath
parent27079765d00123f8e53d0e1ef7f9d46559266e6d (diff)
downloadgcc-8aa540d2f783474d1d2e06f16744bf67b9c1facc.zip
gcc-8aa540d2f783474d1d2e06f16744bf67b9c1facc.tar.gz
gcc-8aa540d2f783474d1d2e06f16744bf67b9c1facc.tar.bz2
Imported GNU Classpath 0.90
Imported GNU Classpath 0.90 * scripts/makemake.tcl: Set gnu/java/awt/peer/swing to ignore. * gnu/classpath/jdwp/VMFrame.java (SIZE): New constant. * java/lang/VMCompiler.java: Use gnu.java.security.hash.MD5. * java/lang/Math.java: New override file. * java/lang/Character.java: Merged from Classpath. (start, end): Now 'int's. (canonicalName): New field. (CANONICAL_NAME, NO_SPACES_NAME, CONSTANT_NAME): New constants. (UnicodeBlock): Added argument. (of): New overload. (forName): New method. Updated unicode blocks. (sets): Updated. * sources.am: Regenerated. * Makefile.in: Likewise. From-SVN: r111942
Diffstat (limited to 'libjava/classpath/gnu/xml/xpath')
-rw-r--r--libjava/classpath/gnu/xml/xpath/LangFunction.java12
-rw-r--r--libjava/classpath/gnu/xml/xpath/NodeTypeTest.java1
-rw-r--r--libjava/classpath/gnu/xml/xpath/Selector.java41
3 files changed, 35 insertions, 19 deletions
diff --git a/libjava/classpath/gnu/xml/xpath/LangFunction.java b/libjava/classpath/gnu/xml/xpath/LangFunction.java
index 2c2506d..584787e 100644
--- a/libjava/classpath/gnu/xml/xpath/LangFunction.java
+++ b/libjava/classpath/gnu/xml/xpath/LangFunction.java
@@ -1,5 +1,5 @@
/* LangFunction.java --
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004,2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -91,9 +91,15 @@ final class LangFunction
String getLang(Node node)
{
- if (node.getNodeType() == Node.ELEMENT_NODE)
+ while (node != null)
{
- return ((Element) node).getAttribute("xml:lang");
+ if (node.getNodeType() == Node.ELEMENT_NODE)
+ {
+ String lang = ((Element) node).getAttribute("xml:lang");
+ if (lang != null)
+ return lang;
+ }
+ node = node.getParentNode();
}
return null;
}
diff --git a/libjava/classpath/gnu/xml/xpath/NodeTypeTest.java b/libjava/classpath/gnu/xml/xpath/NodeTypeTest.java
index 09e92d0..4fe1646 100644
--- a/libjava/classpath/gnu/xml/xpath/NodeTypeTest.java
+++ b/libjava/classpath/gnu/xml/xpath/NodeTypeTest.java
@@ -84,6 +84,7 @@ public final class NodeTypeTest
case Node.TEXT_NODE:
case Node.CDATA_SECTION_NODE:
case Node.COMMENT_NODE:
+ case Node.DOCUMENT_NODE:
if (type > 0)
{
if (nodeType != type)
diff --git a/libjava/classpath/gnu/xml/xpath/Selector.java b/libjava/classpath/gnu/xml/xpath/Selector.java
index 93408e4..c7abb33 100644
--- a/libjava/classpath/gnu/xml/xpath/Selector.java
+++ b/libjava/classpath/gnu/xml/xpath/Selector.java
@@ -90,7 +90,7 @@ public final class Selector
if (len > 0)
tests.toArray(this.tests);
else
- this.tests[0] = new NameTest(null, true, true);
+ this.tests[0] = new NodeTypeTest((short) 0);
if (axis == NAMESPACE && this.tests[0] instanceof NameTest)
{
NameTest nt = (NameTest) this.tests[0];
@@ -108,6 +108,14 @@ public final class Selector
public boolean matches(Node context)
{
+ // If called directly, selector is the top level of the path
+ return matches(context,
+ getContextPosition(context),
+ getContextSize(context));
+ }
+
+ boolean matches(Node context, int pos, int len)
+ {
short nodeType = context.getNodeType();
switch (axis)
{
@@ -125,19 +133,11 @@ public final class Selector
default:
return false;
}
- int tlen = tests.length;
- if (tlen > 0)
+ for (int j = 0; j < tests.length && len > 0; j++)
{
- int pos = getContextPosition(context);
- int len = getContextSize(context);
- if (len == 0)
- System.err.println("WARNING: context size is 0");
- for (int j = 0; j < tlen && len > 0; j++)
- {
- Test test = tests[j];
- if (!test.matches(context, pos, len))
- return false;
- }
+ Test test = tests[j];
+ if (!test.matches(context, pos, len))
+ return false;
}
return true;
}
@@ -147,7 +147,10 @@ public final class Selector
int pos = 1;
for (ctx = ctx.getPreviousSibling(); ctx != null;
ctx = ctx.getPreviousSibling())
- pos++;
+ {
+ if (tests[0].matches(ctx, 1, 1))
+ pos++;
+ }
return pos;
}
@@ -161,10 +164,16 @@ public final class Selector
int count = 1;
Node sib = ctx.getPreviousSibling();
for (; sib != null; sib = sib.getPreviousSibling())
- count++;
+ {
+ if (tests[0].matches(ctx, 1, 1))
+ count++;
+ }
sib = ctx.getNextSibling();
for (; sib != null; sib = sib.getNextSibling())
- count++;
+ {
+ if (tests[0].matches(ctx, 1, 1))
+ count++;
+ }
return count;
}