sboag 01/06/02 20:24:24
Modified: java/src/org/apache/xalan/extensions Tag: DTM_EXP
XSLProcessorContext.java
java/src/org/apache/xalan/templates Tag: DTM_EXP
ElemCopy.java ElemTemplateElement.java ElemUse.java
FuncKey.java StylesheetRoot.java TemplateList.java
java/src/org/apache/xalan/transformer Tag: DTM_EXP
ClonerToResultTree.java KeyIterator.java
TransformSnapshotImpl.java TransformerImpl.java
java/src/org/apache/xml/dtm/ref Tag: DTM_EXP
DTMManagerDefault.java
java/src/org/apache/xpath Tag: DTM_EXP Expression.java
NodeSet.java XPath.java XPathContext.java
java/src/org/apache/xpath/compiler Tag: DTM_EXP
Compiler.java
Removed: java/src/org/apache/xalan/transformer Tag: DTM_EXP
QueuedSAXEvent.java QueuedStartDocument.java
QueuedStartElement.java
java/src/org/apache/xpath/patterns Tag: DTM_EXP
RelativeStepPattern.java
Log:
Various performance tweaks, and work related to my previous check-ins
from tonight.
Revision Changes Path
No revision
No revision
1.8.2.3 +3 -1
xml-xalan/java/src/org/apache/xalan/extensions/XSLProcessorContext.java
Index: XSLProcessorContext.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/extensions/XSLProcessorContext.java,v
retrieving revision 1.8.2.2
retrieving revision 1.8.2.3
diff -u -r1.8.2.2 -r1.8.2.3
--- XSLProcessorContext.java 2001/05/17 05:38:44 1.8.2.2
+++ XSLProcessorContext.java 2001/06/03 03:24:21 1.8.2.3
@@ -64,6 +64,7 @@
import org.apache.xalan.transformer.TransformerImpl;
import org.apache.xalan.transformer.ResultTreeHandler;
+import org.apache.xalan.transformer.ClonerToResultTree;
import org.apache.xalan.templates.Stylesheet;
import org.apache.xml.utils.QName;
@@ -266,7 +267,8 @@
while (DTM.NULL != pos)
{
rtreeHandler.flushPending();
- rtreeHandler.cloneToResultTree(pos, true);
+ ClonerToResultTree.cloneToResultTree(pos, dtm.getNodeType(pos),
+ dtm, rtreeHandler, true);
int nextNode = dtm.getFirstChild(pos);
No revision
No revision
1.12.2.3 +7 -5
xml-xalan/java/src/org/apache/xalan/templates/ElemCopy.java
Index: ElemCopy.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemCopy.java,v
retrieving revision 1.12.2.2
retrieving revision 1.12.2.3
diff -u -r1.12.2.2 -r1.12.2.3
--- ElemCopy.java 2001/05/27 03:05:13 1.12.2.2
+++ ElemCopy.java 2001/06/03 03:24:21 1.12.2.3
@@ -70,6 +70,7 @@
import org.apache.xalan.res.XSLTErrorResources;
import org.apache.xalan.transformer.TransformerImpl;
import org.apache.xalan.transformer.ResultTreeHandler;
+import org.apache.xalan.transformer.ClonerToResultTree;
import javax.xml.transform.TransformerException;
@@ -134,12 +135,12 @@
TransformerImpl transformer)
throws TransformerException
{
- XPathContext xctxt = transformer.getXPathContext();
+ XPathContext xctxt = transformer.getXPathContext();
try
{
int sourceNode = xctxt.getCurrentNode();
- xctxt.pushCurrentNode(sourceNode);
+ xctxt.pushCurrentNode(sourceNode);
DTM dtm = xctxt.getDTM(sourceNode);
short nodeType = dtm.getNodeType(sourceNode);
@@ -148,12 +149,13 @@
ResultTreeHandler rthandler = transformer.getResultTreeHandler();
// TODO: Process the use-attribute-sets stuff
- rthandler.cloneToResultTree(sourceNode, false);
+ ClonerToResultTree.cloneToResultTree(sourceNode, nodeType, dtm,
+ rthandler, false);
if (DTM.ELEMENT_NODE == nodeType)
{
super.execute(transformer);
- rthandler.processNSDecls(sourceNode);
+ rthandler.processNSDecls(sourceNode, nodeType, dtm);
transformer.executeChildTemplates(this, true);
String ns = dtm.getNamespaceURI(sourceNode);
@@ -180,7 +182,7 @@
{
throw new TransformerException(se);
}
- finally
+ finally
{
xctxt.popCurrentNode();
}
1.38.2.4 +11 -1
xml-xalan/java/src/org/apache/xalan/templates/ElemTemplateElement.java
Index: ElemTemplateElement.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemTemplateElement.java,v
retrieving revision 1.38.2.3
retrieving revision 1.38.2.4
diff -u -r1.38.2.3 -r1.38.2.4
--- ElemTemplateElement.java 2001/05/17 05:38:45 1.38.2.3
+++ ElemTemplateElement.java 2001/06/03 03:24:21 1.38.2.4
@@ -379,7 +379,7 @@
last.m_nextSibling = elem;
}
- elem.m_parentNode = this;
+ elem.setParentElem(this);
return elem;
}
@@ -1151,6 +1151,16 @@
public ElemTemplateElement getParentElem()
{
return m_parentNode;
+ }
+
+ /**
+ * Set the parent as an ElemTemplateElement.
+ *
+ * @param parent This node's parent as an ElemTemplateElement
+ */
+ public void setParentElem(ElemTemplateElement p)
+ {
+ m_parentNode = p;
}
/**
1.10.2.2 +22 -0
xml-xalan/java/src/org/apache/xalan/templates/ElemUse.java
Index: ElemUse.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemUse.java,v
retrieving revision 1.10.2.1
retrieving revision 1.10.2.2
diff -u -r1.10.2.1 -r1.10.2.2
--- ElemUse.java 2001/04/10 18:44:50 1.10.2.1
+++ ElemUse.java 2001/06/03 03:24:21 1.10.2.2
@@ -143,6 +143,28 @@
{
return m_attributeSetsNames;
}
+
+ /**
+ * Add the attributes from the named attribute sets to the attribute list.
+ * TODO: Error handling for: "It is an error if there are two attribute
sets
+ * with the same expanded-name and with equal import precedence and that
both
+ * contain the same attribute unless there is a definition of the attribute
+ * set with higher import precedence that also contains the attribute."
+ *
+ * @param transformer non-null reference to the the current transform-time
state.
+ * @param stylesheet The owning root stylesheet
+ * @param attributeSetsNames List of attribute sets names to apply
+ * @param sourceNode non-null reference to the <a
href="http://www.w3.org/TR/xslt#dt-current-node">current source node</a>.
+ * @param mode reference, which may be null, to the <a
href="http://www.w3.org/TR/xslt#modes">current mode</a>.
+ *
+ * @throws TransformerException
+ */
+ public void applyAttrSets(
+ TransformerImpl transformer, StylesheetRoot stylesheet)
+ throws TransformerException
+ {
+ applyAttrSets(transformer, stylesheet, m_attributeSetsNames);
+ }
/**
* Add the attributes from the named attribute sets to the attribute list.
1.8.2.3 +2 -1
xml-xalan/java/src/org/apache/xalan/templates/FuncKey.java
Index: FuncKey.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/FuncKey.java,v
retrieving revision 1.8.2.2
retrieving revision 1.8.2.3
diff -u -r1.8.2.2 -r1.8.2.3
--- FuncKey.java 2001/05/18 07:16:19 1.8.2.2
+++ FuncKey.java 2001/06/03 03:24:21 1.8.2.3
@@ -162,7 +162,8 @@
//mnodeset.addNodesInDocOrder(nl, xctxt); needed??
}
- upi.initContext(xctxt);
+ int current = xctxt.getCurrentNode();
+ upi.setRoot(current, xctxt);
nodes = new XNodeSet(upi);
}
1.40.2.3 +2 -0
xml-xalan/java/src/org/apache/xalan/templates/StylesheetRoot.java
Index: StylesheetRoot.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/StylesheetRoot.java,v
retrieving revision 1.40.2.2
retrieving revision 1.40.2.3
diff -u -r1.40.2.2 -r1.40.2.3
--- StylesheetRoot.java 2001/05/30 20:30:48 1.40.2.2
+++ StylesheetRoot.java 2001/06/03 03:24:21 1.40.2.3
@@ -969,6 +969,7 @@
ElemApplyTemplates childrenElement = new ElemApplyTemplates();
childrenElement.setIsDefaultTemplate(true);
+ childrenElement.setSelect(m_selectDefault);
m_defaultRule.appendChild(childrenElement);
// -----------------------------
@@ -1001,6 +1002,7 @@
childrenElement.setIsDefaultTemplate(true);
m_defaultRootRule.appendChild(childrenElement);
+ childrenElement.setSelect(m_selectDefault);
}
/**
1.30.2.3 +125 -0
xml-xalan/java/src/org/apache/xalan/templates/TemplateList.java
Index: TemplateList.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/TemplateList.java,v
retrieving revision 1.30.2.2
retrieving revision 1.30.2.3
diff -u -r1.30.2.2 -r1.30.2.3
--- TemplateList.java 2001/05/30 20:30:49 1.30.2.2
+++ TemplateList.java 2001/06/03 03:24:21 1.30.2.3
@@ -65,6 +65,8 @@
//import org.w3c.dom.Node;
import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.ref.ExpandedNameTable;
+
import javax.xml.transform.TransformerException;
import org.apache.xml.utils.QName;
@@ -500,6 +502,129 @@
return (null == head) ? m_wildCardPatterns : head;
}
+
+ /**
+ * Get the head of the most likely list of associations to check, based on
+ * the name and type of the targetNode argument.
+ *
+ * @param xctxt The XPath runtime context.
+ * @param targetNode The target node that will be checked for a match.
+ * @param dtm The dtm owner for the target node.
+ *
+ * @return The head of a linked list that contains all possible match
pattern to
+ * template associations.
+ */
+ public TemplateSubPatternAssociation getHeadFast(XPathContext xctxt,
+ int targetNode, DTM dtm,
+ int expNameID)
+ {
+ TemplateSubPatternAssociation head;
+
+ switch (expNameID >> ExpandedNameTable.ROTAMOUNT_TYPE)
+ {
+ case DTM.ELEMENT_NODE :
+ case DTM.ATTRIBUTE_NODE :
+ head = (TemplateSubPatternAssociation) m_patternTable.get(
+ dtm.getLocalName(targetNode));
+ break;
+ case DTM.TEXT_NODE :
+ case DTM.CDATA_SECTION_NODE :
+ head = m_textPatterns;
+ break;
+ case DTM.ENTITY_REFERENCE_NODE :
+ case DTM.ENTITY_NODE :
+ head = (TemplateSubPatternAssociation) m_patternTable.get(
+ dtm.getNodeName(targetNode)); // %REVIEW% I think this is right
+ break;
+ case DTM.PROCESSING_INSTRUCTION_NODE :
+ head = (TemplateSubPatternAssociation) m_patternTable.get(
+ dtm.getLocalName(targetNode));
+ break;
+ case DTM.COMMENT_NODE :
+ head = m_commentPatterns;
+ break;
+ case DTM.DOCUMENT_NODE :
+ case DTM.DOCUMENT_FRAGMENT_NODE :
+ head = m_docPatterns;
+ break;
+ case DTM.NOTATION_NODE :
+ default :
+ head = (TemplateSubPatternAssociation) m_patternTable.get(
+ dtm.getNodeName(targetNode)); // %REVIEW% I think this is right
+ }
+
+ return (null == head) ? m_wildCardPatterns : head;
+ }
+
+ /**
+ * Given a target element, find the template that best
+ * matches in the given XSL document, according
+ * to the rules specified in the xsl draft. This variation of getTemplate
+ * assumes the current node and current expression node have already been
+ * pushed.
+ *
+ * @param xctxt
+ * @param targetNode
+ * @param mode A string indicating the display mode.
+ * @param maxImportLevel The maximum importCountComposed that we should
consider or -1
+ * if we should consider all import levels. This is used by
apply-imports to
+ * access templates that have been overridden.
+ * @param quietConflictWarnings
+ * @return Rule that best matches targetElem.
+ * @throws XSLProcessorException thrown if the active ProblemListener and
XPathContext decide
+ * the error condition is severe enough to halt processing.
+ *
+ * @throws TransformerException
+ */
+ public ElemTemplate getTemplateFast(XPathContext xctxt,
+ int targetNode,
+ int expTypeID,
+ QName mode,
+ int maxImportLevel,
+ boolean quietConflictWarnings,
+ DTM dtm)
+ throws TransformerException
+ {
+
+ TemplateSubPatternAssociation head = getHeadFast(xctxt, targetNode,
+ dtm, expTypeID);
+
+ if(null == head)
+ return null;
+
+ // XSLT functions, such as xsl:key, need to be able to get to
+ // current ElemTemplateElement via a cast to the prefix resolver.
+ // Setting this fixes bug idkey03.
+ final PrefixResolver savedPR = xctxt.getNamespaceContext();
+ try
+ {
+ do
+ {
+ if ( (maxImportLevel > -1) && (head.getImportLevel() >
maxImportLevel) )
+ {
+ continue;
+ }
+ ElemTemplate template = head.getTemplate();
+ xctxt.setNamespaceContext(template);
+
+ if ((head.m_stepPattern.execute(xctxt, targetNode) !=
NodeTest.SCORE_NONE)
+ && head.matchMode(mode))
+ {
+ if (quietConflictWarnings)
+ checkConflicts(head, xctxt, targetNode, mode);
+
+ return template;
+ }
+ }
+ while (null != (head = head.getNext()));
+ }
+ finally
+ {
+ xctxt.setNamespaceContext(savedPR);
+ }
+
+ return null;
+ } // end findTemplate
/**
* Given a target element, find the template that best
No revision
No revision
1.9.2.6 +100 -19
xml-xalan/java/src/org/apache/xalan/transformer/ClonerToResultTree.java
Index: ClonerToResultTree.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/ClonerToResultTree.java,v
retrieving revision 1.9.2.5
retrieving revision 1.9.2.6
diff -u -r1.9.2.5 -r1.9.2.6
--- ClonerToResultTree.java 2001/05/29 14:31:04 1.9.2.5
+++ ClonerToResultTree.java 2001/06/03 03:24:22 1.9.2.6
@@ -97,6 +97,89 @@
m_transformer = transformer;
}
+// /**
+// * Clone an element with or without children.
+// * TODO: Fix or figure out node clone failure!
+// * the error condition is severe enough to halt processing.
+// *
+// * @param node The node to clone
+// * @param shouldCloneAttributes Flag indicating whether to
+// * clone children attributes
+// *
+// * @throws TransformerException
+// */
+// public void cloneToResultTree(int node, boolean shouldCloneAttributes)
+// throws TransformerException
+// {
+//
+// try
+// {
+// XPathContext xctxt = m_transformer.getXPathContext();
+// DTM dtm = xctxt.getDTM(node);
+//
+// int type = dtm.getNodeType(node);
+// switch (type)
+// {
+// case DTM.TEXT_NODE :
+// dtm.dispatchCharactersEvents(node, m_rth, false);
+// break;
+// case DTM.DOCUMENT_FRAGMENT_NODE :
+// case DTM.DOCUMENT_NODE :
+//
+// // Can't clone a document, but refrain from throwing an error
+// // so that copy-of will work
+// break;
+// case DTM.ELEMENT_NODE :
+// {
+// Attributes atts;
+//
+// if (shouldCloneAttributes)
+// {
+// m_rth.addAttributes(node);
+// m_rth.processNSDecls(node, type, dtm);
+// }
+//
+// String ns = dtm.getNamespaceURI(node);
+// String localName = dtm.getLocalName(node);
+//
+// m_rth.startElement(ns, localName, dtm.getNodeNameX(node), null);
+// }
+// break;
+// case DTM.CDATA_SECTION_NODE :
+// m_rth.startCDATA();
+// dtm.dispatchCharactersEvents(node, m_rth, false);
+// m_rth.endCDATA();
+// break;
+// case DTM.ATTRIBUTE_NODE :
+// m_rth.addAttribute(node);
+// break;
+// case DTM.COMMENT_NODE :
+// XMLString xstr = dtm.getStringValue (node);
+// xstr.dispatchAsComment(m_rth);
+// break;
+// case DTM.ENTITY_REFERENCE_NODE :
+// m_rth.entityReference(dtm.getNodeNameX(node));
+// break;
+// case DTM.PROCESSING_INSTRUCTION_NODE :
+// {
+// // %REVIEW% Is the node name the same as the "target"?
+// m_rth.processingInstruction(dtm.getNodeNameX(node),
+// dtm.getNodeValue(node));
+// }
+// break;
+// default :
+// //"Can not create item in result tree: "+node.getNodeName());
+// m_transformer.getMsgMgr().error(null,
+// XSLTErrorResources.ER_CANT_CREATE_ITEM,
+// new Object[]{ dtm.getNodeName(node) });
+// }
+// }
+// catch(org.xml.sax.SAXException se)
+// {
+// throw new TransformerException(se);
+// }
+// } // end cloneToResultTree function
+
/**
* Clone an element with or without children.
* TODO: Fix or figure out node clone failure!
@@ -108,19 +191,18 @@
*
* @throws TransformerException
*/
- public void cloneToResultTree(int node, boolean shouldCloneAttributes)
+ public static void cloneToResultTree(int node, int nodeType, DTM dtm,
+ ResultTreeHandler rth,
+ boolean shouldCloneAttributes)
throws TransformerException
{
try
{
- XPathContext xctxt = m_transformer.getXPathContext();
- DTM dtm = xctxt.getDTM(node);
-
- switch (dtm.getNodeType(node))
+ switch (nodeType)
{
case DTM.TEXT_NODE :
- dtm.dispatchCharactersEvents(node, m_rth, false);
+ dtm.dispatchCharactersEvents(node, rth, false);
break;
case DTM.DOCUMENT_FRAGMENT_NODE :
case DTM.DOCUMENT_NODE :
@@ -134,43 +216,42 @@
if (shouldCloneAttributes)
{
- m_rth.addAttributes(node);
- m_rth.processNSDecls(node);
+ rth.addAttributes(node);
+ rth.processNSDecls(node, nodeType, dtm);
}
String ns = dtm.getNamespaceURI(node);
String localName = dtm.getLocalName(node);
- m_rth.startElement(ns, localName, dtm.getNodeNameX(node), null);
+ rth.startElement(ns, localName, dtm.getNodeNameX(node), null);
}
break;
case DTM.CDATA_SECTION_NODE :
- m_rth.startCDATA();
- dtm.dispatchCharactersEvents(node, m_rth, false);
- m_rth.endCDATA();
+ rth.startCDATA();
+ dtm.dispatchCharactersEvents(node, rth, false);
+ rth.endCDATA();
break;
case DTM.ATTRIBUTE_NODE :
- m_rth.addAttribute(node);
+ rth.addAttribute(node);
break;
case DTM.COMMENT_NODE :
XMLString xstr = dtm.getStringValue (node);
- xstr.dispatchAsComment(m_rth);
+ xstr.dispatchAsComment(rth);
break;
case DTM.ENTITY_REFERENCE_NODE :
- m_rth.entityReference(dtm.getNodeNameX(node));
+ rth.entityReference(dtm.getNodeNameX(node));
break;
case DTM.PROCESSING_INSTRUCTION_NODE :
{
// %REVIEW% Is the node name the same as the "target"?
- m_rth.processingInstruction(dtm.getNodeNameX(node),
+ rth.processingInstruction(dtm.getNodeNameX(node),
dtm.getNodeValue(node));
}
break;
default :
//"Can not create item in result tree: "+node.getNodeName());
- m_transformer.getMsgMgr().error(null,
- XSLTErrorResources.ER_CANT_CREATE_ITEM,
- new Object[]{ dtm.getNodeName(node) });
+ throw new TransformerException(
+ "Can't clone node: "+dtm.getNodeName(node));
}
}
catch(org.xml.sax.SAXException se)
1.9.2.5 +2 -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.4
retrieving revision 1.9.2.5
diff -u -r1.9.2.4 -r1.9.2.5
--- KeyIterator.java 2001/05/28 04:07:20 1.9.2.4
+++ KeyIterator.java 2001/06/03 03:24:22 1.9.2.5
@@ -137,7 +137,8 @@
super(nscontext);
- initContext(xctxt);
+ int current = xctxt.getCurrentNode();
+ setRoot(current, xctxt);
m_name = name;
m_keyDeclarations = keyDeclarations;
1.1.2.3 +198 -100
xml-xalan/java/src/org/apache/xalan/transformer/TransformSnapshotImpl.java
Index: TransformSnapshotImpl.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/TransformSnapshotImpl.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- TransformSnapshotImpl.java 2001/05/27 03:05:14 1.1.2.2
+++ TransformSnapshotImpl.java 2001/06/03 03:24:22 1.1.2.3
@@ -1,3 +1,59 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xalan" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact [EMAIL PROTECTED]
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999, Lotus
+ * Development Corporation., http://www.lotus.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
package org.apache.xalan.transformer;
import org.apache.xpath.XPathContext;
@@ -6,37 +62,43 @@
import org.apache.xml.utils.NodeVector;
import org.apache.xml.utils.BoolStack;
import org.apache.xml.dtm.DTMIterator;
+
import java.util.Stack;
+
import org.xml.sax.helpers.NamespaceSupport;
+
import java.util.Enumeration;
/**
- * This class holds a "snapshot" of it's current transformer state,
+ * This class holds a "snapshot" of it's current transformer state,
* which can later be restored.
- *
- * This only saves state which can change over the course of the
side-effect-free
+ *
+ * This only saves state which can change over the course of the
side-effect-free
* (i.e. no extensions that call setURIResolver, etc.).
*/
class TransformSnapshotImpl implements TransformSnapshot
{
+
/**
* The stack of Variable stack frames.
*/
private VariableStack m_variableStacks;
-
- /** The stack of <a
href="http://www.w3.org/TR/xslt#dt-current-node">current node</a> objects.
- * Not to be confused with the current node list. */
- private NodeVector m_currentNodes;
-
- /** A stack of the current sub-expression nodes. */
- private NodeVector m_currentExpressionNodes;
/**
+ * The stack of <a
href="http://www.w3.org/TR/xslt#dt-current-node">current node</a> objects.
+ * Not to be confused with the current node list.
+ */
+ private int[] m_currentNodes;
+
+ /** A stack of the current sub-expression nodes. */
+ private int[] m_currentExpressionNodes;
+
+ /**
* The current context node lists stack.
*/
private Stack m_contextNodeLists;
-
- /**
+
+ /**
* The current context node list.
*/
private ContextNodeList m_contextNodeList;
@@ -51,26 +113,32 @@
*/
private BoolStack m_currentTemplateRuleIsNull = new BoolStack();
- /** A node vector used as a stack to track the current
- * ElemTemplateElement. Needed for the
- * org.apache.xalan.transformer.TransformState interface,
- * so a tool can discover the calling template. */
+ /**
+ * A node vector used as a stack to track the current
+ * ElemTemplateElement. Needed for the
+ * org.apache.xalan.transformer.TransformState interface,
+ * so a tool can discover the calling template.
+ */
private NodeVector m_currentTemplateElements = new NodeVector(64);
- /** A node vector used as a stack to track the current
- * ElemTemplate that was matched, as well as the node that
- * was matched. Needed for the
- * org.apache.xalan.transformer.TransformState interface,
- * so a tool can discover the matched template, and matched
- * node. */
+ /**
+ * A node vector used as a stack to track the current
+ * ElemTemplate that was matched, as well as the node that
+ * was matched. Needed for the
+ * org.apache.xalan.transformer.TransformState interface,
+ * so a tool can discover the matched template, and matched
+ * node.
+ */
private Stack m_currentMatchTemplates = new Stack();
- /** A node vector used as a stack to track the current
- * ElemTemplate that was matched, as well as the node that
- * was matched. Needed for the
- * org.apache.xalan.transformer.TransformState interface,
- * so a tool can discover the matched template, and matched
- * node. */
+ /**
+ * A node vector used as a stack to track the current
+ * ElemTemplate that was matched, as well as the node that
+ * was matched. Needed for the
+ * org.apache.xalan.transformer.TransformState interface,
+ * so a tool can discover the matched template, and matched
+ * node.
+ */
private NodeVector m_currentMatchNodes = new NodeVector();
/**
@@ -84,8 +152,8 @@
* attribute sets.
*/
private Stack m_attrSetStack = null;
-
- /** Indicate whether a namespace context was pushed */
+
+ /** Indicate whether a namespace context was pushed */
boolean m_nsContextPushed;
/**
@@ -93,111 +161,141 @@
*/
private NamespaceSupport m_nsSupport;
- /** The number of events queued */
+ /** The number of events queued */
int m_eventCount;
-
- /** Queued start document */
- QueuedStartDocument m_startDoc;
- /** Queued start element */
+ /** Queued start element */
QueuedStartElement m_startElement;
-
+
+ /**
+ * Constructor TransformSnapshotImpl
+ *
+ *
+ * NEEDSDOC @param transformer
+ */
TransformSnapshotImpl(TransformerImpl transformer)
{
+
try
{
+
// Are all these clones deep enough?
-
ResultTreeHandler rtf = transformer.getResultTreeHandler();
-
- m_startElement = (QueuedStartElement)rtf.m_startElement.clone();
- m_startDoc = (QueuedStartDocument)rtf.m_startDoc.clone();
+
m_eventCount = rtf.m_eventCount;
-
+
// yuck. No clone. Hope this is good enough.
m_nsSupport = new NamespaceSupport();
+
Enumeration prefixes = rtf.m_nsSupport.getPrefixes();
- while(prefixes.hasMoreElements())
+
+ while (prefixes.hasMoreElements())
{
- String prefix = (String)prefixes.nextElement();
+ String prefix = (String) prefixes.nextElement();
String uri = rtf.m_nsSupport.getURI(prefix);
+
m_nsSupport.declarePrefix(prefix, uri);
}
-
+
m_nsContextPushed = rtf.m_nsContextPushed;
-
+
XPathContext xpc = transformer.getXPathContext();
-
- m_variableStacks = (VariableStack)xpc.getVarStack().clone();
- m_currentNodes = (NodeVector)xpc.getCurrentNodeStack().clone();
- m_currentExpressionNodes =
(NodeVector)xpc.getCurrentExpressionNodeStack().clone();
- m_contextNodeLists = (Stack)xpc.getContextNodeListsStack().clone();
- if (!m_contextNodeLists.empty())
- m_contextNodeList =
(ContextNodeList)xpc.getContextNodeList().clone();
- m_axesIteratorStack = (Stack)xpc.getAxesIteratorStackStacks().clone();
-
- m_currentTemplateRuleIsNull =
(BoolStack)transformer.m_currentTemplateRuleIsNull.clone();
- m_currentTemplateElements =
(NodeVector)transformer.m_currentTemplateElements.clone();
- m_currentMatchTemplates =
(Stack)transformer.m_currentMatchTemplates.clone();
- m_currentMatchNodes =
(NodeVector)transformer.m_currentMatchedNodes.clone();
- m_countersTable =
(CountersTable)transformer.getCountersTable().clone();
- if (transformer.m_attrSetStack != null)
- m_attrSetStack =
(Stack)transformer.m_attrSetStack.clone();
+
+ m_variableStacks = (VariableStack) xpc.getVarStack().clone();
+ m_currentNodes = (int[]) xpc.getCurrentNodeStack().clone();
+ m_currentExpressionNodes =
+ (int[]) xpc.getCurrentExpressionNodeStack().clone();
+ m_contextNodeLists = (Stack) xpc.getContextNodeListsStack().clone();
+
+ if (!m_contextNodeLists.empty())
+ m_contextNodeList =
+ (ContextNodeList) xpc.getContextNodeList().clone();
+
+ m_axesIteratorStack = (Stack) xpc.getAxesIteratorStackStacks().clone();
+ m_currentTemplateRuleIsNull =
+ (BoolStack) transformer.m_currentTemplateRuleIsNull.clone();
+ m_currentTemplateElements =
+ (NodeVector) transformer.m_currentTemplateElements.clone();
+ m_currentMatchTemplates =
+ (Stack) transformer.m_currentMatchTemplates.clone();
+ m_currentMatchNodes =
+ (NodeVector) transformer.m_currentMatchedNodes.clone();
+ m_countersTable =
+ (CountersTable) transformer.getCountersTable().clone();
+
+ if (transformer.m_attrSetStack != null)
+ m_attrSetStack = (Stack) transformer.m_attrSetStack.clone();
}
- catch(CloneNotSupportedException cnse)
+ catch (CloneNotSupportedException cnse)
{
throw new org.apache.xml.utils.WrappedRuntimeException(cnse);
}
}
-
+
+ /**
+ * NEEDSDOC Method apply
+ *
+ *
+ * NEEDSDOC @param transformer
+ */
void apply(TransformerImpl transformer)
{
+
try
{
- // Are all these clones deep enough?
+ // Are all these clones deep enough?
ResultTreeHandler rtf = transformer.getResultTreeHandler();
-
+
if (rtf != null)
- {
- rtf.m_startElement =
(QueuedStartElement)m_startElement.clone();
- rtf.m_startDoc =
(QueuedStartDocument)m_startDoc.clone();
- rtf.m_eventCount = 1; //1 for start document
event! m_eventCount;
-
- // yuck. No clone. Hope this is good enough.
- rtf.m_nsSupport = new NamespaceSupport();
- Enumeration prefixes =
m_nsSupport.getPrefixes();
- while(prefixes.hasMoreElements())
- {
- String prefix =
(String)prefixes.nextElement();
- String uri = m_nsSupport.getURI(prefix);
- rtf.m_nsSupport.declarePrefix(prefix,
uri);
- }
-
- rtf.m_nsContextPushed = m_nsContextPushed;
- }
+ {
+ rtf.m_eventCount = 1; //1 for start document event! m_eventCount;
+
+ // yuck. No clone. Hope this is good enough.
+ rtf.m_nsSupport = new NamespaceSupport();
+
+ Enumeration prefixes = m_nsSupport.getPrefixes();
+
+ while (prefixes.hasMoreElements())
+ {
+ String prefix = (String) prefixes.nextElement();
+ String uri = m_nsSupport.getURI(prefix);
+
+ rtf.m_nsSupport.declarePrefix(prefix, uri);
+ }
+
+ rtf.m_nsContextPushed = m_nsContextPushed;
+ }
+
XPathContext xpc = transformer.getXPathContext();
-
- xpc.setVarStack((VariableStack)m_variableStacks.clone());
- xpc.setCurrentNodeStack((NodeVector)m_currentNodes.clone());
-
xpc.setCurrentExpressionNodeStack((NodeVector)m_currentExpressionNodes.clone());
- xpc.setContextNodeListsStack((Stack)m_contextNodeLists.clone());
- if (m_contextNodeList != null)
-
xpc.pushContextNodeList((DTMIterator)m_contextNodeList.clone());
- xpc.setAxesIteratorStackStacks((Stack)m_axesIteratorStack.clone());
-
- transformer.m_currentTemplateRuleIsNull =
(BoolStack)m_currentTemplateRuleIsNull.clone();
- transformer.m_currentTemplateElements =
(Stack)m_currentTemplateElements.clone();
- transformer.m_currentMatchTemplates =
(Stack)m_currentMatchTemplates.clone();
- transformer.m_currentMatchedNodes =
(NodeVector)m_currentMatchNodes.clone();
- transformer.m_countersTable = (CountersTable)m_countersTable.clone();
- if (m_attrSetStack != null)
- transformer.m_attrSetStack =
(Stack)m_attrSetStack.clone();
+
+ xpc.setVarStack((VariableStack) m_variableStacks.clone());
+ xpc.setCurrentNodeStack((int[]) m_currentNodes.clone());
+ xpc.setCurrentExpressionNodeStack(
+ (int[]) m_currentExpressionNodes.clone());
+ xpc.setContextNodeListsStack((Stack) m_contextNodeLists.clone());
+
+ if (m_contextNodeList != null)
+ xpc.pushContextNodeList((DTMIterator) m_contextNodeList.clone());
+
+ xpc.setAxesIteratorStackStacks((Stack) m_axesIteratorStack.clone());
+
+ transformer.m_currentTemplateRuleIsNull =
+ (BoolStack) m_currentTemplateRuleIsNull.clone();
+ transformer.m_currentTemplateElements =
+ (Stack) m_currentTemplateElements.clone();
+ transformer.m_currentMatchTemplates =
+ (Stack) m_currentMatchTemplates.clone();
+ transformer.m_currentMatchedNodes =
+ (NodeVector) m_currentMatchNodes.clone();
+ transformer.m_countersTable = (CountersTable) m_countersTable.clone();
+
+ if (m_attrSetStack != null)
+ transformer.m_attrSetStack = (Stack) m_attrSetStack.clone();
}
- catch(CloneNotSupportedException cnse)
+ catch (CloneNotSupportedException cnse)
{
throw new org.apache.xml.utils.WrappedRuntimeException(cnse);
}
}
}
-
1.90.2.17 +2 -1
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.16
retrieving revision 1.90.2.17
diff -u -r1.90.2.16 -r1.90.2.17
--- TransformerImpl.java 2001/05/30 20:30:54 1.90.2.16
+++ TransformerImpl.java 2001/06/03 03:24:22 1.90.2.17
@@ -2072,7 +2072,8 @@
{
case DTM.CDATA_SECTION_NODE :
case DTM.TEXT_NODE :
- m_resultTreeHandler.m_cloner.cloneToResultTree(child, false);
+ ClonerToResultTree.cloneToResultTree(child, nodeType,
+ dtm, getResultTreeHandler(), false);
break;
case DTM.ATTRIBUTE_NODE :
dtm.dispatchCharactersEvents(child, getResultTreeHandler(), false);
No revision
No revision
1.1.2.5 +1 -1
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.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- DTMManagerDefault.java 2001/06/01 23:46:31 1.1.2.4
+++ DTMManagerDefault.java 2001/06/03 03:24:23 1.1.2.5
@@ -221,7 +221,7 @@
if (haveXercesParser)
incremental = true; // No matter what. %REVIEW%
- if (true && incremental)
+ if (false && incremental)
{
// Create a CoroutineManager to manage the coordination between
the
No revision
No revision
1.14.2.4 +30 -0 xml-xalan/java/src/org/apache/xpath/Expression.java
Index: Expression.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/Expression.java,v
retrieving revision 1.14.2.3
retrieving revision 1.14.2.4
diff -u -r1.14.2.3 -r1.14.2.4
--- Expression.java 2001/05/30 20:31:14 1.14.2.3
+++ Expression.java 2001/06/03 03:24:23 1.14.2.4
@@ -69,6 +69,8 @@
import javax.xml.transform.TransformerException;
import org.apache.xml.utils.SAXSourceLocator;
+import org.apache.xml.utils.PrefixResolver;
+import org.apache.xml.dtm.DTMIterator;
import javax.xml.transform.SourceLocator;
import javax.xml.transform.ErrorListener;
@@ -170,6 +172,34 @@
throws javax.xml.transform.TransformerException
{
return execute(xctxt).nodeset().nextNode();
+ }
+
+ /**
+ * <meta name="usage" content="experimental"/>
+ * Given an select expression and a context, evaluate the XPath
+ * and return the resulting iterator.
+ *
+ * @param xctxt The execution context.
+ * @param contextNode The node that "." expresses.
+ *
+ * @throws TransformerException thrown if the active ProblemListener
decides
+ * the error condition is severe enough to halt processing.
+ *
+ * @throws javax.xml.transform.TransformerException
+ */
+ public DTMIterator asIterator(
+ XPathContext xctxt, int contextNode)
+ throws javax.xml.transform.TransformerException
+ {
+ try
+ {
+ xctxt.pushCurrentNodeAndExpression(contextNode, contextNode);
+ return execute(xctxt).nodeset();
+ }
+ finally
+ {
+ xctxt.popCurrentNodeAndExpression();
+ }
}
/**
1.10.2.6 +6 -8 xml-xalan/java/src/org/apache/xpath/NodeSet.java
Index: NodeSet.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/NodeSet.java,v
retrieving revision 1.10.2.5
retrieving revision 1.10.2.6
diff -u -r1.10.2.5 -r1.10.2.6
--- NodeSet.java 2001/05/30 20:31:15 1.10.2.5
+++ NodeSet.java 2001/06/03 03:24:23 1.10.2.6
@@ -205,18 +205,16 @@
}
/**
- * The root node of the <code>DTMIterator</code>, as specified when it
- * was created. Note the root node is not the root node of the
- * document tree, but the context node from where the itteration
- * begins.
+ * Initialize the context values for this expression
+ * after it is cloned.
*
- * @param nodeHandle int Handle of the context node.
+ * @param execContext The XPath runtime context for this
+ * transformation.
*/
- public void setRoot(int nodeHandle)
+ public void setRoot(int context, Object environment)
{
- // %TBD%
+ // no-op, I guess... (-sb)
}
-
/**
* Clone this NodeSet.
1.18.2.6 +2 -8 xml-xalan/java/src/org/apache/xpath/XPath.java
Index: XPath.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/XPath.java,v
retrieving revision 1.18.2.5
retrieving revision 1.18.2.6
diff -u -r1.18.2.5 -r1.18.2.6
--- XPath.java 2001/05/29 14:31:32 1.18.2.5
+++ XPath.java 2001/06/03 03:24:23 1.18.2.6
@@ -234,10 +234,7 @@
/**
* <meta name="usage" content="experimental"/>
* Given an expression and a context, evaluate the XPath
- * and call the callback as nodes are found. Only some simple
- * types of expresions right now can call back, so if this
- * method returns null, then the callbacks have been called, otherwise
- * a valid XObject will be returned.
+ * and return the result.
*
* @param xctxt The execution context.
* @param contextNode The node that "." expresses.
@@ -264,10 +261,7 @@
/**
* <meta name="usage" content="experimental"/>
* Given an expression and a context, evaluate the XPath
- * and call the callback as nodes are found. Only some simple
- * types of expresions right now can call back, so if this
- * method returns null, then the callbacks have been called, otherwise
- * a valid XObject will be returned.
+ * and return the result.
*
* @param xctxt The execution context.
* @param contextNode The node that "." expresses.
1.20.2.13 +50 -35 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.12
retrieving revision 1.20.2.13
diff -u -r1.20.2.12 -r1.20.2.13
--- XPathContext.java 2001/05/29 14:31:33 1.20.2.12
+++ XPathContext.java 2001/06/03 03:24:23 1.20.2.13
@@ -78,11 +78,6 @@
import org.apache.xpath.objects.XNodeSet;
import org.apache.xpath.objects.XString;
-// DOM Imports
-//import org.w3c.dom.traversal.NodeIterator;
-//import org.w3c.dom.traversal.TreeWalker;
-//import org.w3c.dom.Node;
-
import org.apache.xalan.extensions.ExpressionContext;
// SAX2 imports
@@ -140,7 +135,7 @@
*/
public DTMManager getDTMManager()
{
- return m_dtmManager;
+ return this;
}
/**
@@ -185,7 +180,7 @@
{
return m_dtmManager.getDTM(nodeHandle);
}
-
+//
/**
* Given a W3C DOM node, try and return a DTM handle.
* Note: calling this may be non-optimal.
@@ -198,8 +193,8 @@
{
return m_dtmManager.getDTMHandleFromNode(node);
}
-
-
+//
+//
/**
* %TBD% Doc
*/
@@ -207,7 +202,7 @@
{
return m_dtmManager.getDTMIdentity(dtm);
}
-
+//
/**
* Creates an empty <code>DocumentFragment</code> object.
* @return A new <code>DocumentFragment handle</code>.
@@ -216,7 +211,7 @@
{
return m_dtmManager.createDocumentFragment();
}
-
+//
/**
* Release a DTM either to a lru pool, or completely remove reference.
* DTMs without system IDs are always hard deleted.
@@ -247,7 +242,7 @@
{
return m_dtmManager.createDTMIterator(xpathCompiler, pos);
}
-
+//
/**
* Create a new <code>DTMIterator</code> based on an XPath
* <a href="http://www.w3.org/TR/xpath#NT-LocationPath>LocationPath</a> or
@@ -266,7 +261,7 @@
{
return m_dtmManager.createDTMIterator(xpathString, presolver);
}
-
+//
/**
* Create a new <code>DTMIterator</code> based only on a whatToShow and
* a DTMFilter. The traversal semantics are defined as the descendant
@@ -300,7 +295,7 @@
public DTMIterator createDTMIterator(int node)
{
DescendantIterator iter = new DescendantIterator();
- iter.initContext(this, node);
+ iter.setRoot(node, this);
return iter;
// return m_dtmManager.createDTMIterator(node);
}
@@ -666,13 +661,20 @@
* (Is this really needed?)
*/
private PrefixResolver m_currentPrefixResolver = null;
+
+ private static final int RECURSIONLIMIT = (1024*4);
/** The stack of <a
href="http://www.w3.org/TR/xslt#dt-current-node">current node</a> objects.
- * Not to be confused with the current node list. */
- private NodeVector m_currentNodes = new NodeVector();
+ * Not to be confused with the current node list. %REVIEW% Note that
there
+ * are no bounds check and resize for this stack, so if it is blown, it's
all
+ * over. */
+ private int m_currentNodes[] = new int[RECURSIONLIMIT];
+ protected int m_currentNodesFirstFree = 0;
+
+// private NodeVector m_currentNodes = new NodeVector();
- public NodeVector getCurrentNodeStack() {return m_currentNodes; }
- public void setCurrentNodeStack(NodeVector nv) { m_currentNodes = nv; }
+ public int[] getCurrentNodeStack() {return m_currentNodes; }
+ public void setCurrentNodeStack(int[] nv) { m_currentNodes = nv; }
/**
* Get the current context node.
@@ -681,7 +683,8 @@
*/
public final int getCurrentNode()
{
- return m_currentNodes.peepOrNull();
+ int i = m_currentNodesFirstFree-1;
+ return (i < 0) ? DTM.NULL : m_currentNodes[i];
}
/**
@@ -692,8 +695,8 @@
*/
public final void pushCurrentNodeAndExpression(int cn, int en)
{
- m_currentNodes.push(cn);
- m_currentExpressionNodes.push(en);
+ m_currentNodes[m_currentNodesFirstFree++] = cn;
+ m_currentExpressionNodes[m_currentExpressionNodesFirstFree++] = cn;
}
/**
@@ -701,8 +704,8 @@
*/
public final void popCurrentNodeAndExpression()
{
- m_currentNodes.popQuick();
- m_currentExpressionNodes.popQuick();
+ m_currentNodesFirstFree--;
+ m_currentExpressionNodesFirstFree--;
}
/**
@@ -711,8 +714,13 @@
* @param n the <a
href="http://www.w3.org/TR/xslt#dt-current-node">current node</a>.
*/
public final void pushCurrentNode(int n)
+ {
+ m_currentNodes[m_currentNodesFirstFree++] = n;
+ }
+
+ public int getCurrentNodeFirstFree()
{
- m_currentNodes.push(n);
+ return m_currentNodesFirstFree;
}
/**
@@ -720,7 +728,7 @@
*/
public final void popCurrentNode()
{
- m_currentNodes.popQuick();
+ m_currentNodesFirstFree--;
}
/**
@@ -779,10 +787,16 @@
private NodeVector m_predicateRoots = new NodeVector();
/** A stack of the current sub-expression nodes. */
- private NodeVector m_currentExpressionNodes = new NodeVector();
-
- public NodeVector getCurrentExpressionNodeStack() { return
m_currentExpressionNodes; }
- public void setCurrentExpressionNodeStack(NodeVector nv) {
m_currentExpressionNodes = nv; }
+ private int m_currentExpressionNodes[] = new int[RECURSIONLIMIT];
+ protected int m_currentExpressionNodesFirstFree = 0;
+
+ public int[] getCurrentExpressionNodeStack() { return
m_currentExpressionNodes; }
+ public void setCurrentExpressionNodeStack(int[] nv) {
m_currentExpressionNodes = nv; }
+ public int getCurrentExpressionNodesFirstFree()
+ {
+ return m_currentExpressionNodesFirstFree;
+ }
+
private IntStack m_predicatePos = new IntStack();
@@ -808,7 +822,8 @@
*/
public final int getCurrentExpressionNode()
{
- return m_currentExpressionNodes.peepOrNull();
+ int i = m_currentExpressionNodesFirstFree-1;
+ return (i < 0) ? DTM.NULL : m_currentExpressionNodes[i];
}
/**
@@ -818,7 +833,7 @@
*/
public final void pushCurrentExpressionNode(int n)
{
- m_currentExpressionNodes.push(n);
+ m_currentExpressionNodes[m_currentExpressionNodesFirstFree++] = n;
}
/**
@@ -826,7 +841,7 @@
*/
public final void popCurrentExpressionNode()
{
- m_currentExpressionNodes.popQuick();
+ m_currentExpressionNodesFirstFree--;
}
/**
@@ -931,7 +946,7 @@
}
}
- XPathExpressionContext expresionContext = new XPathExpressionContext();
+ XPathExpressionContext expressionContext = new XPathExpressionContext();
/**
* The the expression context for extensions for this context.
@@ -940,7 +955,7 @@
*/
public ExpressionContext getExpressionContext()
{
- return expresionContext;
+ return expressionContext;
}
class XPathExpressionContext implements ExpressionContext
@@ -952,7 +967,7 @@
*/
public org.w3c.dom.Node getContextNode()
{
- int context = m_currentNodes.peepOrNull();
+ int context = getCurrentNode();
return getDTM(context).getNode(context);
}
No revision
No revision
1.23.2.6 +3 -4
xml-xalan/java/src/org/apache/xpath/compiler/Compiler.java
Index: Compiler.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xpath/compiler/Compiler.java,v
retrieving revision 1.23.2.5
retrieving revision 1.23.2.6
diff -u -r1.23.2.5 -r1.23.2.6
--- Compiler.java 2001/05/30 20:31:22 1.23.2.5
+++ Compiler.java 2001/06/03 03:24:24 1.23.2.6
@@ -89,6 +89,7 @@
import javax.xml.transform.SourceLocator;
import org.apache.xml.utils.SAXSourceLocator;
import org.apache.xml.dtm.DTMFilter;
+import org.apache.xml.dtm.DTMIterator;
import org.apache.xml.dtm.Axis;
import javax.xml.transform.ErrorListener;
@@ -673,10 +674,8 @@
locPathDepth++;
try
{
- LocPathIterator iter = WalkerFactory.newLocPathIterator(this, opPos);
- if(locPathDepth == 0)
- iter.setIsTopLevel(true);
- return iter;
+ DTMIterator iter = WalkerFactory.newDTMIterator(this, opPos,
(locPathDepth == 0));
+ return (Expression)iter; // cast OK, I guess.
}
finally
{
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]