You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by zo...@apache.org on 2002/10/22 16:52:42 UTC
cvs commit: xml-xalan/java/src/org/apache/xpath/compiler Compiler.java Lexer.java OpMap.java XPathParser.java
zongaro 2002/10/22 07:52:41
Modified: java/src/org/apache/xalan/lib Tag: XSLTC_DTM ExsltMath.java
java/src/org/apache/xalan/processor Tag: XSLTC_DTM
StylesheetHandler.java TransformerFactoryImpl.java
java/src/org/apache/xalan/serialize Tag: XSLTC_DTM
Encodings.java
java/src/org/apache/xalan/templates Tag: XSLTC_DTM
ElemApplyTemplates.java ElemForEach.java
java/src/org/apache/xalan/transformer Tag: XSLTC_DTM
StackGuard.java TransformSnapshotImpl.java
TransformerImpl.java
java/src/org/apache/xalan/xsltc Tag: XSLTC_DTM DOM.java
java/src/org/apache/xalan/xsltc/compiler Tag: XSLTC_DTM
ApplyTemplates.java Constants.java ForEach.java
FunctionCall.java Key.java KeyCall.java
LastCall.java Output.java Param.java Parser.java
PositionCall.java Predicate.java Step.java
XslElement.java
java/src/org/apache/xalan/xsltc/dom Tag: XSLTC_DTM
AbsoluteIterator.java CurrentNodeListIterator.java
DOMAdapter.java DOMImpl.java DupFilterIterator.java
FilterIterator.java FilteredStepIterator.java
KeyIndex.java MatchingIterator.java MultiDOM.java
NodeIteratorBase.java NthIterator.java SAXImpl.java
StepIterator.java UnionIterator.java
java/src/org/apache/xalan/xsltc/runtime Tag: XSLTC_DTM
BasisLibrary.java
java/src/org/apache/xalan/xsltc/trax Tag: XSLTC_DTM
TemplatesImpl.java TransformerFactoryImpl.java
java/src/org/apache/xalan/xsltc/util Tag: XSLTC_DTM
IntegerArray.java
java/src/org/apache/xml/dtm/ref Tag: XSLTC_DTM
DTMAxisIteratorBase.java ExpandedNameTable.java
java/src/org/apache/xml/utils Tag: XSLTC_DTM IntStack.java
IntVector.java
java/src/org/apache/xpath Tag: XSLTC_DTM XPathContext.java
java/src/org/apache/xpath/axes Tag: XSLTC_DTM
DescendantIterator.java UnionPathIterator.java
WalkerFactory.java
java/src/org/apache/xpath/compiler Tag: XSLTC_DTM
Compiler.java Lexer.java OpMap.java
XPathParser.java
Log:
Reflect latest changes from the MAIN branch in the XSLTC_DTM branch.
Revision Changes Path
No revision
No revision
1.2.2.5 +1 -1 xml-xalan/java/src/org/apache/xalan/lib/ExsltMath.java
Index: ExsltMath.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/lib/ExsltMath.java,v
retrieving revision 1.2.2.4
retrieving revision 1.2.2.5
diff -u -r1.2.2.4 -r1.2.2.5
--- ExsltMath.java 26 Sep 2002 13:58:36 -0000 1.2.2.4
+++ ExsltMath.java 22 Oct 2002 14:52:34 -0000 1.2.2.5
@@ -106,7 +106,7 @@
if (nl == null || nl.getLength() == 0)
return Double.NaN;
- double m = Double.MIN_VALUE;
+ double m = - Double.MAX_VALUE;
for (int i = 0; i < nl.getLength(); i++)
{
Node n = nl.item(i);
No revision
No revision
1.50.2.2 +4 -1 xml-xalan/java/src/org/apache/xalan/processor/StylesheetHandler.java
Index: StylesheetHandler.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/processor/StylesheetHandler.java,v
retrieving revision 1.50.2.1
retrieving revision 1.50.2.2
diff -u -r1.50.2.1 -r1.50.2.2
--- StylesheetHandler.java 29 Jul 2002 00:01:17 -0000 1.50.2.1
+++ StylesheetHandler.java 22 Oct 2002 14:52:34 -0000 1.50.2.2
@@ -216,7 +216,10 @@
throws javax.xml.transform.TransformerException
{
ErrorListener handler = m_stylesheetProcessor.getErrorListener();
- return new XPath(str, owningTemplate, this, XPath.MATCH, handler);
+ XPath xpath = new XPath(str, owningTemplate, this, XPath.MATCH, handler);
+ // Visit the expression, registering namespaces for any extension functions it includes.
+ xpath.callVisitors(xpath, new ExpressionVisitor(getStylesheetRoot()));
+ return xpath;
}
/**
1.41.6.2 +6 -17 xml-xalan/java/src/org/apache/xalan/processor/TransformerFactoryImpl.java
Index: TransformerFactoryImpl.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/processor/TransformerFactoryImpl.java,v
retrieving revision 1.41.6.1
retrieving revision 1.41.6.2
diff -u -r1.41.6.1 -r1.41.6.2
--- TransformerFactoryImpl.java 29 Jul 2002 00:01:17 -0000 1.41.6.1
+++ TransformerFactoryImpl.java 22 Oct 2002 14:52:35 -0000 1.41.6.2
@@ -121,16 +121,12 @@
public static String XSLT_PROPERTIES =
"org/apache/xalan/res/XSLTInfo.properties";
- /** Flag tells if the properties file has been loaded to the system */
- private static boolean isInited = false;
-
- /**
+ /**
* Constructor TransformerFactoryImpl
*
*/
public TransformerFactoryImpl()
{
- loadPropertyFileToSystem(XSLT_PROPERTIES);
}
/** a zero length Class array used in loadPropertyFileToSystem() */
@@ -149,16 +145,11 @@
public static final String FEATURE_SOURCE_LOCATION = XalanProperties.SOURCE_LOCATION;
/**
- * Retrieve a propery bundle from a specified file and load it
+ * Retrieve a propery bundle from XSLT_PROPERTIES and load it
* int the System properties.
- *
- * @param file The properties file to be processed.
*/
- private static void loadPropertyFileToSystem(String file)
+ static
{
-
- if (false == isInited)
- {
try
{
InputStream is = null;
@@ -171,7 +162,7 @@
java.lang.reflect.Method getCCL = Thread.class.getMethod("getContextClassLoader", NO_CLASSES);
if (getCCL != null) {
ClassLoader contextClassLoader = (ClassLoader) getCCL.invoke(Thread.currentThread(), NO_OBJS);
- is = contextClassLoader.getResourceAsStream(file); // file should be already fully specified
+ is = contextClassLoader.getResourceAsStream(XSLT_PROPERTIES); // file should be already fully specified
}
}
catch (Exception e) {}
@@ -180,7 +171,7 @@
// NOTE! For the below getResourceAsStream in Sun JDK 1.1.8M
// we apparently must add the leading slash character - I
// don't know why, but if it's not there, we throw an NPE from the below loading
- is = TransformerFactoryImpl.class.getResourceAsStream("/" + file); // file should be already fully specified
+ is = TransformerFactoryImpl.class.getResourceAsStream("/" + XSLT_PROPERTIES); // file should be already fully specified
}
// get a buffered version
@@ -204,7 +195,6 @@
System.setProperties(systemProps);
- isInited = true;
}
catch (Exception ex){}
}
@@ -214,8 +204,7 @@
// In this case the caller is required to have
// the needed attributes already defined.
}
- }
- }
+ }
public javax.xml.transform.Templates processFromNode(Node node)
throws TransformerConfigurationException
No revision
No revision
1.8.10.2 +6 -6 xml-xalan/java/src/org/apache/xalan/serialize/Encodings.java
Index: Encodings.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/serialize/Encodings.java,v
retrieving revision 1.8.10.1
retrieving revision 1.8.10.2
diff -u -r1.8.10.1 -r1.8.10.2
--- Encodings.java 29 Jul 2002 00:01:19 -0000 1.8.10.1
+++ Encodings.java 22 Oct 2002 14:52:35 -0000 1.8.10.2
@@ -385,22 +385,22 @@
EncodingInfo[] ret = new EncodingInfo[totalEntries];
Enumeration keys = props.keys();
for (int i = 0; i < totalEntries; ++i) {
- String mimeName = (String) keys.nextElement();
- String val = props.getProperty(mimeName);
+ String javaName = (String) keys.nextElement();
+ String val = props.getProperty(javaName);
int pos = val.indexOf(' ');
- String javaName;
+ String mimeName;
int lastPrintable;
if (pos < 0)
{
// Maybe report/log this problem?
// "Last printable character not defined for encoding " +
// mimeName + " (" + val + ")" ...
- javaName = val;
+ mimeName = val;
lastPrintable = 0x00FF;
}
else
{
- javaName = val.substring(0, pos);
+ mimeName = val.substring(0, pos);
lastPrintable =
Integer.decode(val.substring(pos).trim()).intValue();
}
No revision
No revision
1.23.2.3 +5 -6 xml-xalan/java/src/org/apache/xalan/templates/ElemApplyTemplates.java
Index: ElemApplyTemplates.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemApplyTemplates.java,v
retrieving revision 1.23.2.2
retrieving revision 1.23.2.3
diff -u -r1.23.2.2 -r1.23.2.3
--- ElemApplyTemplates.java 29 Jul 2002 00:01:19 -0000 1.23.2.2
+++ ElemApplyTemplates.java 22 Oct 2002 14:52:35 -0000 1.23.2.3
@@ -72,6 +72,7 @@
import org.apache.xpath.objects.XObject;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
+import org.apache.xml.utils.IntStack;
/**
* <meta name="usage" content="advanced"/>
@@ -296,12 +297,10 @@
}
xctxt.pushCurrentNode(DTM.NULL);
- int[] currentNodes = xctxt.getCurrentNodeStack();
- int currentNodePos = xctxt.getCurrentNodeFirstFree() - 1;
+ IntStack currentNodes = xctxt.getCurrentNodeStack();
xctxt.pushCurrentExpressionNode(DTM.NULL);
- int[] currentExpressionNodes = xctxt.getCurrentExpressionNodeStack();
- int currentExpressionNodePos = xctxt.getCurrentExpressionNodesFirstFree() - 1;
+ IntStack currentExpressionNodes = xctxt.getCurrentExpressionNodeStack();
xctxt.pushSAXLocatorNull();
xctxt.pushContextNodeList(sourceNodes);
@@ -311,8 +310,8 @@
int child;
while (DTM.NULL != (child = sourceNodes.nextNode()))
{
- currentNodes[currentNodePos] = child;
- currentExpressionNodes[currentExpressionNodePos] = child;
+ currentNodes.setTop(child);
+ currentExpressionNodes.setTop(child);
if(xctxt.getDTM(child) != dtm)
{
1.28.2.2 +5 -7 xml-xalan/java/src/org/apache/xalan/templates/ElemForEach.java
Index: ElemForEach.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemForEach.java,v
retrieving revision 1.28.2.1
retrieving revision 1.28.2.2
diff -u -r1.28.2.1 -r1.28.2.2
--- ElemForEach.java 29 Jul 2002 00:01:19 -0000 1.28.2.1
+++ ElemForEach.java 22 Oct 2002 14:52:35 -0000 1.28.2.2
@@ -75,6 +75,7 @@
import java.util.Vector;
import org.apache.xml.utils.QName;
+import org.apache.xml.utils.IntStack;
import org.apache.xml.utils.PrefixResolver;
import org.apache.xalan.res.XSLTErrorResources;
import org.apache.xalan.transformer.TransformerImpl;
@@ -393,14 +394,11 @@
xctxt.pushCurrentNode(DTM.NULL);
- int[] currentNodes = xctxt.getCurrentNodeStack();
- int currentNodePos = xctxt.getCurrentNodeFirstFree() - 1;
+ IntStack currentNodes = xctxt.getCurrentNodeStack();
xctxt.pushCurrentExpressionNode(DTM.NULL);
- int[] currentExpressionNodes = xctxt.getCurrentExpressionNodeStack();
- int currentExpressionNodePos =
- xctxt.getCurrentExpressionNodesFirstFree() - 1;
+ IntStack currentExpressionNodes = xctxt.getCurrentExpressionNodeStack();
xctxt.pushSAXLocatorNull();
xctxt.pushContextNodeList(sourceNodes);
@@ -414,8 +412,8 @@
while (DTM.NULL != (child = sourceNodes.nextNode()))
{
- currentNodes[currentNodePos] = child;
- currentExpressionNodes[currentExpressionNodePos] = child;
+ currentNodes.setTop(child);
+ currentExpressionNodes.setTop(child);
if ((child & DTMManager.IDENT_DTM_DEFAULT) != docID)
{
No revision
No revision
1.6.12.2 +5 -4 xml-xalan/java/src/org/apache/xalan/transformer/StackGuard.java
Index: StackGuard.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/StackGuard.java,v
retrieving revision 1.6.12.1
retrieving revision 1.6.12.2
diff -u -r1.6.12.1 -r1.6.12.2
--- StackGuard.java 29 Jul 2002 00:01:20 -0000 1.6.12.1
+++ StackGuard.java 22 Oct 2002 14:52:35 -0000 1.6.12.2
@@ -64,6 +64,7 @@
import org.apache.xalan.templates.Constants;
import org.apache.xalan.templates.ElemTemplate;
import org.apache.xalan.templates.ElemTemplateElement;
+import org.apache.xml.utils.ObjectStack;
/**
* Class to guard against recursion getting too deep.
@@ -140,11 +141,11 @@
*/
public int countLikeTemplates(ElemTemplate templ, int pos)
{
- ElemTemplateElement[] elems = m_transformer.getCurrentTemplateElements();
+ ObjectStack elems = m_transformer.getCurrentTemplateElements();
int count = 1;
for (int i = pos-1; i >= 0; i--)
{
- if(elems[i] == templ)
+ if((ElemTemplateElement)elems.elementAt(i) == templ)
count++;
}
@@ -161,10 +162,10 @@
*/
private ElemTemplate getNextMatchOrNamedTemplate(int pos)
{
- ElemTemplateElement[] elems = m_transformer.getCurrentTemplateElements();
+ ObjectStack elems = m_transformer.getCurrentTemplateElements();
for (int i = pos; i >= 0; i--)
{
- ElemTemplateElement elem = elems[i];
+ ElemTemplateElement elem = (ElemTemplateElement) elems.elementAt(i);
if(null != elem)
{
if(elem.getXSLToken() == Constants.ELEMNAME_TEMPLATE)
1.6.10.1 +12 -9 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.6
retrieving revision 1.6.10.1
diff -u -r1.6 -r1.6.10.1
--- TransformSnapshotImpl.java 3 Aug 2001 17:06:05 -0000 1.6
+++ TransformSnapshotImpl.java 22 Oct 2002 14:52:35 -0000 1.6.10.1
@@ -60,14 +60,17 @@
import org.apache.xpath.VariableStack;
import org.apache.xpath.axes.ContextNodeList;
import org.apache.xml.utils.NodeVector;
+import org.apache.xml.utils.IntStack;
import org.apache.xml.utils.BoolStack;
import org.apache.xml.dtm.DTMIterator;
import org.apache.xalan.templates.ElemTemplateElement;
import java.util.Stack;
+
import org.xml.sax.helpers.NamespaceSupport;
import org.apache.xml.utils.NamespaceSupport2;
+import org.apache.xml.utils.ObjectStack;
import java.util.Enumeration;
@@ -90,10 +93,10 @@
* 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;
+ private IntStack m_currentNodes;
/** A stack of the current sub-expression nodes. */
- private int[] m_currentExpressionNodes;
+ private IntStack m_currentExpressionNodes;
/**
* The current context node lists stack.
@@ -121,7 +124,7 @@
* org.apache.xalan.transformer.TransformState interface,
* so a tool can discover the calling template.
*/
- private ElemTemplateElement[] m_currentTemplateElements;
+ private ObjectStack m_currentTemplateElements;
/**
* A node vector used as a stack to track the current
@@ -201,9 +204,9 @@
XPathContext xpc = transformer.getXPathContext();
m_variableStacks = (VariableStack) xpc.getVarStack().clone();
- m_currentNodes = (int[]) xpc.getCurrentNodeStack().clone();
+ m_currentNodes = (IntStack) xpc.getCurrentNodeStack().clone();
m_currentExpressionNodes =
- (int[]) xpc.getCurrentExpressionNodeStack().clone();
+ (IntStack) xpc.getCurrentExpressionNodeStack().clone();
m_contextNodeLists = (Stack) xpc.getContextNodeListsStack().clone();
if (!m_contextNodeLists.empty())
@@ -214,7 +217,7 @@
m_currentTemplateRuleIsNull =
(BoolStack) transformer.m_currentTemplateRuleIsNull.clone();
m_currentTemplateElements =
- (ElemTemplateElement[]) transformer.m_currentTemplateElements.clone();
+ (ObjectStack) transformer.m_currentTemplateElements.clone();
m_currentMatchTemplates =
(Stack) transformer.m_currentMatchTemplates.clone();
m_currentMatchNodes =
@@ -269,9 +272,9 @@
XPathContext xpc = transformer.getXPathContext();
xpc.setVarStack((VariableStack) m_variableStacks.clone());
- xpc.setCurrentNodeStack((int[]) m_currentNodes.clone());
+ xpc.setCurrentNodeStack((IntStack) m_currentNodes.clone());
xpc.setCurrentExpressionNodeStack(
- (int[]) m_currentExpressionNodes.clone());
+ (IntStack) m_currentExpressionNodes.clone());
xpc.setContextNodeListsStack((Stack) m_contextNodeLists.clone());
if (m_contextNodeList != null)
@@ -282,7 +285,7 @@
transformer.m_currentTemplateRuleIsNull =
(BoolStack) m_currentTemplateRuleIsNull.clone();
transformer.m_currentTemplateElements =
- (ElemTemplateElement[]) m_currentTemplateElements.clone();
+ (ObjectStack) m_currentTemplateElements.clone();
transformer.m_currentMatchTemplates =
(Stack) m_currentMatchTemplates.clone();
transformer.m_currentMatchedNodes =
1.131.2.3 +30 -30 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.131.2.2
retrieving revision 1.131.2.3
diff -u -r1.131.2.2 -r1.131.2.3
--- TransformerImpl.java 14 Sep 2002 10:53:24 -0000 1.131.2.2
+++ TransformerImpl.java 22 Oct 2002 14:52:35 -0000 1.131.2.3
@@ -110,6 +110,7 @@
import org.apache.xml.utils.DOMBuilder;
import org.apache.xml.utils.NodeVector;
import org.apache.xml.utils.ObjectPool;
+import org.apache.xml.utils.ObjectStack;
import org.apache.xml.utils.QName;
import org.apache.xml.utils.SAXSourceLocator;
import org.apache.xml.utils.WrappedRuntimeException;
@@ -238,11 +239,11 @@
* so a tool can discover the calling template. Note the use of an array
* for this limits the recursion depth to 4K.
*/
- ElemTemplateElement[] m_currentTemplateElements
- = new ElemTemplateElement[XPathContext.RECURSIONLIMIT];
+ ObjectStack m_currentTemplateElements
+ = new ObjectStack(XPathContext.RECURSIONLIMIT);
/** The top of the currentTemplateElements stack. */
- int m_currentTemplateElementsTop = 0;
+ //int m_currentTemplateElementsTop = 0;
/**
* A node vector used as a stack to track the current
@@ -496,13 +497,7 @@
resetUserParameters();
- int n = m_currentTemplateElements.length;
- for (int i = 0; i < n; i++)
- {
- m_currentTemplateElements[i] = null;
- }
- m_currentTemplateElementsTop = 0;
-
+ m_currentTemplateElements.removeAllElements();
m_currentMatchTemplates.removeAllElements();
m_currentMatchedNodes.removeAllElements();
@@ -2021,11 +2016,12 @@
DTM dtm = m_xcontext.getDTM(child);
short nodeType = dtm.getNodeType(child);
boolean isDefaultTextRule = false;
+ boolean isApplyImports = false;
if (null == template)
{
int maxImportLevel, endImportLevel=0;
- boolean isApplyImports = ((xslInstruction == null)
+ isApplyImports = ((xslInstruction == null)
? false
: xslInstruction.getXSLToken()
== Constants.ELEMNAME_APPLY_IMPORTS);
@@ -2115,8 +2111,10 @@
pushPairCurrentMatched(template, child);
// Fix copy copy29 test.
- DTMIterator cnl = new org.apache.xpath.NodeSetDTM(child, m_xcontext.getDTMManager());
- m_xcontext.pushContextNodeList(cnl);
+ if (!isApplyImports) {
+ DTMIterator cnl = new org.apache.xpath.NodeSetDTM(child, m_xcontext.getDTMManager());
+ m_xcontext.pushContextNodeList(cnl);
+ }
if (isDefaultTextRule)
{
@@ -2165,8 +2163,10 @@
{
m_xcontext.getVarStack().unlink();
m_xcontext.popCurrentNode();
- m_xcontext.popContextNodeList();
- popCurrentMatched();
+ if (!isApplyImports) {
+ m_xcontext.popContextNodeList();
+ popCurrentMatched();
+ }
popElemTemplateElement();
}
@@ -2313,8 +2313,8 @@
XPathContext xctxt = m_xcontext;
xctxt.pushSAXLocatorNull();
- int currentTemplateElementsTop = m_currentTemplateElementsTop;
- m_currentTemplateElementsTop++;
+ int currentTemplateElementsTop = m_currentTemplateElements.size();
+ m_currentTemplateElements.push(null);
try
{
@@ -2327,7 +2327,7 @@
continue;
xctxt.setSAXLocator(t);
- m_currentTemplateElements[currentTemplateElementsTop] = t;
+ m_currentTemplateElements.setElementAt(t,currentTemplateElementsTop);
t.execute(this);
}
}
@@ -2339,7 +2339,7 @@
}
finally
{
- m_currentTemplateElementsTop--;
+ m_currentTemplateElements.pop();
xctxt.popSAXLocator();
}
@@ -2459,10 +2459,10 @@
public Vector getElementCallstack()
{
Vector elems = new Vector();
- int nStackSize = m_currentTemplateElementsTop;
+ int nStackSize = m_currentTemplateElements.size();
for(int i = 0; i < nStackSize; i++)
{
- ElemTemplateElement elem = m_currentTemplateElements[i];
+ ElemTemplateElement elem = (ElemTemplateElement) m_currentTemplateElements.elementAt(i);
if(null != elem)
{
elems.addElement(elem);
@@ -2479,7 +2479,7 @@
*/
public int getCurrentTemplateElementsCount()
{
- return m_currentTemplateElementsTop;
+ return m_currentTemplateElements.size();
}
@@ -2489,7 +2489,7 @@
* @return The number of active elements on
* the currentTemplateElements stack.
*/
- public ElemTemplateElement[] getCurrentTemplateElements()
+ public ObjectStack getCurrentTemplateElements()
{
return m_currentTemplateElements;
}
@@ -2502,7 +2502,7 @@
*/
public void pushElemTemplateElement(ElemTemplateElement elem)
{
- m_currentTemplateElements[m_currentTemplateElementsTop++] = elem;
+ m_currentTemplateElements.push(elem);
}
/**
@@ -2510,7 +2510,7 @@
*/
public void popElemTemplateElement()
{
- m_currentTemplateElementsTop--;
+ m_currentTemplateElements.pop();
}
/**
@@ -2522,7 +2522,7 @@
*/
public void setCurrentElement(ElemTemplateElement e)
{
- m_currentTemplateElements[m_currentTemplateElementsTop-1] = e;
+ m_currentTemplateElements.setTop(e);
}
/**
@@ -2534,8 +2534,8 @@
*/
public ElemTemplateElement getCurrentElement()
{
- return (m_currentTemplateElementsTop > 0) ?
- m_currentTemplateElements[m_currentTemplateElementsTop-1] : null;
+ return (m_currentTemplateElements.size() > 0) ?
+ (ElemTemplateElement) m_currentTemplateElements.peek() : null;
}
/**
@@ -2559,10 +2559,10 @@
public Vector getTemplateCallstack()
{
Vector elems = new Vector();
- int nStackSize = m_currentTemplateElementsTop;
+ int nStackSize = m_currentTemplateElements.size();
for(int i = 0; i < nStackSize; i++)
{
- ElemTemplateElement elem = m_currentTemplateElements[i];
+ ElemTemplateElement elem = (ElemTemplateElement) m_currentTemplateElements.elementAt(i);
if(null != elem && (elem.getXSLToken() != Constants.ELEMNAME_TEMPLATE))
{
elems.addElement(elem);
No revision
No revision
1.9.10.5 +1 -3 xml-xalan/java/src/org/apache/xalan/xsltc/DOM.java
Index: DOM.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/DOM.java,v
retrieving revision 1.9.10.4
retrieving revision 1.9.10.5
diff -u -r1.9.10.4 -r1.9.10.5
--- DOM.java 18 Sep 2002 13:31:52 -0000 1.9.10.4
+++ DOM.java 22 Oct 2002 14:52:36 -0000 1.9.10.5
@@ -120,8 +120,6 @@
public String getLanguage(int node);
public int getSize();
public String getDocumentURI(int node);
- public int getTypedPosition(int type, int node);
- public int getTypedLast(int type, int node);
public void setFilter(StripFilter filter);
public void setupMapping(String[] names, String[] namespaces);
public boolean isElement(final int node);
No revision
No revision
1.12.2.2 +7 -1 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ApplyTemplates.java
Index: ApplyTemplates.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ApplyTemplates.java,v
retrieving revision 1.12.2.1
retrieving revision 1.12.2.2
diff -u -r1.12.2.1 -r1.12.2.2
--- ApplyTemplates.java 29 Jul 2002 00:01:21 -0000 1.12.2.1
+++ ApplyTemplates.java 22 Oct 2002 14:52:36 -0000 1.12.2.2
@@ -103,6 +103,12 @@
if (select.length() > 0) {
_select = parser.parseExpression(this, "select", null);
+
+ // Wrap _select in a ForwardPositionExpr
+ final Expression fpe = new ForwardPositionExpr(_select);
+ _select.setParent(fpe);
+ fpe.setParser(_select.getParser());
+ _select = fpe;
}
if (mode.length() > 0) {
1.19.2.6 +3 -3 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Constants.java
Index: Constants.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Constants.java,v
retrieving revision 1.19.2.5
retrieving revision 1.19.2.6
diff -u -r1.19.2.5 -r1.19.2.6
--- Constants.java 18 Sep 2002 13:31:52 -0000 1.19.2.5
+++ Constants.java 22 Oct 2002 14:52:36 -0000 1.19.2.6
@@ -159,8 +159,8 @@
= "org.apache.xalan.xsltc.dom.SortingIterator";
public static final String SORT_ITERATOR_SIG
= "Lorg.apache.xalan.xsltc.dom.SortingIterator;";
- public static final String REVERSE_ITERATOR
- = "org.apache.xalan.xsltc.dom.ReverseIterator";
+ public static final String FORWARD_POSITION_ITERATOR
+ = "org.apache.xalan.xsltc.dom.ForwardPositionIterator";
public static final String NODE_SORT_RECORD
= "org.apache.xalan.xsltc.dom.NodeSortRecord";
public static final String NODE_SORT_FACTORY
1.12.6.2 +10 -3 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ForEach.java
Index: ForEach.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ForEach.java,v
retrieving revision 1.12.6.1
retrieving revision 1.12.6.2
diff -u -r1.12.6.1 -r1.12.6.2
--- ForEach.java 17 Apr 2002 18:13:41 -0000 1.12.6.1
+++ ForEach.java 22 Oct 2002 14:52:36 -0000 1.12.6.2
@@ -97,8 +97,14 @@
// make sure required attribute(s) have been set
if (_select.isDummy()) {
reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "select");
- return;
}
+ else {
+ // Wrap _select in a ForwardPositionExpr
+ final Expression fpe = new ForwardPositionExpr(_select);
+ _select.setParent(fpe);
+ fpe.setParser(_select.getParser());
+ _select = fpe;
+ }
}
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
@@ -161,7 +167,8 @@
else {
_select.translate(classGen, methodGen);
}
- if (!(_type instanceof ReferenceType)) {
+
+ if (_type instanceof ReferenceType == false) {
_select.startResetIterator(classGen, methodGen);
}
}
1.14.2.5 +126 -151 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FunctionCall.java
Index: FunctionCall.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FunctionCall.java,v
retrieving revision 1.14.2.4
retrieving revision 1.14.2.5
diff -u -r1.14.2.4 -r1.14.2.5
--- FunctionCall.java 27 Sep 2002 21:54:38 -0000 1.14.2.4
+++ FunctionCall.java 22 Oct 2002 14:52:36 -0000 1.14.2.5
@@ -310,34 +310,28 @@
}
public String getClassNameFromUri(String uri)
- {
-
+ {
String className = (String)_extensionNamespaceTable.get(uri);
if (className != null)
- return className;
- else
- {
- if (uri.startsWith(JAVA_EXT_XSLTC))
- {
- int length = JAVA_EXT_XSLTC.length() + 1;
- return (uri.length() > length) ? uri.substring(length) : EMPTYSTRING;
- }
- else if (uri.startsWith(JAVA_EXT_XALAN))
- {
- int length = JAVA_EXT_XALAN.length() + 1;
- return (uri.length() > length) ? uri.substring(length) : EMPTYSTRING;
- }
- else if (uri.startsWith(JAVA_EXT_XALAN_OLD))
- {
- int length = JAVA_EXT_XALAN_OLD.length() + 1;
- return (uri.length() > length) ? uri.substring(length) : EMPTYSTRING;
- }
- else
- {
- int index = uri.lastIndexOf('/');
- return (index > 0) ? uri.substring(index+1) : uri;
- }
+ return className;
+ else {
+ if (uri.startsWith(JAVA_EXT_XSLTC)) {
+ int length = JAVA_EXT_XSLTC.length() + 1;
+ return (uri.length() > length) ? uri.substring(length) : EMPTYSTRING;
+ }
+ else if (uri.startsWith(JAVA_EXT_XALAN)) {
+ int length = JAVA_EXT_XALAN.length() + 1;
+ return (uri.length() > length) ? uri.substring(length) : EMPTYSTRING;
+ }
+ else if (uri.startsWith(JAVA_EXT_XALAN_OLD)) {
+ int length = JAVA_EXT_XALAN_OLD.length() + 1;
+ return (uri.length() > length) ? uri.substring(length) : EMPTYSTRING;
+ }
+ else {
+ int index = uri.lastIndexOf('/');
+ return (index > 0) ? uri.substring(index+1) : uri;
+ }
}
}
@@ -348,85 +342,74 @@
public Type typeCheck(SymbolTable stable)
throws TypeCheckError
{
- if (_type != null) return _type;
+ if (_type != null) return _type;
- final String namespace = _fname.getNamespace();
- String local = _fname.getLocalPart();
+ final String namespace = _fname.getNamespace();
+ String local = _fname.getLocalPart();
- if (isExtension()) {
+ if (isExtension()) {
_fname = new QName(null, null, local);
return typeCheckStandard(stable);
- }
- else if (isStandard()) {
+ }
+ else if (isStandard()) {
return typeCheckStandard(stable);
- }
- // Handle extension functions (they all have a namespace)
- else
- {
- try
- {
- _className = getClassNameFromUri(namespace);
+ }
+ // Handle extension functions (they all have a namespace)
+ else {
+ try {
+ _className = getClassNameFromUri(namespace);
final int pos = local.lastIndexOf('.');
- if (pos > 0)
- {
- _isStatic = true;
- if (_className != null && _className.length() > 0)
- {
- _namespace_format = NAMESPACE_FORMAT_PACKAGE;
- _className = _className + "." + local.substring(0, pos);
- }
- else
- {
- _namespace_format = NAMESPACE_FORMAT_JAVA;
- _className = local.substring(0, pos);
- }
+ if (pos > 0) {
+ _isStatic = true;
+ if (_className != null && _className.length() > 0) {
+ _namespace_format = NAMESPACE_FORMAT_PACKAGE;
+ _className = _className + "." + local.substring(0, pos);
+ }
+ else {
+ _namespace_format = NAMESPACE_FORMAT_JAVA;
+ _className = local.substring(0, pos);
+ }
- _fname = new QName(namespace, null, local.substring(pos + 1));
+ _fname = new QName(namespace, null, local.substring(pos + 1));
}
- else
- {
- if (_className != null && _className.length() > 0)
- {
- try
- {
- TransletLoader loader = new TransletLoader();
- _clazz = loader.loadClass(_className);
- _namespace_format = NAMESPACE_FORMAT_CLASS;
- }
- catch (ClassNotFoundException e)
- {
- _namespace_format = NAMESPACE_FORMAT_PACKAGE;
+ else {
+ if (_className != null && _className.length() > 0) {
+ try {
+ TransletLoader loader = new TransletLoader();
+ _clazz = loader.loadClass(_className);
+ _namespace_format = NAMESPACE_FORMAT_CLASS;
+ }
+ catch (ClassNotFoundException e) {
+ _namespace_format = NAMESPACE_FORMAT_PACKAGE;
+ }
}
- }
- else
- _namespace_format = NAMESPACE_FORMAT_JAVA;
+ else
+ _namespace_format = NAMESPACE_FORMAT_JAVA;
- if (local.indexOf('-') > 0)
- {
- local = replaceDash(local);
- }
+ if (local.indexOf('-') > 0) {
+ local = replaceDash(local);
+ }
- String extFunction = (String)_extensionFunctionTable.get(namespace + ":" + local);
- if (extFunction != null) {
- _fname = new QName(null, null, extFunction);
- return typeCheckStandard(stable);
- }
- else
- _fname = new QName(namespace, null, local);
+ String extFunction = (String)_extensionFunctionTable.get(namespace + ":" + local);
+ if (extFunction != null) {
+ _fname = new QName(null, null, extFunction);
+ return typeCheckStandard(stable);
+ }
+ else
+ _fname = new QName(namespace, null, local);
}
return typeCheckExternal(stable);
}
- catch (TypeCheckError e)
- {
- ErrorMsg errorMsg = e.getErrorMsg();
- if (errorMsg == null) {
+ catch (TypeCheckError e) {
+ ErrorMsg errorMsg = e.getErrorMsg();
+ if (errorMsg == null) {
final String name = _fname.getLocalPart();
errorMsg = new ErrorMsg(ErrorMsg.METHOD_NOT_FOUND_ERR, name);
- }
- getParser().reportError(ERROR, errorMsg);
- return _type = Type.Void;
+ }
+ getParser().reportError(ERROR, errorMsg);
+ return _type = Type.Void;
}
}
}
@@ -541,40 +524,37 @@
return typeCheckConstructor(stable);
}
// check if we are calling an instance method
- else
- {
- boolean hasThisArgument = false;
+ else {
+ boolean hasThisArgument = false;
- if (nArgs == 0)
- _isStatic = true;
+ if (nArgs == 0)
+ _isStatic = true;
- if (!_isStatic)
- {
- if (_namespace_format == NAMESPACE_FORMAT_JAVA ||
- _namespace_format == NAMESPACE_FORMAT_PACKAGE)
- hasThisArgument = true;
+ if (!_isStatic) {
+ if (_namespace_format == NAMESPACE_FORMAT_JAVA
+ || _namespace_format == NAMESPACE_FORMAT_PACKAGE)
+ hasThisArgument = true;
Expression firstArg = (Expression)_arguments.elementAt(0);
Type firstArgType = (Type)firstArg.typeCheck(stable);
- if (_namespace_format == NAMESPACE_FORMAT_CLASS &&
- firstArgType instanceof ObjectType &&
- ((ObjectType)firstArgType).getJavaClassName().equals(_className))
- hasThisArgument = true;
+ if (_namespace_format == NAMESPACE_FORMAT_CLASS
+ && firstArgType instanceof ObjectType
+ && _clazz != null
+ && _clazz.isAssignableFrom(((ObjectType)firstArgType).getJavaClass()))
+ hasThisArgument = true;
- if (hasThisArgument)
- {
- _thisArgument = (Expression) _arguments.elementAt(0);
- _arguments.remove(0); nArgs--;
- if (firstArgType instanceof ObjectType) {
- _className = ((ObjectType) firstArgType).getJavaClassName();
- }
- else
- throw new TypeCheckError(ErrorMsg.NO_JAVA_FUNCT_THIS_REF, name);
+ if (hasThisArgument) {
+ _thisArgument = (Expression) _arguments.elementAt(0);
+ _arguments.remove(0); nArgs--;
+ if (firstArgType instanceof ObjectType) {
+ _className = ((ObjectType) firstArgType).getJavaClassName();
+ }
+ else
+ throw new TypeCheckError(ErrorMsg.NO_JAVA_FUNCT_THIS_REF, name);
}
- }
- else if (_className.length() == 0)
- {
+ }
+ else if (_className.length() == 0) {
/*
* Warn user if external function could not be resolved.
* Warning will _NOT_ be issued is the call is properly
@@ -588,7 +568,7 @@
}
unresolvedExternal = true;
return _type = Type.Int; // use "Int" as "unknown"
- }
+ }
}
final Vector methods = findMethods();
@@ -618,28 +598,24 @@
final Type intType = (Type)argsType.elementAt(j);
Object match = _internal2Java.maps(intType, extType);
if (match != null) {
- currMethodDistance +=
- ((JavaType)match).distance;
+ currMethodDistance += ((JavaType)match).distance;
}
else {
// no mapping available
- if (intType instanceof ObjectType)
- {
- ObjectType object = (ObjectType)intType;
- if (extType.getName().equals(object.getJavaClassName()))
- currMethodDistance += 0;
- else if (extType.isAssignableFrom(object.getJavaClass()))
- currMethodDistance += 1;
- else
- {
- currMethodDistance = Integer.MAX_VALUE;
- break;
- }
+ if (intType instanceof ObjectType) {
+ ObjectType object = (ObjectType)intType;
+ if (extType.getName().equals(object.getJavaClassName()))
+ currMethodDistance += 0;
+ else if (extType.isAssignableFrom(object.getJavaClass()))
+ currMethodDistance += 1;
+ else {
+ currMethodDistance = Integer.MAX_VALUE;
+ break;
+ }
}
- else
- {
- currMethodDistance = Integer.MAX_VALUE;
- break;
+ else {
+ currMethodDistance = Integer.MAX_VALUE;
+ break;
}
}
}
@@ -650,13 +626,13 @@
_type = (Type) _java2Internal.get(extType);
if (_type == null) {
- _type = new ObjectType(extType);
+ _type = new ObjectType(extType);
}
// Use this method if all parameters & return type match
if (_type != null && currMethodDistance < bestMethodDistance) {
- _chosenMethod = method;
- bestMethodDistance = currMethodDistance;
+ _chosenMethod = method;
+ bestMethodDistance = currMethodDistance;
}
}
}
@@ -665,14 +641,14 @@
// have a this argument.
if (_chosenMethod != null && _thisArgument == null &&
!Modifier.isStatic(_chosenMethod.getModifiers())) {
- throw new TypeCheckError(ErrorMsg.NO_JAVA_FUNCT_THIS_REF, getMethodSignature(argsType));
+ throw new TypeCheckError(ErrorMsg.NO_JAVA_FUNCT_THIS_REF, getMethodSignature(argsType));
}
if (_type != null) {
- if (_type == Type.NodeSet) {
- getXSLTC().setMultiDocument(true);
- }
- return _type;
+ if (_type == Type.NodeSet) {
+ getXSLTC().setMultiDocument(true);
+ }
+ return _type;
}
throw new TypeCheckError(ErrorMsg.ARGUMENT_CONVERSION_ERR, getMethodSignature(argsType));
@@ -1046,9 +1022,9 @@
int nArgs = argsType.size();
for (int i = 0; i < nArgs; i++) {
- final Type intType = (Type)argsType.elementAt(i);
- buf.append(intType.toString());
- if (i < nArgs - 1) buf.append(", ");
+ final Type intType = (Type)argsType.elementAt(i);
+ buf.append(intType.toString());
+ if (i < nArgs - 1) buf.append(", ");
}
buf.append(')');
@@ -1062,16 +1038,15 @@
*/
protected static String replaceDash(String name)
{
- char dash = '-';
- StringBuffer buff = new StringBuffer("");
- for (int i = 0; i < name.length(); i++)
- {
+ char dash = '-';
+ StringBuffer buff = new StringBuffer("");
+ for (int i = 0; i < name.length(); i++) {
if (i > 0 && name.charAt(i-1) == dash)
- buff.append(Character.toUpperCase(name.charAt(i)));
+ buff.append(Character.toUpperCase(name.charAt(i)));
else if (name.charAt(i) != dash)
- buff.append(name.charAt(i));
- }
- return buff.toString();
+ buff.append(name.charAt(i));
+ }
+ return buff.toString();
}
}
1.10.6.3 +33 -62 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Key.java
Index: Key.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Key.java,v
retrieving revision 1.10.6.2
retrieving revision 1.10.6.3
diff -u -r1.10.6.2 -r1.10.6.3
--- Key.java 29 Jul 2002 00:01:22 -0000 1.10.6.2
+++ Key.java 22 Oct 2002 14:52:36 -0000 1.10.6.3
@@ -57,6 +57,7 @@
* <http://www.apache.org/>.
*
* @author Morten Jorgensen
+ * @author Santiago Pericas-Geertsen
*
*/
@@ -75,10 +76,25 @@
final class Key extends TopLevelElement {
- private QName _name; // The name of this key (ie. index)
- private Pattern _match; // The nodes to generate index keys from
- private Expression _use; // The nodes to include in the key
- private Type _useType; // The data type of the key's contents
+ /**
+ * The name of this key as defined in xsl:key.
+ */
+ private QName _name;
+
+ /**
+ * The pattern to match starting at the root node.
+ */
+ private Pattern _match;
+
+ /**
+ * The expression that generates the values for this key.
+ */
+ private Expression _use;
+
+ /**
+ * The type of the _use expression.
+ */
+ private Type _useType;
/**
* Parse the <xsl:key> element and attributes
@@ -114,30 +130,16 @@
return _name.toString();
}
- /**
- * Run type check on the "use" attribute and make sure it is something
- * we can use to extract some value from nodes.
- * @param stable The stylesheet parser's symbol table
- * @return The data-type of this key (always void)
- * @throws TypeCheckError If the use attribute does not represent a string,
- * a node-set or a number
- */
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
+ // Type check match pattern
_match.typeCheck(stable);
- _useType = _use.typeCheck(stable);
- // Cast node values to string values
- if (_useType instanceof NodeType) {
+ // Cast node values to string values (except for nodesets)
+ _useType = _use.typeCheck(stable);
+ if (_useType instanceof StringType == false &&
+ _useType instanceof NodeSetType == false)
+ {
_use = new CastExpr(_use, Type.String);
- _useType = Type.String;
- }
-
- // If the 'use' attribute is not a string, node-set or number
- if (!(_useType instanceof StringType) &&
- !(_useType instanceof NodeSetType) &&
- !(_useType instanceof RealType)) {
- ErrorMsg err = new ErrorMsg(ErrorMsg.KEY_USE_ATTR_ERR, this);
- throw new TypeCheckError(err);
}
return Type.Void;
@@ -147,8 +149,6 @@
* This method is called if the "use" attribute of the key contains a
* node set. In this case we must traverse all nodes in the set and
* create one entry in this key's index for each node in the set.
- * @param classGen The Java class generator
- * @param methodGen The method generator
*/
public void traverseNodeSet(ClassGenerator classGen,
MethodGenerator methodGen,
@@ -200,7 +200,6 @@
// Prepare to call buildKeyIndex(String name, int node, String value);
il.append(classGen.loadTranslet());
- // il.append(new PUSH(cpg, getName()));
il.append(new PUSH(cpg, _name.toString()));
il.append(new ILOAD(parentNode.getIndex()));
@@ -232,8 +231,6 @@
/**
* Gather all nodes that match the expression in the attribute "match"
* and add one (or more) entries in this key's index.
- * @param classGen The Java class generator
- * @param methodGen The method generator
*/
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
@@ -283,38 +280,19 @@
_match.synthesize(classGen, methodGen); // Leaves 0 or 1 on stack
final BranchHandle skipNode = il.append(new IFEQ(null));
- // If this is just a single node we should convert that to a string
- // and use that string as the value in the index for this key.
- if (_useType instanceof RealType) {
- final int dbl = cpg.addMethodref(DOUBLE_CLASS,"<init>", "(D)V");
-
- il.append(classGen.loadTranslet());
- il.append(DUP);
- il.append(new PUSH(cpg, _name.toString()));
- il.append(DUP_X1);
+ // If this is a node-set we must go through each node in the set
+ if (_useType instanceof NodeSetType) {
+ // Pass current node as parameter (we're indexing on that node)
il.append(methodGen.loadCurrentNode());
- il.append(new NEW(cpg.addClass(DOUBLE_CLASS)));
- il.append(DUP);
- _use.translate(classGen,methodGen);
- il.append(new INVOKESPECIAL(dbl));
- il.append(SWAP);
- il.append(methodGen.loadDOM());
- il.append(SWAP);
- il.append(new INVOKEINTERFACE(getNodeIdent, 2));
- il.append(SWAP);
- il.append(new INVOKEVIRTUAL(key));
-
- il.append(methodGen.loadDOM());
- il.append(new INVOKEVIRTUAL(keyDom));
-
+ traverseNodeSet(classGen, methodGen, key);
}
- else if (_useType instanceof StringType) {
+ else {
il.append(classGen.loadTranslet());
il.append(DUP);
il.append(new PUSH(cpg, _name.toString()));
il.append(DUP_X1);
il.append(methodGen.loadCurrentNode());
- _use.translate(classGen,methodGen);
+ _use.translate(classGen, methodGen);
il.append(SWAP);
il.append(methodGen.loadDOM());
il.append(SWAP);
@@ -324,13 +302,6 @@
il.append(methodGen.loadDOM());
il.append(new INVOKEVIRTUAL(keyDom));
- }
- // If this is a node-set we must go through each node in the set
- // and create one entry in the key index for each node in the set.
- else {
- // Pass current node as parameter (we're indexing on that node)
- il.append(methodGen.loadCurrentNode());
- traverseNodeSet(classGen,methodGen,key);
}
// Get the next node from the iterator and do loop again...
1.7.6.3 +25 -22 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/KeyCall.java
Index: KeyCall.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/KeyCall.java,v
retrieving revision 1.7.6.2
retrieving revision 1.7.6.3
diff -u -r1.7.6.2 -r1.7.6.3
--- KeyCall.java 29 Jul 2002 00:01:22 -0000 1.7.6.2
+++ KeyCall.java 22 Oct 2002 14:52:36 -0000 1.7.6.3
@@ -57,6 +57,7 @@
* <http://www.apache.org/>.
*
* @author Morten Jorgensen
+ * @author Santiago Pericas-Geertsen
*
*/
@@ -70,10 +71,25 @@
final class KeyCall extends FunctionCall {
- private Expression _name; // The name of this key
- private Expression _value; // The value to look up in the key/index
- private Type _valueType; // The value's data type
- private QName _resolvedQName = null;
+ /**
+ * The name of the key.
+ */
+ private Expression _name;
+
+ /**
+ * The value to look up in the key/index.
+ */
+ private Expression _value;
+
+ /**
+ * The value's data type.
+ */
+ private Type _valueType; // The value's data type
+
+ /**
+ * Expanded qname when name is literal.
+ */
+ private QName _resolvedQName = null;
/**
* Get the parameters passed to function:
@@ -138,11 +154,9 @@
// be added to the resulting node-set.
_valueType = _value.typeCheck(stable);
- if ((_valueType != Type.NodeSet) &&
- (_valueType != Type.ResultTree) &&
- (_valueType != Type.String) &&
- (_valueType != Type.Real) &&
- (_valueType != Type.Int)) {
+ if (_valueType != Type.NodeSet && _valueType != Type.ResultTree
+ && _valueType != Type.String)
+ {
_value = new CastExpr(_value, Type.String);
}
@@ -339,18 +353,7 @@
// the iterator should return.
il.append(DUP);
- if (_valueType == Type.Int || _valueType == Type.Real) {
- final int dbl = cpg.addMethodref(DOUBLE_CLASS,"<init>", "(D)V");
- il.append(new NEW(cpg.addClass(DOUBLE_CLASS)));
- il.append(DUP);
- _value.translate(classGen, methodGen);
- if (_valueType == Type.Int)
- il.append(new I2D());
- il.append(new INVOKESPECIAL(dbl));
- }
- else {
- _value.translate(classGen, methodGen);
- }
+ _value.translate(classGen, methodGen);
if (_name == null) {
il.append(new INVOKEVIRTUAL(lookupId));
1.7.6.2 +8 -66 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/LastCall.java
Index: LastCall.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/LastCall.java,v
retrieving revision 1.7.6.1
retrieving revision 1.7.6.2
diff -u -r1.7.6.1 -r1.7.6.2
--- LastCall.java 17 Apr 2002 18:13:41 -0000 1.7.6.1
+++ LastCall.java 22 Oct 2002 14:52:36 -0000 1.7.6.2
@@ -73,17 +73,10 @@
final class LastCall extends FunctionCall {
- private int _type = -1;
-
public LastCall(QName fname) {
super(fname);
}
- public LastCall(QName fname, int type) {
- this(fname);
- _type = type;
- }
-
public boolean hasPositionCall() {
return true;
}
@@ -93,72 +86,21 @@
}
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
-
final InstructionList il = methodGen.getInstructionList();
- final ConstantPoolGen cpg = classGen.getConstantPool();
-
- boolean lastChild = false;
-
- // If we're a part of an pattern's predicate we want to know what
- // type of node we want to be looking for (not just any).
- if (getParent() instanceof Expression) {
- if (getParent().getParent() instanceof Predicate) {
- Predicate pred = (Predicate)getParent().getParent();
- _type = pred.getPosType();
- if ((_type==DTM.ELEMENT_NODE) || (_type==DTM.ATTRIBUTE_NODE)) _type = -1;
- }
- }
-
- // If we're a part of a step-type expression we want the last of the
- // current node's children and not the last in the current iterator.
- if (getParent() instanceof Predicate) {
- _type = ((Predicate)getParent()).getPosType();
- if ((_type==DTM.ELEMENT_NODE) || (_type==DTM.ATTRIBUTE_NODE)) _type = -1;
- if (getParent().getParent() instanceof Step) {
- lastChild = true;
- }
- }
if (methodGen instanceof CompareGenerator) {
il.append(((CompareGenerator)methodGen).loadLastNode());
}
- else if (classGen.isExternal()) {
+ else if (methodGen instanceof TestGenerator) {
il.append(new ILOAD(LAST_INDEX));
}
- else if (_type == -1) {
- final int last = cpg.addInterfaceMethodref(NODE_ITERATOR,
- "getLast",
- "()I");
- final int git = cpg.addInterfaceMethodref(DOM_INTF,
- "getTypedAxisIterator",
- "(II)"+NODE_ITERATOR_SIG);
- final int start = cpg.addInterfaceMethodref(NODE_ITERATOR,
- "setStartNode",
- "(I)"+
- NODE_ITERATOR_SIG);
- if (lastChild) {
- il.append(methodGen.loadDOM());
- il.append(new PUSH(cpg, Axis.CHILD));
- il.append(new PUSH(cpg, DTM.ELEMENT_NODE));
- il.append(new INVOKEINTERFACE(git, 3));
- il.append(methodGen.loadCurrentNode());
- il.append(new INVOKEINTERFACE(start, 2));
- }
- else {
- il.append(methodGen.loadIterator());
- }
- il.append(new INVOKEINTERFACE(last, 1));
- }
else {
- // public int getTypedLast(int type, int node) {
- final int last = cpg.addInterfaceMethodref(DOM_INTF,
- "getTypedLast",
- "(II)I");
- il.append(methodGen.loadDOM());
- il.append(new PUSH(cpg, _type));
- il.append(methodGen.loadContextNode());
- il.append(new INVOKEINTERFACE(last, 3));
-
+ final ConstantPoolGen cpg = classGen.getConstantPool();
+ final int getLast = cpg.addInterfaceMethodref(NODE_ITERATOR,
+ "getLast",
+ "()I");
+ il.append(methodGen.loadIterator());
+ il.append(new INVOKEINTERFACE(getLast, 1));
}
}
}
1.12.6.2 +21 -6 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Output.java
Index: Output.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Output.java,v
retrieving revision 1.12.6.1
retrieving revision 1.12.6.2
diff -u -r1.12.6.1 -r1.12.6.2
--- Output.java 29 Jul 2002 00:01:22 -0000 1.12.6.1
+++ Output.java 22 Oct 2002 14:52:36 -0000 1.12.6.2
@@ -75,6 +75,7 @@
import org.apache.bcel.classfile.JavaClass;
import org.apache.xalan.xsltc.compiler.util.*;
+import org.apache.xalan.xsltc.runtime.output.StreamOutput;
final class Output extends TopLevelElement {
@@ -92,6 +93,7 @@
private String _cdata;
private boolean _indent = false;
private String _mediaType;
+ private String _cdataToMerge;
// Disables this output element (when other element has higher precedence)
private boolean _disabled = false;
@@ -122,6 +124,14 @@
return !_disabled;
}
+ public String getCdata() {
+ return _cdata;
+ }
+
+ public void mergeCdata(String cdata) {
+ _cdataToMerge = cdata;
+ }
+
/**
* Scans the attribute list for the xsl:output instruction
*/
@@ -162,8 +172,10 @@
}
else {
try {
+ // Create a write to verify encoding support
OutputStreamWriter writer =
- new OutputStreamWriter(System.out, _encoding);
+ new OutputStreamWriter(System.out,
+ StreamOutput.getCanonicalEncoding(_encoding));
}
catch (java.io.UnsupportedEncodingException e) {
ErrorMsg msg = new ErrorMsg(ErrorMsg.UNSUPPORTED_ENCODING,
@@ -220,12 +232,15 @@
// Make sure to store names in expanded form
while (tokens.hasMoreTokens()) {
- expandedNames.append(parser.getQName(tokens.nextToken()).toString())
- .append(' ');
+ expandedNames.append(
+ parser.getQName(tokens.nextToken()).toString()).append(' ');
}
_cdata = expandedNames.toString();
-
- outputProperties.setProperty(OutputKeys.CDATA_SECTION_ELEMENTS, _cdata);
+ if (_cdataToMerge != null) {
+ _cdata = _cdata + _cdataToMerge;
+ }
+ outputProperties.setProperty(OutputKeys.CDATA_SECTION_ELEMENTS,
+ _cdata);
}
// Get the indent setting - only has effect for xml and html output
1.19.6.1 +1 -4 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Param.java
Index: Param.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Param.java,v
retrieving revision 1.19
retrieving revision 1.19.6.1
diff -u -r1.19 -r1.19.6.1
--- Param.java 1 Feb 2002 20:07:08 -0000 1.19
+++ Param.java 22 Oct 2002 14:52:36 -0000 1.19.6.1
@@ -149,15 +149,12 @@
* element has a body and no 'select' expression.
*/
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
-
- // Get the type from the select exrepssion...
if (_select != null) {
_type = _select.typeCheck(stable);
if (_type instanceof ReferenceType == false) {
_select = new CastExpr(_select, Type.Reference);
}
}
- // ...or set the type to result tree
else if (hasContents()) {
typeCheckContents(stable);
}
1.39.2.4 +4 -1 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Parser.java
Index: Parser.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Parser.java,v
retrieving revision 1.39.2.3
retrieving revision 1.39.2.4
diff -u -r1.39.2.3 -r1.39.2.4
--- Parser.java 18 Sep 2002 13:31:52 -0000 1.39.2.3
+++ Parser.java 22 Oct 2002 14:52:36 -0000 1.39.2.4
@@ -154,6 +154,8 @@
public void setOutput(Output output) {
if (_output != null) {
if (_output.getImportPrecedence() <= output.getImportPrecedence()) {
+ String cdata = _output.getCdata();
+ output.mergeCdata(cdata);
_output.disable();
_output = output;
}
@@ -1103,6 +1105,7 @@
node.setParser(this);
node.setParent(parent);
node.setLineNumber(line);
+// System.out.println("e = " + text + " " + node);
return node;
}
}
1.8.6.1 +7 -44 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/PositionCall.java
Index: PositionCall.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/PositionCall.java,v
retrieving revision 1.8
retrieving revision 1.8.6.1
diff -u -r1.8 -r1.8.6.1
--- PositionCall.java 1 Feb 2002 20:07:08 -0000 1.8
+++ PositionCall.java 22 Oct 2002 14:52:36 -0000 1.8.6.1
@@ -71,68 +71,31 @@
final class PositionCall extends FunctionCall {
- private int _type = -1;
-
public PositionCall(QName fname) {
super(fname);
}
- public PositionCall(QName fname, int type) {
- this(fname);
- _type = type;
- }
-
public boolean hasPositionCall() {
return true;
}
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
-
final InstructionList il = methodGen.getInstructionList();
- SyntaxTreeNode parent = getParent();
- SyntaxTreeNode granny = parent.getParent();
-
- // If we're a part of an expression's predicate we want to know what
- // type of node we want to be looking for
- if ((parent instanceof Expression) && (granny instanceof Predicate)) {
- _type = ((Predicate)granny).getPosType();
- }
- else {
- while ((granny != null) && !(granny instanceof StepPattern)) {
- parent = granny;
- granny = granny.getParent();
- }
- if ((parent instanceof Predicate) &&
- (granny instanceof StepPattern)){
- _type = ((StepPattern)granny).getNodeType();
- }
- }
-
if (methodGen instanceof CompareGenerator) {
il.append(((CompareGenerator)methodGen).loadCurrentNode());
}
else if (methodGen instanceof TestGenerator) {
il.append(new ILOAD(POSITION_INDEX));
}
- else if (_type == -1) {
- final ConstantPoolGen cpg = classGen.getConstantPool();
- final int getPosition = cpg.addInterfaceMethodref(NODE_ITERATOR,
- "getPosition",
- "()I");
- il.append(methodGen.loadIterator());
- il.append(new INVOKEINTERFACE(getPosition, 1));
- }
else {
final ConstantPoolGen cpg = classGen.getConstantPool();
- // public int getTypedPosition(int type, int node)
- final int pos = cpg.addInterfaceMethodref(DOM_INTF,
- "getTypedPosition",
- "(II)I");
- il.append(methodGen.loadDOM());
- il.append(new PUSH(cpg, _type));
- il.append(methodGen.loadContextNode());
- il.append(new INVOKEINTERFACE(pos, 3));
+ final int index =
+ cpg.addMethodref(BASIS_LIBRARY_CLASS, "positionF",
+ "("+NODE_ITERATOR_SIG+")I");
+
+ il.append(methodGen.loadIterator());
+ il.append(new INVOKESTATIC(index));
}
}
}
1.22.6.4 +2 -2 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Predicate.java
Index: Predicate.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Predicate.java,v
retrieving revision 1.22.6.3
retrieving revision 1.22.6.4
diff -u -r1.22.6.3 -r1.22.6.4
--- Predicate.java 1 Oct 2002 20:58:32 -0000 1.22.6.3
+++ Predicate.java 22 Oct 2002 14:52:36 -0000 1.22.6.4
@@ -250,7 +250,7 @@
(parent instanceof Pattern) ||
(parent instanceof FilterExpr)) {
- if (parent instanceof Pattern) {
+ if (parent instanceof Pattern && !(_exp instanceof LastCall)) {
_nthPositionFilter = _canOptimize;
}
else if (parent instanceof FilterExpr) {
1.30.2.4 +10 -73 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Step.java
Index: Step.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Step.java,v
retrieving revision 1.30.2.3
retrieving revision 1.30.2.4
diff -u -r1.30.2.3 -r1.30.2.4
--- Step.java 17 Sep 2002 21:08:35 -0000 1.30.2.3
+++ Step.java 22 Oct 2002 14:52:36 -0000 1.30.2.4
@@ -151,10 +151,12 @@
* Returns the vector containing all predicates for this step.
*/
public void addPredicates(Vector predicates) {
- if (_predicates == null)
+ if (_predicates == null) {
_predicates = predicates;
- else
+ }
+ else {
_predicates.addAll(predicates);
+ }
}
/**
@@ -215,9 +217,12 @@
// combinations of steps and patterns than can be optimised
_hadPredicates = hasPredicates();
- // Special case for '.'
+ // Special case for '.'
+ // in the case where '.' has a context such as book/.
+ // or .[false()] we can not optimize the nodeset to a single node.
if (isAbbreviatedDot()) {
- _type = (hasParentPattern()) ? Type.NodeSet : Type.Node;
+ _type = (hasParentPattern() || hasPredicates() ) ?
+ Type.NodeSet : Type.Node;
}
else {
_type = Type.NodeSet;
@@ -237,46 +242,6 @@
}
/**
- * This method is used to determine whether the node-set produced by
- * this step must be reversed before returned to the parent element.
- * <xsl:apply-templates> should always return nodes in document order,
- * while others, such as <xsl:value-of> and <xsl:for-each> should return
- * nodes in the order of the axis in use.
- */
- private boolean reverseNodeSet() {
- // Check if axis returned nodes in reverse document order
- // The sense of the following might appear to be reversed, but in
- // fact, the DTM ancestor and preceding iterators return nodes in
- // document order, rather than reverse document order. In
- // cases where we want the nodes returned in document order from
- // those iterators, this method must return false.
- if ((_axis == Axis.ANCESTOR) || (_axis == Axis.ANCESTORORSELF) ||
- (_axis == Axis.PRECEDING) || (_axis == Axis.PRECEDINGSIBLING)) {
-
- // If there were any predicates, put nodes in reverse document order
- if (hasPredicates()) return true;
- if (_hadPredicates) return true;
-
- // Order node set if it's a descendant of any of following:
- for (SyntaxTreeNode parent = this.getParent();
- parent != null;
- parent = parent.getParent()) {
- if (parent instanceof ApplyImports
- || parent instanceof ApplyTemplates
- || parent instanceof ForEach
- || parent instanceof FilterExpr
- || parent instanceof FilterParentPath
- || parent instanceof WithParam
- || parent instanceof ValueOf) {
- return false;
- }
- }
- return true;
- }
- return false;
- }
-
- /**
* Translate a step by pushing the appropriate iterator onto the stack.
* The abbreviated steps '.' and '@attr' do not create new iterators
* if they are not part of a LocationPath and have no filters.
@@ -289,9 +254,6 @@
if (hasPredicates()) {
translatePredicates(classGen, methodGen);
-
- // If needed, create a reverse iterator after compiling preds
- orderIterator(classGen, methodGen);
}
else {
// If it is an attribute but not '@*' or '@attr' with a parent
@@ -388,9 +350,6 @@
break;
}
-
- // If needed, create a reverse iterator
- orderIterator(classGen, methodGen);
}
}
@@ -496,28 +455,6 @@
}
}
}
-
-
- /**
- * This method tests if this step needs to have its axis reversed,
- * and wraps its iterator inside a ReverseIterator to return the node-set
- * in document order.
- */
- public void orderIterator(ClassGenerator classGen,
- MethodGenerator methodGen) {
- // First test if nodes are in reverse document order
- if (!reverseNodeSet()) return;
-
- final ConstantPoolGen cpg = classGen.getConstantPool();
- final InstructionList il = methodGen.getInstructionList();
- final int init = cpg.addMethodref(REVERSE_ITERATOR, "<init>",
- "("+NODE_ITERATOR_SIG+")V");
- il.append(new NEW(cpg.addClass(REVERSE_ITERATOR)));
- il.append(DUP_X1);
- il.append(SWAP);
- il.append(new INVOKESPECIAL(init));
- }
-
/**
* Returns a string representation of this step.
1.16.2.3 +18 -50 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XslElement.java
Index: XslElement.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XslElement.java,v
retrieving revision 1.16.2.2
retrieving revision 1.16.2.3
diff -u -r1.16.2.2 -r1.16.2.3
--- XslElement.java 24 Aug 2002 12:39:05 -0000 1.16.2.2
+++ XslElement.java 22 Oct 2002 14:52:36 -0000 1.16.2.3
@@ -279,62 +279,30 @@
}
if (!_ignore) {
+ // Push handler for call to endElement()
il.append(methodGen.loadHandler());
- _name.translate(classGen, methodGen);
-
- // Call BasisLibrary.getPrefix() and store result in local variable
- il.append(DUP);
- final int getPrefix = cpg.addMethodref(BASIS_LIBRARY_CLASS, "getPrefix",
- "(" + STRING_SIG + ")" + STRING_SIG);
- il.append(new INVOKESTATIC(getPrefix));
- il.append(DUP);
- local = methodGen.addLocalVariable("prefix",
- org.apache.bcel.generic.Type.STRING,
- il.getEnd(), null);
- il.append(new ASTORE(local.getIndex()));
-
- // If prefix is null then generate a prefix at runtime
- final BranchHandle ifNotNull = il.append(new IFNONNULL(null));
- if (_namespace != null) {
- final int generatePrefix = cpg.addMethodref(BASIS_LIBRARY_CLASS,
- "generatePrefix",
- "()" + STRING_SIG);
- il.append(new INVOKESTATIC(generatePrefix));
- il.append(DUP);
- il.append(new ASTORE(local.getIndex()));
-
- // Prepend newly generated prefix to the name
- final int makeQName = cpg.addMethodref(BASIS_LIBRARY_CLASS, "makeQName",
- "(" + STRING_SIG + STRING_SIG + ")" + STRING_SIG);
- il.append(new INVOKESTATIC(makeQName));
- }
- ifNotNull.setTarget(il.append(DUP2));
- il.append(methodGen.startElement());
+ // Push name and namespace URI
+ _name.translate(classGen, methodGen);
if (_namespace != null) {
- il.append(methodGen.loadHandler());
- il.append(new ALOAD(local.getIndex()));
_namespace.translate(classGen, methodGen);
- il.append(methodGen.namespace());
}
else {
- // If prefix not known at compile time, call DOM.lookupNamespace()
- il.append(new ALOAD(local.getIndex()));
- final BranchHandle ifNull = il.append(new IFNULL(null));
- il.append(methodGen.loadHandler());
- il.append(new ALOAD(local.getIndex()));
+ il.append(ACONST_NULL);
+ }
- il.append(methodGen.loadDOM());
- il.append(methodGen.loadCurrentNode());
- il.append(new ALOAD(local.getIndex()));
+ // Push additional arguments
+ il.append(methodGen.loadHandler());
+ il.append(methodGen.loadDOM());
+ il.append(methodGen.loadCurrentNode());
- final int lookupNamespace = cpg.addInterfaceMethodref(DOM_INTF,
- "lookupNamespace",
- "(I" + STRING_SIG + ")" + STRING_SIG);
- il.append(new INVOKEINTERFACE(lookupNamespace, 3));
- il.append(methodGen.namespace());
- ifNull.setTarget(il.append(NOP));
- }
+ // Invoke BasisLibrary.startXslElement()
+ il.append(new INVOKESTATIC(
+ cpg.addMethodref(BASIS_LIBRARY_CLASS, "startXslElement",
+ "(" + STRING_SIG
+ + STRING_SIG
+ + TRANSLET_OUTPUT_SIG
+ + DOM_INTF_SIG + "I)" + STRING_SIG)));
}
translateContents(classGen, methodGen);
No revision
No revision
1.6.10.4 +30 -15 xml-xalan/java/src/org/apache/xalan/xsltc/dom/AbsoluteIterator.java
Index: AbsoluteIterator.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/AbsoluteIterator.java,v
retrieving revision 1.6.10.3
retrieving revision 1.6.10.4
diff -u -r1.6.10.3 -r1.6.10.4
--- AbsoluteIterator.java 18 Sep 2002 13:31:53 -0000 1.6.10.3
+++ AbsoluteIterator.java 22 Oct 2002 14:52:37 -0000 1.6.10.4
@@ -71,39 +71,54 @@
import org.apache.xml.dtm.DTMAxisIterator;
import org.apache.xml.dtm.ref.DTMDefaultBase;
+/**
+ * Absolute iterators ignore the node that is passed to setStartNode().
+ * Instead, they always start from the root node. The node passed to
+ * setStartNode() is not totally useless, though. It is needed to obtain the
+ * DOM mask, i.e. the index into the MultiDOM table that corresponds to the
+ * DOM "owning" the node.
+ *
+ * The DOM mask is cached, so successive calls to setStartNode() passing
+ * nodes from other DOMs will have no effect (i.e. this iterator cannot
+ * migrate between DOMs).
+ */
public final class AbsoluteIterator extends DTMAxisIteratorBase {
+
+ /**
+ * Source for this iterator.
+ */
private DTMAxisIterator _source;
-
+
public AbsoluteIterator(DTMAxisIterator source) {
_source = source;
- }
-
- public int next() {
- return returnNode(_source.next());
+// System.out.println("AI source = " + source + " this = " + this);
}
public void setRestartable(boolean isRestartable) {
_isRestartable = isRestartable;
_source.setRestartable(isRestartable);
}
-
+
public DTMAxisIterator setStartNode(int node) {
_startNode = DTMDefaultBase.ROOTNODE;
-
if (_isRestartable) {
- resetPosition();
_source.setStartNode(_startNode);
- return this;
+ resetPosition();
}
- return reset();
+ return this;
+ }
+
+ public int next() {
+ return returnNode(_source.next());
}
public DTMAxisIterator cloneIterator() {
try {
- final AbsoluteIterator clone = (AbsoluteIterator)super.clone();
- clone.setRestartable(false);
- clone._source = _source.cloneIterator();
- return clone.reset();
+ final AbsoluteIterator clone = (AbsoluteIterator) super.clone();
+ clone._source = _source.cloneIterator(); // resets source
+ clone.resetPosition();
+ clone._isRestartable = false;
+ return clone;
}
catch (CloneNotSupportedException e) {
BasisLibrary.runTimeError(BasisLibrary.ITERATOR_CLONE_ERR,
1.6.2.3 +61 -24 xml-xalan/java/src/org/apache/xalan/xsltc/dom/CurrentNodeListIterator.java
Index: CurrentNodeListIterator.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/CurrentNodeListIterator.java,v
retrieving revision 1.6.2.2
retrieving revision 1.6.2.3
diff -u -r1.6.2.2 -r1.6.2.3
--- CurrentNodeListIterator.java 29 Jul 2002 00:01:27 -0000 1.6.2.2
+++ CurrentNodeListIterator.java 22 Oct 2002 14:52:37 -0000 1.6.2.3
@@ -68,20 +68,54 @@
import org.apache.xalan.xsltc.runtime.AbstractTranslet;
import org.apache.xalan.xsltc.util.IntegerArray;
import org.apache.xalan.xsltc.runtime.BasisLibrary;
-
import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
import org.apache.xml.dtm.DTMAxisIterator;
+/**
+ * Iterators of this kind use a CurrentNodeListFilter to filter a subset of
+ * nodes from a source iterator. For each node from the source, the boolean
+ * method CurrentNodeListFilter.test() is called.
+ *
+ * All nodes from the source are read into an array upon calling setStartNode()
+ * (this is needed to determine the value of last, a parameter to
+ * CurrentNodeListFilter.test()). The method getLast() returns the last element
+ * after applying the filter.
+ */
+
public final class CurrentNodeListIterator extends DTMAxisIteratorBase {
- private DTMAxisIterator _source;
+ /**
+ * A flag indicating if nodes are returned in document order.
+ */
private boolean _docOrder;
+
+ /**
+ * The source for this iterator.
+ */
+ private DTMAxisIterator _source;
+
+ /**
+ * A reference to a filter object.
+ */
private final CurrentNodeListFilter _filter;
+
+ /**
+ * An integer array to store nodes from source iterator.
+ */
private IntegerArray _nodes = new IntegerArray();
- private int _current; // index in _nodes of the next node to try
- private int _last = -1;
+ /**
+ * Index in _nodes of the next node to filter.
+ */
+ private int _currentIndex;
+ /**
+ * The current node in the stylesheet at the time of evaluation.
+ */
private final int _currentNode;
+
+ /**
+ * A reference to the translet.
+ */
private AbstractTranslet _translet;
public CurrentNodeListIterator(DTMAxisIterator source,
@@ -121,9 +155,10 @@
public DTMAxisIterator cloneIterator() {
try {
final CurrentNodeListIterator clone =
- (CurrentNodeListIterator)super.clone();
- clone._nodes = (IntegerArray)_nodes.clone();
- clone.setRestartable(false);
+ (CurrentNodeListIterator) super.clone();
+ clone._nodes = (IntegerArray) _nodes.clone();
+ clone._source = _source.cloneIterator();
+ clone._isRestartable = false;
return clone.reset();
}
catch (CloneNotSupportedException e) {
@@ -134,7 +169,7 @@
}
public DTMAxisIterator reset() {
- _current = 0;
+ _currentIndex = 0;
return resetPosition();
}
@@ -143,10 +178,13 @@
final int currentNode = _currentNode;
final AbstractTranslet translet = _translet;
- for (int index = _current; index < last; ) {
+ for (int index = _currentIndex; index < last; ) {
+ final int position = _docOrder ? index + 1 : last - index;
final int node = _nodes.at(index++); // note increment
- if (_filter.test(node, index, last, currentNode, translet, this)) {
- _current = index;
+
+ if (_filter.test(node, position, last, currentNode, translet,
+ this)) {
+ _currentIndex = index;
return returnNode(node);
}
}
@@ -154,8 +192,6 @@
}
public DTMAxisIterator setStartNode(int node) {
- DTMAxisIterator retval = this;
-
if (_isRestartable) {
_source.setStartNode(_startNode = node);
@@ -163,10 +199,10 @@
while ((node = _source.next()) != END) {
_nodes.add(node);
}
- _current = 0;
- retval = resetPosition();
+ _currentIndex = 0;
+ resetPosition();
}
- return retval;
+ return this;
}
public int getLast() {
@@ -177,13 +213,11 @@
}
public void setMark() {
- _source.setMark();
- _markedNode = _current;
+ _markedNode = _currentIndex;
}
public void gotoMark() {
- _source.gotoMark();
- _current = _markedNode;
+ _currentIndex = _markedNode;
}
private int computePositionOfLast() {
@@ -191,10 +225,13 @@
final int currNode = _currentNode;
final AbstractTranslet translet = _translet;
- int lastPosition = 0;
- for (int index = _current; index < last; ) {
+ int lastPosition = _position;
+ for (int index = _currentIndex; index < last; ) {
+ final int position = _docOrder ? index + 1 : last - index;
int nodeIndex = _nodes.at(index++); // note increment
- if (_filter.test(nodeIndex, index, last, currNode, translet, this)) {
+
+ if (_filter.test(nodeIndex, position, last, currNode, translet,
+ this)) {
lastPosition++;
}
}
1.11.10.6 +1 -9 xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMAdapter.java
Index: DOMAdapter.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMAdapter.java,v
retrieving revision 1.11.10.5
retrieving revision 1.11.10.6
diff -u -r1.11.10.5 -r1.11.10.6
--- DOMAdapter.java 23 Sep 2002 17:24:07 -0000 1.11.10.5
+++ DOMAdapter.java 22 Oct 2002 14:52:37 -0000 1.11.10.6
@@ -293,14 +293,6 @@
return _dom.getParent(node);
}
- public int getTypedPosition(int type, int node) {
- return _dom.getTypedPosition(getReverse()[type], node);
- }
-
- public int getTypedLast(int type, int node) {
- return _dom.getTypedLast(getReverse()[type], node);
- }
-
public int getAttributeNode(final int type, final int element) {
return _dom.getAttributeNode(getReverse()[type], element);
}
1.68.2.13 +1 -91 xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMImpl.java
Index: DOMImpl.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMImpl.java,v
retrieving revision 1.68.2.12
retrieving revision 1.68.2.13
diff -u -r1.68.2.12 -r1.68.2.13
--- DOMImpl.java 27 Sep 2002 21:54:39 -0000 1.68.2.12
+++ DOMImpl.java 22 Oct 2002 14:52:37 -0000 1.68.2.13
@@ -855,96 +855,6 @@
return _parent[node];
} use DTM's */
- public int getElementPosition(int node)
- {
- // Initialize with the first sbiling of the current node
- int match = 0;
- int curr = getFirstChild(getParent(node));
- if (isElement(curr)) match++;
-
- // Then traverse all other siblings up until the current node
- while (curr != node)
- {
- curr = getNextSibling(curr);
- if (isElement(curr)) match++;
- }
-
- // And finally return number of matches
- return match;
- }
-
- public int getAttributePosition(int attr)
- {
- // Initialize with the first sbiling of the current node
- int match = 1;
- int curr = getFirstChild(getParent(attr));
-
- // Then traverse all other siblings up until the current node
- while (curr != attr)
- {
- curr = getNextSibling(curr);
- match++;
- }
-
- // And finally return number of matches
- return match;
- }
-
- /**
- * Returns a node's position amongst other nodes of the same type
- */
- public int getTypedPosition(int type, int node)
- {
- // Just return the basic position if no type is specified
- switch(type)
- {
- case DTM.ELEMENT_NODE:
- return getElementPosition(node);
- case DTM.ATTRIBUTE_NODE:
- return getAttributePosition(node);
- case -1:
- type = getNodeType(node);
- }
-
- // Initialize with the first sbiling of the current node
- int match = 0;
- int curr = getFirstChild(getParent(node));
- if (getExpandedTypeID(curr) == type) match++;
-
- // Then traverse all other siblings up until the current node
- while (curr != node)
- {
- curr = getNextSibling(curr);
- if (getExpandedTypeID(curr) == type) match++;
- }
-
- // And finally return number of matches
- return match;
- }
-
- /**
- * Returns an iterator's last node of a given type
- */
- public int getTypedLast(int type, int node)
- {
- // Just return the basic position if no type is specified
- if (type == -1) type = getNodeType(node);
-
- // Initialize with the first sbiling of the current node
- int match = 0;
- int curr = getFirstChild(getParent(node));
- if (getExpandedTypeID(curr) == type) match++;
-
- // Then traverse all other siblings up until the very last one
- while (curr != DTM.NULL)
- {
- curr = getNextSibling(curr);
- if (getExpandedTypeID(curr) == type) match++;
- }
-
- return match;
- }
-
/**
* Returns singleton iterator containg the document root
* Works for them main document (mark == 0)
1.8.10.3 +81 -169 xml-xalan/java/src/org/apache/xalan/xsltc/dom/DupFilterIterator.java
Index: DupFilterIterator.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DupFilterIterator.java,v
retrieving revision 1.8.10.2
retrieving revision 1.8.10.3
diff -u -r1.8.10.2 -r1.8.10.3
--- DupFilterIterator.java 3 Oct 2002 23:25:14 -0000 1.8.10.2
+++ DupFilterIterator.java 22 Oct 2002 14:52:37 -0000 1.8.10.3
@@ -70,214 +70,126 @@
import org.apache.xml.dtm.DTMAxisIterator;
import org.apache.xml.dtm.ref.DTMDefaultBase;
+import org.apache.xalan.xsltc.util.IntegerArray;
+import org.apache.xalan.xsltc.runtime.BasisLibrary;
+
+/**
+ * Removes duplicates and sorts a source iterator. The nodes from the
+ * source are collected in an array upon calling setStartNode(). This
+ * array is later sorted and duplicates are ignored in next().
+ */
public final class DupFilterIterator extends DTMAxisIteratorBase {
- private final static int INIT_DATA_SIZE = 16;
+ /**
+ * Reference to source iterator.
+ */
+ private DTMAxisIterator _source;
- private final DTMAxisIterator _source; // the source iterator
- private int[] _data = null; // cached nodes from the source
- private int _last = 0; // the number of nodes in this iterator
+ /**
+ * Array to cache all nodes from source.
+ */
+ private IntegerArray _nodes = new IntegerArray();
+
+ /**
+ * Index in _nodes array to current node.
+ */
private int _current = 0;
/**
- * Creates a new duplicate filter iterator based on an existing iterator.
- * This iterator should be used with union expressions and other complex
- * iterator combinations (like 'get me the parents of all child node in
- * the dom' sort of thing). The iterator is also used to cache node-sets
- * returned by id() and key() iterators.
- * @param source The iterator this iterator will get its nodes from
+ * Cardinality of _nodes array.
+ */
+ private int _nodesSize = 0;
+
+ /**
+ * Last value returned by next().
*/
+ private int _lastNext = END;
+
public DupFilterIterator(DTMAxisIterator source) {
- // Save a reference to the source iterator
_source = source;
+// System.out.println("DFI source = " + source + " this = " + this);
// Cache contents of id() or key() index right away. Necessary for
// union expressions containing multiple calls to the same index, and
// correct as well since start-node is irrelevant for id()/key() exrp.
- if (source instanceof KeyIndex) setStartNode(DTMDefaultBase.ROOTNODE);
- }
-
- /**
- * Returns the next node in this iterator - excludes duplicates.
- * @return The next node in this iterator
- */
- public int next() {
- return _current < _last ? _data[_current++] : END;
+ if (source instanceof KeyIndex) {
+ setStartNode(DTMDefaultBase.ROOTNODE);
+ }
}
-
/**
* Set the start node for this iterator
* @param node The start node
* @return A reference to this node iterator
*/
public DTMAxisIterator setStartNode(int node) {
-
- int i, j; // loop variables declared first for speed - don't move!!!
-
- // KeyIndex iterators are always relative to the root node, so there
- // is never any point in re-reading the iterator (and we SHOULD NOT).
- if ((_source instanceof KeyIndex) && (_data != null)) {
- return this;
- }
-
- // If the _data array is populated, and the current start node is
- // equal to the new start node, we know we already have what we need.
- if ((_data == null) || (node != _startNode)) {
- _startNode = node;
- _source.setStartNode(node);
- int[] data = new int[INIT_DATA_SIZE];
- int sourceNodeCount = 0;
-
- // Gather all nodes from the source iterator
- while ((node = _source.next()) != END) {
- if (sourceNodeCount == data.length) {
- int[] newArray = new int[data.length * 2];
- System.arraycopy(data, 0, newArray, 0, sourceNodeCount);
- data = newArray;
- }
- data[sourceNodeCount++] = node;
- }
-
- // %REVIEW%: Is this the best approach? Code used to keep nodes
- // in sorted order as they were retrieved from _source.next(),
- // inserting at appropriate point at each step, eliminating
- // duplicates. That was a win when there were relatively few
- // unique nodes. When there were very many, the insertions
- // became very expensive. Perhaps we could use that approach
- // while the number of nodes is small, and then switch to sorting
- // after the fact when it reaches a threshold.
-
- // Factor out the trivial case to avoid overhead of sort
- if (sourceNodeCount > 1) {
- // Sort source nodes using merge sort: Merge two sorted
- // subranges of the array into new sorted ranges, beginning
- // with trivially sorted subranges of size 1.
- int[] mergeArray = new int[sourceNodeCount];
-
- int doubleMergeSize = 1;
- for (int mergeSize = 1;
- mergeSize < sourceNodeCount;
- mergeSize = doubleMergeSize) {
- int mLow = 0;
- doubleMergeSize = mergeSize + mergeSize;
-
- // Merge adjacent subranges of the array of appropriate size
- for (int r1Low = 0;
- r1Low < sourceNodeCount;
- r1Low = r1Low + doubleMergeSize) {
- final int r2Low = r1Low + mergeSize;
- final int numElemsInSecondSet =
- Math.min(mergeSize, sourceNodeCount-r2Low);
- merge(data, r1Low, mergeSize,
- data, r2Low, numElemsInSecondSet,
- mergeArray, mLow);
- mLow = mLow + mergeSize + numElemsInSecondSet;
- }
-
- // Now switch the arrays to double the merger ranges
- int[] tempArr = mergeArray;
- mergeArray = data;
- data = tempArr;
- }
-
- // Sweep through to see whether there are any duplicates
- for (i = 0;
- i < sourceNodeCount-1 && data[i] != data[i+1];
- i++);
-
- // If any duplicates were found, start compacting them out
- if (i < sourceNodeCount-1) {
- int nextUniqueIdx = i+1;
- for (j = i+2; j < sourceNodeCount; j++) {
- if (data[nextUniqueIdx-1] != data[j]) {
- data[nextUniqueIdx++] = data[j];
- }
- }
- sourceNodeCount = nextUniqueIdx;
- }
- }
- _last = sourceNodeCount;
- _data = data;
+ if (_isRestartable) {
+ // KeyIndex iterators are always relative to the root node, so there
+ // is never any point in re-reading the iterator (and we SHOULD NOT).
+ if (_source instanceof KeyIndex
+ && _startNode == DTMDefaultBase.ROOTNODE) {
+ return this;
+ }
+
+ if (node != _startNode) {
+ _source.setStartNode(_startNode = node);
+
+ _nodes.clear();
+ while ((node = _source.next()) != END) {
+ _nodes.add(node);
+ }
+ _nodes.sort();
+ _nodesSize = _nodes.cardinality();
+ _current = 0;
+ _lastNext = END;
+ resetPosition();
+ }
}
-
- _current = 0; // set to beginning
return this;
}
- /**
- *
- * Merge two sorted subranges of arrays into a target array. The resulting
- * elements in the target array will be in sorted order.
- *
- * @param a An array containing the first sorted subrange
- * @param aLow The starting index for the first array's subrange
- * @param aCount The number of elements in the first array's subrange
- * @param b An array containing the second sorted subrange
- * @param bLow The starting index for the second array's subrange
- * @param bCount The number of elements in the second array's subrange
- * @param t The target array which will contain the two merged subranges
- * @param tLow The starting index in the target array for the merged result
- *
- */
- private static void merge(int[] a, int aLow, int aCount,
- int[] b, int bLow, int bCount,
- int[] t, int tLow) {
- int aHigh = aLow + aCount - 1;
- int bHigh = bLow + bCount - 1;
- int tHigh = tLow + aCount + bCount - 1;
-
- for (int i = tLow; i <= tHigh; i++) {
- if (aLow > aHigh) {
- for (int j = i; j <= tHigh; j++) {
- t[j] = b[bLow++];
- }
- break;
- } else if (bLow > bHigh) {
- for (int j = i; j <= tHigh; j++) {
- t[j] = a[aLow++];
- }
- break;
- }
-
- t[i] = (a[aLow] < b[bLow]) ? a[aLow++] : b[bLow++];
- }
+
+ public int next() {
+ while (_current < _nodesSize) {
+ final int next = _nodes.at(_current++);
+ if (next != _lastNext) {
+ return returnNode(_lastNext = next);
+ }
+ }
+ return END;
}
- /**
- * Returns the current position of the iterator. The position is within the
- * node set covered by this iterator, not within the DOM.
- */
- public int getPosition() {
- return (_current);
+ public DTMAxisIterator cloneIterator() {
+ try {
+ final DupFilterIterator clone =
+ (DupFilterIterator) super.clone();
+ clone._nodes = (IntegerArray) _nodes.clone();
+ clone._source = _source.cloneIterator();
+ clone._isRestartable = false;
+ return clone.reset();
+ }
+ catch (CloneNotSupportedException e) {
+ BasisLibrary.runTimeError(BasisLibrary.ITERATOR_CLONE_ERR,
+ e.toString());
+ return null;
+ }
}
- /**
- * Returns the position of the last node in this iterator. The integer
- * returned is equivalent to the number of nodes in this iterator.
- */
- public int getLast() {
- return _last;
+ public void setRestartable(boolean isRestartable) {
+ _isRestartable = isRestartable;
+ _source.setRestartable(isRestartable);
}
- /**
- * Saves the position of this iterator - see gotoMark()
- */
public void setMark() {
- _source.setMark();
_markedNode = _current;
}
- /**
- * Restores the position of this iterator - see setMark()
- */
public void gotoMark() {
- _source.gotoMark();
_current = _markedNode;
}
public DTMAxisIterator reset() {
_current = 0;
- return(this);
+ _lastNext = END;
+ return resetPosition();
}
-
}
1.4.10.2 +22 -3 xml-xalan/java/src/org/apache/xalan/xsltc/dom/FilterIterator.java
Index: FilterIterator.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/FilterIterator.java,v
retrieving revision 1.4.10.1
retrieving revision 1.4.10.2
diff -u -r1.4.10.1 -r1.4.10.2
--- FilterIterator.java 17 Apr 2002 18:13:44 -0000 1.4.10.1
+++ FilterIterator.java 22 Oct 2002 14:52:38 -0000 1.4.10.2
@@ -71,13 +71,32 @@
import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
import org.apache.xml.dtm.DTMFilter;
+/**
+ * Similar to a CurrentNodeListIterator except that the filter has a
+ * simpler interface (only needs the node, no position, last, etc.)
+ * It takes a source iterator and a Filter object and returns nodes
+ * from the source after filtering them by calling filter.test(node).
+ */
public final class FilterIterator extends DTMAxisIteratorBase {
+
+ /**
+ * Reference to source iterator.
+ */
private DTMAxisIterator _source;
+
+ /**
+ * Reference to a filter object that to be applied to each node.
+ */
private final DTMFilter _filter;
+
+ /**
+ * A flag indicating if position is reversed.
+ */
private final boolean _isReverse;
public FilterIterator(DTMAxisIterator source, DTMFilter filter) {
_source = source;
+// System.out.println("FI souce = " + source + " this = " + this);
_filter = filter;
_isReverse = source.isReverse();
}
@@ -95,9 +114,9 @@
public DTMAxisIterator cloneIterator() {
try {
- final FilterIterator clone = (FilterIterator)super.clone();
- clone.setRestartable(false);
+ final FilterIterator clone = (FilterIterator) super.clone();
clone._source = _source.cloneIterator();
+ clone._isRestartable = false;
return clone.reset();
}
catch (CloneNotSupportedException e) {
1.5.10.2 +9 -44 xml-xalan/java/src/org/apache/xalan/xsltc/dom/FilteredStepIterator.java
Index: FilteredStepIterator.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/FilteredStepIterator.java,v
retrieving revision 1.5.10.1
retrieving revision 1.5.10.2
diff -u -r1.5.10.1 -r1.5.10.2
--- FilteredStepIterator.java 17 Apr 2002 18:13:44 -0000 1.5.10.1
+++ FilteredStepIterator.java 22 Oct 2002 14:52:38 -0000 1.5.10.2
@@ -70,64 +70,29 @@
import org.apache.xml.dtm.DTMAxisIterator;
import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
+/**
+ * Extends a StepIterator by adding the ability to filter nodes. It
+ * uses filters similar to those of a FilterIterator.
+ */
public final class FilteredStepIterator extends StepIterator {
- //private DTMAxisIterator _source;
- // private DTMAxisIterator _iterator;
+
private Filter _filter;
-
public FilteredStepIterator(DTMAxisIterator source,
DTMAxisIterator iterator,
Filter filter) {
- //_source = source;
- //_iterator = iterator;
super(source, iterator);
_filter = filter;
}
- public DTMAxisIterator cloneIterator() {
- try {
- final FilteredStepIterator clone =
- (FilteredStepIterator)super.clone();
- clone._source = _source.cloneIterator();
- clone._iterator = _iterator.cloneIterator();
- clone._filter = _filter;
- clone._isRestartable = false;
- return clone.reset();
- }
- catch (CloneNotSupportedException e) {
- BasisLibrary.runTimeError(BasisLibrary.ITERATOR_CLONE_ERR,
- e.toString());
- return null;
- }
- }
-
-
- public DTMAxisIterator setStartNode(int node) {
- if (_isRestartable) {
- // iterator is not a clone
- _source.setStartNode(_startNode = node);
- _iterator.setStartNode(_source.next());
- return resetPosition();
- }
- return this;
- }
-
-
- public DTMAxisIterator reset() {
- _source.reset();
- _iterator.setStartNode(_source.next());
- return resetPosition();
- }
-
-
public int next() {
int node;
while ((node = super.next()) != END) {
- if (_filter.test(node))
+ if (_filter.test(node)) {
return returnNode(node);
+ }
}
- return(node);
+ return node;
}
}
1.7.10.4 +110 -144 xml-xalan/java/src/org/apache/xalan/xsltc/dom/KeyIndex.java
Index: KeyIndex.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/KeyIndex.java,v
retrieving revision 1.7.10.3
retrieving revision 1.7.10.4
diff -u -r1.7.10.3 -r1.7.10.4
--- KeyIndex.java 30 Sep 2002 17:57:40 -0000 1.7.10.3
+++ KeyIndex.java 22 Oct 2002 14:52:38 -0000 1.7.10.4
@@ -57,74 +57,78 @@
* <http://www.apache.org/>.
*
* @author Morten Jorgensen
+ * @author Santiago Pericas-Geertsen
*
*/
package org.apache.xalan.xsltc.dom;
import java.util.Vector;
+import java.util.Enumeration;
import java.util.StringTokenizer;
import org.apache.xalan.xsltc.DOM;
-import org.apache.xalan.xsltc.NodeIterator;
import org.apache.xalan.xsltc.runtime.Hashtable;
-import org.apache.xml.dtm.DTM;
+import org.apache.xalan.xsltc.util.IntegerArray;
+import org.apache.xml.dtm.DTM;
import org.apache.xml.dtm.DTMAxisIterator;
+import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
-public class KeyIndex implements DTMAxisIterator {
+public class KeyIndex extends DTMAxisIteratorBase {
+ /**
+ * A mapping between values and nodesets.
+ */
private Hashtable _index = new Hashtable();
- private BitArray _nodes = null;
- private int _pos = 0;
- private int _mark = 0;
- private int _save = 0;
- private int _start = 0;
- private int _arraySize = 0;
- private int _node = -1;
+
+ /**
+ * The node set associated to the current value passed
+ * to lookupKey();
+ */
+ private IntegerArray _nodes = null;
+
+ /**
+ * The XSLTC DOM object if this KeyIndex is being used to implement the
+ * id() function.
+ */
private DOM _dom;
/**
- * Creates an index for a key defined by xsl:key
+ * Store position after call to setMark()
*/
- public KeyIndex(int size) {
- _arraySize = size;
+ private int _markedPosition = 0;
+
+ public KeyIndex(int dummy) {
}
public void setRestartable(boolean flag) {
-
}
-
+
/**
- * Adds a node to the node list for a given value.
- * The BitArray object makes sure duplicate nodes are eliminated.
+ * Adds a node to the node list for a given value. Nodes will
+ * always be added in document order.
*/
public void add(Object value, int node) {
- if ((_nodes = (BitArray)_index.get(value)) == null) {
- _nodes = new BitArray(_arraySize);
- _nodes.setMask(node & 0xff000000);
- _index.put(value,_nodes);
+ IntegerArray nodes;
+ if ((nodes = (IntegerArray) _index.get(value)) == null) {
+ _index.put(value, nodes = new IntegerArray());
}
- _nodes.setBit(node & 0x00ffffff);
-
- /*
- * TODO: A bit array can currently only hold nodes from one DOM.
- * An index will therefore only return nodes from a single document.
- */
+ nodes.add(node);
}
/**
- * Merge this node set with nodes from another index
+ * Merge the current value's nodeset set by lookupKey() with _nodes.
*/
public void merge(KeyIndex other) {
- // Only merge if other node set is not empty
- if (other != null) {
- if (other._nodes != null) {
- // Create new Vector for nodes if this set is empty
- if (_nodes == null)
- _nodes = other._nodes;
- else
- _nodes = _nodes.merge(other._nodes);
+ if (other == null) return;
+
+ if (other._nodes != null) {
+ if (_nodes == null) {
+ _nodes = other._nodes;
+ }
+ else {
+ _nodes.merge(other._nodes);
}
}
}
@@ -137,58 +141,45 @@
* key() function.
*/
public void lookupId(Object value) {
- _nodes = null;
- if (value instanceof String) {
- boolean firstTime = true;
- final String string = (String)value;
-
- if (string.indexOf(' ') > -1) {
- StringTokenizer values = new StringTokenizer(string);
- while (values.hasMoreElements()) {
- String token = (String)values.nextElement();
- BitArray nodes = (BitArray)_index.get(token);
- if (nodes == null && _dom instanceof DOMImpl) {
- nodes = getDOMNodeById(token);
- }
-
- if (nodes != null) {
- if (firstTime) {
- _nodes = nodes;
- firstTime = false;
- } else {
- _nodes = _nodes.merge(nodes);
- }
- }
- }
+ // Clear _nodes array
+ _nodes = null;
+
+ final StringTokenizer values = new StringTokenizer((String) value);
+ while (values.hasMoreElements()) {
+ final String token = (String) values.nextElement();
+ IntegerArray nodes = (IntegerArray) _index.get(token);
+
+ if (nodes == null && _dom instanceof DOMImpl) {
+ nodes = getDOMNodeById(token);
}
- else {
- _nodes = (BitArray)_index.get(value);
- if (_nodes == null && _dom instanceof DOMImpl) {
- _nodes = getDOMNodeById(string);
- }
- }
- }
- else
- _nodes = (BitArray)_index.get(value);
+
+ if (nodes == null) continue;
+
+ if (_nodes == null) {
+ _nodes = nodes;
+ }
+ else {
+ _nodes.merge(nodes);
+ }
+ }
}
/**
- * Return a BitArray for the DOM Node which has the given id.
+ * Return an IntegerArray for the DOM Node which has the given id.
*
* @param id The id
- * @return A BitArray representing the Node whose id is the given value.
+ * @return A IntegerArray representing the Node whose id is the given value.
*/
- public BitArray getDOMNodeById(String id) {
- BitArray nodes = null;
+ public IntegerArray getDOMNodeById(String id) {
+ IntegerArray nodes = null;
if (_dom instanceof DOMImpl) {
DOMImpl domImpl = (DOMImpl)_dom;
int node = domImpl.getElementById(id);
int ident = domImpl.getNodeIdent(node);
if (ident != DTM.NULL) {
- nodes = new BitArray(_arraySize);
- nodes.setMask(ident & 0xff000000);
+ nodes = new IntegerArray();
_index.put(id, nodes);
- nodes.setBit(ident & 0x00ffffff);
+ nodes.add(ident);
}
}
return nodes;
@@ -199,101 +190,86 @@
* prior to returning the node iterator.
*/
public void lookupKey(Object value) {
- _nodes = (BitArray)_index.get(value);
+ _nodes = (IntegerArray) _index.get(value);
+ _position = 0;
}
/**
* Callers should not call next() after it returns END.
*/
public int next() {
- if (_nodes == null) return(END);
- if ((_node = _nodes.getNextBit(++_node)) == END) return(END);
- _pos++;
- return _dom.getNodeHandle(_node | _nodes.getMask());
+ if (_nodes == null) return DTMAxisIterator.END;
+
+ return (_position < _nodes.cardinality()) ?
+ _dom.getNodeHandle(_nodes.at(_position++)) : DTMAxisIterator.END;
}
public int containsID(int node, Object value) {
- if (value instanceof String) {
- final String string = (String)value;
- if (string.indexOf(' ') > -1) {
- StringTokenizer values = new StringTokenizer(string);
- while (values.hasMoreElements()) {
- String token = (String)values.nextElement();
- BitArray nodes = (BitArray)_index.get(token);
- if (nodes == null && _dom instanceof DOMImpl) {
- nodes = getDOMNodeById(token);
- }
- if ((nodes != null) && (nodes.getBit(node))) return(1);
+ final String string = (String)value;
+ if (string.indexOf(' ') > -1) {
+ final StringTokenizer values = new StringTokenizer(string);
+
+ while (values.hasMoreElements()) {
+ final String token = (String) values.nextElement();
+ IntegerArray nodes = (IntegerArray) _index.get(token);
+
+ if (nodes == null && _dom instanceof DOMImpl) {
+ nodes = getDOMNodeById(token);
+ }
+ if (nodes != null && nodes.indexOf(node) >= 0) {
+ return 1;
}
- return(0);
}
- else {
- BitArray nodes = (BitArray)_index.get(value);
- if (nodes == null && _dom instanceof DOMImpl) {
- nodes = getDOMNodeById(string);
- }
-
- if ((nodes != null) && (nodes.getBit(node)))
- return(1);
- else
- return(0);
- }
+ return 0;
}
else {
- BitArray nodes = (BitArray)_index.get(value);
- if ((nodes != null) && (nodes.getBit(node)))
- return(1);
- else
- return(0);
+ IntegerArray nodes = (IntegerArray) _index.get(value);
+ if (nodes == null && _dom instanceof DOMImpl) {
+ nodes = getDOMNodeById(string);
+ }
+ return (nodes != null && nodes.indexOf(node) >= 0) ? 1 : 0;
}
}
public int containsKey(int node, Object value) {
- BitArray nodes = (BitArray)_index.get(value);
- if ((nodes != null) && (nodes.getBit(node))) return(1);
- return(0);
+ final IntegerArray nodes = (IntegerArray) _index.get(value);
+ return (nodes != null && nodes.indexOf(node) >= 0) ? 1 : 0;
}
/**
* Resets the iterator to the last start node.
*/
public DTMAxisIterator reset() {
- _pos = _start;
- _node = _start - 1;
- return(this);
+ _position = 0;
+ return this;
}
/**
* Returns the number of elements in this iterator.
*/
public int getLast() {
- if (_nodes == null)
- return(0);
- else
- return(_nodes.size()); // TODO: count actual nodes
+ return (_nodes == null) ? 0 : _nodes.cardinality();
}
/**
* Returns the position of the current node in the set.
*/
public int getPosition() {
- return(_pos);
+ return _position;
}
/**
* Remembers the current node for the next call to gotoMark().
*/
public void setMark() {
- _mark = _pos;
- _save = _node;
+ _markedPosition = _position;
}
/**
* Restores the current node remembered by setMark().
*/
public void gotoMark() {
- _pos = _mark;
- _node = _save;
+ _position = _markedPosition;
}
/**
@@ -301,25 +277,21 @@
* i.e. subsequent call to next() should return END.
*/
public DTMAxisIterator setStartNode(int start) {
- if (start == END) {
+ if (start == DTMAxisIterator.END) {
_nodes = null;
}
else if (_nodes != null) {
- // Node count starts with 1, while bit arrays count from 0. Must
- // subtract one from 'start' to initialize bit array correctly.
- _start = _nodes.getBitNumber(start);
- _node = _start;
+ _position = 0;
}
- return((DTMAxisIterator)this);
+ return (DTMAxisIterator) this;
}
/**
* Get start to END should 'close' the iterator,
* i.e. subsequent call to next() should return END.
*/
- public int getStartNode()
- {
- return _start;
+ public int getStartNode() {
+ return 0;
}
/**
@@ -333,20 +305,14 @@
* Returns a deep copy of this iterator.
*/
public DTMAxisIterator cloneIterator() {
- KeyIndex other = new KeyIndex(_arraySize);
-
+ KeyIndex other = new KeyIndex(0);
other._index = _index;
- other._nodes = _nodes.cloneArray();
- other._pos = _pos;
- other._start = _start;
- other._node = _node;
-
- return(other);
+ other._nodes = _nodes;
+ other._position = _position;
+ return (DTMAxisIterator) other;
}
- public void setDom(DOM dom)
- {
+ public void setDom(DOM dom) {
_dom = dom;
}
-
}
1.6.10.2 +42 -16 xml-xalan/java/src/org/apache/xalan/xsltc/dom/MatchingIterator.java
Index: MatchingIterator.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/MatchingIterator.java,v
retrieving revision 1.6.10.1
retrieving revision 1.6.10.2
diff -u -r1.6.10.1 -r1.6.10.2
--- MatchingIterator.java 17 Apr 2002 18:13:44 -0000 1.6.10.1
+++ MatchingIterator.java 22 Oct 2002 14:52:38 -0000 1.6.10.2
@@ -69,11 +69,36 @@
import org.apache.xml.dtm.DTMAxisIterator;
import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
+/**
+ * This is a special kind of iterator that takes a source iterator and a
+ * node N. If initialized with a node M (the parent of N) it computes the
+ * position of N amongst the children of M. This position can be obtained
+ * by calling getPosition().
+ * It is an iterator even though next() will never be called. It is used to
+ * match patterns with a single predicate like:
+ *
+ * BOOK[position() = last()]
+ *
+ * In this example, the source iterator will return elements of type BOOK,
+ * a call to position() will return the position of N. Notice that because
+ * of the way the pattern matching is implemented, N will always be a node
+ * in the source since (i) it is a BOOK or the test sequence would not be
+ * considered and (ii) the source iterator is initialized with M which is
+ * the parent of N. Also, and still in this example, a call to last() will
+ * return the number of elements in the source (i.e. the number of BOOKs).
+ */
public final class MatchingIterator extends DTMAxisIteratorBase {
+
+ /**
+ * A reference to a source iterator.
+ */
private DTMAxisIterator _source;
- private final int _match;
- private int _matchPos, _matchLast = -1;
-
+
+ /**
+ * The node to match.
+ */
+ private final int _match;
+
public MatchingIterator(int match, DTMAxisIterator source) {
_source = source;
_match = match;
@@ -88,10 +113,10 @@
public DTMAxisIterator cloneIterator() {
try {
- final MatchingIterator clone = (MatchingIterator)super.clone();
+ final MatchingIterator clone = (MatchingIterator) super.clone();
clone._source = _source.cloneIterator();
- clone.setRestartable(false);
- return clone;
+ clone._isRestartable = false;
+ return clone.reset();
}
catch (CloneNotSupportedException e) {
BasisLibrary.runTimeError(BasisLibrary.ITERATOR_CLONE_ERR,
@@ -106,17 +131,17 @@
_source.setStartNode(node);
// Calculate the position of the node in the set
- _matchPos = 1;
- _matchLast = -1;
- while ( ((node = _source.next()) != END) && (node != _match) )
- _matchPos++;
+ _position = 1;
+ while ((node = _source.next()) != END && node != _match) {
+ _position++;
+ }
}
return this;
}
public DTMAxisIterator reset() {
_source.reset();
- return this;
+ return resetPosition();
}
public int next() {
@@ -124,13 +149,14 @@
}
public int getLast() {
- if (_matchLast == -1)
- _matchLast = _source.getLast();
- return _matchLast;
+ if (_last == -1) {
+ _last = _source.getLast();
+ }
+ return _last;
}
public int getPosition() {
- return _matchPos;
+ return _position;
}
public void setMark() {
1.16.10.6 +2 -10 xml-xalan/java/src/org/apache/xalan/xsltc/dom/MultiDOM.java
Index: MultiDOM.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/MultiDOM.java,v
retrieving revision 1.16.10.5
retrieving revision 1.16.10.6
diff -u -r1.16.10.5 -r1.16.10.6
--- MultiDOM.java 18 Sep 2002 13:31:54 -0000 1.16.10.5
+++ MultiDOM.java 22 Oct 2002 14:52:38 -0000 1.16.10.6
@@ -427,14 +427,6 @@
return _adapters[getDTMId(node)].getParent(node & CLR) | node&SET;
}
- public int getTypedPosition(int type, int node) {
- return _adapters[getDTMId(node)].getTypedPosition(type, node&CLR);
- }
-
- public int getTypedLast(int type, int node) {
- return _adapters[getDTMId(node)].getTypedLast(type, node&CLR);
- }
-
public int getAttributeNode(final int type, final int el) {
if (el == DTM.NULL) {
return DTM.NULL;
@@ -620,7 +612,7 @@
public String lookupNamespace(int node, String prefix)
throws TransletException
{
- return _adapters[node>>>24].lookupNamespace(node, prefix);
+ return _adapters[node>>>24].lookupNamespace(node & CLR, prefix);
}
// %HZ% Does this method make any sense here???
1.6.10.2 +69 -3 xml-xalan/java/src/org/apache/xalan/xsltc/dom/NodeIteratorBase.java
Index: NodeIteratorBase.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/NodeIteratorBase.java,v
retrieving revision 1.6.10.1
retrieving revision 1.6.10.2
diff -u -r1.6.10.1 -r1.6.10.2
--- NodeIteratorBase.java 29 Jul 2002 00:01:27 -0000 1.6.10.1
+++ NodeIteratorBase.java 22 Oct 2002 14:52:38 -0000 1.6.10.2
@@ -68,18 +68,56 @@
import org.apache.xalan.xsltc.runtime.BasisLibrary;
public abstract class NodeIteratorBase implements NodeIterator {
- private int _last = -1;
+
+ /**
+ * Cached computed value of last().
+ */
+ protected int _last = -1;
+
+ /**
+ * Value of position() in this iterator. Incremented in
+ * returnNode().
+ */
protected int _position = 0;
+ /**
+ * Store node in call to setMark().
+ */
protected int _markedNode;
+
+ /**
+ * Store node in call to setStartNode().
+ */
protected int _startNode = NodeIterator.END;
+
+ /**
+ * Flag indicating if "self" should be returned.
+ */
protected boolean _includeSelf = false;
+
+ /**
+ * Flag indicating if iterator can be restarted.
+ */
protected boolean _isRestartable = true;
+ /**
+ * Setter for _isRestartable flag.
+ */
public void setRestartable(boolean isRestartable) {
_isRestartable = isRestartable;
}
+ /**
+ * Initialize iterator using a node. If iterator is not
+ * restartable, then do nothing. If node is equal to END then
+ * subsequent calls to next() must return END.
+ */
+ abstract public NodeIterator setStartNode(int node);
+
+ /**
+ * Reset this iterator using state from last call to
+ * setStartNode().
+ */
public NodeIterator reset() {
final boolean temp = _isRestartable;
_isRestartable = true;
@@ -89,11 +127,19 @@
return this;
}
+ /**
+ * Setter for _includeSelf flag.
+ */
public NodeIterator includeSelf() {
_includeSelf = true;
return this;
}
+ /**
+ * Default implementation of getLast(). Stores current position
+ * and current node, resets the iterator, counts all nodes and
+ * restores iterator to original state.
+ */
public int getLast() {
if (_last == -1) {
final int temp = _position;
@@ -108,14 +154,28 @@
return _last;
}
+ /**
+ * Returns the position() in this iterator.
+ */
public int getPosition() {
return _position == 0 ? 1 : _position;
}
+ /**
+ * Indicates if position in this iterator is computed in reverse
+ * document order. Note that nodes are always returned in document
+ * order.
+ */
public boolean isReverse() {
return false;
}
+ /**
+ * Clones and resets this iterator. Note that the cloned iterator is
+ * not restartable. This is because cloning is needed for variable
+ * references, and the context node of the original variable
+ * declaration must be preserved.
+ */
public NodeIterator cloneIterator() {
try {
final NodeIteratorBase clone = (NodeIteratorBase)super.clone();
@@ -129,14 +189,20 @@
}
}
+ /**
+ * Utility method that increments position and returns its
+ * argument.
+ */
protected final int returnNode(final int node) {
_position++;
return node;
}
+ /**
+ * Reset the position in this iterator.
+ */
protected final NodeIterator resetPosition() {
_position = 0;
return this;
}
-
}
1.9.10.2 +28 -30 xml-xalan/java/src/org/apache/xalan/xsltc/dom/NthIterator.java
Index: NthIterator.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/NthIterator.java,v
retrieving revision 1.9.10.1
retrieving revision 1.9.10.2
diff -u -r1.9.10.1 -r1.9.10.2
--- NthIterator.java 17 Apr 2002 18:13:44 -0000 1.9.10.1
+++ NthIterator.java 22 Oct 2002 14:52:38 -0000 1.9.10.2
@@ -72,9 +72,7 @@
public final class NthIterator extends DTMAxisIteratorBase {
// ...[N]
-
- private final DTMAxisIterator _source;
-
+ private DTMAxisIterator _source;
private final int _position;
private boolean _ready;
@@ -88,28 +86,42 @@
_source.setRestartable(isRestartable);
}
+ public DTMAxisIterator cloneIterator() {
+ try {
+ final NthIterator clone = (NthIterator) super.clone();
+ clone._source = _source.cloneIterator(); // resets source
+ clone._isRestartable = false;
+ return clone;
+ }
+ catch (CloneNotSupportedException e) {
+ BasisLibrary.runTimeError(BasisLibrary.ITERATOR_CLONE_ERR,
+ e.toString());
+ return null;
+ }
+ }
+
public int next() {
if (_ready && _position > 0) {
+ final int pos = _source.isReverse()
+ ? _source.getLast() - _position + 1
+ : _position;
+
_ready = false;
- // skip N-1 nodes
- final int pos = _position;
- for (int n = pos - 1; n-- > 0;) {
- if (_source.next() == DTMAxisIterator.END) {
- return DTMAxisIterator.END;
+ int node;
+ while ((node = _source.next()) != DTMAxisIterator.END) {
+ if (pos == _source.getPosition()) {
+ return node;
}
}
- return _source.next();
}
return DTMAxisIterator.END;
}
-
public DTMAxisIterator setStartNode(final int node) {
- if (_isRestartable) {
- _source.setStartNode(node);
- _ready = true;
- }
-
+ if (_isRestartable) {
+ _source.setStartNode(node);
+ _ready = true;
+ }
return this;
}
@@ -127,25 +139,11 @@
return 1;
}
- public boolean isReverse() {
- return _source.isReverse();
- }
-
public void setMark() {
_source.setMark();
}
public void gotoMark() {
_source.gotoMark();
- }
-
- public DTMAxisIterator cloneIterator() {
- //!! not clear when cloning is performed
- // and what's the desired state of the new clone
- //return new NthIterator(_source.cloneIterator(), _position);
- DTMAxisIterator clone = _source.cloneIterator();
- NthIterator other = new NthIterator(clone, _position);
- other.setRestartable(false);
- return other.reset();
}
}
1.1.2.16 +1 -90 xml-xalan/java/src/org/apache/xalan/xsltc/dom/Attic/SAXImpl.java
Index: SAXImpl.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/Attic/SAXImpl.java,v
retrieving revision 1.1.2.15
retrieving revision 1.1.2.16
diff -u -r1.1.2.15 -r1.1.2.16
--- SAXImpl.java 3 Oct 2002 23:25:57 -0000 1.1.2.15
+++ SAXImpl.java 22 Oct 2002 14:52:38 -0000 1.1.2.16
@@ -716,95 +716,6 @@
return _parent[node];
} use DTM's */
- public int getElementPosition(int node) {
- // Initialize with the first sbiling of the current node
- int match = 0;
- int curr = getFirstChild(getParent(node));
- if (isElement(curr)) match++;
-
- // Then traverse all other siblings up until the current node
- while (curr != node)
- {
- curr = getNextSibling(curr);
- if (isElement(curr)) match++;
- }
-
- // And finally return number of matches
- return match;
- }
-
- public int getAttributePosition(int attr)
- {
- // Initialize with the first sbiling of the current node
- int match = 1;
- int curr = getFirstChild(getParent(attr));
-
- // Then traverse all other siblings up until the current node
- while (curr != attr)
- {
- curr = getNextSibling(curr);
- match++;
- }
-
- // And finally return number of matches
- return match;
- }
-
- /**
- * Returns a node's position amongst other nodes of the same type
- */
- public int getTypedPosition(int type, int node)
- {
- // Just return the basic position if no type is specified
- switch(type)
- {
- case DTM.ELEMENT_NODE:
- return getElementPosition(node);
- case DTM.ATTRIBUTE_NODE:
- return getAttributePosition(node);
- case -1:
- type = getNodeType(node);
- }
-
- // Initialize with the first sbiling of the current node
- int match = 0;
- int curr = getFirstChild(getParent(node));
- if (getExpandedTypeID(curr) == type) match++;
-
- // Then traverse all other siblings up until the current node
- while (curr != node)
- {
- curr = getNextSibling(curr);
- if (getExpandedTypeID(curr) == type) match++;
- }
-
- // And finally return number of matches
- return match;
- }
-
- /**
- * Returns an iterator's last node of a given type
- */
- public int getTypedLast(int type, int node)
- {
- // Just return the basic position if no type is specified
- if (type == -1) type = getNodeType(node);
-
- // Initialize with the first sbiling of the current node
- int match = 0;
- int curr = getFirstChild(getParent(node));
- if (getExpandedTypeID(curr) == type) match++;
-
- // Then traverse all other siblings up until the very last one
- while (curr != DTM.NULL)
- {
- curr = getNextSibling(curr);
- if (getExpandedTypeID(curr) == type) match++;
- }
-
- return match;
- }
-
/**
* Returns singleton iterator containg the document root
* Works for them main document (mark == 0)
1.11.10.3 +29 -12 xml-xalan/java/src/org/apache/xalan/xsltc/dom/StepIterator.java
Index: StepIterator.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/StepIterator.java,v
retrieving revision 1.11.10.2
retrieving revision 1.11.10.3
diff -u -r1.11.10.2 -r1.11.10.3
--- StepIterator.java 29 Jul 2002 00:01:27 -0000 1.11.10.2
+++ StepIterator.java 22 Oct 2002 14:52:38 -0000 1.11.10.3
@@ -68,41 +68,58 @@
import org.apache.xalan.xsltc.NodeIterator;
import org.apache.xalan.xsltc.runtime.BasisLibrary;
-
import org.apache.xml.dtm.DTMAxisIterator;
import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
+/**
+ * A step iterator is used to evaluate expressions like "BOOK/TITLE".
+ * A better name for this iterator would have been ParentIterator since
+ * both "BOOK" and "TITLE" are steps in XPath lingo. Step iterators are
+ * constructed from two other iterators which we are going to refer to
+ * as "outer" and "inner". Every node from the outer iterator (the one
+ * for BOOK in our example) is used to initialize the inner iterator.
+ * After this initialization, every node from the inner iterator is
+ * returned (in essence, implementing a "nested loop").
+ */
public class StepIterator extends DTMAxisIteratorBase {
- private int _pos = -1;
+ /**
+ * A reference to the "outer" iterator.
+ */
protected DTMAxisIterator _source;
+
+ /**
+ * A reference to the "inner" iterator.
+ */
protected DTMAxisIterator _iterator;
+ /**
+ * Temp variable to store a marked position.
+ */
+ private int _pos = -1;
+
public StepIterator(DTMAxisIterator source, DTMAxisIterator iterator) {
_source = source;
_iterator = iterator;
+// System.out.println("SI source = " + source + " this = " + this);
+// System.out.println("SI iterator = " + iterator + " this = " + this);
}
public void setRestartable(boolean isRestartable) {
_isRestartable = isRestartable;
_source.setRestartable(isRestartable);
- _iterator.setRestartable(true); // must _always_ be restartable
+ _iterator.setRestartable(true); // must be restartable
}
public DTMAxisIterator cloneIterator() {
_isRestartable = false;
try {
- final StepIterator clone = (StepIterator)super.clone();
+ final StepIterator clone = (StepIterator) super.clone();
clone._source = _source.cloneIterator();
clone._iterator = _iterator.cloneIterator();
-
- // Special case -> _iterator must be restartable
- // if (clone._iterator instanceof DTMAxisIteratorBase) {
- // ((DTMAxisIteratorBase)(clone._iterator))._isRestartable = true;
- // }
-
- clone.setRestartable(false);
+ clone._iterator.setRestartable(true); // must be restartable
+ clone._isRestartable = false;
return clone.reset();
}
catch (CloneNotSupportedException e) {
1.11.2.3 +13 -3 xml-xalan/java/src/org/apache/xalan/xsltc/dom/UnionIterator.java
Index: UnionIterator.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/UnionIterator.java,v
retrieving revision 1.11.2.2
retrieving revision 1.11.2.3
diff -u -r1.11.2.2 -r1.11.2.3
--- UnionIterator.java 29 Jul 2002 00:01:27 -0000 1.11.2.2
+++ UnionIterator.java 22 Oct 2002 14:52:38 -0000 1.11.2.3
@@ -84,7 +84,7 @@
private final static class LookAheadIterator {
public int node, markedNode;
- public final DTMAxisIterator iterator;
+ public DTMAxisIterator iterator;
public LookAheadIterator(DTMAxisIterator iterator) {
this.iterator = iterator;
@@ -95,6 +95,14 @@
return node;
}
+ public LookAheadIterator cloneIterator() {
+ final LookAheadIterator clone =
+ new LookAheadIterator(iterator.cloneIterator());
+ clone.node = node;
+ clone.markedNode = node;
+ return clone;
+ }
+
public void setMark() {
markedNode = node;
iterator.setMark();
@@ -129,7 +137,9 @@
new LookAheadIterator[_heap.length];
try {
final UnionIterator clone = (UnionIterator)super.clone();
- System.arraycopy(_heap, 0, heapCopy, 0, _heap.length);
+ for (int i = 0; i < _free; i++) {
+ heapCopy[i] = _heap[i].cloneIterator();
+ }
clone.setRestartable(false);
clone._heap = heapCopy;
return clone.reset();
No revision
No revision
1.35.2.9 +54 -10 xml-xalan/java/src/org/apache/xalan/xsltc/runtime/BasisLibrary.java
Index: BasisLibrary.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/BasisLibrary.java,v
retrieving revision 1.35.2.8
retrieving revision 1.35.2.9
diff -u -r1.35.2.8 -r1.35.2.9
--- BasisLibrary.java 4 Oct 2002 09:24:46 -0000 1.35.2.8
+++ BasisLibrary.java 22 Oct 2002 14:52:39 -0000 1.35.2.9
@@ -119,6 +119,15 @@
}
/**
+ * Standard function position()
+ */
+ public static int positionF(DTMAxisIterator iterator) {
+ return iterator.isReverse()
+ ? iterator.getLast() - iterator.getPosition() + 1
+ : iterator.getPosition();
+ }
+
+ /**
* XSLT Standard function sum(node-set).
* stringToDouble is inlined
*/
@@ -1165,7 +1174,49 @@
runTimeError(RUN_TIME_COPY_ERR);
}
}
-
+
+ /**
+ * Utility function for the implementation of xsl:element.
+ */
+ public static String startXslElement(String qname, String namespace,
+ TransletOutputHandler handler, DOM dom, int node)
+ {
+ try {
+ // Get prefix from qname
+ String prefix;
+ final int index = qname.indexOf(':');
+
+ if (index > 0) {
+ prefix = qname.substring(0, index);
+
+ // Handle case when prefix is not known at compile time
+ if (namespace == null || namespace.length() == 0) {
+ namespace = dom.lookupNamespace(node, prefix);
+ }
+
+ handler.startElement(qname);
+ handler.namespace(prefix, namespace);
+ }
+ else {
+ // Need to generate a prefix?
+ if (namespace != null && namespace.length() > 0) {
+ prefix = generatePrefix();
+ qname = prefix + ':' + qname;
+ handler.startElement(qname);
+ handler.namespace(prefix, namespace);
+ }
+ else {
+ handler.startElement(qname);
+ }
+ }
+ }
+ catch (TransletException e) {
+ throw new RuntimeException(e.getMessage());
+ }
+
+ return qname;
+ }
+
/**
* This function is used in the execution of xsl:element
*/
@@ -1177,16 +1228,9 @@
/**
* This function is used in the execution of xsl:element
*/
- private static int prefixIndex = 0;
+ private static int prefixIndex = 0; // not thread safe!!
public static String generatePrefix() {
return ("ns" + prefixIndex++);
- }
-
- /**
- * This function is used in the execution of xsl:element
- */
- public static String makeQName(String localName, String prefix) {
- return (new StringBuffer(prefix).append(':').append(localName).toString());
}
public static final int RUN_TIME_INTERNAL_ERR = 0;
No revision
No revision
1.10.2.4 +18 -15 xml-xalan/java/src/org/apache/xalan/xsltc/trax/TemplatesImpl.java
Index: TemplatesImpl.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/TemplatesImpl.java,v
retrieving revision 1.10.2.3
retrieving revision 1.10.2.4
diff -u -r1.10.2.3 -r1.10.2.4
--- TemplatesImpl.java 24 Aug 2002 12:39:06 -0000 1.10.2.3
+++ TemplatesImpl.java 22 Oct 2002 14:52:39 -0000 1.10.2.4
@@ -68,6 +68,7 @@
import java.io.Serializable;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+import java.io.ObjectInputStream;
import java.io.IOException;
import java.util.Properties;
import java.security.AccessController;
@@ -132,7 +133,7 @@
* A reference to the transformer factory that this templates
* object belongs to.
*/
- private TransformerFactoryImpl _tfactory = null;
+ private transient TransformerFactoryImpl _tfactory = null;
private class TransletClassLoader extends ClassLoader {
@@ -144,6 +145,7 @@
}
}
+
/**
* The only way to create an XSLTC emplate object
* The bytecodes for the translet and auxiliary classes, plus the name of
@@ -160,21 +162,22 @@
_tfactory = tfactory;
}
- public synchronized void writeExternal(ObjectOutput out)
- throws IOException
- {
- out.writeObject(_name);
- out.writeObject(_bytecodes);
- out.flush();
- }
+ /**
+ * Need for de-serialization, see readObject().
+ */
+ public TemplatesImpl() { }
- public synchronized void readExternal(ObjectInput in)
- throws IOException, ClassNotFoundException
+ /**
+ * Overrides the default readObject implementation since we decided
+ * it would be cleaner not to serialize the entire tranformer
+ * factory. [ ref bugzilla 12317 ]
+ */
+ private void readObject(ObjectInputStream is)
+ throws IOException, ClassNotFoundException
{
- _name = (String)in.readObject();
- _bytecodes = (byte[][])in.readObject();
- _class = null; // must be created again...
- }
+ is.defaultReadObject();
+ _tfactory = new TransformerFactoryImpl();
+ }
/**
* Store URIResolver needed for Transformers.
1.34.2.7 +2 -2 xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerFactoryImpl.java
Index: TransformerFactoryImpl.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerFactoryImpl.java,v
retrieving revision 1.34.2.6
retrieving revision 1.34.2.7
diff -u -r1.34.2.6 -r1.34.2.7
--- TransformerFactoryImpl.java 4 Oct 2002 09:24:46 -0000 1.34.2.6
+++ TransformerFactoryImpl.java 22 Oct 2002 14:52:39 -0000 1.34.2.7
@@ -162,7 +162,7 @@
/**
* The above hashtable stores objects of this class.
*/
- private class PIParamWrapper {
+ private static class PIParamWrapper {
public String _media = null;
public String _title = null;
public String _charset = null;
No revision
No revision
1.1.14.2 +91 -2 xml-xalan/java/src/org/apache/xalan/xsltc/util/IntegerArray.java
Index: IntegerArray.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/util/IntegerArray.java,v
retrieving revision 1.1.14.1
retrieving revision 1.1.14.2
diff -u -r1.1.14.1 -r1.1.14.2
--- IntegerArray.java 29 Jul 2002 00:01:30 -0000 1.1.14.1
+++ IntegerArray.java 22 Oct 2002 14:52:39 -0000 1.1.14.2
@@ -120,12 +120,101 @@
_array[_free++] = value;
}
- /** adds new int at the end if not already present */
+ /**
+ * Adds new int at the end if not already present.
+ */
public void addNew(int value) {
for (int i = 0; i < _free; i++) {
if (_array[i] == value) return; // already in array
}
add(value);
+ }
+
+ public void reverse() {
+ int left = 0;
+ int right = _free - 1;
+
+ while (left < right) {
+ int temp = _array[left];
+ _array[left++] = _array[right];
+ _array[right--] = temp;
+ }
+ }
+
+ /**
+ * Merge two sorted arrays and eliminate duplicates.
+ */
+ public void merge(IntegerArray other) {
+ final int newSize = _free + other._free;
+// System.out.println("IntegerArray.merge() begin newSize = " + newSize);
+ int[] newArray = new int[newSize];
+
+ // Merge the two arrays
+ int i = 0, j = 0, k;
+ for (k = 0; i < _free && j < other._free; k++) {
+ int x = _array[i];
+ int y = other._array[j];
+
+ if (x < y) {
+ newArray[k] = x;
+ i++;
+ }
+ else if (x > y) {
+ newArray[k] = y;
+ j++;
+ }
+ else {
+ newArray[k] = x;
+ i++; j++;
+ }
+ }
+
+ // Copy the rest if of different lengths
+ if (i >= _free) {
+ while (j < other._free) {
+ newArray[k++] = other._array[j++];
+ }
+ }
+ else {
+ while (i < _free) {
+ newArray[k++] = _array[i++];
+ }
+ }
+
+ // Update reference to this array
+ _array = newArray;
+ _free = _size = newSize;
+// System.out.println("IntegerArray.merge() end");
+ }
+
+ public void sort() {
+ quicksort(_array, 0, _free - 1);
+ }
+
+ private static void quicksort(int[] array, int p, int r) {
+ if (p < r) {
+ final int q = partition(array, p, r);
+ quicksort(array, p, q);
+ quicksort(array, q + 1, r);
+ }
+ }
+
+ private static int partition(int[] array, int p, int r) {
+ final int x = array[p];
+ int i = p - 1; int j = r + 1;
+
+ while (true) {
+ while (x < array[--j]);
+ while (x > array[++i]);
+ if (i < j) {
+ int temp = array[i];
+ array[i] = array[j];
+ array[j] = temp;
+ }
+ else {
+ return j;
+ }
+ }
}
private void growArray(int size) {
No revision
No revision
1.5.12.2 +3 -3 xml-xalan/java/src/org/apache/xml/dtm/ref/DTMAxisIteratorBase.java
Index: DTMAxisIteratorBase.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMAxisIteratorBase.java,v
retrieving revision 1.5.12.1
retrieving revision 1.5.12.2
diff -u -r1.5.12.1 -r1.5.12.2
--- DTMAxisIteratorBase.java 17 Apr 2002 18:13:48 -0000 1.5.12.1
+++ DTMAxisIteratorBase.java 22 Oct 2002 14:52:39 -0000 1.5.12.2
@@ -68,12 +68,12 @@
* Note that this is _not_ the node's handle within the DTM. Also, don't
* confuse it with the current (most recently returned) position.
*/
- private int _last = -1;
+ protected int _last = -1;
/** The position of the current node within the iteration, as defined by XPath.
* Note that this is _not_ the node's handle within the DTM!
*/
- public int _position = 0;
+ protected int _position = 0;
/** The position of the marked node within the iteration;
* a saved itaration state that we may want to come back to.
@@ -95,7 +95,7 @@
* we are iterating over a stream that can not be re-scanned, or if
* the iterator was produced by cloning another iterator.)
*/
- public boolean _isRestartable = true;
+ protected boolean _isRestartable = true;
/**
* Get start to END should 'close' the iterator,
1.4.2.4 +101 -118 xml-xalan/java/src/org/apache/xml/dtm/ref/ExpandedNameTable.java
Index: ExpandedNameTable.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/ExpandedNameTable.java,v
retrieving revision 1.4.2.3
retrieving revision 1.4.2.4
diff -u -r1.4.2.3 -r1.4.2.4
--- ExpandedNameTable.java 29 Jul 2002 00:01:30 -0000 1.4.2.3
+++ ExpandedNameTable.java 22 Oct 2002 14:52:40 -0000 1.4.2.4
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * 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
@@ -18,7 +18,7 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * 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,
@@ -26,7 +26,7 @@
*
* 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
+ * software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
@@ -80,19 +80,19 @@
{
/** Probably a reference to static pool. */
- private DTMStringPool m_locNamesPool;
+ //private DTMStringPool m_locNamesPool;
/** Probably a reference to static pool. */
- private DTMStringPool m_namespaceNames;
-
+ //private DTMStringPool m_namespaceNames;
+
/** Vector of extended types for this document */
private /*static*/ Vector m_extendedTypes;
-
+
/** Next available extended type */
// %REVIEW% Since this is (should be) always equal
// to the length of m_extendedTypes, do we need this?
private int m_nextType;
-
+
// These are all the types prerotated, for caller convenience.
public static final int ELEMENT = ((int)DTM.ELEMENT_NODE) ;
public static final int ATTRIBUTE = ((int)DTM.ATTRIBUTE_NODE) ;
@@ -110,19 +110,37 @@
Hashtable m_hashtable = new Hashtable();
-
- /** Workspace for lookup. NOT THREAD SAFE!
- * */
- ExtendedType hashET=new ExtendedType(-1,"","");
+ /** Workspace for lookup. NOT THREAD SAFE!
+ * */
+ ExtendedType hashET=new ExtendedType(-1,"","");
+
+ private static Hashtable m_defaultHashtable;
+ private static Vector m_defaultExtendedTypes;
+
+ /**
+ * Init default vales
+ */
+ static {
+ // use bigger values than default, to avoid reallocation in the future
+ m_defaultExtendedTypes = new Vector(23);
+ m_defaultHashtable = new Hashtable(23, 0.75f);
+
+ for (int i = 0; i < DTM.NTYPES; i++)
+ {
+ ExtendedType newET = new ExtendedType(i, "", "");
+ m_defaultExtendedTypes.addElement(newET);
+ m_defaultHashtable.put(newET, new Integer(i));
+ }
+ }
/**
* Create an expanded name table that uses private string pool lookup.
*/
public ExpandedNameTable()
{
- m_locNamesPool = new DTMSafeStringPool();
- m_namespaceNames = new DTMSafeStringPool();
- initExtendedTypes();
+ //m_locNamesPool = new DTMSafeStringPool();
+ //m_namespaceNames = new DTMSafeStringPool();
+ initExtendedTypes();
}
/**
@@ -134,31 +152,21 @@
public ExpandedNameTable(DTMStringPool locNamesPool,
DTMStringPool namespaceNames)
{
- m_locNamesPool = locNamesPool;
- m_namespaceNames = namespaceNames;
+ //m_locNamesPool = locNamesPool;
+ //m_namespaceNames = namespaceNames;
initExtendedTypes();
}
-
+
/**
- * Initialize the vector of extended types with the
- * basic DOM node types.
+ * Initialize the vector of extended types with the
+ * basic DOM node types.
*/
private void initExtendedTypes()
{
- m_extendedTypes = new Vector();
- int i;
- for (i = 0; i < DTM.NTYPES; i++)
- {
- ExtendedType newET = new ExtendedType(i, "", "");
- m_extendedTypes.addElement(newET);
- m_hashtable.put(newET, new Integer(i));
- }
-
- /* for (i = 0; i < HASHPRIME; i++)
- {
- m_hashtable[i] = -1;
- }*/
-
+ // Since objects in the Vector a m_extendedTypes and m_hashtable are never changed
+ // it should be safe to copy default tables
+ m_extendedTypes = (Vector)m_defaultExtendedTypes.clone();
+ m_hashtable = (Hashtable)m_defaultHashtable.clone();
m_nextType = m_extendedTypes.size();
}
@@ -175,59 +183,35 @@
*/
public int getExpandedTypeID(String namespace, String localName, int type)
{
- if (null == namespace)
+ /*int nsID = (null != namespace) ? m_namespaceNames.stringToIndex(namespace) : 0;
+ int lnID = m_locNamesPool.stringToIndex(localName);
+
+ int expandedTypeID = (type << (BITS_PER_NAMESPACE+BITS_PER_LOCALNAME))
+ | (nsID << BITS_PER_LOCALNAME) | lnID;
+ return expandedTypeID;
+*/
+ if (null == namespace)
namespace = "";
- if (null == localName)
+ if (null == localName)
localName = "";
-
-
- // %REVIEW% Linear search is slow. Can we do better?
- // Some form of hashtable or binary search or...?
- // The hard part is that we have to hash by multiple
- // values. Hash by one, test others? Add/XOR their
- // hash values together to form a combined hash?
- // (If we're using standard hashtable, that means
- // defining an object which we'd set these values
- // into to obtain that hashvalue. See also our string
- // tables, which implement their own hash lookup, as
- // a possible alternative approach.)
- //
- // %REVIEW% Vectors are slower than arrays. Should we
- // consider using a reallocated array instead? This
- // would also avoid the need to cast the returned
- // object; casting also adds a bit of overhead.
- // This would cost us when the array has to be expanded
- // but would make lookup -- our most critical operation
- // -- faster. That tradeoff's why we went with our own
- // custom IntVector/SuballocatedIntVector elsewhere
- // in the DTM code.
- //
- // See also comments in the ExtendedType class.
- //
- // REMINDER: THIS IS BRAINSTORMING ONLY. I could
- // be completely off base. Apply common sense and
- // run benchmark tests, rather than assuming these
- // ideas make any sense whatsoever, and feel free to
- // apply better solutons! -- JJK
-
- // Set our reusable ExpandedType so we can look
- // it up in the hashtable. Not threadsafe, but
- // avoids creating a new object until we know
- // this isn't one we've seen before.
- hashET.redefine(type,namespace,localName);
-
- Object eType;
- if ((eType = m_hashtable.get(hashET)) != null )
- return ((Integer)eType).intValue();
-
- ExtendedType newET=new ExtendedType(type, namespace, localName);
- m_extendedTypes.addElement(newET);
- m_hashtable.put(newET, new Integer(m_nextType));
+ // Set our reusable ExpandedType so we can look
+ // it up in the hashtable. Not threadsafe, but
+ // avoids creating a new object until we know
+ // this isn't one we've seen before.
+ hashET.redefine(type,namespace,localName);
+
+ Object eType;
+ if ((eType = m_hashtable.get(hashET)) != null )
+ return ((Integer)eType).intValue();
+
+ ExtendedType newET=new ExtendedType(type, namespace, localName);
+ m_extendedTypes.addElement(newET);
+ m_hashtable.put(newET, new Integer(m_nextType));
return m_nextType++;
}
-
+
/**
- * Given a type, return an expanded name ID.Any additional nodes that are
+ * Given a type, return an expanded name ID.Any additional nodes that are
* created that have this expanded name will use this ID.
*
* @param namespace
@@ -236,8 +220,8 @@
* @return the expanded-name id of the node.
*/
public int getExpandedTypeID(int type)
- {
- return type;
+ {
+ return type;
}
/**
@@ -252,7 +236,7 @@
ExtendedType etype = (ExtendedType)m_extendedTypes.elementAt (ExpandedNameID);
return etype.localName;
}
-
+
/**
* Given an expanded-name ID, return the local name ID.
*
@@ -283,9 +267,9 @@
//int id = (ExpandedNameID & MASK_NAMESPACE) >> BITS_PER_LOCALNAME;
//return (0 == id) ? null : m_namespaceNames.indexToString(id);
ExtendedType etype = (ExtendedType)m_extendedTypes.elementAt (ExpandedNameID);
- return (etype.namespace.equals("") ? null : etype.namespace);
+ return (etype.namespace.equals("") ? null : etype.namespace);
}
-
+
/**
* Given an expanded-name ID, return the namespace URI ID.
*
@@ -301,7 +285,7 @@
else
return ExpandedNameID;
}
-
+
/**
* Given an expanded-name ID, return the local name ID.
*
@@ -314,23 +298,22 @@
return (short)etype.nodetype;
}
- public int getSize()
+ public int getSize()
{
return m_nextType;
}
/**
- * Private class representing an extended type object
- *
+ * Private class representing an extended type object
*/
- private class ExtendedType
+ private static class ExtendedType
{
protected int nodetype;
protected String namespace;
protected String localName;
protected int hash;
-
+
protected ExtendedType (int nodetype, String namespace, String localName)
{
this.nodetype = nodetype;
@@ -350,37 +333,37 @@
this.localName = localName;
this.hash=nodetype+namespace.hashCode()+localName.hashCode();
}
-
+
/* Override super method
* */
- public int hashCode()
+ public int hashCode()
{
return hash;
}
/* Override super method
* */
- public boolean equals(Object other)
- {
- //Usually an optimization, but
- // won't arise in our usage:
- //if(other==this) return true;
- try
- {
- ExtendedType et=(ExtendedType)other;
- return et.nodetype==this.nodetype &&
- et.localName.equals(this.localName) &&
- et.namespace.equals(this.namespace);
- }
- catch(ClassCastException e)
- {
- return false;
- }
- catch(NullPointerException e)
- {
- return false;
- }
- }
+ public boolean equals(Object other)
+ {
+ //Usually an optimization, but
+ // won't arise in our usage:
+ //if(other==this) return true;
+ try
+ {
+ ExtendedType et=(ExtendedType)other;
+ return et.nodetype==this.nodetype &&
+ et.localName.equals(this.localName) &&
+ et.namespace.equals(this.namespace);
+ }
+ catch(ClassCastException e)
+ {
+ return false;
+ }
+ catch(NullPointerException e)
+ {
+ return false;
+ }
+ }
}
-
+
}
No revision
No revision
1.6.2.1 +21 -0 xml-xalan/java/src/org/apache/xml/utils/IntStack.java
Index: IntStack.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/utils/IntStack.java,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -u -r1.6 -r1.6.2.1
--- IntStack.java 4 Mar 2002 18:47:44 -0000 1.6
+++ IntStack.java 22 Oct 2002 14:52:40 -0000 1.6.2.1
@@ -88,6 +88,16 @@
{
super(blocksize);
}
+
+ /**
+ * Copy constructor for IntStack
+ *
+ * @param v IntStack to copy
+ */
+ public IntStack (IntStack v)
+ {
+ super(v);
+ }
/**
* Pushes an item onto the top of this stack.
@@ -222,5 +232,16 @@
}
return -1;
+ }
+
+ /**
+ * Returns clone of current IntStack
+ *
+ * @return clone of current IntStack
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ return (IntStack) super.clone();
}
}
1.4.10.1 +26 -1 xml-xalan/java/src/org/apache/xml/utils/IntVector.java
Index: IntVector.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/utils/IntVector.java,v
retrieving revision 1.4
retrieving revision 1.4.10.1
diff -u -r1.4 -r1.4.10.1
--- IntVector.java 21 Jun 2001 18:52:53 -0000 1.4
+++ IntVector.java 22 Oct 2002 14:52:40 -0000 1.4.10.1
@@ -66,7 +66,7 @@
* access to existing nodes is O(1) fast but appending may be O(N**2)
* slow. See also SuballocatedIntVector.
*/
-public class IntVector
+public class IntVector implements Cloneable
{
/** Size of blocks to allocate */
@@ -119,6 +119,19 @@
m_map = new int[blocksize];
}
+ /**
+ * Copy constructor for IntVector
+ *
+ * @param v Existing IntVector to copy
+ */
+ public IntVector(IntVector v)
+ {
+ m_map = new int[v.m_mapSize];
+ m_mapSize = v.m_mapSize;
+ m_firstFree = v.m_firstFree;
+ m_blocksize = v.m_blocksize;
+ System.arraycopy(v.m_map, 0, m_map, 0, m_firstFree);
+ }
/**
* Get the length of the list.
@@ -427,4 +440,16 @@
return java.lang.Integer.MIN_VALUE;
}
+
+ /**
+ * Returns clone of current IntVector
+ *
+ * @return clone of current IntVector
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ return new IntVector(this);
+ }
+
}
No revision
No revision
1.37.2.3 +57 -75 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.37.2.2
retrieving revision 1.37.2.3
diff -u -r1.37.2.2 -r1.37.2.3
--- XPathContext.java 27 Sep 2002 21:54:40 -0000 1.37.2.2
+++ XPathContext.java 22 Oct 2002 14:52:40 -0000 1.37.2.3
@@ -67,6 +67,7 @@
// Xalan imports
import org.apache.xml.utils.IntStack;
+import org.apache.xml.utils.ObjectStack;
import org.apache.xml.utils.NSInfo;
import org.apache.xml.utils.PrefixResolver;
import org.apache.xml.utils.QName;
@@ -341,10 +342,10 @@
*/
public XPathContext()
{
- m_prefixResolvers[m_prefixResolversTop++] = null;
- m_currentNodes[m_currentNodesFirstFree++] = DTM.NULL;
- m_currentNodes[m_currentExpressionNodesFirstFree++] = DTM.NULL;
- m_saxLocations[m_saxLocationsTop++] = null;
+ m_prefixResolvers.push(null);
+ m_currentNodes.push(DTM.NULL);
+ m_currentExpressionNodes.push(DTM.NULL);
+ m_saxLocations.push(null);
}
/**
@@ -359,10 +360,10 @@
m_ownerGetErrorListener = m_owner.getClass().getMethod("getErrorListener", new Class[] {});
}
catch (NoSuchMethodException nsme) {}
- m_prefixResolvers[m_prefixResolversTop++] = null;
- m_currentNodes[m_currentNodesFirstFree++] = DTM.NULL;
- m_currentNodes[m_currentExpressionNodesFirstFree++] = DTM.NULL;
- m_saxLocations[m_saxLocationsTop++] = null;
+ m_prefixResolvers.push(null);
+ m_currentNodes.push(DTM.NULL);
+ m_currentExpressionNodes.push(DTM.NULL);
+ m_saxLocations.push(null);
}
/**
@@ -385,30 +386,24 @@
m_dtmManager = DTMManager.newInstance(
org.apache.xpath.objects.XMLStringFactoryImpl.getFactory());
- m_saxLocations = new SourceLocator[RECURSIONLIMIT];
- m_saxLocationsTop = 0;
-
- m_axesIteratorStack = new Stack();
- m_contextNodeLists = new Stack();
- m_currentExpressionNodes = new int[RECURSIONLIMIT];
- m_currentExpressionNodesFirstFree = 0;
- m_currentNodes = new int[RECURSIONLIMIT];
- m_currentNodesFirstFree = 0;
- m_iteratorRoots = new NodeVector();
- m_predicatePos = new IntStack();
- m_predicateRoots = new NodeVector();
- m_prefixResolvers = new PrefixResolver[RECURSIONLIMIT];
- int m_prefixResolversTop = 0;
+ m_saxLocations.removeAllElements();
+ m_axesIteratorStack.clear();
+ m_contextNodeLists.clear();
+ m_currentExpressionNodes.removeAllElements();
+ m_currentNodes.removeAllElements();
+ m_iteratorRoots.RemoveAllNoClear();
+ m_predicatePos.removeAllElements();
+ m_predicateRoots.RemoveAllNoClear();
+ m_prefixResolvers.removeAllElements();
- m_prefixResolvers[m_prefixResolversTop++] = null;
- m_currentNodes[m_currentNodesFirstFree++] = DTM.NULL;
- m_currentNodes[m_currentExpressionNodesFirstFree++] = DTM.NULL;
- m_saxLocations[m_saxLocationsTop++] = null;
+ m_prefixResolvers.push(null);
+ m_currentNodes.push(DTM.NULL);
+ m_currentExpressionNodes.push(DTM.NULL);
+ m_saxLocations.push(null);
}
/** The current stylesheet locator. */
- SourceLocator[] m_saxLocations = new SourceLocator[RECURSIONLIMIT];
- int m_saxLocationsTop = 0;
+ ObjectStack m_saxLocations = new ObjectStack(RECURSIONLIMIT);
/**
* Set the current locater in the stylesheet.
@@ -417,7 +412,7 @@
*/
public void setSAXLocator(SourceLocator location)
{
- m_saxLocations[m_saxLocationsTop-1] = location;
+ m_saxLocations.setTop(location);
}
/**
@@ -427,7 +422,7 @@
*/
public void pushSAXLocator(SourceLocator location)
{
- m_saxLocations[m_saxLocationsTop++] = location;
+ m_saxLocations.push(location);
}
/**
@@ -438,7 +433,7 @@
*/
public void pushSAXLocatorNull()
{
- m_saxLocationsTop++;
+ m_saxLocations.push(null);
}
@@ -447,7 +442,7 @@
*/
public void popSAXLocator()
{
- m_saxLocationsTop--;
+ m_saxLocations.pop();
}
/**
@@ -457,7 +452,7 @@
*/
public SourceLocator getSAXLocator()
{
- return m_saxLocations[m_saxLocationsTop-1];
+ return (SourceLocator) m_saxLocations.peek();
}
/** The owner context of this XPathContext. In the case of XSLT, this will be a
@@ -733,13 +728,12 @@
* 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 IntStack m_currentNodes = new IntStack(RECURSIONLIMIT);
// private NodeVector m_currentNodes = new NodeVector();
- public int[] getCurrentNodeStack() {return m_currentNodes; }
- public void setCurrentNodeStack(int[] nv) { m_currentNodes = nv; }
+ public IntStack getCurrentNodeStack() {return m_currentNodes; }
+ public void setCurrentNodeStack(IntStack nv) { m_currentNodes = nv; }
/**
* Get the current context node.
@@ -748,7 +742,7 @@
*/
public final int getCurrentNode()
{
- return m_currentNodes[m_currentNodesFirstFree-1];
+ return m_currentNodes.peek();
}
/**
@@ -759,8 +753,8 @@
*/
public final void pushCurrentNodeAndExpression(int cn, int en)
{
- m_currentNodes[m_currentNodesFirstFree++] = cn;
- m_currentExpressionNodes[m_currentExpressionNodesFirstFree++] = cn;
+ m_currentNodes.push(cn);
+ m_currentExpressionNodes.push(cn);
}
/**
@@ -768,8 +762,8 @@
*/
public final void popCurrentNodeAndExpression()
{
- m_currentNodesFirstFree--;
- m_currentExpressionNodesFirstFree--;
+ m_currentNodes.quickPop(1);
+ m_currentExpressionNodes.quickPop(1);
}
/**
@@ -781,9 +775,9 @@
*/
public final void pushExpressionState(int cn, int en, PrefixResolver nc)
{
- m_currentNodes[m_currentNodesFirstFree++] = cn;
- m_currentExpressionNodes[m_currentExpressionNodesFirstFree++] = cn;
- m_prefixResolvers[m_prefixResolversTop++] = nc;
+ m_currentNodes.push(cn);
+ m_currentExpressionNodes.push(cn);
+ m_prefixResolvers.push(nc);
}
/**
@@ -791,9 +785,9 @@
*/
public final void popExpressionState()
{
- m_currentNodesFirstFree--;
- m_currentExpressionNodesFirstFree--;
- m_prefixResolversTop--;
+ m_currentNodes.quickPop(1);
+ m_currentExpressionNodes.quickPop(1);
+ m_prefixResolvers.pop();
}
@@ -805,20 +799,15 @@
*/
public final void pushCurrentNode(int n)
{
- m_currentNodes[m_currentNodesFirstFree++] = n;
+ m_currentNodes.push(n);
}
- public int getCurrentNodeFirstFree()
- {
- return m_currentNodesFirstFree;
- }
-
/**
* Pop the current context node.
*/
public final void popCurrentNode()
{
- m_currentNodesFirstFree--;
+ m_currentNodes.quickPop(1);
}
/**
@@ -876,17 +865,11 @@
private NodeVector m_predicateRoots = new NodeVector();
/** A stack of the current sub-expression nodes. */
- private int m_currentExpressionNodes[] = new int[RECURSIONLIMIT];
- protected int m_currentExpressionNodesFirstFree = 0;
+ private IntStack m_currentExpressionNodes = new IntStack(RECURSIONLIMIT);
- public int[] getCurrentExpressionNodeStack() { return m_currentExpressionNodes; }
- public void setCurrentExpressionNodeStack(int[] nv) { m_currentExpressionNodes = nv; }
- public int getCurrentExpressionNodesFirstFree()
- {
- return m_currentExpressionNodesFirstFree;
- }
-
+ public IntStack getCurrentExpressionNodeStack() { return m_currentExpressionNodes; }
+ public void setCurrentExpressionNodeStack(IntStack nv) { m_currentExpressionNodes = nv; }
private IntStack m_predicatePos = new IntStack();
@@ -912,7 +895,7 @@
*/
public final int getCurrentExpressionNode()
{
- return m_currentExpressionNodes[m_currentExpressionNodesFirstFree-1];
+ return m_currentExpressionNodes.peek();
}
/**
@@ -922,7 +905,7 @@
*/
public final void pushCurrentExpressionNode(int n)
{
- m_currentExpressionNodes[m_currentExpressionNodesFirstFree++] = n;
+ m_currentExpressionNodes.push(n);
}
/**
@@ -931,12 +914,11 @@
*/
public final void popCurrentExpressionNode()
{
- m_currentExpressionNodesFirstFree--;
+ m_currentExpressionNodes.quickPop(1);
}
- private PrefixResolver[] m_prefixResolvers
- = new PrefixResolver[RECURSIONLIMIT];
- private int m_prefixResolversTop = 0;
+ private ObjectStack m_prefixResolvers
+ = new ObjectStack(RECURSIONLIMIT);
/**
* Get the current namespace context for the xpath.
@@ -946,7 +928,7 @@
*/
public final PrefixResolver getNamespaceContext()
{
- return m_prefixResolvers[m_prefixResolversTop-1];
+ return (PrefixResolver) m_prefixResolvers.peek();
}
/**
@@ -957,7 +939,7 @@
*/
public final void setNamespaceContext(PrefixResolver pr)
{
- m_prefixResolvers[m_prefixResolversTop-1] = pr;
+ m_prefixResolvers.setTop(pr);
}
/**
@@ -968,7 +950,7 @@
*/
public final void pushNamespaceContext(PrefixResolver pr)
{
- m_prefixResolvers[m_prefixResolversTop++] = pr;
+ m_prefixResolvers.push(pr);
}
/**
@@ -977,7 +959,7 @@
*/
public final void pushNamespaceContextNull()
{
- m_prefixResolversTop++;
+ m_prefixResolvers.push(null);
}
/**
@@ -985,7 +967,7 @@
*/
public final void popNamespaceContext()
{
- m_prefixResolversTop--;
+ m_prefixResolvers.pop();
}
//==========================================================
No revision
No revision
1.15.2.1 +2 -3 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.15
retrieving revision 1.15.2.1
diff -u -r1.15 -r1.15.2.1
--- DescendantIterator.java 22 Mar 2002 01:04:42 -0000 1.15
+++ DescendantIterator.java 22 Oct 2002 14:52:40 -0000 1.15.2.1
@@ -92,9 +92,8 @@
super(compiler, opPos, analysis, false);
- int ops[] = compiler.getOpMap();
int firstStepPos = compiler.getFirstChildPos(opPos);
- int stepType = ops[firstStepPos];
+ int stepType = compiler.getOp(firstStepPos);
boolean orSelf = (OpCodes.FROM_DESCENDANTS_OR_SELF == stepType);
boolean fromRoot = false;
@@ -108,7 +107,7 @@
fromRoot = true;
// Ugly code... will go away when AST work is done.
int nextStepPos = compiler.getNextStepPos(firstStepPos);
- if(ops[nextStepPos] == OpCodes.FROM_DESCENDANTS_OR_SELF)
+ if(compiler.getOp(nextStepPos) == OpCodes.FROM_DESCENDANTS_OR_SELF)
orSelf = true;
// firstStepPos += 8;
}
1.26.2.1 +3 -3 xml-xalan/java/src/org/apache/xpath/axes/UnionPathIterator.java
Index: UnionPathIterator.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/UnionPathIterator.java,v
retrieving revision 1.26
retrieving revision 1.26.2.1
diff -u -r1.26 -r1.26.2.1
--- UnionPathIterator.java 22 Mar 2002 01:04:43 -0000 1.26
+++ UnionPathIterator.java 22 Oct 2002 14:52:40 -0000 1.26.2.1
@@ -372,7 +372,7 @@
{
// TODO: Handle unwrapped FilterExpr
- int steptype = compiler.getOpMap()[opPos];
+ int steptype = compiler.getOp(opPos);
if (steptype == OpCodes.OP_LOCATIONPATH)
{
@@ -545,7 +545,7 @@
{
return m_exprs[m_index];
}
-
+
/**
* @see ExpressionOwner#setExpression(Expression)
*/
@@ -569,7 +569,7 @@
exp.exprSetParent(UnionPathIterator.this);
m_exprs[m_index] = (LocPathIterator)exp;
}
-
+
}
/**
1.22.2.2 +10 -15 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.22.2.1
retrieving revision 1.22.2.2
diff -u -r1.22.2.1 -r1.22.2.2
--- WalkerFactory.java 29 Jul 2002 00:01:32 -0000 1.22.2.1
+++ WalkerFactory.java 22 Oct 2002 14:52:40 -0000 1.22.2.2
@@ -102,7 +102,7 @@
{
AxesWalker firstWalker = null;
- int stepType = compiler.getOpMap()[stepOpCodePos];
+ int stepType = compiler.getOp(stepOpCodePos);
if (stepType != OpCodes.ENDOP)
{
@@ -142,10 +142,10 @@
int stepType;
AxesWalker firstWalker = null;
AxesWalker walker, prevWalker = null;
- int ops[] = compiler.getOpMap();
+
int analysis = analyze(compiler, stepOpCodePos, stepIndex);
- while (OpCodes.ENDOP != (stepType = ops[stepOpCodePos]))
+ while (OpCodes.ENDOP != (stepType = compiler.getOp(stepOpCodePos)))
{
walker = createDefaultWalker(compiler, stepOpCodePos, lpi, analysis);
@@ -345,8 +345,7 @@
throws javax.xml.transform.TransformerException
{
- int ops[] = compiler.getOpMap();
- int stepType = ops[stepOpCodePos];
+ int stepType = compiler.getOp(stepOpCodePos);
switch (stepType)
{
@@ -603,7 +602,6 @@
{
int stepType;
- int ops[] = compiler.getOpMap();
int stepCount = 0;
boolean foundDorDS = false;
boolean foundSelf = false;
@@ -611,7 +609,7 @@
int nodeTestType = OpCodes.NODETYPE_NODE;
- while (OpCodes.ENDOP != (stepType = ops[stepOpCodePos]))
+ while (OpCodes.ENDOP != (stepType = compiler.getOp(stepOpCodePos)))
{
// The DescendantIterator can only do one node test. If there's more
// than one, use another iterator.
@@ -677,7 +675,7 @@
if (nextStepOpCodePos < 0)
break;
- if(OpCodes.ENDOP != ops[nextStepOpCodePos])
+ if(OpCodes.ENDOP != compiler.getOp(nextStepOpCodePos))
{
if(compiler.countPredicates(stepOpCodePos) > 0)
{
@@ -712,11 +710,10 @@
{
int stepType;
- int ops[] = compiler.getOpMap();
int stepCount = 0;
int analysisResult = 0x00000000; // 32 bits of analysis
- while (OpCodes.ENDOP != (stepType = ops[stepOpCodePos]))
+ while (OpCodes.ENDOP != (stepType = compiler.getOp(stepOpCodePos)))
{
stepCount++;
@@ -802,7 +799,7 @@
//+ stepType);
}
- if (OpCodes.NODETYPE_NODE == ops[stepOpCodePos + 3]) // child::node()
+ if (OpCodes.NODETYPE_NODE == compiler.getOp(stepOpCodePos + 3)) // child::node()
{
analysisResult |= BIT_NODETEST_ANY;
}
@@ -875,10 +872,9 @@
int stepType;
StepPattern step = null;
StepPattern firstStep = null, prevStep = null;
- int ops[] = compiler.getOpMap();
int analysis = analyze(compiler, stepOpCodePos, stepIndex);
- while (OpCodes.ENDOP != (stepType = ops[stepOpCodePos]))
+ while (OpCodes.ENDOP != (stepType = compiler.getOp(stepOpCodePos)))
{
step = createDefaultStepPattern(compiler, stepOpCodePos, mpi, analysis,
firstStep, prevStep);
@@ -1697,7 +1693,6 @@
// Unfortunately, we can't do this just via the analysis bits.
int stepType;
- int ops[] = compiler.getOpMap();
int stepCount = 0;
boolean foundWildAttribute = false;
@@ -1706,7 +1701,7 @@
// combonation are counted with this variable.
int potentialDuplicateMakingStepCount = 0;
- while (OpCodes.ENDOP != (stepType = ops[stepOpCodePos]))
+ while (OpCodes.ENDOP != (stepType = compiler.getOp(stepOpCodePos)))
{
stepCount++;
No revision
No revision
1.27.2.2 +16 -16 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.27.2.1
retrieving revision 1.27.2.2
diff -u -r1.27.2.1 -r1.27.2.2
--- Compiler.java 29 Jul 2002 00:01:33 -0000 1.27.2.1
+++ Compiler.java 22 Oct 2002 14:52:41 -0000 1.27.2.2
@@ -146,7 +146,7 @@
public Expression compile(int opPos) throws TransformerException
{
- int op = m_opMap[opPos];
+ int op = getOp(opPos);
Expression expr = null;
// System.out.println(getPatternString()+"op: "+op);
@@ -220,7 +220,7 @@
break;
default :
error(XPATHErrorResources.ER_UNKNOWN_OPCODE,
- new Object[]{ Integer.toString(m_opMap[opPos]) }); //"ERROR! Unknown op code: "+m_opMap[opPos]);
+ new Object[]{ Integer.toString(getOp(opPos)) }); //"ERROR! Unknown op code: "+m_opMap[opPos]);
}
// if(null != expr)
// expr.setSourceLocator(m_locator);
@@ -537,7 +537,7 @@
opPos = getFirstChildPos(opPos);
- return (XString) m_tokenQueue[m_opMap[opPos]];
+ return (XString) getTokenQueue().elementAt(getOp(opPos));
}
/**
@@ -554,7 +554,7 @@
opPos = getFirstChildPos(opPos);
- return (XNumber) m_tokenQueue[m_opMap[opPos]];
+ return (XNumber) getTokenQueue().elementAt(getOp(opPos));
}
/**
@@ -573,12 +573,12 @@
opPos = getFirstChildPos(opPos);
- int nsPos = m_opMap[opPos];
+ int nsPos = getOp(opPos);
java.lang.String namespace
= (OpCodes.EMPTY == nsPos) ? null
- : (java.lang.String) m_tokenQueue[nsPos];
+ : (java.lang.String) getTokenQueue().elementAt(nsPos);
java.lang.String localname
- = (java.lang.String) m_tokenQueue[m_opMap[opPos+1]];
+ = (java.lang.String) getTokenQueue().elementAt(getOp(opPos+1));
QName qname = new QName(namespace, localname);
var.setQName(qname);
@@ -708,7 +708,7 @@
int nextOpPos = opPos;
int i;
- for (i = 0; m_opMap[nextOpPos] == OpCodes.OP_LOCATIONPATHPATTERN; i++)
+ for (i = 0; getOp(nextOpPos) == OpCodes.OP_LOCATIONPATHPATTERN; i++)
{
nextOpPos = getNextOpPos(nextOpPos);
}
@@ -719,7 +719,7 @@
UnionPattern up = new UnionPattern();
StepPattern[] patterns = new StepPattern[i];
- for (i = 0; m_opMap[opPos] == OpCodes.OP_LOCATIONPATHPATTERN; i++)
+ for (i = 0; getOp(opPos) == OpCodes.OP_LOCATIONPATHPATTERN; i++)
{
nextOpPos = getNextOpPos(opPos);
patterns[i] = (StepPattern) compile(opPos);
@@ -848,7 +848,7 @@
{
int startOpPos = opPos;
- int stepType = getOpMap()[opPos];
+ int stepType = getOp(opPos);
if (OpCodes.ENDOP == stepType)
{
@@ -871,7 +871,7 @@
if(DEBUG)
System.out.println("MATCH_FUNCTION: "+m_currentPattern);
addMagicSelf = false;
- argLen = m_opMap[opPos + OpMap.MAPINDEX_LENGTH];
+ argLen = getOp(opPos + OpMap.MAPINDEX_LENGTH);
pattern = new FunctionPattern(compileFunction(opPos), Axis.PARENT, Axis.CHILD);
break;
case OpCodes.FROM_ROOT :
@@ -1042,11 +1042,11 @@
Expression compileFunction(int opPos) throws TransformerException
{
- int endFunc = opPos + m_opMap[opPos + 1] - 1;
+ int endFunc = opPos + getOp(opPos + 1) - 1;
opPos = getFirstChildPos(opPos);
- int funcID = m_opMap[opPos];
+ int funcID = getOp(opPos);
opPos++;
@@ -1103,16 +1103,16 @@
throws TransformerException
{
- int endExtFunc = opPos + m_opMap[opPos + 1] - 1;
+ int endExtFunc = opPos + getOp(opPos + 1) - 1;
opPos = getFirstChildPos(opPos);
- java.lang.String ns = (java.lang.String) m_tokenQueue[m_opMap[opPos]];
+ java.lang.String ns = (java.lang.String) getTokenQueue().elementAt(getOp(opPos));
opPos++;
java.lang.String funcName =
- (java.lang.String) m_tokenQueue[m_opMap[opPos]];
+ (java.lang.String) getTokenQueue().elementAt(getOp(opPos));
opPos++;
1.9.10.2 +12 -16 xml-xalan/java/src/org/apache/xpath/compiler/Lexer.java
Index: Lexer.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/compiler/Lexer.java,v
retrieving revision 1.9.10.1
retrieving revision 1.9.10.2
diff -u -r1.9.10.1 -r1.9.10.2
--- Lexer.java 29 Jul 2002 00:01:33 -0000 1.9.10.1
+++ Lexer.java 22 Oct 2002 14:52:41 -0000 1.9.10.2
@@ -56,15 +56,10 @@
*/
package org.apache.xpath.compiler;
-import org.apache.xml.utils.PrefixResolver;
-
import java.util.Vector;
+import org.apache.xml.utils.PrefixResolver;
import org.apache.xpath.res.XPATHErrorResources;
-import org.apache.xpath.XPath;
-import org.apache.xpath.compiler.Compiler;
-import org.apache.xpath.compiler.OpCodes;
-import org.apache.xpath.compiler.XPathParser;
/**
* This class is in charge of lexical processing of the XPath
@@ -151,13 +146,14 @@
throws javax.xml.transform.TransformerException
{
- m_compiler.m_tokenQueueSize = 0;
m_compiler.m_currentPattern = pat;
- m_patternMapSize = 0;
- m_compiler.m_opMap = new int[OpMap.MAXTOKENQUEUESIZE * 5];
+ m_patternMapSize = 0;
+
+ // This needs to grow too.
+ m_compiler.m_opMap = new OpMapVector(OpMap.MAXTOKENQUEUESIZE * 5, OpMap.BLOCKTOKENQUEUESIZE * 5, OpMap.MAPINDEX_LENGTH);
int nChars = pat.length();
- int startSubstring = -1;
+ int startSubstring = -1;
int posOfNSSep = -1;
boolean isStartOfPat = true;
boolean isAttrName = false;
@@ -403,7 +399,7 @@
}
}
- if (0 == m_compiler.m_tokenQueueSize)
+ if (0 == m_compiler.getTokenQueueSize())
{
m_processor.error(XPATHErrorResources.ER_EMPTY_EXPRESSION, null); //"Empty expression!");
}
@@ -444,7 +440,7 @@
m_patternMap[m_patternMapSize - 1] -= TARGETEXTRA;
}
m_patternMap[m_patternMapSize] =
- (m_compiler.m_tokenQueueSize - (isAttrName ? 1 : 0)) + TARGETEXTRA;
+ (m_compiler.getTokenQueueSize() - (isAttrName ? 1 : 0)) + TARGETEXTRA;
m_patternMapSize++;
@@ -477,7 +473,7 @@
private final void resetTokenMark(int mark)
{
- int qsz = m_compiler.m_tokenQueueSize;
+ int qsz = m_compiler.getTokenQueueSize();
m_processor.m_queueMark = (mark > 0)
? ((mark <= qsz) ? mark - 1 : mark) : 0;
@@ -485,7 +481,7 @@
if (m_processor.m_queueMark < qsz)
{
m_processor.m_token =
- (String) m_compiler.m_tokenQueue[m_processor.m_queueMark++];
+ (String) m_compiler.getTokenQueue().elementAt(m_processor.m_queueMark++);
m_processor.m_tokenChar = m_processor.m_token.charAt(0);
}
else
@@ -579,7 +575,7 @@
tokPos += 2;
}
- targetStrings.addElement(m_compiler.m_tokenQueue[tokPos]);
+ targetStrings.addElement(m_compiler.getTokenQueue().elementAt(tokPos));
}
}
@@ -591,7 +587,7 @@
*/
private final void addToTokenQueue(String s)
{
- m_compiler.m_tokenQueue[m_compiler.m_tokenQueueSize++] = s;
+ m_compiler.getTokenQueue().addElement(s);
}
/**
1.10.10.2 +53 -54 xml-xalan/java/src/org/apache/xpath/compiler/OpMap.java
Index: OpMap.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/compiler/OpMap.java,v
retrieving revision 1.10.10.1
retrieving revision 1.10.10.2
diff -u -r1.10.10.1 -r1.10.10.2
--- OpMap.java 29 Jul 2002 00:01:33 -0000 1.10.10.1
+++ OpMap.java 22 Oct 2002 14:52:41 -0000 1.10.10.2
@@ -56,12 +56,10 @@
*/
package org.apache.xpath.compiler;
-import java.util.Vector;
-
-import org.apache.xml.utils.QName;
+import org.apache.xalan.res.XSLMessages;
+import org.apache.xml.utils.ObjectVector;
import org.apache.xpath.patterns.NodeTest;
import org.apache.xpath.res.XPATHErrorResources;
-import org.apache.xalan.res.XSLMessages;
/**
* This class represents the data structure basics of the XPath
@@ -96,23 +94,28 @@
}
/**
- * The max size that the token queue can grow to.
+ * The starting size of the token queue.
*/
static final int MAXTOKENQUEUESIZE = 500;
+ /*
+ * Amount to grow token queue when it becomes full
+ */
+ static final int BLOCKTOKENQUEUESIZE = 500;
+
/**
* TokenStack is the queue of used tokens. The current token is the token at the
* end of the m_tokenQueue. The idea is that the queue can be marked and a sequence
* of tokens can be reused.
*/
- public Object[] m_tokenQueue = new Object[MAXTOKENQUEUESIZE];
+ ObjectVector m_tokenQueue = new ObjectVector(MAXTOKENQUEUESIZE, BLOCKTOKENQUEUESIZE);
/**
* Get the XPath as a list of tokens.
*
- * @return an array of string tokens.
+ * @return ObjectVector of tokens.
*/
- public Object[] getTokenQueue()
+ public ObjectVector getTokenQueue()
{
return m_tokenQueue;
}
@@ -126,13 +129,13 @@
*/
public Object getToken(int pos)
{
- return m_tokenQueue[pos];
+ return m_tokenQueue.elementAt(pos);
}
/**
* The current size of the token queue.
*/
- public int m_tokenQueueSize = 0;
+// public int m_tokenQueueSize = 0;
/**
* Get size of the token queue.
@@ -141,7 +144,8 @@
*/
public int getTokenQueueSize()
{
- return m_tokenQueueSize;
+ return m_tokenQueue.size();
+
}
/**
@@ -150,7 +154,7 @@
* I use an array instead of a full parse tree in order to cut down
* on the number of objects created.
*/
- public int m_opMap[] = null;
+ OpMapVector m_opMap = null;
/**
* Get the opcode list that describes the XPath operations. It contains
@@ -158,9 +162,9 @@
* I use an array instead of a full parse tree in order to cut down
* on the number of objects created.
*
- * @return An array of integers that is the opcode list that describes the XPath operations.
+ * @return An IntVector that is the opcode list that describes the XPath operations.
*/
- public int[] getOpMap()
+ public OpMapVector getOpMap()
{
return m_opMap;
}
@@ -181,36 +185,20 @@
void shrink()
{
- int map[] = m_opMap;
- int n = m_opMap[MAPINDEX_LENGTH];
- ;
+ int n = m_opMap.elementAt(MAPINDEX_LENGTH);
+ m_opMap.setToSize(n + 4);
- m_opMap = new int[n + 4];
+ m_opMap.setElementAt(0,n);
+ m_opMap.setElementAt(0,n+1);
+ m_opMap.setElementAt(0,n+2);
- int i;
- for (i = 0; i < n; i++)
- {
- m_opMap[i] = map[i];
- }
-
- m_opMap[i] = 0;
- m_opMap[i + 1] = 0;
- m_opMap[i + 2] = 0;
+ n = m_tokenQueue.size();
+ m_tokenQueue.setToSize(n + 4);
- Object[] tokens = m_tokenQueue;
-
- n = m_tokenQueueSize;
- m_tokenQueue = new Object[n + 4];
-
- for (i = 0; i < n; i++)
- {
- m_tokenQueue[i] = tokens[i];
- }
-
- m_tokenQueue[i] = null;
- m_tokenQueue[i + 1] = null;
- m_tokenQueue[i + 2] = null;
+ m_tokenQueue.setElementAt(null,n);
+ m_tokenQueue.setElementAt(null,n + 1);
+ m_tokenQueue.setElementAt(null,n + 2);
}
/**
@@ -221,10 +209,21 @@
*/
public int getOp(int opPos)
{
- return m_opMap[opPos];
+ return m_opMap.elementAt(opPos);
}
/**
+ * Set the op at index to the given int.
+ *
+ * @param opPos index into op map.
+ * @param value Value to set
+ */
+ public void setOp(int opPos, int value)
+ {
+ m_opMap.setElementAt(value,opPos);
+ }
+
+ /**
* Given an operation position, return the end position, i.e. the
* beginning of the next operation.
*
@@ -234,7 +233,7 @@
*/
public int getNextOpPos(int opPos)
{
- return opPos + m_opMap[opPos + 1];
+ return opPos + m_opMap.elementAt(opPos + 1);
}
/**
@@ -311,17 +310,17 @@
throws javax.xml.transform.TransformerException
{
- int stepType = m_opMap[opPos];
+ int stepType = m_opMap.elementAt(opPos);
if ((stepType >= OpCodes.AXES_START_TYPES)
&& (stepType <= OpCodes.AXES_END_TYPES))
{
- return opPos + m_opMap[opPos + 2];
+ return opPos + m_opMap.elementAt(opPos + 2);
}
else if ((stepType >= OpCodes.FIRST_NODESET_OP)
&& (stepType <= OpCodes.LAST_NODESET_OP))
{
- return opPos + m_opMap[opPos + 1];
+ return opPos + m_opMap.elementAt(opPos + 1);
}
else if(-2 == stepType)
{
@@ -379,7 +378,7 @@
*/
public int getArgLength(int opPos)
{
- return m_opMap[opPos + MAPINDEX_LENGTH];
+ return m_opMap.elementAt(opPos + MAPINDEX_LENGTH);
}
/**
@@ -391,7 +390,7 @@
*/
public int getArgLengthOfStep(int opPos)
{
- return m_opMap[opPos + MAPINDEX_LENGTH + 1] - 3;
+ return m_opMap.elementAt(opPos + MAPINDEX_LENGTH + 1) - 3;
}
/**
@@ -415,7 +414,7 @@
*/
public int getStepTestType(int opPosOfStep)
{
- return m_opMap[opPosOfStep + 3]; // skip past op, len, len without predicates
+ return m_opMap.elementAt(opPosOfStep + 3); // skip past op, len, len without predicates
}
/**
@@ -433,10 +432,10 @@
// System.out.println("getStepNS.argLenOfStep: "+argLenOfStep);
if (argLenOfStep == 3)
{
- int index = m_opMap[opPosOfStep + 4];
+ int index = m_opMap.elementAt(opPosOfStep + 4);
if (index >= 0)
- return (String) m_tokenQueue[index];
+ return (String) m_tokenQueue.elementAt(index);
else if (OpCodes.ELEMWILDCARD == index)
return NodeTest.WILD;
else
@@ -469,10 +468,10 @@
index = OpCodes.ELEMWILDCARD;
break;
case 2 :
- index = m_opMap[opPosOfStep + 4];
+ index = m_opMap.elementAt(opPosOfStep + 4);
break;
case 3 :
- index = m_opMap[opPosOfStep + 5];
+ index = m_opMap.elementAt(opPosOfStep + 5);
break;
default :
index = OpCodes.EMPTY;
@@ -482,11 +481,11 @@
// int index = (argLenOfStep == 3) ? m_opMap[opPosOfStep+5]
// : ((argLenOfStep == 1) ? -3 : -2);
if (index >= 0)
- return (String) m_tokenQueue[index].toString();
+ return (String) m_tokenQueue.elementAt(index).toString();
else if (OpCodes.ELEMWILDCARD == index)
return NodeTest.WILD;
else
return null;
}
-
+
}
1.19.2.3 +188 -197 xml-xalan/java/src/org/apache/xpath/compiler/XPathParser.java
Index: XPathParser.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/compiler/XPathParser.java,v
retrieving revision 1.19.2.2
retrieving revision 1.19.2.3
diff -u -r1.19.2.2 -r1.19.2.3
--- XPathParser.java 29 Jul 2002 00:01:33 -0000 1.19.2.2
+++ XPathParser.java 22 Oct 2002 14:52:41 -0000 1.19.2.3
@@ -154,8 +154,8 @@
lexer.tokenize(expression);
- m_ops.m_opMap[0] = OpCodes.OP_XPATH;
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] = 2;
+ m_ops.setOp(0,OpCodes.OP_XPATH);
+ m_ops.setOp(OpMap.MAPINDEX_LENGTH,2);
// Patch for Christine's gripe. She wants her errorHandler to return from
@@ -229,8 +229,8 @@
lexer.tokenize(expression);
- m_ops.m_opMap[0] = OpCodes.OP_MATCHPATTERN;
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] = 2;
+ m_ops.setOp(0, OpCodes.OP_MATCHPATTERN);
+ m_ops.setOp(OpMap.MAPINDEX_LENGTH, 2);
nextToken();
Pattern();
@@ -254,8 +254,8 @@
}
// Terminate for safety.
- m_ops.m_opMap[m_ops.m_opMap[OpMap.MAPINDEX_LENGTH]] = OpCodes.ENDOP;
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] += 1;
+ m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH), OpCodes.ENDOP);
+ m_ops.setOp(OpMap.MAPINDEX_LENGTH, m_ops.getOp(OpMap.MAPINDEX_LENGTH)+1);
m_ops.shrink();
}
@@ -332,10 +332,10 @@
int pos = (m_queueMark + n);
boolean b;
- if ((pos <= m_ops.m_tokenQueueSize) && (pos > 0)
- && (m_ops.m_tokenQueueSize != 0))
+ if ((pos <= m_ops.getTokenQueueSize()) && (pos > 0)
+ && (m_ops.getTokenQueueSize() != 0))
{
- String tok = ((String) m_ops.m_tokenQueue[pos - 1]);
+ String tok = ((String) m_ops.m_tokenQueue.elementAt(pos - 1));
b = (tok.length() == 1) ? (tok.charAt(0) == c) : false;
}
@@ -369,7 +369,7 @@
if (lookBehindPos >= 0)
{
- String lookbehind = (String) m_ops.m_tokenQueue[lookBehindPos];
+ String lookbehind = (String) m_ops.m_tokenQueue.elementAt(lookBehindPos);
if (lookbehind.length() == 1)
{
@@ -409,7 +409,7 @@
if ((m_queueMark - n) > 0)
{
- String lookbehind = (String) m_ops.m_tokenQueue[m_queueMark - (n - 1)];
+ String lookbehind = (String) m_ops.m_tokenQueue.elementAt(m_queueMark - (n - 1));
char c0 = (lookbehind == null) ? '|' : lookbehind.charAt(0);
hasToken = (c0 == '|') ? false : true;
@@ -438,9 +438,9 @@
boolean isToken;
- if ((m_queueMark + n) <= m_ops.m_tokenQueueSize)
+ if ((m_queueMark + n) <= m_ops.getTokenQueueSize())
{
- String lookahead = (String) m_ops.m_tokenQueue[m_queueMark + (n - 1)];
+ String lookahead = (String) m_ops.m_tokenQueue.elementAt(m_queueMark + (n - 1));
isToken = (lookahead != null) ? lookahead.equals(s) : (s == null);
}
@@ -459,9 +459,9 @@
private final void nextToken()
{
- if (m_queueMark < m_ops.m_tokenQueueSize)
+ if (m_queueMark < m_ops.getTokenQueueSize())
{
- m_token = (String) m_ops.m_tokenQueue[m_queueMark++];
+ m_token = (String) m_ops.m_tokenQueue.elementAt(m_queueMark++);
m_tokenChar = m_token.charAt(0);
}
else
@@ -485,9 +485,9 @@
String tok;
int relative = m_queueMark + i;
- if ((relative > 0) && (relative < m_ops.m_tokenQueueSize))
+ if ((relative > 0) && (relative < m_ops.getTokenQueueSize()))
{
- tok = (String) m_ops.m_tokenQueue[relative];
+ tok = (String) m_ops.m_tokenQueue.elementAt(relative);
}
else
{
@@ -508,7 +508,7 @@
{
m_queueMark--;
- m_token = (String) m_ops.m_tokenQueue[m_queueMark];
+ m_token = (String) m_ops.m_tokenQueue.elementAt(m_queueMark);
m_tokenChar = m_token.charAt(0);
}
else
@@ -672,13 +672,13 @@
int q = m_queueMark;
String returnMsg;
- if (q < m_ops.m_tokenQueueSize)
+ if (q < m_ops.getTokenQueueSize())
{
String msg = "\n Remaining tokens: (";
- while (q < m_ops.m_tokenQueueSize)
+ while (q < m_ops.getTokenQueueSize())
{
- String t = (String) m_ops.m_tokenQueue[q++];
+ String t = (String) m_ops.m_tokenQueue.elementAt(q++);
msg += (" '" + t + "'");
}
@@ -735,15 +735,15 @@
void insertOp(int pos, int length, int op)
{
- int totalLen = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH];
+ int totalLen = m_ops.getOp(OpMap.MAPINDEX_LENGTH);
for (int i = totalLen - 1; i >= pos; i--)
{
- m_ops.m_opMap[i + length] = m_ops.m_opMap[i];
+ m_ops.setOp(i + length, m_ops.getOp(i));
}
- m_ops.m_opMap[pos] = op;
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] = totalLen + length;
+ m_ops.setOp(pos,op);
+ m_ops.setOp(OpMap.MAPINDEX_LENGTH,totalLen + length);
}
/**
@@ -757,11 +757,11 @@
void appendOp(int length, int op)
{
- int totalLen = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH];
+ int totalLen = m_ops.getOp(OpMap.MAPINDEX_LENGTH);
- m_ops.m_opMap[totalLen] = op;
- m_ops.m_opMap[totalLen + OpMap.MAPINDEX_LENGTH] = length;
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] = totalLen + length;
+ m_ops.setOp(totalLen, op);
+ m_ops.setOp(totalLen + OpMap.MAPINDEX_LENGTH, length);
+ m_ops.setOp(OpMap.MAPINDEX_LENGTH, totalLen + length);
}
// ============= EXPRESSIONS FUNCTIONS =================
@@ -791,7 +791,7 @@
protected void OrExpr() throws javax.xml.transform.TransformerException
{
- int opPos = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH];
+ int opPos = m_ops.getOp(OpMap.MAPINDEX_LENGTH);
AndExpr();
@@ -801,8 +801,8 @@
insertOp(opPos, 2, OpCodes.OP_OR);
OrExpr();
- m_ops.m_opMap[opPos + OpMap.MAPINDEX_LENGTH] =
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - opPos;
+ m_ops.setOp(opPos + OpMap.MAPINDEX_LENGTH,
+ m_ops.getOp(OpMap.MAPINDEX_LENGTH) - opPos);
}
}
@@ -818,7 +818,7 @@
protected void AndExpr() throws javax.xml.transform.TransformerException
{
- int opPos = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH];
+ int opPos = m_ops.getOp(OpMap.MAPINDEX_LENGTH);
EqualityExpr(-1);
@@ -828,8 +828,8 @@
insertOp(opPos, 2, OpCodes.OP_AND);
AndExpr();
- m_ops.m_opMap[opPos + OpMap.MAPINDEX_LENGTH] =
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - opPos;
+ m_ops.setOp(opPos + OpMap.MAPINDEX_LENGTH,
+ m_ops.getOp(OpMap.MAPINDEX_LENGTH) - opPos);
}
}
@@ -851,7 +851,7 @@
protected int EqualityExpr(int addPos) throws javax.xml.transform.TransformerException
{
- int opPos = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH];
+ int opPos = m_ops.getOp(OpMap.MAPINDEX_LENGTH);
if (-1 == addPos)
addPos = opPos;
@@ -866,11 +866,11 @@
nextToken();
insertOp(addPos, 2, OpCodes.OP_NOTEQUALS);
- int opPlusLeftHandLen = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - addPos;
+ int opPlusLeftHandLen = m_ops.getOp(OpMap.MAPINDEX_LENGTH) - addPos;
addPos = EqualityExpr(addPos);
- m_ops.m_opMap[addPos + OpMap.MAPINDEX_LENGTH] =
- m_ops.m_opMap[addPos + opPlusLeftHandLen + 1] + opPlusLeftHandLen;
+ m_ops.setOp(addPos + OpMap.MAPINDEX_LENGTH,
+ m_ops.getOp(addPos + opPlusLeftHandLen + 1) + opPlusLeftHandLen);
addPos += 2;
}
else if (tokenIs('='))
@@ -878,11 +878,11 @@
nextToken();
insertOp(addPos, 2, OpCodes.OP_EQUALS);
- int opPlusLeftHandLen = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - addPos;
+ int opPlusLeftHandLen = m_ops.getOp(OpMap.MAPINDEX_LENGTH) - addPos;
addPos = EqualityExpr(addPos);
- m_ops.m_opMap[addPos + OpMap.MAPINDEX_LENGTH] =
- m_ops.m_opMap[addPos + opPlusLeftHandLen + 1] + opPlusLeftHandLen;
+ m_ops.setOp(addPos + OpMap.MAPINDEX_LENGTH,
+ m_ops.getOp(addPos + opPlusLeftHandLen + 1) + opPlusLeftHandLen);
addPos += 2;
}
}
@@ -911,7 +911,7 @@
protected int RelationalExpr(int addPos) throws javax.xml.transform.TransformerException
{
- int opPos = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH];
+ int opPos = m_ops.getOp(OpMap.MAPINDEX_LENGTH);
if (-1 == addPos)
addPos = opPos;
@@ -934,11 +934,11 @@
insertOp(addPos, 2, OpCodes.OP_LT);
}
- int opPlusLeftHandLen = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - addPos;
+ int opPlusLeftHandLen = m_ops.getOp(OpMap.MAPINDEX_LENGTH) - addPos;
addPos = RelationalExpr(addPos);
- m_ops.m_opMap[addPos + OpMap.MAPINDEX_LENGTH] =
- m_ops.m_opMap[addPos + opPlusLeftHandLen + 1] + opPlusLeftHandLen;
+ m_ops.setOp(addPos + OpMap.MAPINDEX_LENGTH,
+ m_ops.getOp(addPos + opPlusLeftHandLen + 1) + opPlusLeftHandLen);
addPos += 2;
}
else if (tokenIs('>'))
@@ -955,11 +955,11 @@
insertOp(addPos, 2, OpCodes.OP_GT);
}
- int opPlusLeftHandLen = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - addPos;
+ int opPlusLeftHandLen = m_ops.getOp(OpMap.MAPINDEX_LENGTH) - addPos;
addPos = RelationalExpr(addPos);
- m_ops.m_opMap[addPos + OpMap.MAPINDEX_LENGTH] =
- m_ops.m_opMap[addPos + opPlusLeftHandLen + 1] + opPlusLeftHandLen;
+ m_ops.setOp(addPos + OpMap.MAPINDEX_LENGTH,
+ m_ops.getOp(addPos + opPlusLeftHandLen + 1) + opPlusLeftHandLen);
addPos += 2;
}
}
@@ -986,7 +986,7 @@
protected int AdditiveExpr(int addPos) throws javax.xml.transform.TransformerException
{
- int opPos = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH];
+ int opPos = m_ops.getOp(OpMap.MAPINDEX_LENGTH);
if (-1 == addPos)
addPos = opPos;
@@ -1000,11 +1000,11 @@
nextToken();
insertOp(addPos, 2, OpCodes.OP_PLUS);
- int opPlusLeftHandLen = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - addPos;
+ int opPlusLeftHandLen = m_ops.getOp(OpMap.MAPINDEX_LENGTH) - addPos;
addPos = AdditiveExpr(addPos);
- m_ops.m_opMap[addPos + OpMap.MAPINDEX_LENGTH] =
- m_ops.m_opMap[addPos + opPlusLeftHandLen + 1] + opPlusLeftHandLen;
+ m_ops.setOp(addPos + OpMap.MAPINDEX_LENGTH,
+ m_ops.getOp(addPos + opPlusLeftHandLen + 1) + opPlusLeftHandLen);
addPos += 2;
}
else if (tokenIs('-'))
@@ -1012,11 +1012,11 @@
nextToken();
insertOp(addPos, 2, OpCodes.OP_MINUS);
- int opPlusLeftHandLen = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - addPos;
+ int opPlusLeftHandLen = m_ops.getOp(OpMap.MAPINDEX_LENGTH) - addPos;
addPos = AdditiveExpr(addPos);
- m_ops.m_opMap[addPos + OpMap.MAPINDEX_LENGTH] =
- m_ops.m_opMap[addPos + opPlusLeftHandLen + 1] + opPlusLeftHandLen;
+ m_ops.setOp(addPos + OpMap.MAPINDEX_LENGTH,
+ m_ops.getOp(addPos + opPlusLeftHandLen + 1) + opPlusLeftHandLen);
addPos += 2;
}
}
@@ -1044,7 +1044,7 @@
protected int MultiplicativeExpr(int addPos) throws javax.xml.transform.TransformerException
{
- int opPos = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH];
+ int opPos = m_ops.getOp(OpMap.MAPINDEX_LENGTH);
if (-1 == addPos)
addPos = opPos;
@@ -1058,11 +1058,11 @@
nextToken();
insertOp(addPos, 2, OpCodes.OP_MULT);
- int opPlusLeftHandLen = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - addPos;
+ int opPlusLeftHandLen = m_ops.getOp(OpMap.MAPINDEX_LENGTH) - addPos;
addPos = MultiplicativeExpr(addPos);
- m_ops.m_opMap[addPos + OpMap.MAPINDEX_LENGTH] =
- m_ops.m_opMap[addPos + opPlusLeftHandLen + 1] + opPlusLeftHandLen;
+ m_ops.setOp(addPos + OpMap.MAPINDEX_LENGTH,
+ m_ops.getOp(addPos + opPlusLeftHandLen + 1) + opPlusLeftHandLen);
addPos += 2;
}
else if (tokenIs("div"))
@@ -1070,11 +1070,11 @@
nextToken();
insertOp(addPos, 2, OpCodes.OP_DIV);
- int opPlusLeftHandLen = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - addPos;
+ int opPlusLeftHandLen = m_ops.getOp(OpMap.MAPINDEX_LENGTH) - addPos;
addPos = MultiplicativeExpr(addPos);
- m_ops.m_opMap[addPos + OpMap.MAPINDEX_LENGTH] =
- m_ops.m_opMap[addPos + opPlusLeftHandLen + 1] + opPlusLeftHandLen;
+ m_ops.setOp(addPos + OpMap.MAPINDEX_LENGTH,
+ m_ops.getOp(addPos + opPlusLeftHandLen + 1) + opPlusLeftHandLen);
addPos += 2;
}
else if (tokenIs("mod"))
@@ -1082,11 +1082,11 @@
nextToken();
insertOp(addPos, 2, OpCodes.OP_MOD);
- int opPlusLeftHandLen = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - addPos;
+ int opPlusLeftHandLen = m_ops.getOp(OpMap.MAPINDEX_LENGTH) - addPos;
addPos = MultiplicativeExpr(addPos);
- m_ops.m_opMap[addPos + OpMap.MAPINDEX_LENGTH] =
- m_ops.m_opMap[addPos + opPlusLeftHandLen + 1] + opPlusLeftHandLen;
+ m_ops.setOp(addPos + OpMap.MAPINDEX_LENGTH,
+ m_ops.getOp(addPos + opPlusLeftHandLen + 1) + opPlusLeftHandLen);
addPos += 2;
}
else if (tokenIs("quo"))
@@ -1094,11 +1094,11 @@
nextToken();
insertOp(addPos, 2, OpCodes.OP_QUO);
- int opPlusLeftHandLen = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - addPos;
+ int opPlusLeftHandLen = m_ops.getOp(OpMap.MAPINDEX_LENGTH) - addPos;
addPos = MultiplicativeExpr(addPos);
- m_ops.m_opMap[addPos + OpMap.MAPINDEX_LENGTH] =
- m_ops.m_opMap[addPos + opPlusLeftHandLen + 1] + opPlusLeftHandLen;
+ m_ops.setOp(addPos + OpMap.MAPINDEX_LENGTH,
+ m_ops.getOp(addPos + opPlusLeftHandLen + 1) + opPlusLeftHandLen);
addPos += 2;
}
}
@@ -1117,7 +1117,7 @@
protected void UnaryExpr() throws javax.xml.transform.TransformerException
{
- int opPos = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH];
+ int opPos = m_ops.getOp(OpMap.MAPINDEX_LENGTH);
boolean isNeg = false;
if (m_tokenChar == '-')
@@ -1131,8 +1131,8 @@
UnionExpr();
if (isNeg)
- m_ops.m_opMap[opPos + OpMap.MAPINDEX_LENGTH] =
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - opPos;
+ m_ops.setOp(opPos + OpMap.MAPINDEX_LENGTH,
+ m_ops.getOp(OpMap.MAPINDEX_LENGTH) - opPos);
}
/**
@@ -1145,13 +1145,13 @@
protected void StringExpr() throws javax.xml.transform.TransformerException
{
- int opPos = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH];
+ int opPos = m_ops.getOp(OpMap.MAPINDEX_LENGTH);
appendOp(2, OpCodes.OP_STRING);
Expr();
- m_ops.m_opMap[opPos + OpMap.MAPINDEX_LENGTH] =
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - opPos;
+ m_ops.setOp(opPos + OpMap.MAPINDEX_LENGTH,
+ m_ops.getOp(OpMap.MAPINDEX_LENGTH) - opPos);
}
/**
@@ -1165,19 +1165,19 @@
protected void BooleanExpr() throws javax.xml.transform.TransformerException
{
- int opPos = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH];
+ int opPos = m_ops.getOp(OpMap.MAPINDEX_LENGTH);
appendOp(2, OpCodes.OP_BOOL);
Expr();
- int opLen = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - opPos;
+ int opLen = m_ops.getOp(OpMap.MAPINDEX_LENGTH) - opPos;
if (opLen == 2)
{
error(XPATHErrorResources.ER_BOOLEAN_ARG_NO_LONGER_OPTIONAL, null); //"boolean(...) argument is no longer optional with 19990709 XPath draft.");
}
- m_ops.m_opMap[opPos + OpMap.MAPINDEX_LENGTH] = opLen;
+ m_ops.setOp(opPos + OpMap.MAPINDEX_LENGTH, opLen);
}
/**
@@ -1191,13 +1191,13 @@
protected void NumberExpr() throws javax.xml.transform.TransformerException
{
- int opPos = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH];
+ int opPos = m_ops.getOp(OpMap.MAPINDEX_LENGTH);
appendOp(2, OpCodes.OP_NUMBER);
Expr();
- m_ops.m_opMap[opPos + OpMap.MAPINDEX_LENGTH] =
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - opPos;
+ m_ops.setOp(opPos + OpMap.MAPINDEX_LENGTH,
+ m_ops.getOp(OpMap.MAPINDEX_LENGTH) - opPos);
}
/**
@@ -1216,7 +1216,7 @@
protected void UnionExpr() throws javax.xml.transform.TransformerException
{
- int opPos = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH];
+ int opPos = m_ops.getOp(OpMap.MAPINDEX_LENGTH);
boolean continueOrLoop = true;
boolean foundUnion = false;
@@ -1244,8 +1244,8 @@
}
while (continueOrLoop);
- m_ops.m_opMap[opPos + OpMap.MAPINDEX_LENGTH] =
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - opPos;
+ m_ops.setOp(opPos + OpMap.MAPINDEX_LENGTH,
+ m_ops.getOp(OpMap.MAPINDEX_LENGTH) - opPos);
}
/**
@@ -1262,7 +1262,7 @@
protected void PathExpr() throws javax.xml.transform.TransformerException
{
- int opPos = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH];
+ int opPos = m_ops.getOp(OpMap.MAPINDEX_LENGTH);
int filterExprMatch = FilterExpr();
@@ -1295,10 +1295,10 @@
// Terminate for safety.
if (locationPathStarted)
{
- m_ops.m_opMap[m_ops.m_opMap[OpMap.MAPINDEX_LENGTH]] = OpCodes.ENDOP;
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] += 1;
- m_ops.m_opMap[opPos + OpMap.MAPINDEX_LENGTH] =
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - opPos;
+ m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH), OpCodes.ENDOP);
+ m_ops.setOp(OpMap.MAPINDEX_LENGTH, m_ops.getOp(OpMap.MAPINDEX_LENGTH) + 1);
+ m_ops.setOp(opPos + OpMap.MAPINDEX_LENGTH,
+ m_ops.getOp(OpMap.MAPINDEX_LENGTH) - opPos);
}
}
else
@@ -1327,7 +1327,7 @@
protected int FilterExpr() throws javax.xml.transform.TransformerException
{
- int opPos = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH];
+ int opPos = m_ops.getOp(OpMap.MAPINDEX_LENGTH);
int filterMatch;
@@ -1384,15 +1384,15 @@
{
boolean matchFound;
- int opPos = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH];
+ int opPos = m_ops.getOp(OpMap.MAPINDEX_LENGTH);
if ((m_tokenChar == '\'') || (m_tokenChar == '"'))
{
appendOp(2, OpCodes.OP_LITERAL);
Literal();
- m_ops.m_opMap[opPos + OpMap.MAPINDEX_LENGTH] =
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - opPos;
+ m_ops.setOp(opPos + OpMap.MAPINDEX_LENGTH,
+ m_ops.getOp(OpMap.MAPINDEX_LENGTH) - opPos);
matchFound = true;
}
@@ -1402,8 +1402,8 @@
appendOp(2, OpCodes.OP_VARIABLE);
QName();
- m_ops.m_opMap[opPos + OpMap.MAPINDEX_LENGTH] =
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - opPos;
+ m_ops.setOp(opPos + OpMap.MAPINDEX_LENGTH,
+ m_ops.getOp(OpMap.MAPINDEX_LENGTH) - opPos);
matchFound = true;
}
@@ -1414,8 +1414,8 @@
Expr();
consumeExpected(')');
- m_ops.m_opMap[opPos + OpMap.MAPINDEX_LENGTH] =
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - opPos;
+ m_ops.setOp(opPos + OpMap.MAPINDEX_LENGTH,
+ m_ops.getOp(OpMap.MAPINDEX_LENGTH) - opPos);
matchFound = true;
}
@@ -1425,8 +1425,8 @@
appendOp(2, OpCodes.OP_NUMBERLIT);
Number();
- m_ops.m_opMap[opPos + OpMap.MAPINDEX_LENGTH] =
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - opPos;
+ m_ops.setOp(opPos + OpMap.MAPINDEX_LENGTH,
+ m_ops.getOp(OpMap.MAPINDEX_LENGTH) - opPos);
matchFound = true;
}
@@ -1452,13 +1452,13 @@
protected void Argument() throws javax.xml.transform.TransformerException
{
- int opPos = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH];
+ int opPos = m_ops.getOp(OpMap.MAPINDEX_LENGTH);
appendOp(2, OpCodes.OP_ARGUMENT);
Expr();
- m_ops.m_opMap[opPos + OpMap.MAPINDEX_LENGTH] =
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - opPos;
+ m_ops.setOp(opPos + OpMap.MAPINDEX_LENGTH,
+ m_ops.getOp(OpMap.MAPINDEX_LENGTH) - opPos);
}
/**
@@ -1472,18 +1472,18 @@
protected boolean FunctionCall() throws javax.xml.transform.TransformerException
{
- int opPos = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH];
+ int opPos = m_ops.getOp(OpMap.MAPINDEX_LENGTH);
if (lookahead(':', 1))
{
appendOp(4, OpCodes.OP_EXTFUNCTION);
- m_ops.m_opMap[opPos + OpMap.MAPINDEX_LENGTH + 1] = m_queueMark - 1;
+ m_ops.setOp(opPos + OpMap.MAPINDEX_LENGTH + 1, m_queueMark - 1);
nextToken();
consumeExpected(':');
- m_ops.m_opMap[opPos + OpMap.MAPINDEX_LENGTH + 2] = m_queueMark - 1;
+ m_ops.setOp(opPos + OpMap.MAPINDEX_LENGTH + 2, m_queueMark - 1);
nextToken();
}
@@ -1508,7 +1508,7 @@
default :
appendOp(3, OpCodes.OP_FUNCTION);
- m_ops.m_opMap[opPos + OpMap.MAPINDEX_LENGTH + 1] = funcTok;
+ m_ops.setOp(opPos + OpMap.MAPINDEX_LENGTH + 1, funcTok);
}
nextToken();
@@ -1540,10 +1540,10 @@
consumeExpected(')');
// Terminate for safety.
- m_ops.m_opMap[m_ops.m_opMap[OpMap.MAPINDEX_LENGTH]] = OpCodes.ENDOP;
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] += 1;
- m_ops.m_opMap[opPos + OpMap.MAPINDEX_LENGTH] =
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - opPos;
+ m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH), OpCodes.ENDOP);
+ m_ops.setOp(OpMap.MAPINDEX_LENGTH,m_ops.getOp(OpMap.MAPINDEX_LENGTH) + 1);
+ m_ops.setOp(opPos + OpMap.MAPINDEX_LENGTH,
+ m_ops.getOp(OpMap.MAPINDEX_LENGTH) - opPos);
return true;
}
@@ -1561,7 +1561,7 @@
protected void LocationPath() throws javax.xml.transform.TransformerException
{
- int opPos = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH];
+ int opPos = m_ops.getOp(OpMap.MAPINDEX_LENGTH);
// int locationPathOpPos = opPos;
appendOp(2, OpCodes.OP_LOCATIONPATH);
@@ -1573,9 +1573,8 @@
appendOp(4, OpCodes.FROM_ROOT);
// Tell how long the step is without the predicate
- m_ops.m_opMap[m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - 2] = 4;
- m_ops.m_opMap[m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - 1] =
- OpCodes.NODETYPE_ROOT;
+ m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH) - 2, 4);
+ m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH) - 1, OpCodes.NODETYPE_ROOT);
nextToken();
}
@@ -1592,10 +1591,10 @@
}
// Terminate for safety.
- m_ops.m_opMap[m_ops.m_opMap[OpMap.MAPINDEX_LENGTH]] = OpCodes.ENDOP;
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] += 1;
- m_ops.m_opMap[opPos + OpMap.MAPINDEX_LENGTH] =
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - opPos;
+ m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH), OpCodes.ENDOP);
+ m_ops.setOp(OpMap.MAPINDEX_LENGTH,m_ops.getOp(OpMap.MAPINDEX_LENGTH) + 1);
+ m_ops.setOp(opPos + OpMap.MAPINDEX_LENGTH,
+ m_ops.getOp(OpMap.MAPINDEX_LENGTH) - opPos);
}
/**
@@ -1642,7 +1641,7 @@
*/
protected boolean Step() throws javax.xml.transform.TransformerException
{
- int opPos = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH];
+ int opPos = m_ops.getOp(OpMap.MAPINDEX_LENGTH);
boolean doubleSlash = tokenIs('/');
@@ -1661,20 +1660,19 @@
// by a regular step pattern.
// Make room for telling how long the step is without the predicate
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] += 1;
- m_ops.m_opMap[m_ops.m_opMap[OpMap.MAPINDEX_LENGTH]] =
- OpCodes.NODETYPE_NODE;
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] += 1;
+ m_ops.setOp(OpMap.MAPINDEX_LENGTH,m_ops.getOp(OpMap.MAPINDEX_LENGTH) + 1);
+ m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH), OpCodes.NODETYPE_NODE);
+ m_ops.setOp(OpMap.MAPINDEX_LENGTH,m_ops.getOp(OpMap.MAPINDEX_LENGTH) + 1);
// Tell how long the step is without the predicate
- m_ops.m_opMap[opPos + OpMap.MAPINDEX_LENGTH + 1] =
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - opPos;
+ m_ops.setOp(opPos + OpMap.MAPINDEX_LENGTH + 1,
+ m_ops.getOp(OpMap.MAPINDEX_LENGTH) - opPos);
// Tell how long the step is with the predicate
- m_ops.m_opMap[opPos + OpMap.MAPINDEX_LENGTH] =
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - opPos;
+ m_ops.setOp(opPos + OpMap.MAPINDEX_LENGTH,
+ m_ops.getOp(OpMap.MAPINDEX_LENGTH) - opPos);
- opPos = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH];
+ opPos = m_ops.getOp(OpMap.MAPINDEX_LENGTH);
}
if (tokenIs("."))
@@ -1689,9 +1687,8 @@
appendOp(4, OpCodes.FROM_SELF);
// Tell how long the step is without the predicate
- m_ops.m_opMap[m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - 2] = 4;
- m_ops.m_opMap[m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - 1] =
- OpCodes.NODETYPE_NODE;
+ m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH) - 2,4);
+ m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH) - 1, OpCodes.NODETYPE_NODE);
}
else if (tokenIs(".."))
{
@@ -1699,9 +1696,8 @@
appendOp(4, OpCodes.FROM_PARENT);
// Tell how long the step is without the predicate
- m_ops.m_opMap[m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - 2] = 4;
- m_ops.m_opMap[m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - 1] =
- OpCodes.NODETYPE_NODE;
+ m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH) - 2,4);
+ m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH) - 1, OpCodes.NODETYPE_NODE);
}
// There is probably a better way to test for this
@@ -1718,8 +1714,8 @@
}
// Tell how long the entire step is.
- m_ops.m_opMap[opPos + OpMap.MAPINDEX_LENGTH] =
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - opPos;
+ m_ops.setOp(opPos + OpMap.MAPINDEX_LENGTH,
+ m_ops.getOp(OpMap.MAPINDEX_LENGTH) - opPos);
}
else
{
@@ -1746,7 +1742,7 @@
protected void Basis() throws javax.xml.transform.TransformerException
{
- int opPos = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH];
+ int opPos = m_ops.getOp(OpMap.MAPINDEX_LENGTH);
int axesType;
// The next blocks guarantee that a FROM_XXX will be added.
@@ -1772,14 +1768,14 @@
}
// Make room for telling how long the step is without the predicate
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] += 1;
+ m_ops.setOp(OpMap.MAPINDEX_LENGTH, m_ops.getOp(OpMap.MAPINDEX_LENGTH) + 1);
NodeTest(axesType);
// Tell how long the step is without the predicate
- m_ops.m_opMap[opPos + OpMap.MAPINDEX_LENGTH + 1] =
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - opPos;
- }
+ m_ops.setOp(opPos + OpMap.MAPINDEX_LENGTH + 1,
+ m_ops.getOp(OpMap.MAPINDEX_LENGTH) - opPos);
+ }
/**
*
@@ -1836,8 +1832,8 @@
int nt = ((Integer) nodeTestOp).intValue();
- m_ops.m_opMap[m_ops.m_opMap[OpMap.MAPINDEX_LENGTH]] = nt;
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] += 1;
+ m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH), nt);
+ m_ops.setOp(OpMap.MAPINDEX_LENGTH, m_ops.getOp(OpMap.MAPINDEX_LENGTH) + 1);
consumeExpected('(');
@@ -1856,20 +1852,18 @@
{
// Assume name of attribute or element.
- m_ops.m_opMap[m_ops.m_opMap[OpMap.MAPINDEX_LENGTH]] = OpCodes.NODENAME;
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] += 1;
+ m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH), OpCodes.NODENAME);
+ m_ops.setOp(OpMap.MAPINDEX_LENGTH, m_ops.getOp(OpMap.MAPINDEX_LENGTH) + 1);
if (lookahead(':', 1))
{
if (tokenIs('*'))
{
- m_ops.m_opMap[m_ops.m_opMap[OpMap.MAPINDEX_LENGTH]] =
- OpCodes.ELEMWILDCARD;
+ m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH), OpCodes.ELEMWILDCARD);
}
else
{
- m_ops.m_opMap[m_ops.m_opMap[OpMap.MAPINDEX_LENGTH]] = m_queueMark
- - 1;
+ m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH), m_queueMark - 1);
// Minimalist check for an NCName - just check first character
// to distinguish from other possible tokens
@@ -1885,29 +1879,28 @@
}
else
{
- m_ops.m_opMap[m_ops.m_opMap[OpMap.MAPINDEX_LENGTH]] = OpCodes.EMPTY;
+ m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH), OpCodes.EMPTY);
}
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] += 1;
+ m_ops.setOp(OpMap.MAPINDEX_LENGTH, m_ops.getOp(OpMap.MAPINDEX_LENGTH) + 1);
if (tokenIs('*'))
{
- m_ops.m_opMap[m_ops.m_opMap[OpMap.MAPINDEX_LENGTH]] =
- OpCodes.ELEMWILDCARD;
+ m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH), OpCodes.ELEMWILDCARD);
}
else
{
if (OpCodes.FROM_NAMESPACE == axesType)
{
- String prefix = (String) this.m_ops.m_tokenQueue[m_queueMark - 1];
+ String prefix = (String) this.m_ops.m_tokenQueue.elementAt(m_queueMark - 1);
String namespace =
((PrefixResolver) m_namespaceContext).getNamespaceForPrefix(
prefix);
- this.m_ops.m_tokenQueue[m_queueMark - 1] = namespace;
+ this.m_ops.m_tokenQueue.setElementAt(namespace,m_queueMark - 1);
}
- m_ops.m_opMap[m_ops.m_opMap[OpMap.MAPINDEX_LENGTH]] = m_queueMark - 1;
+ m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH), m_queueMark - 1);
// Minimalist check for an NCName - just check first character
// to distinguish from other possible tokens
@@ -1918,7 +1911,7 @@
}
}
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] += 1;
+ m_ops.setOp(OpMap.MAPINDEX_LENGTH, m_ops.getOp(OpMap.MAPINDEX_LENGTH) + 1);
nextToken();
}
@@ -1952,16 +1945,16 @@
protected void PredicateExpr() throws javax.xml.transform.TransformerException
{
- int opPos = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH];
+ int opPos = m_ops.getOp(OpMap.MAPINDEX_LENGTH);
appendOp(2, OpCodes.OP_PREDICATE);
Expr();
// Terminate for safety.
- m_ops.m_opMap[m_ops.m_opMap[OpMap.MAPINDEX_LENGTH]] = OpCodes.ENDOP;
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] += 1;
- m_ops.m_opMap[opPos + OpMap.MAPINDEX_LENGTH] =
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - opPos;
+ m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH), OpCodes.ENDOP);
+ m_ops.setOp(OpMap.MAPINDEX_LENGTH, m_ops.getOp(OpMap.MAPINDEX_LENGTH) + 1);
+ m_ops.setOp(opPos + OpMap.MAPINDEX_LENGTH,
+ m_ops.getOp(OpMap.MAPINDEX_LENGTH) - opPos);
}
/**
@@ -1976,21 +1969,21 @@
// Namespace
if(lookahead(':', 1))
{
- m_ops.m_opMap[m_ops.m_opMap[OpMap.MAPINDEX_LENGTH]] = m_queueMark - 1;
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] += 1;
+ m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH), m_queueMark - 1);
+ m_ops.setOp(OpMap.MAPINDEX_LENGTH, m_ops.getOp(OpMap.MAPINDEX_LENGTH) + 1);
nextToken();
consumeExpected(':');
}
else
{
- m_ops.m_opMap[m_ops.m_opMap[OpMap.MAPINDEX_LENGTH]] = OpCodes.EMPTY;
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] += 1;
+ m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH), OpCodes.EMPTY);
+ m_ops.setOp(OpMap.MAPINDEX_LENGTH, m_ops.getOp(OpMap.MAPINDEX_LENGTH) + 1);
}
// Local name
- m_ops.m_opMap[m_ops.m_opMap[OpMap.MAPINDEX_LENGTH]] = m_queueMark - 1;
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] += 1;
+ m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH), m_queueMark - 1);
+ m_ops.setOp(OpMap.MAPINDEX_LENGTH, m_ops.getOp(OpMap.MAPINDEX_LENGTH) + 1);
nextToken();
}
@@ -2002,8 +1995,8 @@
protected void NCName()
{
- m_ops.m_opMap[m_ops.m_opMap[OpMap.MAPINDEX_LENGTH]] = m_queueMark - 1;
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] += 1;
+ m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH), m_queueMark - 1);
+ m_ops.setOp(OpMap.MAPINDEX_LENGTH, m_ops.getOp(OpMap.MAPINDEX_LENGTH) + 1);
nextToken();
}
@@ -2032,15 +2025,15 @@
// already made.
int tokenQueuePos = m_queueMark - 1;
- m_ops.m_tokenQueue[tokenQueuePos] = null;
+ m_ops.m_tokenQueue.setElementAt(null,tokenQueuePos);
Object obj = new XString(m_token.substring(1, last));
- m_ops.m_tokenQueue[tokenQueuePos] = obj;
+ m_ops.m_tokenQueue.setElementAt(obj,tokenQueuePos);
// lit = m_token.substring(1, last);
- m_ops.m_opMap[m_ops.m_opMap[OpMap.MAPINDEX_LENGTH]] = tokenQueuePos;
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] += 1;
+ m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH), tokenQueuePos);
+ m_ops.setOp(OpMap.MAPINDEX_LENGTH, m_ops.getOp(OpMap.MAPINDEX_LENGTH) + 1);
nextToken();
}
@@ -2080,9 +2073,9 @@
new Object[]{ m_token }); //m_token+" could not be formatted to a number!");
}
- m_ops.m_tokenQueue[m_queueMark - 1] = new XNumber(num);
- m_ops.m_opMap[m_ops.m_opMap[OpMap.MAPINDEX_LENGTH]] = m_queueMark - 1;
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] += 1;
+ m_ops.m_tokenQueue.setElementAt(new XNumber(num),m_queueMark - 1);
+ m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH), m_queueMark - 1);
+ m_ops.setOp(OpMap.MAPINDEX_LENGTH, m_ops.getOp(OpMap.MAPINDEX_LENGTH) + 1);
nextToken();
}
@@ -2129,7 +2122,7 @@
protected void LocationPathPattern() throws javax.xml.transform.TransformerException
{
- int opPos = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH];
+ int opPos = m_ops.getOp(OpMap.MAPINDEX_LENGTH);
final int RELATIVE_PATH_NOT_PERMITTED = 0;
final int RELATIVE_PATH_PERMITTED = 1;
@@ -2161,9 +2154,8 @@
}
// Tell how long the step is without the predicate
- m_ops.m_opMap[m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - 2] = 4;
- m_ops.m_opMap[m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - 1] =
- OpCodes.NODETYPE_FUNCTEST;
+ m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH) - 2, 4);
+ m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH) - 1, OpCodes.NODETYPE_FUNCTEST);
relativePathStatus = RELATIVE_PATH_REQUIRED;
}
@@ -2191,9 +2183,8 @@
// Tell how long the step is without the predicate
- m_ops.m_opMap[m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - 2] = 4;
- m_ops.m_opMap[m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - 1] =
- OpCodes.NODETYPE_ROOT;
+ m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH) - 2, 4);
+ m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH) - 1, OpCodes.NODETYPE_ROOT);
nextToken();
}
@@ -2216,10 +2207,10 @@
}
// Terminate for safety.
- m_ops.m_opMap[m_ops.m_opMap[OpMap.MAPINDEX_LENGTH]] = OpCodes.ENDOP;
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] += 1;
- m_ops.m_opMap[opPos + OpMap.MAPINDEX_LENGTH] =
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - opPos;
+ m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH), OpCodes.ENDOP);
+ m_ops.setOp(OpMap.MAPINDEX_LENGTH, m_ops.getOp(OpMap.MAPINDEX_LENGTH) + 1);
+ m_ops.setOp(opPos + OpMap.MAPINDEX_LENGTH,
+ m_ops.getOp(OpMap.MAPINDEX_LENGTH) - opPos);
}
/**
@@ -2295,7 +2286,7 @@
throws javax.xml.transform.TransformerException
{
- int opPos = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH];
+ int opPos = m_ops.getOp(OpMap.MAPINDEX_LENGTH);
int axesType;
// The next blocks guarantee that a MATCH_XXX will be added.
@@ -2318,7 +2309,7 @@
}
else if (tokenIs("child"))
{
- matchTypePos = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH];
+ matchTypePos = m_ops.getOp(OpMap.MAPINDEX_LENGTH);
axesType = OpCodes.MATCH_IMMEDIATE_ANCESTOR;
appendOp(2, axesType);
@@ -2348,20 +2339,20 @@
}
else
{
- matchTypePos = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH];
+ matchTypePos = m_ops.getOp(OpMap.MAPINDEX_LENGTH);
axesType = OpCodes.MATCH_IMMEDIATE_ANCESTOR;
appendOp(2, axesType);
}
// Make room for telling how long the step is without the predicate
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] += 1;
+ m_ops.setOp(OpMap.MAPINDEX_LENGTH, m_ops.getOp(OpMap.MAPINDEX_LENGTH) + 1);
NodeTest(axesType);
// Tell how long the step is without the predicate
- m_ops.m_opMap[opPos + OpMap.MAPINDEX_LENGTH + 1] =
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - opPos;
+ m_ops.setOp(opPos + OpMap.MAPINDEX_LENGTH + 1,
+ m_ops.getOp(OpMap.MAPINDEX_LENGTH) - opPos);
while (tokenIs('['))
{
@@ -2384,7 +2375,7 @@
// MATCH_ANY_ANCESTOR on next call instead.
if ((matchTypePos > -1) && tokenIs('/') && lookahead('/', 1))
{
- m_ops.m_opMap[matchTypePos] = OpCodes.MATCH_ANY_ANCESTOR;
+ m_ops.setOp(matchTypePos, OpCodes.MATCH_ANY_ANCESTOR);
nextToken();
@@ -2396,8 +2387,8 @@
}
// Tell how long the entire step is.
- m_ops.m_opMap[opPos + OpMap.MAPINDEX_LENGTH] =
- m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - opPos;
+ m_ops.setOp(opPos + OpMap.MAPINDEX_LENGTH,
+ m_ops.getOp(OpMap.MAPINDEX_LENGTH) - opPos);
return trailingSlashConsumed;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org