sboag 01/05/23 11:18:10
Modified: java/src/org/apache/xml/dtm/ref Tag: DTM_EXP
DTMDefaultBaseTraversers.java
Log:
Fixed some bugs.
Revision Changes Path
No revision
No revision
1.1.2.2 +54 -52
xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/DTMDefaultBaseTraversers.java
Index: DTMDefaultBaseTraversers.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/DTMDefaultBaseTraversers.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- DTMDefaultBaseTraversers.java 2001/05/23 02:56:59 1.1.2.1
+++ DTMDefaultBaseTraversers.java 2001/05/23 18:18:04 1.1.2.2
@@ -130,7 +130,7 @@
traverser = new DescendantTraverser();
break;
case Axis.DESCENDANTORSELF :
- traverser = new DescendantTraverser();
+ traverser = new DescendantOrSelfTraverser();
break;
case Axis.FOLLOWING :
traverser = new FollowingTraverser();
@@ -157,13 +157,13 @@
traverser = new SelfTraverser();
break;
case Axis.ALL :
- traverser = new AllTraverser();
+ traverser = new AllFromRootTraverser();
break;
case Axis.ALLFROMNODE :
traverser = new AllFromNodeTraverser();
break;
case Axis.DESCENDANTSFROMROOT :
- traverser = new AllFromRootTraverser();
+ traverser = new DescendantFromRootTraverser();
break;
case Axis.ROOT :
traverser = new RootTraverser();
@@ -979,27 +979,40 @@
}
}
+
/**
- * A non-xpath axis, returns all nodes in the tree from and including the
- * root.
+ * Implements traversal of the Ancestor access, in reverse document order.
*/
- private class AllTraverser extends DTMAxisTraverser
+ private class AllFromRootTraverser extends AllFromNodeTraverser
{
/**
- * Return the root node.
+ * Return the root.
*
* @param context The context node of this traversal.
*
- * @return the first node in the traversal, which is the root node in the
- * DTM.
+ * @return the first node in the traversal.
*/
public int first(int context)
{
- return getDocument(); // context is ignored.
+ return getDocument();
}
/**
+ * Return the root if it matches the extended type ID.
+ *
+ * @param context The context node of this traversal.
+ * @param extendedTypeID The extended type ID that must match.
+ *
+ * @return the first node in the traversal.
+ */
+ public int first(int context, int extendedTypeID)
+ {
+ return (m_exptype[getDocument() & m_mask] == extendedTypeID)
+ ? context : next(context, context, extendedTypeID);
+ }
+
+ /**
* Traverse to the next node after the current node.
*
* @param context The context node of this iteration.
@@ -1015,8 +1028,7 @@
for (current = (current & m_mask) + 1; ; current++)
{
int type = _type(current); // may call nextNode()
-
- if (NULL == type)
+ if(type == NULL)
return NULL;
return (current | m_dtmIdent); // make handle.
@@ -1041,8 +1053,7 @@
for (current = (current & m_mask) + 1; ; current++)
{
int exptype = _exptype(current); // may call nextNode()
-
- if (NULL == exptype)
+ if(exptype == NULL)
return NULL;
if (exptype != extendedTypeID)
@@ -1054,39 +1065,6 @@
}
/**
- * Implements traversal of the Ancestor access, in reverse document order.
- */
- private class AllFromRootTraverser extends AllTraverser
- {
-
- /**
- * Return the root.
- *
- * @param context The context node of this traversal.
- *
- * @return the first node in the traversal.
- */
- public int first(int context)
- {
- return getDocument();
- }
-
- /**
- * Return the root if it matches the extended type ID.
- *
- * @param context The context node of this traversal.
- * @param extendedTypeID The extended type ID that must match.
- *
- * @return the first node in the traversal.
- */
- public int first(int context, int extendedTypeID)
- {
- return (m_exptype[getDocument() & m_mask] == extendedTypeID)
- ? context : next(context, context, extendedTypeID);
- }
- }
-
- /**
* Implements traversal of the Self axis.
*/
private class RootTraverser extends AllFromRootTraverser
@@ -1125,10 +1103,36 @@
* A non-xpath axis, returns all nodes that aren't namespaces or
attributes,
* from and including the root.
*/
- private class DescendantFromRootTraverser extends AllFromRootTraverser
+ private class DescendantFromRootTraverser extends DescendantTraverser
{
/**
+ * Return the root.
+ *
+ * @param context The context node of this traversal.
+ *
+ * @return the first node in the traversal.
+ */
+ public int first(int context)
+ {
+ return getDocument();
+ }
+
+ /**
+ * Return the root if it matches the extended type ID.
+ *
+ * @param context The context node of this traversal.
+ * @param extendedTypeID The extended type ID that must match.
+ *
+ * @return the first node in the traversal.
+ */
+ public int first(int context, int extendedTypeID)
+ {
+ return (m_exptype[getDocument() & m_mask] == extendedTypeID)
+ ? context : next(context, context, extendedTypeID);
+ }
+
+ /**
* Traverse to the next node after the current node.
*
* @param context The context node of this iteration.
@@ -1144,8 +1148,7 @@
for (current = (current & m_mask) + 1; ; current++)
{
int type = _type(current); // may call nextNode()
-
- if (NULL == type)
+ if(type == NULL)
return NULL;
if (ATTRIBUTE_NODE == type || NAMESPACE_NODE == type)
@@ -1173,8 +1176,7 @@
for (current = (current & m_mask) + 1; ; current++)
{
int exptype = _exptype(current); // may call nextNode()
-
- if (NULL == exptype)
+ if(exptype == NULL)
return NULL;
if (exptype != extendedTypeID)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]