sboag 01/05/27 21:07:46
Modified: java/src/org/apache/xalan/lib/sql Tag: DTM_EXP
StreamableNode.java
java/src/org/apache/xalan/transformer Tag: DTM_EXP
KeyIterator.java KeyWalker.java
TransformerHandlerImpl.java TransformerImpl.java
java/src/org/apache/xml/dtm Tag: DTM_EXP DTMManager.java
java/src/org/apache/xml/dtm/ref Tag: DTM_EXP
DTMDefaultBase.java DTMDefaultBaseIterators.java
DTMDefaultBaseTraversers.java
DTMManagerDefault.java ExpandedNameTable.java
java/src/org/apache/xml/dtm/ref/dom2dtm Tag: DTM_EXP
DOM2DTM.java
java/src/org/apache/xml/dtm/ref/sax2dtm Tag: DTM_EXP
SAX2DTM.java
java/src/org/apache/xpath Tag: DTM_EXP
SourceTreeManager.java XPathContext.java
java/src/org/apache/xpath/axes Tag: DTM_EXP AxesWalker.java
DescendantIterator.java FilterExprWalker.java
OneStepIterator.java PredicatedNodeTest.java
ReverseAxesWalker.java WalkerFactory.java
java/src/org/apache/xpath/patterns Tag: DTM_EXP
NodeTest.java
Log:
Element indexing in the DTM is now implemented. It's only used
for the moment with DescendantTraversers, and taken advantage
of by the xpath DescendantIterator. The signature for getDTM changed
to add a boolean argument that tells if indexing is requested (we
of course don't want to do indexing for RTFs, and there may be
other cases where we don't want to do indexing). The index
lookup is done with a binary search. We might be able to optimize
this for short lists. Also, perhaps the next operation should look to
the next first to see if it matches, before looking to the index.
Joe should review this mechanism.
Also generalized AxisWalker, and got rid of all the derivatives
except the reverse walker. This will allow me to optimize AxisWalker
and it's use of traversers (and iterators for the reverse walker).
I may have noticed a bit of a slowdown since I did this, perhaps
since there were specialized AxisWalker derivatives. If this is so,
and it might be my imagination, I'll have to see what's going on
in the profiler.
Revision Changes Path
No revision
No revision
1.10.2.1 +14 -14
xml-xalan/java/src/org/apache/xalan/lib/sql/StreamableNode.java
Index: StreamableNode.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/lib/sql/StreamableNode.java,v
retrieving revision 1.10
retrieving revision 1.10.2.1
diff -u -r1.10 -r1.10.2.1
--- StreamableNode.java 2001/02/21 14:05:41 1.10
+++ StreamableNode.java 2001/05/28 04:07:18 1.10.2.1
@@ -90,20 +90,20 @@
return m_statement;
}
- /**
- * Check if a given feature is supported
- *
- *
- * @param feature Feature to check
- * @param version Version to check
- *
- * @return True if NodeTest feature is supported
- */
- public boolean isSupported(String feature, String version)
- {
- return (AxesWalker.FEATURE_NODETESTFILTER == feature)
- || feature.equals(AxesWalker.FEATURE_NODETESTFILTER);
- }
+// /**
+// * Check if a given feature is supported
+// *
+// *
+// * @param feature Feature to check
+// * @param version Version to check
+// *
+// * @return True if NodeTest feature is supported
+// */
+// public boolean isSupported(String feature, String version)
+// {
+// return (AxesWalker.FEATURE_NODETESTFILTER == feature)
+// || feature.equals(AxesWalker.FEATURE_NODETESTFILTER);
+// }
/** Instance of a NodeTest */
private NodeTest m_nodetest;
No revision
No revision
1.9.2.4 +0 -1
xml-xalan/java/src/org/apache/xalan/transformer/KeyIterator.java
Index: KeyIterator.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/KeyIterator.java,v
retrieving revision 1.9.2.3
retrieving revision 1.9.2.4
diff -u -r1.9.2.3 -r1.9.2.4
--- KeyIterator.java 2001/05/27 02:28:45 1.9.2.3
+++ KeyIterator.java 2001/05/28 04:07:20 1.9.2.4
@@ -64,7 +64,6 @@
import org.apache.xml.utils.QName;
import org.apache.xalan.templates.KeyDeclaration;
import org.apache.xpath.XPathContext;
-import org.apache.xpath.axes.DescendantOrSelfWalker;
import org.apache.xpath.objects.XObject;
import org.apache.xpath.XPath;
1.12.2.3 +5 -4
xml-xalan/java/src/org/apache/xalan/transformer/KeyWalker.java
Index: KeyWalker.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/KeyWalker.java,v
retrieving revision 1.12.2.2
retrieving revision 1.12.2.3
diff -u -r1.12.2.2 -r1.12.2.3
--- KeyWalker.java 2001/05/18 07:16:26 1.12.2.2
+++ KeyWalker.java 2001/05/28 04:07:21 1.12.2.3
@@ -66,13 +66,14 @@
import org.apache.xalan.res.XSLMessages;
import org.apache.xalan.res.XSLTErrorResources;
import org.apache.xpath.XPathContext;
-import org.apache.xpath.axes.DescendantOrSelfWalker;
+import org.apache.xpath.axes.AxesWalker;
import org.apache.xpath.objects.XObject;
import org.apache.xpath.XPath;
import org.apache.xml.dtm.DTM;
import org.apache.xml.dtm.DTMIterator;
import org.apache.xml.dtm.DTMFilter;
+import org.apache.xml.dtm.Axis;
import javax.xml.transform.TransformerException;
@@ -80,7 +81,7 @@
* <meta name="usage" content="internal"/>
* Walker for a Key() function.
*/
-public class KeyWalker extends DescendantOrSelfWalker
+public class KeyWalker extends AxesWalker
{
/**
@@ -90,7 +91,7 @@
*/
public KeyWalker(LocPathIterator locPathIterator)
{
- super(locPathIterator);
+ super(locPathIterator, Axis.DESCENDANTORSELF);
}
/**
@@ -133,7 +134,7 @@
m_foundAttrs = true;
if (DTM.NULL != m_nextAttr)
return m_nextAttr;
- }
+ }
else if (DTM.NULL != m_nextAttr)
{
m_nextAttr = dtm.getNextAttribute(m_nextAttr);
1.1.2.6 +1 -1
xml-xalan/java/src/org/apache/xalan/transformer/Attic/TransformerHandlerImpl.java
Index: TransformerHandlerImpl.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/Attic/TransformerHandlerImpl.java,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- TransformerHandlerImpl.java 2001/05/23 02:55:35 1.1.2.5
+++ TransformerHandlerImpl.java 2001/05/28 04:07:21 1.1.2.6
@@ -123,7 +123,7 @@
m_baseSystemID = baseSystemID;
XPathContext xctxt = transformer.getXPathContext();
- DTM dtm = xctxt.getDTM(null, true, transformer, true);
+ DTM dtm = xctxt.getDTM(null, true, transformer, true, true);
m_dtm = dtm;
dtm.setDocumentBaseURI(baseSystemID);
1.90.2.14 +54 -54
xml-xalan/java/src/org/apache/xalan/transformer/TransformerImpl.java
Index: TransformerImpl.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/TransformerImpl.java,v
retrieving revision 1.90.2.13
retrieving revision 1.90.2.14
diff -u -r1.90.2.13 -r1.90.2.14
--- TransformerImpl.java 2001/05/27 03:05:14 1.90.2.13
+++ TransformerImpl.java 2001/05/28 04:07:22 1.90.2.14
@@ -359,13 +359,13 @@
/** Flag to to tell if the tranformer needs to be reset. */
private boolean m_hasBeenReset = false;
-
- private boolean m_shouldReset = true;
+
+ private boolean m_shouldReset = true;
- public void setShouldReset(boolean shouldReset)
- {
- m_shouldReset = shouldReset;
- }
+ public void setShouldReset(boolean shouldReset)
+ {
+ m_shouldReset = shouldReset;
+ }
/**
* A stack of current template modes.
@@ -498,7 +498,7 @@
try
{
DTMManager mgr = this.getXPathContext().getDTMManager();
- DTM dtm = mgr.getDTM(source, false, this, true);
+ DTM dtm = mgr.getDTM(source, false, this, true, true);
boolean hardDelete = true; // %REVIEW% I have to think about this. -sb
try
@@ -557,7 +557,7 @@
SAXSourceLocator loc = new SAXSourceLocator(spe);
//m_errorHandler.fatalError(new TransformerException( msg, loc ));
- m_errorHandler.fatalError(new TransformerException( spe
));
+ m_errorHandler.fatalError(new TransformerException(
spe ));
}
catch(org.xml.sax.SAXException se)
{
@@ -1533,7 +1533,7 @@
// in scope, when really only the current stylesheet's
// global variables should be in scope. Have to think on
// this more...
- XObject xobj;
+ XObject xobj;
XPathContext xctxt = getXPathContext();
VariableStack vs = xctxt.getVarStack();
StylesheetRoot sr = getStylesheet();
@@ -1552,7 +1552,7 @@
{
previouslyDeclared.setIsVisible(true);
}
- else
+ else
{
xobj = new XUnresolvedVariable(v, contextNode,
this, vs.getSearchStartOrTop(), 0, true);
@@ -1664,7 +1664,7 @@
{
XPathContext xctxt = getXPathContext();
- DTM dtmFrag = xctxt.getDTM(null, true, this, false);
+ DTM dtmFrag = xctxt.getDTM(null, true, this, false, false);
ContentHandler rtfHandler = dtmFrag.getContentHandler();
// Create a ResultTreeFrag object.
@@ -1865,26 +1865,26 @@
{
template = null;
}
- else
- {
- // Find the XSL template that is the best match
for the
- // element.
- XPathContext xctxt = getXPathContext();
- PrefixResolver savedPrefixResolver =
xctxt.getNamespaceContext();
-
- try
- {
-
xctxt.setNamespaceContext(xslInstruction);
-
- QName mode = this.getMode();
- template =
m_stylesheetRoot.getTemplateComposed(xctxt, child, mode, maxImportLevel,
-
m_quietConflictWarnings);
- }
- finally
- {
-
xctxt.setNamespaceContext(savedPrefixResolver);
- }
- }
+ else
+ {
+ // Find the XSL template that is the best
match for the
+ // element.
+ XPathContext xctxt = getXPathContext();
+ PrefixResolver savedPrefixResolver =
xctxt.getNamespaceContext();
+
+ try
+ {
+
xctxt.setNamespaceContext(xslInstruction);
+
+ QName mode = this.getMode();
+ template =
m_stylesheetRoot.getTemplateComposed(xctxt, child, mode, maxImportLevel,
+
m_quietConflictWarnings);
+ }
+ finally
+ {
+
xctxt.setNamespaceContext(savedPrefixResolver);
+ }
+ }
// If that didn't locate a node, fall back to a default template rule.
// See http://www.w3.org/TR/xslt#built-in-rule.
@@ -2360,8 +2360,8 @@
try
{
- DTMIterator cnl =
getXPathContext().getContextNodeList();
- return (cnl == null)? null :
(DTMIterator)cnl.cloneWithReset();
+ DTMIterator cnl =
getXPathContext().getContextNodeList();
+ return (cnl == null)? null :
(DTMIterator)cnl.cloneWithReset();
}
catch (CloneNotSupportedException cnse)
{
@@ -2744,8 +2744,8 @@
////////////////////////
// Implement Runnable //
////////////////////////
-
- /** Base thread controler for xalan. Must be overriden with
+
+ /** Base thread controler for xalan. Must be overriden with
a derived class to support thread pooling.
All thread-related stuff is in this class.
@@ -2808,8 +2808,8 @@
public void runTransformThread( ) {
tpool.run( this, -1);
}
-
- /** Used by SourceTreeHandler to wait until the transform
+
+ /** Used by SourceTreeHandler to wait until the transform
* completes
*/
public void waitTransformThread() throws SAXException {
@@ -2822,17 +2822,17 @@
if (null != transformThread)
{
try
- {
- tpool.waitThread( transformThread, this );
-
- if(!this.hasTransformThreadErrorCatcher())
- {
- Exception e = this.getExceptionThrown();
- if(null != e)
- throw new org.xml.sax.SAXException(e);
- }
- this.setTransformThread(null);
- }
+ {
+ tpool.waitThread( transformThread, this );
+
+ if(!this.hasTransformThreadErrorCatcher())
+ {
+ Exception e = this.getExceptionThrown();
+ if(null != e)
+ throw new org.xml.sax.SAXException(e);
+ }
+ this.setTransformThread(null);
+ }
catch (InterruptedException ie){}
}
}
@@ -3023,16 +3023,16 @@
* from the snapshot point.
*/
public void executeFromSnapshot(TransformSnapshot ts)
- throws TransformerException
+ throws TransformerException
{
ElemTemplateElement template = getMatchedTemplate();
- int child = getMatchedNode();
- pushElemTemplateElement(template); //needed??
+ int child = getMatchedNode();
+ pushElemTemplateElement(template); //needed??
m_xcontext.pushCurrentNode(child); //needed??
- this.executeChildTemplates(template, true); //
getResultTreeHandler());
+ this.executeChildTemplates(template, true); //
getResultTreeHandler());
}
-
- /**
+
+ /**
* This will execute the following XSLT instructions
* from the snapshot point.
*/
No revision
No revision
1.1.2.14 +3 -1
xml-xalan/java/src/org/apache/xml/dtm/Attic/DTMManager.java
Index: DTMManager.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/Attic/DTMManager.java,v
retrieving revision 1.1.2.13
retrieving revision 1.1.2.14
diff -u -r1.1.2.13 -r1.1.2.14
--- DTMManager.java 2001/05/23 02:56:05 1.1.2.13
+++ DTMManager.java 2001/05/28 04:07:25 1.1.2.14
@@ -223,12 +223,14 @@
* be null.
* @param incremental true if the DTM should be built incrementally, if
* possible.
+ * @param doIndexing true if the caller considers it worth it to use
+ * indexing schemes.
*
* @return a non-null DTM reference.
*/
public abstract DTM getDTM(javax.xml.transform.Source source,
boolean unique, DTMWSFilter whiteSpaceFilter,
- boolean incremental);
+ boolean incremental, boolean doIndexing);
/**
* Get the instance of DTM that "owns" a node handle.
No revision
No revision
1.1.2.2 +200 -12
xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/DTMDefaultBase.java
Index: DTMDefaultBase.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/DTMDefaultBase.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- DTMDefaultBase.java 2001/05/23 02:56:55 1.1.2.1
+++ DTMDefaultBase.java 2001/05/28 04:07:27 1.1.2.2
@@ -109,6 +109,14 @@
/** Previous sibling values, one array element for each node. */
protected short[] m_parent;
+ /**
+ * These hold indexes to elements based on namespace and local name.
+ * The base lookup is the the namespace. The second lookup is the local
+ * name, and the last array contains the the first free element
+ * at the start, and the list of element handles following.
+ */
+ protected short[][][] m_elemIndexes;
+
/** The default initial block size of the node arrays */
protected int m_initialblocksize = 512; // favor small docs.
@@ -155,6 +163,15 @@
public static final int ROOTNODE = 0;
/**
+ * The table for exandedNameID lookups. This may or may not be the same
+ * table as is contained in the DTMManagerDefault.
+ */
+ protected ExpandedNameTable m_expandedNameTable;
+
+ /** true if indexing is turned on. */
+ protected boolean m_indexing;
+
+ /**
* Construct a DTMDefaultBase object from a DOM node.
*
* @param mgr The DTMManager who owns this DTM.
@@ -164,10 +181,12 @@
* @param whiteSpaceFilter The white space filter for this DTM, which may
* be null.
* @param xstringfactory The factory to use for creating XMLStrings.
+ * @param doIndexing true if the caller considers it worth it to use
+ * indexing schemes.
*/
public DTMDefaultBase(DTMManager mgr, Source source, int dtmIdentity,
DTMWSFilter whiteSpaceFilter,
- XMLStringFactory xstringfactory)
+ XMLStringFactory xstringfactory, boolean doIndexing)
{
m_exptype = new int[m_initialblocksize];
@@ -182,7 +201,21 @@
m_mask = mgr.getNodeIdentityMask();
m_wsfilter = whiteSpaceFilter;
m_xstrf = xstringfactory;
+ m_indexing = doIndexing;
+
+ if (doIndexing)
+ {
+ m_expandedNameTable = new ExpandedNameTable();
+ }
+ else
+ {
+
+ // %REVIEW% Is there a better way to do this?
+ DTMManagerDefault dmd = (DTMManagerDefault) m_mgr;
+ m_expandedNameTable = dmd.getExpandedNameTable(this);
+ }
+
if (null != whiteSpaceFilter)
{
m_shouldStripWhitespaceStack = new BoolStack();
@@ -192,6 +225,168 @@
}
/**
+ * Ensure that the size of the element indexes can hold the information.
+ *
+ * @param namespaceID Namespace ID index.
+ * @param LocalNameID Local name ID.
+ */
+ protected void ensureSizeOfIndex(int namespaceID, int LocalNameID)
+ {
+
+ if (null == m_elemIndexes)
+ {
+ m_elemIndexes = new short[namespaceID + 20][][];
+ }
+ else if (m_elemIndexes.length <= namespaceID)
+ {
+ short[][][] indexes = m_elemIndexes;
+
+ m_elemIndexes = new short[namespaceID + 20][][];
+
+ System.arraycopy(indexes, 0, m_elemIndexes, 0, indexes.length);
+ }
+
+ short[][] localNameIndex = m_elemIndexes[namespaceID];
+
+ if (null == localNameIndex)
+ {
+ localNameIndex = new short[LocalNameID + 100][];
+ m_elemIndexes[namespaceID] = localNameIndex;
+ }
+ else if (localNameIndex.length <= LocalNameID)
+ {
+ short[][] indexes = localNameIndex;
+
+ localNameIndex = new short[LocalNameID + 100][];
+
+ System.arraycopy(indexes, 0, localNameIndex, 0, indexes.length);
+
+ m_elemIndexes[namespaceID] = localNameIndex;
+ }
+
+ short[] elemHandles = localNameIndex[LocalNameID];
+
+ if (null == elemHandles)
+ {
+ elemHandles = new short[128];
+ localNameIndex[LocalNameID] = elemHandles;
+ elemHandles[0] = 1;
+ }
+ else if (elemHandles.length <= elemHandles[0] + 1)
+ {
+ short[] indexes = elemHandles;
+
+ elemHandles = new short[elemHandles[0] + 1024];
+
+ System.arraycopy(indexes, 0, elemHandles, 0, indexes.length);
+
+ localNameIndex[LocalNameID] = elemHandles;
+ }
+ }
+
+ /**
+ * Add a node to the element indexes. The node will not be added unless
+ * it's an element.
+ *
+ * @param expandedTypeID The expanded type ID of the node.
+ * @param identity The node identity index.
+ */
+ protected void indexNode(int expandedTypeID, int identity)
+ {
+
+ ExpandedNameTable ent = m_expandedNameTable;
+ int type = ent.getType(expandedTypeID);
+
+ if (DTM.ELEMENT_NODE == type)
+ {
+ int namespaceID = ent.getNamespaceID(expandedTypeID);
+ int localNameID = ent.getLocalNameID(expandedTypeID);
+
+ ensureSizeOfIndex(namespaceID, localNameID);
+
+ short[] index = m_elemIndexes[namespaceID][localNameID];
+
+ index[index[0]] = (short) identity;
+
+ index[0]++;
+ }
+ }
+
+ /**
+ * Find the first index that occurs in the list that is greater than or
+ * equal to the given value.
+ *
+ * @param list A list of integers.
+ * @param start The start index to begin the search.
+ * @param len The number of items to search.
+ * @param value Find the slot that has a value that is greater than or
+ * identical to this argument.
+ *
+ * @return The index in the list of the slot that is higher or identical
+ * to the identity argument, or -1 if no node is higher or equal.
+ */
+ protected int findGTE(short[] list, int start, int len, int value)
+ {
+
+ int low = start;
+ int high = start + (len - 1);
+
+ while (low <= high)
+ {
+ int mid = (low + high) / 2;
+ int c = list[mid];
+
+ if (c > value)
+ high = mid - 1;
+ else if (c < value)
+ low = mid + 1;
+ else
+ return mid;
+ }
+
+ return (list[low] > value) ? low : -1;
+ }
+
+ /**
+ * Find the first matching element from the index at or after the
+ * given node.
+ *
+ * @param nsIndex The namespace index lookup.
+ * @param lnIndex The local name index lookup.
+ * @param firstPotential The first potential match that is worth looking
at.
+ *
+ * @return The first node that is greater than or equal to the
+ * firstPotential argument, or DTM.NOTPROCESSED if not found.
+ */
+ int findElementFromIndex(int nsIndex, int lnIndex, int firstPotential)
+ {
+
+ short[][][] indexes = m_elemIndexes;
+
+ if (null != indexes && nsIndex < indexes.length)
+ {
+ short[][] lnIndexs = indexes[nsIndex];
+
+ if (null != lnIndexs && lnIndex < lnIndexs.length)
+ {
+ short[] elems = lnIndexs[lnIndex];
+
+ if (null != elems)
+ {
+ int pos = findGTE(elems, 1, elems[0], firstPotential);
+
+ if (pos > -1)
+ {
+ return elems[pos];
+ }
+ }
+ }
+ }
+
+ return NOTPROCESSED;
+ }
+
+ /**
* Get the next node identity value in the list, and call the iterator
* if it hasn't been added yet.
*
@@ -222,10 +417,8 @@
* Ensure that the size of the information arrays can hold another entry
* at the given index.
*
- * @param on exit from this function, the information arrays sizes must be
+ * @param index On exit from this function, the information arrays sizes
must be
* at least index+1.
- *
- * NEEDSDOC @param index
*/
protected void ensureSize(int index)
{
@@ -239,7 +432,6 @@
// %OPT% Compilers might be happier if we operated on one array
// at a time, though the parallel code might be a trifle less
// obvious.
-
int[] exptype = m_exptype;
byte[] level = m_level;
int[] firstch = m_firstch;
@@ -1133,7 +1325,7 @@
public int getExpandedTypeID(String namespace, String localName, int type)
{
- ExpandedNameTable ent =
((DTMManagerDefault)m_mgr).getExpandedNameTable(this);
+ ExpandedNameTable ent = m_expandedNameTable;
return ent.getExpandedTypeID(namespace, localName, type);
}
@@ -1147,7 +1339,7 @@
public String getLocalNameFromExpandedNameID(int ExpandedNameID)
{
- ExpandedNameTable ent =
((DTMManagerDefault)m_mgr).getExpandedNameTable(this);
+ ExpandedNameTable ent = m_expandedNameTable;
return ent.getLocalName(ExpandedNameID);
}
@@ -1161,10 +1353,7 @@
*/
public String getNamespaceFromExpandedNameID(int ExpandedNameID)
{
-
- ExpandedNameTable ent =
((DTMManagerDefault)m_mgr).getExpandedNameTable(this);
-
- return ent.getNamespace(ExpandedNameID);
+ return m_expandedNameTable.getNamespace(ExpandedNameID);
}
/**
@@ -1719,5 +1908,4 @@
if (null != m_shouldStripWhitespaceStack)
m_shouldStripWhitespaceStack.setTop(shouldStrip);
}
-
}
1.1.2.3 +17 -2
xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/DTMDefaultBaseIterators.java
Index: DTMDefaultBaseIterators.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/DTMDefaultBaseIterators.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- DTMDefaultBaseIterators.java 2001/05/27 02:28:46 1.1.2.2
+++ DTMDefaultBaseIterators.java 2001/05/28 04:07:27 1.1.2.3
@@ -78,13 +78,17 @@
* @param whiteSpaceFilter The white space filter for this DTM, which may
* be null.
* @param xstringfactory The factory to use for creating XMLStrings.
+ * @param doIndexing true if the caller considers it worth it to use
+ * indexing schemes.
*/
public DTMDefaultBaseIterators(DTMManager mgr, Source source,
int dtmIdentity,
DTMWSFilter whiteSpaceFilter,
- XMLStringFactory xstringfactory)
+ XMLStringFactory xstringfactory,
+ boolean doIndexing)
{
- super(mgr, source, dtmIdentity, whiteSpaceFilter, xstringfactory);
+ super(mgr, source, dtmIdentity, whiteSpaceFilter,
+ xstringfactory, doIndexing);
}
/**
@@ -1021,8 +1025,19 @@
if (_isRestartable)
{
_startNode = node;
+
if(node == NULL)
+ {
+ _currentNode = node;
+ return resetPosition();
+ }
+
+ int type = getExpandedTypeID(node) & ExpandedNameTable.MASK_NODETYPE;
+ if(ExpandedNameTable.ATTRIBUTE == type
+ || ExpandedNameTable.NAMESPACE == type )
+ {
_currentNode = node;
+ }
else
_currentNode = getFirstChild(getParent(node));
1.1.2.5 +305 -149
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.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- DTMDefaultBaseTraversers.java 2001/05/27 02:28:46 1.1.2.4
+++ DTMDefaultBaseTraversers.java 2001/05/28 04:07:28 1.1.2.5
@@ -57,6 +57,7 @@
package org.apache.xml.dtm.ref;
import org.apache.xml.dtm.*;
+
import javax.xml.transform.Source;
import org.apache.xml.utils.XMLStringFactory;
@@ -77,13 +78,17 @@
* @param whiteSpaceFilter The white space filter for this DTM, which may
* be null.
* @param xstringfactory The factory to use for creating XMLStrings.
+ * @param doIndexing true if the caller considers it worth it to use
+ * indexing schemes.
*/
public DTMDefaultBaseTraversers(DTMManager mgr, Source source,
int dtmIdentity,
DTMWSFilter whiteSpaceFilter,
- XMLStringFactory xstringfactory)
+ XMLStringFactory xstringfactory,
+ boolean doIndexing)
{
- super(mgr, source, dtmIdentity, whiteSpaceFilter, xstringfactory);
+ super(mgr, source, dtmIdentity, whiteSpaceFilter, xstringfactory,
+ doIndexing);
}
/**
@@ -171,8 +176,10 @@
case Axis.ROOT :
traverser = new RootTraverser();
break;
+ case Axis.FILTEREDLIST :
+ return null; // Don't want to throw an exception for this one.
default :
- throw new DTMException("Unknown axis traversal type");
+ throw new DTMException("Unknown axis traversal type: "+axis);
}
if (null == traverser)
@@ -364,10 +371,136 @@
}
/**
+ * Super class for derived classes that want a convenient way to access
+ * the indexing mechanism.
+ */
+ private abstract class IndexedDTMAxisTraverser extends DTMAxisTraverser
+ {
+
+ /**
+ * Tell if the indexing is on and the given extended type ID matches
+ * what is in the indexes. Derived classes should call this before
+ * calling [EMAIL PROTECTED] #getNextIndexed(int, int, int)
getNextIndexed} method.
+ *
+ * @param extendedTypeID The extended type ID being requested.
+ *
+ * @return true if it is OK to call the
+ * [EMAIL PROTECTED] #getNextIndexed(int, int, int)
getNextIndexed} method.
+ */
+ protected final boolean isIndexed(int extendedTypeID)
+ {
+
+ return (m_indexing
+ && ExpandedNameTable.ELEMENT
+ == (extendedTypeID & ExpandedNameTable.MASK_NODETYPE));
+ }
+
+ /**
+ * Tell if a node is outside the axis being traversed. This method must
be
+ * implemented by derived classes, and must be robust enough to handle
any
+ * node that occurs after the axis root.
+ *
+ * @param axisRoot The root identity of the axis.
+ * @param identity The node in question.
+ *
+ * @return true if the given node falls outside the axis being traversed.
+ */
+ protected abstract boolean isAfterAxis(int axisRoot, int identity);
+
+ /**
+ * Tell if the axis has been fully processed to tell if a the wait for
+ * an arriving node should terminate. This method must be implemented
+ * be a derived class.
+ *
+ * @param axisRoot The root identity of the axis.
+ *
+ * @return true if the axis has been fully processed.
+ */
+ protected abstract boolean axisHasBeenProcessed(int axisRoot);
+
+ /**
+ * Get the next indexed node that matches the extended type ID. Before
+ * calling this function, one should first call
+ * [EMAIL PROTECTED] #isIndexed(int) isIndexed} to make sure that the
index can
+ * contain nodes that match the given extended type ID.
+ *
+ * @param axisRoot The root identity of the axis.
+ * @param nextPotential The node found must match or occur after this
node.
+ * @param extendedTypeID The extended type ID for the request.
+ *
+ * @return The node or NULL if not found.
+ */
+ protected int getNextIndexed(int axisRoot, int nextPotential,
+ int extendedTypeID)
+ {
+
+ int nsIndex = m_expandedNameTable.getNamespaceID(extendedTypeID);
+ int lnIndex = m_expandedNameTable.getLocalNameID(extendedTypeID);
+
+ do
+ {
+ int next = findElementFromIndex(nsIndex, lnIndex, nextPotential);
+
+ if (NOTPROCESSED != next)
+ {
+ if (isAfterAxis(axisRoot, next))
+ return NULL;
+
+ // System.out.println("Found node via index: "+first);
+ return next;
+ }
+
+ nextNode();
+ }
+ while( !axisHasBeenProcessed(axisRoot) );
+
+ return DTM.NULL;
+ }
+ }
+
+ /**
* Implements traversal of the Ancestor access, in reverse document order.
*/
- private class DescendantTraverser extends DTMAxisTraverser
+ private class DescendantTraverser extends IndexedDTMAxisTraverser
{
+ /**
+ * Get the first potential identity that can be returned. This should
+ * be overridded by classes that need to return the self node.
+ *
+ * @param identity The node identity of the root context of the
traversal.
+ *
+ * @return The first potential node that can be in the traversal.
+ */
+ protected int getFirstPotential(int identity)
+ {
+ return identity + 1;
+ }
+
+ /**
+ * Tell if the axis has been fully processed to tell if a the wait for
+ * an arriving node should terminate.
+ *
+ * @param axisRoot The root identity of the axis.
+ *
+ * @return true if the axis has been fully processed.
+ */
+ protected boolean axisHasBeenProcessed(int axisRoot)
+ {
+ return !(m_nextsib[axisRoot] == NOTPROCESSED);
+ }
+
+ /**
+ * Get the subtree root identity from the handle that was passed in by
+ * the caller. Derived classes may override this to change the root
+ * context of the traversal.
+ *
+ * @param handle handle to the root context.
+ * @return identity of the root of the subtree.
+ */
+ protected int getSubtreeRoot(int handle)
+ {
+ return handle & m_mask;
+ }
/**
* Tell if this node identity is a descendant. Assumes that
@@ -377,7 +510,7 @@
* which fails if the parent starts after the root ends.
* May be sufficient for this class's logic, but misleadingly named!
*
- * NEEDSDOC @param subtreeRootIdentity
+ * @param subtreeRootIdentity The root context of the subtree in
question.
* @param identity The index number of the node in question.
* @return true if the index is a descendant of _startNode.
*/
@@ -387,6 +520,58 @@
}
/**
+ * Tell if a node is outside the axis being traversed. This method must
be
+ * implemented by derived classes, and must be robust enough to handle
any
+ * node that occurs after the axis root.
+ *
+ * @param axisRoot The root identity of the axis.
+ * @param identity The node in question.
+ *
+ * @return true if the given node falls outside the axis being traversed.
+ */
+ protected boolean isAfterAxis(int axisRoot, int identity)
+ {
+ // %REVIEW% Is there *any* cheaper way to do this?
+ do
+ {
+ if(identity == axisRoot)
+ return false;
+ identity = m_parent[identity];
+ }
+ while(identity >= axisRoot);
+
+ return true;
+ }
+
+ /**
+ * By the nature of the stateless traversal, the context node can not be
+ * returned or the iteration will go into an infinate loop. So to
traverse
+ * an axis, the first function must be used to get the first node.
+ *
+ * <p>This method needs to be overloaded only by those axis that process
+ * the self node. <\p>
+ *
+ * @param context The context node of this traversal. This is the point
+ * of origin for the traversal -- its "root node" or starting point.
+ * @param extendedTypeID The extended type ID that must match.
+ *
+ * @return the first node in the traversal.
+ */
+ public int first(int context, int extendedTypeID)
+ {
+
+ if (isIndexed(extendedTypeID))
+ {
+ int identity = getSubtreeRoot(context);
+ int firstPotential = getFirstPotential(identity);
+
+ return getNextIndexed(identity, firstPotential, extendedTypeID);
+ }
+
+ return next(context, context, extendedTypeID);
+ }
+
+ /**
* Traverse to the next node after the current node.
*
* @param context The context node of this iteration.
@@ -397,7 +582,7 @@
public int next(int context, int current)
{
- int subtreeRootIdent = context & m_mask;
+ int subtreeRootIdent = getSubtreeRoot(context);
for (current = (current & m_mask) + 1; ; current++)
{
@@ -426,10 +611,17 @@
public int next(int context, int current, int extendedTypeID)
{
- int subtreeRootIdent = context & m_mask;
+ int subtreeRootIdent = getSubtreeRoot(context);
- for (current = (current & m_mask) + 1; ; current++)
+ current = (current & m_mask) + 1;
+
+ if (isIndexed(extendedTypeID))
{
+ return getNextIndexed(subtreeRootIdent, current, extendedTypeID);
+ }
+
+ for (; ; current++)
+ {
int exptype = _exptype(current); // may call nextNode()
if (!isDescendant(subtreeRootIdent, current))
@@ -450,35 +642,30 @@
{
/**
- * By the nature of the stateless traversal, the context node can not be
- * returned or the iteration will go into an infinate loop. To see if
- * the self node should be processed, use this function.
+ * Get the first potential identity that can be returned, which is the
+ * axis context, in this case.
*
- * @param context The context node of this traversal.
+ * @param identity The node identity of the root context of the
traversal.
*
- * @return the first node in the traversal.
+ * @return The axis context.
*/
- public int first(int context)
+ protected int getFirstPotential(int identity)
{
- return context;
+ return identity;
}
/**
* By the nature of the stateless traversal, the context node can not be
* returned or the iteration will go into an infinate loop. To see if
- * the self node should be processed, use this function. If the context
- * node does not match the extended type ID, this function will return
- * false.
+ * the self node should be processed, use this function.
*
* @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)
+ public int first(int context)
{
- return (m_exptype[context & m_mask] == extendedTypeID)
- ? context : next(context, context, extendedTypeID);
+ return context;
}
}
@@ -524,76 +711,88 @@
*/
private class FollowingTraverser extends DescendantTraverser
{
-
- /**
- * Get the first of the following.
- *
- * @param context The context node of this traversal. This is the point
- * that the traversal starts from.
- * @return the first node in the traversal.
- */
- public int first(int context)
- {
- int first;
- int type = getNodeType(context);
- if((DTM.ATTRIBUTE_NODE == type) || (DTM.NAMESPACE_NODE == type))
- {
- context = getParent(context);
- first = getFirstChild(context);
- if(NULL != first)
- return first;
- }
- do
- {
- first = getNextSibling(context);
- if(NULL == first)
- context = getParent(context);
- }
- while(NULL == first && NULL != context);
-
- return first;
- }
- /**
- * Get the first of the following.
- *
- * @param context The context node of this traversal. This is the point
- * of origin for the traversal -- its "root node" or starting point.
- * @param extendedTypeID The extended type ID that must match.
- *
- * @return the first node in the traversal.
- */
- public int first(int context, int extendedTypeID)
- {
- int first;
- int type = getNodeType(context);
- if((DTM.ATTRIBUTE_NODE == type) || (DTM.NAMESPACE_NODE == type))
+ /**
+ * Get the first of the following.
+ *
+ * @param context The context node of this traversal. This is the point
+ * that the traversal starts from.
+ * @return the first node in the traversal.
+ */
+ public int first(int context)
{
- context = getParent(context);
- first = getFirstChild(context);
- if(NULL != first)
+
+ int first;
+ int type = getNodeType(context);
+
+ if ((DTM.ATTRIBUTE_NODE == type) || (DTM.NAMESPACE_NODE == type))
{
- if(_exptype(first) == extendedTypeID)
+ context = getParent(context);
+ first = getFirstChild(context);
+
+ if (NULL != first)
return first;
- else return next(context, first, extendedTypeID);
}
+
+ do
+ {
+ first = getNextSibling(context);
+
+ if (NULL == first)
+ context = getParent(context);
+ }
+ while (NULL == first && NULL != context);
+
+ return first;
}
- do
+
+ /**
+ * Get the first of the following.
+ *
+ * @param context The context node of this traversal. This is the point
+ * of origin for the traversal -- its "root node" or starting point.
+ * @param extendedTypeID The extended type ID that must match.
+ *
+ * @return the first node in the traversal.
+ */
+ public int first(int context, int extendedTypeID)
{
- first = getNextSibling(context);
- if(NULL == first)
+
+ int first;
+ int type = getNodeType(context);
+
+ if ((DTM.ATTRIBUTE_NODE == type) || (DTM.NAMESPACE_NODE == type))
+ {
context = getParent(context);
- else
+ first = getFirstChild(context);
+
+ if (NULL != first)
+ {
+ if (_exptype(first) == extendedTypeID)
+ return first;
+ else
+ return next(context, first, extendedTypeID);
+ }
+ }
+
+ do
{
- if(_exptype(first) == extendedTypeID)
- return first;
- else return next(context, first, extendedTypeID);
+ first = getNextSibling(context);
+
+ if (NULL == first)
+ context = getParent(context);
+ else
+ {
+ if (_exptype(first) == extendedTypeID)
+ return first;
+ else
+ return next(context, first, extendedTypeID);
+ }
}
+ while (NULL == first && NULL != context);
+
+ return first;
}
- while(NULL == first && NULL != context);
-
- return first;
- }
/**
* Traverse to the next node after the current node.
@@ -609,6 +808,7 @@
while (true)
{
current++;
+
int type = _type(current); // may call nextNode()
if (NULL == type)
@@ -637,6 +837,7 @@
while (true)
{
current++;
+
int etype = _exptype(current); // may call nextNode()
if (NULL == etype)
@@ -931,9 +1132,9 @@
return NULL;
}
}
-
+
/**
- * Implements traversal of the Ancestor and the Preceding axis,
+ * Implements traversal of the Ancestor and the Preceding axis,
* in reverse document order.
*/
private class PrecedingAndAncestorTraverser extends DTMAxisTraverser
@@ -996,7 +1197,6 @@
}
}
-
/**
* Implements traversal of the Ancestor access, in reverse document order.
*/
@@ -1105,7 +1305,6 @@
}
}
-
/**
* Implements traversal of the Ancestor access, in reverse document order.
*/
@@ -1137,7 +1336,7 @@
return (m_exptype[getDocument() & m_mask] == extendedTypeID)
? context : next(context, context, extendedTypeID);
}
-
+
/**
* Traverse to the next node after the current node.
*
@@ -1154,7 +1353,8 @@
for (current = (current & m_mask) + 1; ; current++)
{
int type = _type(current); // may call nextNode()
- if(type == NULL)
+
+ if (type == NULL)
return NULL;
return (current | m_dtmIdent); // make handle.
@@ -1179,7 +1379,8 @@
for (current = (current & m_mask) + 1; ; current++)
{
int exptype = _exptype(current); // may call nextNode()
- if(exptype == NULL)
+
+ if (exptype == NULL)
return NULL;
if (exptype != extendedTypeID)
@@ -1233,83 +1434,38 @@
{
/**
- * Return the root.
+ * Get the first potential identity that can be returned, which is the
axis
+ * root context in this case.
*
- * @param context The context node of this traversal.
+ * @param identity The node identity of the root context of the
traversal.
*
- * @return the first node in the traversal.
+ * @return The identity argument.
*/
- public int first(int context)
+ protected int getFirstPotential(int identity)
{
- return getDocument();
+ return identity;
}
- /**
- * 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.
- * @param current The current node of the iteration.
- *
- * @return the next node in the iteration, or DTM.NULL.
+ * Get the first potential identity that can be returned.
+ * @param handle handle to the root context.
+ * @return identity of the root of the subtree.
*/
- public int next(int context, int current)
+ protected int getSubtreeRoot(int handle)
{
-
- int subtreeRootIdent = context & m_mask;
-
- for (current = (current & m_mask) + 1; ; current++)
- {
- int type = _type(current); // may call nextNode()
- if(type == NULL)
- return NULL;
-
- if (ATTRIBUTE_NODE == type || NAMESPACE_NODE == type)
- continue;
-
- return (current | m_dtmIdent); // make handle.
- }
+ return getDocument() & m_mask;
}
/**
- * Traverse to the next node after the current node that is matched
- * by the extended type ID.
+ * Return the root.
*
- * @param context The context node of this iteration.
- * @param current The current node of the iteration.
- * @param extendedTypeID The extended type ID that must match.
+ * @param context The context node of this traversal.
*
- * @return the next node in the iteration, or DTM.NULL.
+ * @return the first node in the traversal.
*/
- public int next(int context, int current, int extendedTypeID)
+ public int first(int context)
{
-
- int subtreeRootIdent = context & m_mask;
-
- for (current = (current & m_mask) + 1; ; current++)
- {
- int exptype = _exptype(current); // may call nextNode()
- if(exptype == NULL)
- return NULL;
-
- if (exptype != extendedTypeID)
- continue;
-
- return (current | m_dtmIdent); // make handle.
- }
+ return getDocument();
}
}
}
1.1.2.2 +9 -6
xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/DTMManagerDefault.java
Index: DTMManagerDefault.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/DTMManagerDefault.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- DTMManagerDefault.java 2001/05/23 02:57:03 1.1.2.1
+++ DTMManagerDefault.java 2001/05/28 04:07:28 1.1.2.2
@@ -99,7 +99,7 @@
public class DTMManagerDefault extends DTMManager
{
- /** NEEDSDOC Field m_dtms */
+ /** Vector of DTMs that this manager manages. */
protected Vector m_dtms = new Vector();
/**
@@ -136,11 +136,14 @@
* be null.
* @param incremental true if the DTM should be built incrementally, if
* possible.
+ * @param doIndexing true if the caller considers it worth it to use
+ * indexing schemes.
*
* @return a non-null DTM reference.
*/
public DTM getDTM(Source source, boolean unique,
- DTMWSFilter whiteSpaceFilter, boolean incremental)
+ DTMWSFilter whiteSpaceFilter, boolean incremental,
+ boolean doIndexing)
{
if(DEBUG && null != source)
System.out.println("Starting source: "+source.getSystemId());
@@ -150,7 +153,7 @@
if ((null != source) && source instanceof DOMSource)
{
DOM2DTM dtm = new DOM2DTM(this, (DOMSource) source, documentID,
- whiteSpaceFilter, xstringFactory);
+ whiteSpaceFilter, xstringFactory,
doIndexing);
m_dtms.add(dtm);
@@ -204,7 +207,7 @@
// Create the basic SAX2DTM.
SAX2DTM dtm = new SAX2DTM(this, source, documentID, whiteSpaceFilter,
- xstringFactory);
+ xstringFactory, doIndexing);
// Go ahead and add the DTM to the lookup table. This needs to be
// done before any parsing occurs.
@@ -413,7 +416,7 @@
// Current solution: Generate a new DOM2DTM with this node as root.
// %REVIEW% Maybe the best I can do??
DTM dtm = getDTM(new javax.xml.transform.dom.DOMSource(node), false,
- null, true);
+ null, true, false);
return dtm.getDocument();
}
@@ -588,7 +591,7 @@
Document doc = db.newDocument();
Node df = doc.createDocumentFragment();
- return getDTM(new DOMSource(df), true, null, false);
+ return getDTM(new DOMSource(df), true, null, false, false);
}
catch (Exception e)
{
1.1.2.2 +21 -2
xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/ExpandedNameTable.java
Index: ExpandedNameTable.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/ExpandedNameTable.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- ExpandedNameTable.java 2001/05/23 02:57:17 1.1.2.1
+++ ExpandedNameTable.java 2001/05/28 04:07:29 1.1.2.2
@@ -56,6 +56,8 @@
*/
package org.apache.xml.dtm.ref;
+import org.apache.xml.dtm.DTM;
+
/**
* This is a default implementation of a table that manages mappings from
* expanded names to expandedNameIDs.
@@ -85,6 +87,23 @@
public static int MASK_LOCALNAME = 0x0000FFFF;
public static int MASK_NAMESPACE = 0x03FF0000;
public static int MASK_NODETYPE = 0xFC000000;
+
+ public static final int ROTAMOUNT_TYPE =
(BITS_PER_NAMESPACE+BITS_PER_LOCALNAME);
+
+ // These are all the types prerotated, for caller convenience.
+ public static final int ELEMENT = ((int)DTM.ELEMENT_NODE) <<
ROTAMOUNT_TYPE;
+ public static final int ATTRIBUTE = ((int)DTM.ATTRIBUTE_NODE) <<
ROTAMOUNT_TYPE;
+ public static final int TEXT = ((int)DTM.TEXT_NODE) << ROTAMOUNT_TYPE;
+ public static final int CDATA_SECTION = ((int)DTM.CDATA_SECTION_NODE) <<
ROTAMOUNT_TYPE;
+ public static final int ENTITY_REFERENCE =
((int)DTM.ENTITY_REFERENCE_NODE) << ROTAMOUNT_TYPE;
+ public static final int ENTITY = ((int)DTM.ENTITY_NODE) << ROTAMOUNT_TYPE;
+ public static final int PROCESSING_INSTRUCTION =
((int)DTM.PROCESSING_INSTRUCTION_NODE) << ROTAMOUNT_TYPE;
+ public static final int COMMENT = ((int)DTM.COMMENT_NODE) <<
ROTAMOUNT_TYPE;
+ public static final int DOCUMENT = ((int)DTM.DOCUMENT_NODE) <<
ROTAMOUNT_TYPE;
+ public static final int DOCUMENT_TYPE = ((int)DTM.DOCUMENT_TYPE_NODE) <<
ROTAMOUNT_TYPE;
+ public static final int DOCUMENT_FRAGMENT
=((int)DTM.DOCUMENT_FRAGMENT_NODE) << ROTAMOUNT_TYPE;
+ public static final int NOTATION = ((int)DTM.NOTATION_NODE) <<
ROTAMOUNT_TYPE;
+ public static final int NAMESPACE = ((int)DTM.NAMESPACE_NODE) <<
ROTAMOUNT_TYPE;
/**
* Create an expanded name table that uses private string pool lookup.
@@ -207,7 +226,7 @@
*/
public static final int getType(int ExpandedNameID)
{
- return ExpandedNameID >> (BITS_PER_NAMESPACE+BITS_PER_LOCALNAME);
+ return ExpandedNameID >> ROTAMOUNT_TYPE;
}
-
+
}
No revision
No revision
1.1.2.3 +8 -3
xml-xalan/java/src/org/apache/xml/dtm/ref/dom2dtm/Attic/DOM2DTM.java
Index: DOM2DTM.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/dom2dtm/Attic/DOM2DTM.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- DOM2DTM.java 2001/05/23 21:01:45 1.1.2.2
+++ DOM2DTM.java 2001/05/28 04:07:32 1.1.2.3
@@ -191,12 +191,17 @@
* @param dtmIdentity The DTM identity ID for this DTM.
* @param whiteSpaceFilter The white space filter for this DTM, which may
* be null.
+ * @param xstringfactory XMLString factory for creating character content.
+ * @param doIndexing true if the caller considers it worth it to use
+ * indexing schemes.
*/
public DOM2DTM(DTMManager mgr, DOMSource domSource,
int dtmIdentity, DTMWSFilter whiteSpaceFilter,
- XMLStringFactory xstringfactory)
+ XMLStringFactory xstringfactory,
+ boolean doIndexing)
{
- super(mgr, domSource, dtmIdentity, whiteSpaceFilter, xstringfactory);
+ super(mgr, domSource, dtmIdentity, whiteSpaceFilter,
+ xstringfactory, doIndexing);
m_root = domSource.getNode();
m_pos = null;
@@ -279,7 +284,7 @@
String localName = (type == Node.PROCESSING_INSTRUCTION_NODE) ?
node.getNodeName() :
node.getLocalName();
- ExpandedNameTable exnt =
((DTMManagerDefault)m_mgr).getExpandedNameTable(this);
+ ExpandedNameTable exnt = m_expandedNameTable;
// %TBD% Nodes created with the old non-namespace-aware DOM
No revision
No revision
1.1.2.2 +28 -22
xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/Attic/SAX2DTM.java
Index: SAX2DTM.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/Attic/SAX2DTM.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- SAX2DTM.java 2001/05/23 02:57:32 1.1.2.1
+++ SAX2DTM.java 2001/05/28 04:07:34 1.1.2.2
@@ -74,6 +74,7 @@
import org.apache.xml.dtm.*;
import org.apache.xml.utils.XMLString;
import org.apache.xml.utils.XMLStringFactory;
+import org.apache.xml.utils.WrappedRuntimeException;
/**
* This class implements a DTM that tends to be optimized more for speed than
@@ -125,9 +126,6 @@
/** This vector holds offset and length data. */
protected IntVector m_data = new IntVector();
- /** The table of expanded names, which may well be owned by the DTMManager
*/
- ExpandedNameTable m_ent;
-
/** The parent stack, needed only for construction. */
transient private IntStack m_parents = new IntStack();
@@ -223,22 +221,22 @@
* @param whiteSpaceFilter The white space filter for this DTM, which may
* be null.
* @param xstringfactory XMLString factory for creating character content.
+ * @param doIndexing true if the caller considers it worth it to use
+ * indexing schemes.
*/
public SAX2DTM(DTMManager mgr, Source source, int dtmIdentity,
DTMWSFilter whiteSpaceFilter,
- XMLStringFactory xstringfactory)
+ XMLStringFactory xstringfactory,
+ boolean doIndexing)
{
- super(mgr, source, dtmIdentity, whiteSpaceFilter, xstringfactory);
+ super(mgr, source, dtmIdentity, whiteSpaceFilter,
+ xstringfactory, doIndexing);
m_dataOrQName = new short[m_initialblocksize];
- m_ent = ((DTMManagerDefault)mgr).getExpandedNameTable(this);
-
- if (null == m_ent)
- m_ent = new ExpandedNameTable();
int doc = addNode(DTM.DOCUMENT_NODE,
- m_ent.getExpandedTypeID(DTM.DOCUMENT_NODE),
+
m_expandedNameTable.getExpandedTypeID(DTM.DOCUMENT_NODE),
m_levelAmount, DTM.NULL, DTM.NULL, 0, true);
m_levelAmount++;
@@ -543,7 +541,7 @@
if (0 == namespaceID)
{
- String name = m_ent.getLocalName(expandedTypeID);
+ String name = m_expandedNameTable.getLocalName(expandedTypeID);
int type = getNodeType(nodeHandle);
if (type == DTM.NAMESPACE_NODE)
@@ -591,7 +589,7 @@
if (0 == namespaceID)
{
- String name = m_ent.getLocalName(expandedTypeID);
+ String name = m_expandedNameTable.getLocalName(expandedTypeID);
if (name == null)
return "";
@@ -743,7 +741,14 @@
// no-op.
if (!(gotMore instanceof Boolean))
{
-
+ if(gotMore instanceof RuntimeException)
+ {
+ throw (RuntimeException)gotMore;
+ }
+ else if(gotMore instanceof Exception)
+ {
+ throw new WrappedRuntimeException((Exception)gotMore);
+ }
// for now...
clearCoRoutine();
@@ -907,7 +912,7 @@
{
int expandedTypeID = getExpandedTypeID(nodeHandle);
- String name = m_ent.getLocalName(expandedTypeID);
+ String name = m_expandedNameTable.getLocalName(expandedTypeID);
if (name == null)
return "";
@@ -1110,7 +1115,7 @@
int expandedTypeID = getExpandedTypeID(nodeHandle);
- return m_ent.getNamespace(expandedTypeID);
+ return m_expandedNameTable.getNamespace(expandedTypeID);
}
/**
@@ -1319,7 +1324,7 @@
m_chars.setLength(m_textPendingStart); // Discard accumulated text
else
{
- int exName = m_ent.getExpandedTypeID(DTM.TEXT_NODE);
+ int exName = m_expandedNameTable.getExpandedTypeID(DTM.TEXT_NODE);
int dataIndex = m_data.size();
m_previous = addNode(m_coalescedTextType, exName, m_levelAmount,
@@ -1630,13 +1635,14 @@
charactersFlush();
- int exName = m_ent.getExpandedTypeID(uri, localName, DTM.ELEMENT_NODE);
+ int exName = m_expandedNameTable.getExpandedTypeID(uri, localName,
DTM.ELEMENT_NODE);
String prefix = getPrefix(qName, uri);
int prefixIndex = (null != prefix)
? m_valuesOrPrefixes.stringToIndex(qName) : 0;
int elemNode = addNode(DTM.ELEMENT_NODE, exName, m_levelAmount,
m_parents.peek(), m_previous, prefixIndex, true);
-
+ indexNode(exName, elemNode);
+
m_levelAmount++;
m_parents.push(elemNode);
@@ -1654,7 +1660,7 @@
String declURL = (String) m_prefixMappings.elementAt(i + 1);
- exName = m_ent.getExpandedTypeID(null, prefix, DTM.NAMESPACE_NODE);
+ exName = m_expandedNameTable.getExpandedTypeID(null, prefix,
DTM.NAMESPACE_NODE);
int val = m_valuesOrPrefixes.stringToIndex(declURL);
@@ -1706,7 +1712,7 @@
val = -dataIndex;
}
- exName = m_ent.getExpandedTypeID(attrUri, attrLocalName, nodeType);
+ exName = m_expandedNameTable.getExpandedTypeID(attrUri, attrLocalName,
nodeType);
prev = addNode(nodeType, exName, m_levelAmount, elemNode, prev, val,
false);
}
@@ -1861,7 +1867,7 @@
charactersFlush();
- int exName = m_ent.getExpandedTypeID(null, target,
+ int exName = m_expandedNameTable.getExpandedTypeID(null, target,
DTM.PROCESSING_INSTRUCTION_NODE);
int dataIndex = m_valuesOrPrefixes.stringToIndex(data);
@@ -2176,7 +2182,7 @@
charactersFlush();
- int exName = m_ent.getExpandedTypeID(DTM.COMMENT_NODE);
+ int exName = m_expandedNameTable.getExpandedTypeID(DTM.COMMENT_NODE);
// For now, treat comments as strings... I guess we should do a
// seperate FSB buffer instead.
No revision
No revision
1.24.2.7 +2 -2
xml-xalan/java/src/org/apache/xpath/SourceTreeManager.java
Index: SourceTreeManager.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xpath/SourceTreeManager.java,v
retrieving revision 1.24.2.6
retrieving revision 1.24.2.7
diff -u -r1.24.2.6 -r1.24.2.7
--- SourceTreeManager.java 2001/05/18 07:17:00 1.24.2.6
+++ SourceTreeManager.java 2001/05/28 04:07:35 1.24.2.7
@@ -343,11 +343,11 @@
if(null != xowner && xowner instanceof org.apache.xml.dtm.DTMWSFilter)
{
dtm = xctxt.getDTM(source, false,
- (org.apache.xml.dtm.DTMWSFilter)xowner, false);
+ (org.apache.xml.dtm.DTMWSFilter)xowner, false,
true);
}
else
{
- dtm = xctxt.getDTM(source, false, null, false);
+ dtm = xctxt.getDTM(source, false, null, false, true);
}
return dtm.getDocument();
}
1.20.2.11 +5 -2 xml-xalan/java/src/org/apache/xpath/XPathContext.java
Index: XPathContext.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/XPathContext.java,v
retrieving revision 1.20.2.10
retrieving revision 1.20.2.11
diff -u -r1.20.2.10 -r1.20.2.11
--- XPathContext.java 2001/05/25 17:36:37 1.20.2.10
+++ XPathContext.java 2001/05/28 04:07:36 1.20.2.11
@@ -160,15 +160,18 @@
* @param whiteSpaceFilter Enables filtering of whitespace nodes, and may
* be null.
* @param incremental true if the construction should try and be
incremental.
+ * @param doIndexing true if the caller considers it worth it to use
+ * indexing schemes.
*
* @return a non-null DTM reference.
*/
public DTM getDTM(javax.xml.transform.Source source, boolean unique,
DTMWSFilter wsfilter,
- boolean incremental)
+ boolean incremental,
+ boolean doIndexing)
{
return m_dtmManager.getDTM(source, unique, wsfilter,
- incremental);
+ incremental, doIndexing);
}
/**
No revision
No revision
1.18.2.8 +25 -563 xml-xalan/java/src/org/apache/xpath/axes/AxesWalker.java
Index: AxesWalker.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/AxesWalker.java,v
retrieving revision 1.18.2.7
retrieving revision 1.18.2.8
diff -u -r1.18.2.7 -r1.18.2.8
--- AxesWalker.java 2001/05/27 02:28:48 1.18.2.7
+++ AxesWalker.java 2001/05/28 04:07:38 1.18.2.8
@@ -75,6 +75,8 @@
import org.apache.xml.dtm.DTM;
import org.apache.xml.dtm.DTMIterator;
import org.apache.xml.dtm.DTMFilter;
+import org.apache.xml.dtm.DTMAxisTraverser;
+import org.apache.xml.dtm.Axis;
import org.apache.xml.utils.XMLString;
@@ -82,8 +84,8 @@
* Serves as common interface for axes Walkers, and stores common
* state variables.
*/
-public abstract class AxesWalker extends PredicatedNodeTest
- implements Cloneable , DTMFilter
+public class AxesWalker extends PredicatedNodeTest
+ implements Cloneable
{
/**
@@ -91,9 +93,10 @@
*
* @param locPathIterator non-null reference to the parent iterator.
*/
- public AxesWalker(LocPathIterator locPathIterator)
+ public AxesWalker(LocPathIterator locPathIterator, int axis)
{
super( locPathIterator );
+ m_axis = axis;
}
public final WalkingIterator wi()
@@ -115,21 +118,6 @@
throws javax.xml.transform.TransformerException
{
- // int nodeTestOpPos = compiler.getFirstChildPosOfStep(opPos);
- m_stepType = stepType;
-
- switch (stepType)
- {
- case OpCodes.OP_VARIABLE :
- case OpCodes.OP_EXTFUNCTION :
- case OpCodes.OP_FUNCTION :
- case OpCodes.OP_GROUP :
- m_argLen = compiler.getArgLength(opPos);
- break;
- default :
- m_argLen = compiler.getArgLengthOfStep(opPos);
- }
-
initPredicateInfo(compiler, opPos);
// int testType = compiler.getOp(nodeTestOpPos);
@@ -227,68 +215,6 @@
return null;
}
- /**
- * Tell if this expression or it's subexpressions can traverse outside
- * the current subtree.
- *
- * @return true if traversal outside the context node's subtree can occur.
- */
- public boolean canTraverseOutsideSubtree()
- {
- if(super.canTraverseOutsideSubtree())
- return true;
- if(null != m_nextWalker)
- return m_nextWalker.canTraverseOutsideSubtree();
- return false;
- }
-
- /**
- * The the step type op code.
- *
- *
- * @return An integer that represents an axes traversal opcode found in
- * [EMAIL PROTECTED] org.apache.xpath.compiler.OpCodes}.
- */
- protected int getStepType()
- {
- return m_stepType;
- }
-
- /**
- * Get the argument length of the location step in the opcode map.
- * TODO: Can this be removed since it is only valuable at compile time?
- *
- * @return The argument length of the location step in the opcode map.
- */
- protected int getArgLen()
- {
- return m_argLen;
- }
-
- /**
- * Tell if the given node is a parent of the
- * step context, or the step context node itself.
- *
- * @param n The node being tested.
- *
- * @return true if n is a parent of the step context, or the step context
- * itself.
- */
- boolean isAncestorOfRootContext(int n)
- {
-
- int parent = m_root;
-
- DTM dtm = getDTM(parent);
- while (DTM.NULL != (parent = dtm.getParent(parent)))
- {
- if (parent == n)
- return true;
- }
-
- return false;
- }
-
//=============== TreeWalker Implementation ===============
/**
@@ -312,6 +238,7 @@
{
// %OPT% Get this directly from the lpi.
m_dtm = wi().getXPathContext().getDTM(root);
+ m_traverser = m_dtm.getAxisTraverser(m_axis);
m_isFresh = true;
m_isDone = false;
m_root = root;
@@ -347,140 +274,6 @@
}
/**
- * Set the current node.
- *
- * @param currentNode The current itteration node, should not be null.
- */
- public void setCurrentNode(int currentNode)
- {
- m_currentNode = currentNode;
- }
-
- /**
- * Set the current node if it's not null.
- *
- * @param currentNode The current node or null.
- * @return The node passed in.
- */
- protected int setCurrentIfNotNull(int currentNode)
- {
-
- if (DTM.NULL != currentNode)
- m_currentNode = currentNode;
-
- return currentNode;
- }
-
- /**
- * The filter used to screen nodes.
- *
- * @return This AxesWalker.
- */
- public DTMFilter getFilter()
- {
- return this;
- }
-
- /**
- * The value of this flag determines whether the children of entity
- * reference nodes are visible to the TreeWalker. If false, they will be
- * skipped over.
- * <br> To produce a view of the document that has entity references
- * expanded and does not expose the entity reference node itself, use the
- * whatToShow flags to hide the entity reference node and set
- * expandEntityReferences to true when creating the TreeWalker. To
- * produce a view of the document that has entity reference nodes but no
- * entity expansion, use the whatToShow flags to show the entity
- * reference node and set expandEntityReferences to false.
- *
- * @return true.
- */
- public boolean getExpandEntityReferences()
- {
- return true;
- }
-
- /**
- * Moves to and returns the closest visible ancestor node of the current
- * node. If the search for parentNode attempts to step upward from the
- * TreeWalker's root node, or if it fails to find a visible ancestor
- * node, this method retains the current position and returns null.
- * @return The new parent node, or null if the current node has no parent
- * in the TreeWalker's logical view.
- */
- public int parentNode()
- {
- return DTM.NULL;
- }
-
- /**
- * Moves the <code>TreeWalker</code> to the first visible child of the
- * current node, and returns the new node. If the current node has no
- * visible children, returns <code>null</code> , and retains the current
- * node.
- * @return The new node, or <code>null</code> if the current node has no
- * visible children in the TreeWalker's logical view.
- */
- public int firstChild()
- {
- return DTM.NULL;
- }
-
- /**
- * Moves the <code>TreeWalker</code> to the next sibling of the current
- * node, and returns the new node. If the current node has no visible
- * next sibling, returns <code>null</code> , and retains the current node.
- * @return The new node, or <code>null</code> if the current node has no
- * next sibling in the TreeWalker's logical view.
- */
- public int nextSibling()
- {
- return DTM.NULL;
- }
-
- /**
- * Moves the <code>TreeWalker</code> to the last visible child of the
- * current node, and returns the new node. If the current node has no
- * visible children, returns <code>null</code> , and retains the current
- * node.
- * @return The new node, or <code>null</code> if the current node has no
- * children in the TreeWalker's logical view.
- */
- public int lastChild()
- {
-
- // We may need to support this...
- throw new RuntimeException("lastChild not supported!");
- }
-
- /**
- * Moves the <code>TreeWalker</code> to the previous sibling of the
- * current node, and returns the new node. If the current node has no
- * visible previous sibling, returns <code>null</code> , and retains the
- * current node.
- * @return The new node, or <code>null</code> if the current node has no
- * previous sibling in the TreeWalker's logical view.
- */
- public int previousSibling()
- {
- throw new RuntimeException("previousSibling not supported!");
- }
-
- /**
- * Moves the <code>TreeWalker</code> to the previous visible node in
- * document order relative to the current node, and returns the new node.
- * If the current node has no previous node, or if the search for
- * previousNode attempts to step upward from the TreeWalker's root node,
- * returns <code>null</code> , and retains the current node.
- * @return The new node, or <code>null</code> if the current node has no
- * previous node in the TreeWalker's logical view.
- */
- public int previousNode()
- {
- throw new RuntimeException("previousNode not supported!");
- }
-
- /**
* Set the next walker in the location step chain.
*
*
@@ -527,40 +320,6 @@
}
/**
- * Diagnostic string for this walker.
- *
- * @return Diagnostic string for this walker.
- */
- public String toString()
- {
-
- Class cl = this.getClass();
- String clName = cl.getName();
- java.util.StringTokenizer tokenizer =
- new java.util.StringTokenizer(clName, ".");
-
- while (tokenizer.hasMoreTokens())
- {
- clName = tokenizer.nextToken();
- }
-
- String rootName;
- String currentNodeName;
-
- rootName = (DTM.NULL == m_root)
- ? "null"
- : getDTM(m_root).getNodeName(m_root) + "{"
- + (m_root+1) + "}";
- currentNodeName =
- (DTM.NULL == m_currentNode)
- ? "null"
- : getDTM(m_currentNode).getNodeName(m_currentNode) + "{"
- + (m_currentNode+1) + "}";
-
- return clName + "[" + rootName + "][" + currentNodeName + "]";
- }
-
- /**
* This is simply a way to bottle-neck the return of the next node, for
* diagnostic purposes.
*
@@ -571,170 +330,10 @@
private int returnNextNode(int n)
{
- if (DEBUG_LOCATED && (DTM.NULL != n))
- {
- printDebug("RETURN --->" + nodeToString(n));
- }
- else if (DEBUG_LOCATED)
- {
- printDebug("RETURN --->null");
- }
-
return n;
}
/**
- * Print a diagnostics string, adding a line break before the print.
- *
- * @param s String to print.
- */
- private void printDebug(String s)
- {
-
- if (DEBUG)
- {
- System.out.print("\n");
-
- if (DTM.NULL != m_currentNode)
- {
- try
- {
- int depth = getDTM(m_currentNode).getLevel(m_currentNode);
-
- for (int i = 0; i < depth; i++)
- {
- System.out.print(" ");
- }
- }
- catch (ClassCastException cce){}
- }
-
- System.out.print(s);
- }
- }
-
- /**
- * Do a diagnostics dump of an entire subtree.
- *
- * @param node The top of the subtree.
- * @param indent The amount to begin the indenting at.
- */
- private void dumpAll(int node, int indent)
- {
-
- for (int i = 0; i < indent; i++)
- {
- System.out.print(" ");
- }
-
- System.out.print(nodeToString(node));
-
- if (DTM.TEXT_NODE == getDTM(node).getNodeType(node))
- {
- XMLString value = getDTM(node).getStringValue(node);
-
- if (null != value)
- {
- System.out.print("+= -->" + value.trim());
- }
- }
-
- System.out.println("");
-
- DTM dtm = getDTM(node);
- for (int attr = dtm.getFirstAttribute(node); attr != DTM.NULL;
- attr = dtm.getNextAttribute(attr))
- {
- for (int k = 0; k < indent; k++)
- {
- System.out.print(" ");
- }
-
- System.out.print("attr -->");
- System.out.print(nodeToString(attr));
-
- XMLString value = dtm.getStringValue(attr);
-
- if (null != value)
- {
- System.out.print("+= -->" + value.trim());
- }
-
- System.out.println("");
- }
-
- for (int child = dtm.getFirstChild(node); DTM.NULL != child;
- child = dtm.getNextSibling(child))
- {
- dumpAll(child, indent + 1);
- }
- }
-
- /**
- * Print a diagnostic string without adding a line break.
- *
- * @param s The string to print.
- */
- private void printDebugAdd(String s)
- {
-
- if (DEBUG)
- {
- System.out.print("; " + s);
- }
- }
-
- /**
- * Diagnostics.
- */
- private void printEntryDebug()
- {
-
- if (true && DEBUG_TRAVERSAL)
- {
- System.out.print("\n============================\n");
-
- if (DTM.NULL != m_currentNode)
- {
- try
- {
- int depth = getDTM(m_currentNode).getLevel(m_currentNode);
-
- for (int i = 0; i < depth; i++)
- {
- System.out.print("+");
- }
- }
- catch (ClassCastException cce){}
- }
-
- System.out.print(" " + this.toString() + ", "
- + nodeToString(this.m_currentNode));
- }
- }
-
- /**
- * Tell what's the maximum level this axes can descend to. This method is
- * meant to be overloaded by derived classes.
- *
- * @return An estimation of the maximum level this axes can descend to.
- */
- protected int getLevelMax()
- {
- return 0;
- }
-
- /**
- * Tell what's the next level this axes can descend to.
- *
- * @return An estimation of the next level that this walker will traverse
to.
- */
- protected int getNextLevelAmount()
- {
- return m_nextLevelAmount;
- }
-
- /**
* Get the next node in document order on the axes.
*
* @return the next node in document order on the axes, or null.
@@ -743,34 +342,22 @@
{
if (m_isFresh)
+ {
+ m_currentNode = m_traverser.first(m_root);
m_isFresh = false;
-
- int current = this.getCurrentNode();
-
- // %NODETESTFILTER%
-// if (current.isSupported(FEATURE_NODETESTFILTER, "1.0"))
-// ((NodeTestFilter) current).setNodeTest(this);
-
- int next = this.firstChild();
-
- while (DTM.NULL == next)
+ }
+ // I shouldn't have to do this the check for current node, I think.
+ // numbering\numbering24.xsl fails if I don't do this. I think
+ // it occurs as the walkers are backing up. -sb
+ else if(DTM.NULL != m_currentNode)
{
- next = this.nextSibling();
-
- if (DTM.NULL == next)
- {
- int p = this.parentNode();
-
- if (DTM.NULL == p)
- break;
- }
+ m_currentNode = m_traverser.next(m_root, m_currentNode);
}
- if (DTM.NULL == next)
+ if (DTM.NULL == m_currentNode)
this.m_isDone = true;
- // System.out.println("Returning: "+this);
- return next;
+ return m_currentNode;
}
/**
@@ -785,14 +372,6 @@
public int nextNode()
{
- if (DEBUG_TRAVERSAL &&!m_didDumpAll)
- {
- m_didDumpAll = true;
-
- // Node doc = (Node.DOCUMENT_NODE == m_root.getNodeType()) ? m_root :
m_root.getOwnerDocument();
- // dumpAll(doc, 0);
- }
-
int nextNode = DTM.NULL;
AxesWalker walker = wi().getLastUsedWalker();
@@ -805,10 +384,6 @@
nextNode = walker.getNextNode();
- if (DEBUG_TRAVERSAL)
- walker.printDebug(walker.toString() + "--NEXT->"
- + nodeToString(nextNode) + ")");
-
if (DTM.NULL == nextNode)
{
@@ -818,28 +393,11 @@
{
if (walker.acceptNode(nextNode) != DTMIterator.FILTER_ACCEPT)
{
- if (DEBUG_TRAVERSAL)
- printDebugAdd("[FILTER_SKIP]");
-
continue;
}
- else
- {
- if (DEBUG_TRAVERSAL)
- printDebugAdd("[FILTER_ACCEPT]");
- }
if (null == walker.m_nextWalker)
{
-
- // walker.pushState();
- if (DEBUG_TRAVERSAL)
- printDebug("May be returning: " + nodeToString(nextNode));
-
- if (DEBUG_TRAVERSAL && (DTM.NULL != m_prevReturned))
- printDebugAdd(", m_prevReturned: "
- + nodeToString(m_prevReturned));
-
wi().setLastUsedWalker(walker);
// return walker.returnNextNode(nextNode);
@@ -855,8 +413,6 @@
walker.m_prevWalker = prev;
- walker.printEntryDebug();
-
continue;
}
} // if(null != nextNode)
@@ -873,10 +429,7 @@
m_prevReturned = nextNode;
- if (DEBUG_LOCATED)
- return returnNextNode(nextNode);
- else
- return nextNode;
+ return nextNode;
}
//============= End TreeWalker Implementation =============
@@ -934,82 +487,6 @@
return pos;
}
- /**
- * Tell if this is a special type of walker compatible with
ChildWalkerMultiStep.
- *
- * @return true this is a special type of walker compatible with
ChildWalkerMultiStep.
- */
- protected boolean isFastWalker()
- {
- return false;
- }
-
- /**
- * Test whether a specified node is visible in the logical view of a
- * <code>DTMIterator</code>. Normally, this function
- * will be called by the implementation of <code>DTMIterator</code>;
- * it is not normally called directly from
- * user code.
- *
- * @param nodeHandle int Handle of the node.
- * @param whatToShow one of SHOW_XXX values.
- * @return one of FILTER_ACCEPT, FILTER_REJECT, or FILTER_SKIP.
- */
- public short acceptNode(int nodeHandle, int whatToShow)
- {
- return DTMIterator.FILTER_ACCEPT; // %TBD%
- }
-
- /**
- * Test whether a specified node is visible in the logical view of a
- * <code>DTMIterator</code>. Normally, this function
- * will be called by the implementation of <code>DTMIterator</code>;
- * it is not normally called directly from
- * user code.
- *
- * @param nodeHandle int Handle of the node.
- * @param whatToShow one of SHOW_XXX values.
- * @param expandedName a value defining the exanded name as defined in
- * the DTM interface. Wild cards will be defined
- * by 0xFFFF in the high word and/or in the low word.
- * @return one of FILTER_ACCEPT, FILTER_REJECT, or FILTER_SKIP.
- */
- public short acceptNode(int nodeHandle, int whatToShow, int expandedName)
- {
- return DTMIterator.FILTER_ACCEPT; // %TBD%
- }
-
- //============= Static Data =============
-
- // These are useful to enable if you want to turn diagnostics messages
- // on or off temporarily from another module.
-// public static boolean DEBUG = false;
-// public static boolean DEBUG_WAITING = false;
-// public static boolean DEBUG_TRAVERSAL = false;
-// public static boolean DEBUG_LOCATED = false;
-// public static boolean DEBUG_PREDICATECOUNTING = false;
-
- /** General static debug flag. Setting this to false will suppress some
- * of the output messages caused by the other debug categories. */
- static final boolean DEBUG = false;
-
- /** If true, diagnostic messages about the waiting queue will be posted.
*/
- static final boolean DEBUG_WAITING = false;
-
- /** If true, diagnostic messages about the tree traversal will be posted.
*/
- static final boolean DEBUG_TRAVERSAL = false;
-
- /** If true, diagnostic messages about the nodes that have
- * been 'located' will be posted. */
- static final boolean DEBUG_LOCATED = false;
-
- /** For diagnostic purposes, tells if we already did a subtree dump. */
- static boolean m_didDumpAll = false;
-
- /** String passed to [EMAIL PROTECTED] org.w3c.dom.Node#isSupported} to
see if it implements
- * a [EMAIL PROTECTED] org.apache.xpath.patterns.NodeTestFilter}
interface. */
- public static final String FEATURE_NODETESTFILTER = "NodeTestFilter";
-
//============= State Data =============
/**
@@ -1049,37 +526,17 @@
/**
* The node at which the TreeWalker is currently positioned.
*/
- transient int m_currentNode = DTM.NULL;
+ private transient int m_currentNode = DTM.NULL;
/** The node last returned from nextNode(). */
transient int m_prevReturned = DTM.NULL;
- /**
- * The arg length of the XPath step. Does not change after the constructor.
- * TODO: Can this be removed since it is only valuable at compile time?
- * @serial
- */
- private int m_argLen;
-
- /**
- * The step type of the XPath step. Does not change after the constructor.
- * @serial
- */
- private int m_stepType;
-
- /** Fairly short lived flag to tell if we switched to a waiting walker. */
- transient private boolean m_didSwitch = false;
-
/** True if this walker has found it's last node. */
transient boolean m_isDone = false;
/** True if an itteration has not begun. */
transient boolean m_isFresh;
- /** An estimation of the next level that this walker will traverse to.
Not
- * always accurate. */
- transient protected int m_nextLevelAmount;
-
/** The next walker in the location step chain.
* @serial */
protected AxesWalker m_nextWalker;
@@ -1087,5 +544,10 @@
/** The previous walker in the location step chain, or null.
* @serial */
AxesWalker m_prevWalker;
-
+
+ /** The traversal axis from where the nodes will be filtered. */
+ protected int m_axis = -1;
+
+ /** The DTM inner traversal class, that corresponds to the super axis. */
+ protected DTMAxisTraverser m_traverser;
}
1.8.2.8 +80 -88
xml-xalan/java/src/org/apache/xpath/axes/DescendantIterator.java
Index: DescendantIterator.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xpath/axes/DescendantIterator.java,v
retrieving revision 1.8.2.7
retrieving revision 1.8.2.8
diff -u -r1.8.2.7 -r1.8.2.8
--- DescendantIterator.java 2001/05/27 03:45:09 1.8.2.7
+++ DescendantIterator.java 2001/05/28 04:07:38 1.8.2.8
@@ -62,15 +62,13 @@
import org.apache.xpath.patterns.NodeTest;
import org.apache.xpath.objects.XObject;
import org.apache.xpath.compiler.OpCodes;
+import org.apache.xpath.XPathContext;
-//import org.w3c.dom.traversal.NodeIterator;
-//import org.w3c.dom.Node;
-//import org.w3c.dom.NamedNodeMap;
-//import org.w3c.dom.DOMException;
-//import org.w3c.dom.traversal.NodeFilter;
import org.apache.xml.dtm.DTM;
import org.apache.xml.dtm.DTMIterator;
import org.apache.xml.dtm.DTMFilter;
+import org.apache.xml.dtm.DTMAxisTraverser;
+import org.apache.xml.dtm.Axis;
/**
* <meta name="usage" content="advanced"/>
@@ -80,7 +78,6 @@
*/
public class DescendantIterator extends LocPathIterator
{
-
/**
* Create a DescendantIterator object.
*
@@ -100,18 +97,27 @@
int firstStepPos = compiler.getFirstChildPos(opPos);
int stepType = ops[firstStepPos];
- m_orSelf = (OpCodes.FROM_DESCENDANTS_OR_SELF == stepType);
+ boolean orSelf = (OpCodes.FROM_DESCENDANTS_OR_SELF == stepType);
+ boolean fromRoot = false;
if (OpCodes.FROM_SELF == stepType)
{
- m_orSelf = true;
+ orSelf = true;
firstStepPos += 8;
}
else if(OpCodes.FROM_ROOT == stepType)
{
- m_fromRoot = true;
- m_orSelf = true;
+ // %TBD% orSelf and fromRoot should be considered seperately.
+ fromRoot = true;
+ orSelf = true;
firstStepPos += 8;
}
+
+ if(fromRoot)
+ m_axis = Axis.DESCENDANTSFROMROOT;
+ else if(orSelf)
+ m_axis = Axis.DESCENDANTORSELF;
+ else
+ m_axis = Axis.DESCENDANT;
int whatToShow = compiler.getWhatToShow(firstStepPos);
@@ -140,8 +146,7 @@
public DescendantIterator()
{
super(null);
- m_orSelf = true;
- m_fromRoot = true;
+ m_axis = Axis.DESCENDANTSFROMROOT;
int whatToShow = DTMFilter.SHOW_ALL;
initNodeTest(whatToShow);
}
@@ -179,7 +184,6 @@
*/
public int nextNode()
{
-
// If the cache is on, and the node has already been found, then
// just return from the list.
// If the cache is on, and the node has already been found, then
@@ -197,37 +201,13 @@
if (m_foundLast)
return DTM.NULL;
-
- int pos; // our main itteration node.
- boolean getSelf;
-
- // Figure out what the start context should be.
- // If the m_lastFetched is null at this point we're at the start
- // of a fresh iteration.
- if (DTM.NULL == m_lastFetched)
- {
- getSelf = m_orSelf; // true if descendants-or-self.
- // The start context can either be the location path context node,
- // or the root node.
- if (m_fromRoot)
- {
- if(m_cdtm.getNodeType(m_context) == DTM.DOCUMENT_NODE)
- pos = m_context;
- else
- pos = m_cdtm.getDocument();
- }
- else
- pos = m_context;
- m_startContext = pos;
- resetProximityPositions();
- }
- else
+ if(DTM.NULL == m_lastFetched)
{
- // if the iterator is not fresh...
- pos = m_lastFetched;
- getSelf = false; // never process the start node at this point.
+ resetProximityPositions();
}
+
+ int next;
org.apache.xpath.VariableStack vars;
int savedStart;
@@ -250,55 +230,38 @@
try
{
- int top = m_startContext; // tells us when to stop.
- int next = DTM.NULL;
-
- // non-recursive depth-first traversal.
- while (DTM.NULL != pos)
+ do
{
- if(getSelf)
+ if(0 == m_extendedTypeID)
{
- m_lastFetched = pos; // we have to do this for a clone in a
predicate to work correctly.
- if(DTMIterator.FILTER_ACCEPT == acceptNode(pos))
- {
- next = pos;
- break;
- }
+ next = m_lastFetched = (DTM.NULL == m_lastFetched)
+ ? m_traverser.first(m_context)
+ : m_traverser.next(m_context, m_lastFetched);
}
else
- getSelf = true;
-
- int nextNode = m_cdtm.getFirstChild(pos);
+ {
+ next = m_lastFetched = (DTM.NULL == m_lastFetched)
+ ? m_traverser.first(m_context, m_extendedTypeID)
+ : m_traverser.next(m_context, m_lastFetched,
+ m_extendedTypeID);
+ }
- while (DTM.NULL == nextNode)
+ if (DTM.NULL != next)
{
- if (top == pos)
+ if(DTMIterator.FILTER_ACCEPT == acceptNode(next))
break;
-
- nextNode = m_cdtm.getNextSibling(pos);
-
- if (DTM.NULL == nextNode)
- {
- pos = m_cdtm.getParent(pos);
-
- if ((DTM.NULL == pos) || (top == pos))
- {
- nextNode = DTM.NULL;
-
- break;
- }
- }
+ else
+ continue;
}
-
- pos = nextNode;
+ else
+ break;
}
-
- m_lastFetched = next;
+ while (next != DTM.NULL);
if (DTM.NULL != next)
{
if (null != m_cachedNodes)
- m_cachedNodes.addElement(next);
+ m_cachedNodes.addElement(m_lastFetched);
m_next++;
@@ -307,7 +270,6 @@
else
{
m_foundLast = true;
- m_startContext = DTM.NULL;
return DTM.NULL;
}
@@ -323,14 +285,44 @@
}
}
- /** The top of the subtree, may not be the same as m_context if "//foo"
pattern. */
- transient private int m_startContext = DTM.NULL;
-
- /** True if this is a descendants-or-self axes.
- * @serial */
- private boolean m_orSelf;
-
- /** True if this is a descendants-or-self axes.
- * @serial */
- private boolean m_fromRoot;
+ /**
+ * Initialize the context values for this expression
+ * after it is cloned.
+ *
+ * @param execContext The XPath runtime context for this
+ * transformation.
+ */
+ public void initContext(XPathContext execContext)
+ {
+ super.initContext(execContext);
+ m_traverser = m_cdtm.getAxisTraverser(m_axis);
+
+ String localName = getLocalName();
+ String namespace = getNamespace();
+ int what = m_whatToShow;
+ // System.out.println("what: ");
+ // NodeTest.debugWhatToShow(what);
+ if(DTMFilter.SHOW_ALL == what
+ || localName == NodeTest.WILD
+ || namespace == NodeTest.WILD)
+ {
+ m_extendedTypeID = 0;
+ }
+ else
+ {
+ int type = getNodeTypeTest(what);
+ m_extendedTypeID = m_cdtm.getExpandedTypeID(namespace, localName,
type);
+ }
+
+ }
+
+ /** The traverser to use to navigate over the descendants. */
+ transient protected DTMAxisTraverser m_traverser;
+
+ /** The axis that we are traversing. */
+ protected int m_axis;
+
+ /** The extended type ID, not set until initContext. */
+ protected int m_extendedTypeID;
+
}
1.14.2.6 +4 -34
xml-xalan/java/src/org/apache/xpath/axes/FilterExprWalker.java
Index: FilterExprWalker.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xpath/axes/FilterExprWalker.java,v
retrieving revision 1.14.2.5
retrieving revision 1.14.2.6
diff -u -r1.14.2.5 -r1.14.2.6
--- FilterExprWalker.java 2001/05/27 02:28:49 1.14.2.5
+++ FilterExprWalker.java 2001/05/28 04:07:39 1.14.2.6
@@ -69,12 +69,10 @@
import java.util.Vector;
-//import org.w3c.dom.Node;
-//import org.w3c.dom.traversal.NodeIterator;
-//import org.w3c.dom.traversal.NodeFilter;
import org.apache.xml.dtm.DTM;
import org.apache.xml.dtm.DTMIterator;
import org.apache.xml.dtm.DTMFilter;
+import org.apache.xml.dtm.Axis;
/**
* Walker for the OP_VARIABLE, or OP_EXTFUNCTION, or OP_FUNCTION, or
OP_GROUP,
@@ -91,7 +89,7 @@
*/
public FilterExprWalker(WalkingIterator locPathIterator)
{
- super(locPathIterator);
+ super(locPathIterator, Axis.FILTEREDLIST);
}
/**
@@ -258,43 +256,15 @@
{
int current = this.getCurrentNode();
- // %NODETESTFILTER%
-// if (current instanceof NodeTestFilter)
-// ((NodeTestFilter) current).setNodeTest(this);
-
next = m_nodeSet.nextNode();
}
else
next = DTM.NULL;
}
-
- // Bogus, I think, but probably OK for right now since a filterExpr
- // can only occur at the head of a location path.
- if (DTM.NULL == next)
- {
- m_nextLevelAmount = 0;
- }
- else
- {
-
- // System.out.println("FilterExprWalker.getNextNode");
- m_nextLevelAmount = ((getDTM(next).getFirstChild(next) != DTM.NULL) ?
1 : 0);
-
- /* ...WAIT TO SEE IF WE REALLY NEED THIS...
- m_peek = m_nodeSet.nextNode();
- if(null == m_peek)
- m_nextLevelAmount = 0;
- else
- {
- DOMHelper dh = m_lpi.getDOMHelper();
- m_nextLevelAmount = dh.getLevel(m_peek) - dh.getLevel(next);
- }
- */
- }
- int current = setCurrentIfNotNull(next);
+ // int current = setCurrentIfNotNull(next);
// System.out.println("Returning: "+this);
- return current;
+ return next;
}
/** The contained expression. Should be non-null.
1.1.2.2 +2 -2
xml-xalan/java/src/org/apache/xpath/axes/Attic/OneStepIterator.java
Index: OneStepIterator.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xpath/axes/Attic/OneStepIterator.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- OneStepIterator.java 2001/05/27 02:28:49 1.1.2.1
+++ OneStepIterator.java 2001/05/28 04:07:39 1.1.2.2
@@ -69,9 +69,9 @@
}
/**
- * Get a cloned AxesWalker.
+ * Get a cloned iterator.
*
- * @return A new AxesWalker that can be used without mutating this one.
+ * @return A new iterator that can be used without mutating this one.
*
* @throws CloneNotSupportedException
*/
1.3.2.4 +2 -2
xml-xalan/java/src/org/apache/xpath/axes/PredicatedNodeTest.java
Index: PredicatedNodeTest.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xpath/axes/PredicatedNodeTest.java,v
retrieving revision 1.3.2.3
retrieving revision 1.3.2.4
diff -u -r1.3.2.3 -r1.3.2.4
--- PredicatedNodeTest.java 2001/05/27 02:28:50 1.3.2.3
+++ PredicatedNodeTest.java 2001/05/28 04:07:40 1.3.2.4
@@ -37,9 +37,9 @@
}
/**
- * Get a cloned AxesWalker.
+ * Get a cloned PrdicatedNodeTest.
*
- * @return A new AxesWalker that can be used without mutating this one.
+ * @return A new PredicatedNodeTest that can be used without mutating this
one.
*
* @throws CloneNotSupportedException
*/
1.6.2.4 +40 -6
xml-xalan/java/src/org/apache/xpath/axes/ReverseAxesWalker.java
Index: ReverseAxesWalker.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xpath/axes/ReverseAxesWalker.java,v
retrieving revision 1.6.2.3
retrieving revision 1.6.2.4
diff -u -r1.6.2.3 -r1.6.2.4
--- ReverseAxesWalker.java 2001/05/27 02:28:50 1.6.2.3
+++ ReverseAxesWalker.java 2001/05/28 04:07:40 1.6.2.4
@@ -66,10 +66,10 @@
import javax.xml.transform.TransformerException;
-//import org.w3c.dom.Node;
-//import org.w3c.dom.traversal.NodeFilter;
import org.apache.xml.dtm.DTM;
import org.apache.xml.dtm.DTMIterator;
+import org.apache.xml.dtm.DTMAxisIterator;
+import org.apache.xml.dtm.Axis;
/**
* Walker for a reverse axes.
@@ -83,10 +83,43 @@
*
* @param locPathIterator The location path iterator that 'owns' this
walker.
*/
- public ReverseAxesWalker(LocPathIterator locPathIterator)
+ public ReverseAxesWalker(LocPathIterator locPathIterator, int axis)
{
- super(locPathIterator);
+ super(locPathIterator, axis);
}
+
+ /**
+ * Set the root node of the TreeWalker.
+ * (Not part of the DOM2 TreeWalker interface).
+ *
+ * @param root The context node of this step.
+ */
+ public void setRoot(int root)
+ {
+ super.setRoot(root);
+ m_iterator = getDTM(root).getAxisIterator(m_axis);
+ m_iterator.setStartNode(root);
+ }
+
+ /**
+ * Get the next node in document order on the axes.
+ *
+ * @return the next node in document order on the axes, or null.
+ */
+ protected int getNextNode()
+ {
+
+ int next = m_iterator.next();
+
+ if (m_isFresh)
+ m_isFresh = false;
+
+ if (DTM.NULL == next)
+ this.m_isDone = true;
+
+ return next;
+ }
+
/**
* Tells if this is a reverse axes. Overrides AxesWalker#isReverseAxes.
@@ -225,8 +258,9 @@
wi().setLastUsedWalker(savedWalker);
}
- // System.out.println("getLastPos - pos: "+count);
- // System.out.println("pos (ReverseAxesWalker): "+count);
return count;
}
+
+ /** The DTM inner traversal class, that corresponds to the super axis. */
+ protected DTMAxisIterator m_iterator;
}
1.13.2.6 +15 -165
xml-xalan/java/src/org/apache/xpath/axes/WalkerFactory.java
Index: WalkerFactory.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xpath/axes/WalkerFactory.java,v
retrieving revision 1.13.2.5
retrieving revision 1.13.2.6
diff -u -r1.13.2.5 -r1.13.2.6
--- WalkerFactory.java 2001/05/27 02:28:50 1.13.2.5
+++ WalkerFactory.java 2001/05/28 04:07:40 1.13.2.6
@@ -1128,7 +1128,7 @@
WalkingIterator lpi, int analysis)
{
- AxesWalker ai;
+ AxesWalker ai = null;
int stepType = compiler.getOp(opPos);
/*
@@ -1159,205 +1159,55 @@
simpleInit = true;
break;
case OpCodes.FROM_ROOT :
- if (0 == (analysis
- & ~(BIT_ROOT | BIT_CHILD | BIT_ATTRIBUTE | BIT_NAMESPACE
- | BIT_PREDICATE | BITS_COUNT)))
- {
- if (DEBUG_WALKER_CREATION)
- System.out.println("new walker: RootWalkerMultiStep: " + analysis
- + ", " + compiler.toString());
-
- ai = new RootWalkerMultiStep(lpi);
- }
- else
- {
- if (DEBUG_WALKER_CREATION)
- System.out.println("new walker: RootWalker: " + analysis + ", "
- + compiler.toString());
-
- ai = new RootWalker(lpi);
- }
+ ai = new AxesWalker(lpi, Axis.ROOT);
break;
case OpCodes.FROM_ANCESTORS :
prevIsOneStepDown = false;
-
- if (DEBUG_WALKER_CREATION)
- System.out.println("new walker: AncestorWalker: " + analysis + ", "
- + compiler.toString());
-
- ai = new AncestorWalker(lpi);
+ ai = new ReverseAxesWalker(lpi, Axis.ANCESTOR);
break;
case OpCodes.FROM_ANCESTORS_OR_SELF :
prevIsOneStepDown = false;
-
- if (DEBUG_WALKER_CREATION)
- System.out.println("new walker: AncestorOrSelfWalker: " + analysis
- + ", " + compiler.toString());
-
- ai = new AncestorOrSelfWalker(lpi);
+ ai = new ReverseAxesWalker(lpi, Axis.ANCESTORORSELF);
break;
case OpCodes.FROM_ATTRIBUTES :
- if (1 == totalNumberWalkers)
- {
- if (DEBUG_WALKER_CREATION)
- System.out.println("new walker: AttributeWalkerOneStep: "
- + analysis + ", " + compiler.toString());
-
- // TODO: We should be able to do this as long as this is
- // the last step.
- ai = new AttributeWalkerOneStep(lpi);
- }
- else
- {
- if (DEBUG_WALKER_CREATION)
- System.out.println("new walker: AttributeWalker: " + analysis
- + ", " + compiler.toString());
-
- ai = new AttributeWalker(lpi);
- }
+ ai = new AxesWalker(lpi, Axis.ATTRIBUTE);
break;
case OpCodes.FROM_NAMESPACE :
- if (DEBUG_WALKER_CREATION)
- System.out.println("new walker: NamespaceWalker: " + analysis + ", "
- + compiler.toString());
-
- ai = new NamespaceWalker(lpi);
+ ai = new AxesWalker(lpi, Axis.NAMESPACE);
break;
case OpCodes.FROM_CHILDREN :
- if (1 == totalNumberWalkers)
- {
-
- // I don't think this will ever happen any more. -sb
- if (DEBUG_WALKER_CREATION)
- System.out.println("new walker: ChildWalkerOneStep: " + analysis
- + ", " + compiler.toString());
-
- ai = new ChildWalkerOneStep(lpi);
- }
- else
- {
- if (0 == (analysis
- & ~(BIT_ROOT | BIT_CHILD | BIT_ATTRIBUTE | BIT_NAMESPACE
- | BIT_PREDICATE | BITS_COUNT)))
- {
- if (DEBUG_WALKER_CREATION)
- System.out.println("new walker: ChildWalkerMultiStep: "
- + analysis + ", " + compiler.toString());
-
- ai = new ChildWalkerMultiStep(lpi);
- }
- else
- {
- if (DEBUG_WALKER_CREATION)
- System.out.println("new walker: ChildWalker: " + analysis + ", "
- + compiler.toString());
-
- ai = new ChildWalker(lpi);
- }
- }
+ ai = new AxesWalker(lpi, Axis.CHILD);
break;
case OpCodes.FROM_DESCENDANTS :
prevIsOneStepDown = false;
-
- if (DEBUG_WALKER_CREATION)
- System.out.println("new walker: DescendantWalker: " + analysis
- + ", " + compiler.toString());
-
- ai = new DescendantWalker(lpi);
+ ai = new AxesWalker(lpi, Axis.DESCENDANT);
break;
case OpCodes.FROM_DESCENDANTS_OR_SELF :
prevIsOneStepDown = false;
-
- if (DEBUG_WALKER_CREATION)
- System.out.println("new walker: DescendantOrSelfWalker: " + analysis
- + ", " + compiler.toString());
-
- ai = new DescendantOrSelfWalker(lpi);
+ ai = new AxesWalker(lpi, Axis.DESCENDANTORSELF);
break;
case OpCodes.FROM_FOLLOWING :
prevIsOneStepDown = false;
-
- if (DEBUG_WALKER_CREATION)
- System.out.println("new walker: FollowingWalker: " + analysis + ", "
- + compiler.toString());
-
- ai = new FollowingWalker(lpi);
+ ai = new AxesWalker(lpi, Axis.FOLLOWING);
break;
case OpCodes.FROM_FOLLOWING_SIBLINGS :
prevIsOneStepDown = false;
-
- if (DEBUG_WALKER_CREATION)
- System.out.println("new walker: FollowingSiblingWalker: " + analysis
- + ", " + compiler.toString());
-
- ai = new FollowingSiblingWalker(lpi);
+ ai = new AxesWalker(lpi, Axis.FOLLOWINGSIBLING);
break;
case OpCodes.FROM_PRECEDING :
prevIsOneStepDown = false;
-
- if (DEBUG_WALKER_CREATION)
- System.out.println("new walker: PrecedingWalker: " + analysis + ", "
- + compiler.toString());
-
- ai = new PrecedingWalker(lpi);
+ ai = new ReverseAxesWalker(lpi, Axis.PRECEDING);
break;
case OpCodes.FROM_PRECEDING_SIBLINGS :
prevIsOneStepDown = false;
-
- if (DEBUG_WALKER_CREATION)
- System.out.println("new walker: PrecedingSiblingWalker: " + analysis
- + ", " + compiler.toString());
-
- ai = new PrecedingSiblingWalker(lpi);
+ ai = new ReverseAxesWalker(lpi, Axis.PRECEDINGSIBLING);
break;
case OpCodes.FROM_PARENT :
prevIsOneStepDown = false;
-
- if (DEBUG_WALKER_CREATION)
- System.out.println("new walker: ParentWalker: " + analysis + ", "
- + compiler.toString());
-
- ai = new ParentWalker(lpi);
+ ai = new ReverseAxesWalker(lpi, Axis.PARENT);
break;
case OpCodes.FROM_SELF :
- if (1 == totalNumberWalkers)
- {
- if (DEBUG_WALKER_CREATION)
- System.out.println("new walker: SelfWalkerOneStep: " + analysis
- + ", " + compiler.toString());
-
- ai = new SelfWalkerOneStep(lpi);
- }
- else
- {
- if (DEBUG_WALKER_CREATION)
- System.out.println("new walker: SelfWalker: " + analysis + ", "
- + compiler.toString());
-
- ai = new SelfWalker(lpi);
- }
- break;
- case OpCodes.MATCH_ATTRIBUTE :
- if (DEBUG_WALKER_CREATION)
- System.out.println("new walker: AttributeWalker(MATCH_ATTRIBUTE): "
- + analysis + ", " + compiler.toString());
-
- ai = new AttributeWalker(lpi);
- break;
- case OpCodes.MATCH_ANY_ANCESTOR :
- if (DEBUG_WALKER_CREATION)
- System.out.println("new walker: ChildWalker(MATCH_ANY_ANCESTOR): "
- + analysis + ", " + compiler.toString());
-
- ai = new ChildWalker(lpi);
- break;
- case OpCodes.MATCH_IMMEDIATE_ANCESTOR :
- if (DEBUG_WALKER_CREATION)
- System.out.println(
- "new walker: ChildWalker(MATCH_IMMEDIATE_ANCESTOR): " + analysis
- + ", " + compiler.toString());
-
- ai = new ChildWalker(lpi);
+ ai = new AxesWalker(lpi, Axis.SELF);
break;
default :
throw new RuntimeException("Programmer's assertion: unknown opcode: "
No revision
No revision
1.20.2.7 +61 -2
xml-xalan/java/src/org/apache/xpath/patterns/NodeTest.java
Index: NodeTest.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xpath/patterns/NodeTest.java,v
retrieving revision 1.20.2.6
retrieving revision 1.20.2.7
diff -u -r1.20.2.6 -r1.20.2.7
--- NodeTest.java 2001/05/25 17:37:02 1.20.2.6
+++ NodeTest.java 2001/05/28 04:07:45 1.20.2.7
@@ -154,7 +154,7 @@
* The local name to be tested for.
* @serial
*/
- String m_name;
+ protected String m_name;
/**
* Return the local name to be tested.
@@ -341,12 +341,71 @@
{
return m_score.num();
}
+
+ /**
+ * Tell what node type to test, if not DTMFilter.SHOW_ALL.
+ *
+ * @param whatToShow Bit set defined mainly by
+ * [EMAIL PROTECTED] org.apache.xml.dtm.DTMFilter}.
+ * @return the node type for the whatToShow. Since whatToShow can specify
+ * multiple types, it will return the first bit tested that is on,
+ * so the caller of this function should take care that this is
+ * the function they really want to call. If none of the known
bits
+ * are set, this function will return zero.
+ */
+ public static int getNodeTypeTest(int whatToShow)
+ {
+ // %REVIEW% Is there a better way?
+ if (0 != (whatToShow & DTMFilter.SHOW_ELEMENT))
+ return DTM.ELEMENT_NODE;
+
+ if (0 != (whatToShow & DTMFilter.SHOW_ATTRIBUTE))
+ return DTM.ATTRIBUTE_NODE;
+
+ if (0 != (whatToShow & DTMFilter.SHOW_TEXT))
+ return DTM.TEXT_NODE;
+
+ if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT))
+ return DTM.DOCUMENT_NODE;
+
+ if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT_FRAGMENT))
+ return DTM.DOCUMENT_FRAGMENT_NODE;
+
+ if (0 != (whatToShow & DTMFilter.SHOW_NAMESPACE))
+ return DTM.NAMESPACE_NODE;
+
+ if (0 != (whatToShow & DTMFilter.SHOW_COMMENT))
+ return DTM.COMMENT_NODE;
+
+ if (0 != (whatToShow & DTMFilter.SHOW_PROCESSING_INSTRUCTION))
+ return DTM.PROCESSING_INSTRUCTION_NODE;
+ if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT_TYPE))
+ return DTM.DOCUMENT_TYPE_NODE;
+
+ if (0 != (whatToShow & DTMFilter.SHOW_ENTITY))
+ return DTM.ENTITY_NODE;
+
+ if (0 != (whatToShow & DTMFilter.SHOW_ENTITY_REFERENCE))
+ return DTM.ENTITY_REFERENCE_NODE;
+
+ if (0 != (whatToShow & DTMFilter.SHOW_NOTATION))
+ return DTM.NOTATION_NODE;
+
+ if (0 != (whatToShow & DTMFilter.SHOW_CDATA_SECTION))
+ return DTM.CDATA_SECTION_NODE;
+
+
+ return 0;
+ }
+
+
/**
* Do a diagnostics dump of a whatToShow bit set.
*
*
- * @param whatToShow Bit set defined mainly by [EMAIL PROTECTED]
org.w3c.dom.traversal.NodeFilter}.
+ * @param whatToShow Bit set defined mainly by
+ * [EMAIL PROTECTED] org.apache.xml.dtm.DTMFilter}.
*/
public static void debugWhatToShow(int whatToShow)
{
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]