You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by sb...@apache.org on 2001/06/15 07:16:02 UTC
cvs commit: xml-xalan/java/src/org/apache/xpath/res XPATHErrorResources.java
sboag 01/06/14 22:16:01
Modified: java/src/org/apache/xalan/extensions
ExtensionHandlerGeneral.java MethodResolver.java
java/src/org/apache/xalan/lib Extensions.java
java/src/org/apache/xalan/templates ElemNumber.java
ElemPI.java ElemTemplateElement.java
FuncDocument.java FuncKey.java
java/src/org/apache/xalan/transformer Counter.java
CountersTable.java KeyManager.java
KeyRefIterator.java KeyTable.java NodeSorter.java
TransformerImpl.java
java/src/org/apache/xalan/xsltc/compiler
AbsoluteLocationPath.java ApplyImports.java
ApplyTemplates.java CastExpr.java CopyOf.java
DocumentCall.java EqualityExpr.java Expression.java
FilterExpr.java FilterParentPath.java ForEach.java
FunctionCall.java IdKeyPattern.java Key.java
KeyCall.java NameBase.java ParentLocationPath.java
Parser.java Predicate.java RelationalExpr.java
Step.java UnionPathExpr.java
java/src/org/apache/xalan/xsltc/compiler/util
NodeSetType.java NodeType.java ReferenceType.java
ResultTreeType.java Type.java
java/src/org/apache/xalan/xsltc/dom UnionIterator.java
java/src/org/apache/xalan/xsltc/runtime BasisLibrary.java
java/src/org/apache/xml/dtm DTMIterator.java
java/src/org/apache/xml/dtm/ref DTMManagerDefault.java
DTMNodeIterator.java DTMNodeList.java
java/src/org/apache/xml/utils StringBufferPool.java
java/src/org/apache/xpath DOM2Helper.java DOMHelper.java
NodeSet.java XPathAPI.java XPathContext.java
java/src/org/apache/xpath/axes ContextNodeList.java
LocPathIterator.java UnionPathIterator.java
WalkingIterator.java
java/src/org/apache/xpath/functions FuncExtFunction.java
FuncId.java FuncLast.java FuncPosition.java
java/src/org/apache/xpath/objects XNodeSet.java XNull.java
XObject.java XRTreeFrag.java
java/src/org/apache/xpath/res XPATHErrorResources.java
Added: java/src/org/apache/xpath NodeSetDTM.java
Log:
Renamed NodeSet to NodeSetDTM, and made NodeSet hold
DOM nodes, for extension compatibility.
Uncommented extensions.java.
Tweaked DTMNodeList so it calls runto(-1).
Enabled parts labled %DTBD%, which had to do with various aspects
of DTM to DOM conversion.
There still seems to be some problems with extensions.
Revision Changes Path
1.13 +21 -15 xml-xalan/java/src/org/apache/xalan/extensions/ExtensionHandlerGeneral.java
Index: ExtensionHandlerGeneral.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/extensions/ExtensionHandlerGeneral.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- ExtensionHandlerGeneral.java 2001/06/12 19:14:33 1.12
+++ ExtensionHandlerGeneral.java 2001/06/15 05:13:46 1.13
@@ -80,6 +80,10 @@
import java.lang.reflect.Method;
+import org.apache.xml.dtm.ref.DTMNodeIterator;
+import org.apache.xml.dtm.ref.DTMNodeList;
+import org.apache.xml.dtm.DTMIterator;
+
/**
* <meta name="usage" content="internal"/>
* Class handling an extension namespace for XPath. Provides functions
@@ -139,12 +143,12 @@
try
{
//managerClass = Class.forName(BSF_MANAGER);
- managerClass = ExtensionHandler.getClassForName(BSF_MANAGER);
+ managerClass = ExtensionHandler.getClassForName(BSF_MANAGER);
mgrLoadScriptingEngine = managerClass.getMethod("loadScriptingEngine",
new Class[]{ String.class });
//Class engineClass = Class.forName(BSF_ENGINE);
- Class engineClass = ExtensionHandler.getClassForName(BSF_ENGINE);
+ Class engineClass = ExtensionHandler.getClassForName(BSF_ENGINE);
engineExec = engineClass.getMethod("exec", new Class[]{ String.class,
Integer.TYPE,
@@ -296,6 +300,11 @@
Object o = args.elementAt(i);
argArray[i] = (o instanceof XObject) ? ((XObject) o).object() : o;
+ o = argArray[i];
+ if(null != o && o instanceof DTMIterator)
+ {
+ argArray[i] = new DTMNodeList((DTMIterator)o);
+ }
}
return engineCall.invoke(m_engine, new Object[]{ null, funcName,
@@ -357,25 +366,22 @@
Object result = null;
XSLProcessorContext xpc = new XSLProcessorContext(transformer, stylesheetTree);
- // %DTBD%
-// try
+ try
{
Vector argv = new Vector(2);
argv.addElement(xpc);
argv.addElement(element);
- // %DTBD% This wants an ExpressionContext.
-// result = callFunction(localPart, argv, methodKey,
-// transformer.getXPathContext());
- }
- // %DTBD%
-// catch (XPathProcessorException e)
-// {
-//
-// // e.printStackTrace ();
-// throw new TransformerException(e.getMessage(), e);
-// }
+ result = callFunction(localPart, argv, methodKey,
+ transformer.getXPathContext().getExpressionContext());
+ }
+ catch (XPathProcessorException e)
+ {
+
+ // e.printStackTrace ();
+ throw new TransformerException(e.getMessage(), e);
+ }
if (result != null)
{
1.23 +46 -35 xml-xalan/java/src/org/apache/xalan/extensions/MethodResolver.java
Index: MethodResolver.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/extensions/MethodResolver.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- MethodResolver.java 2001/06/12 19:14:33 1.22
+++ MethodResolver.java 2001/06/15 05:13:47 1.23
@@ -68,6 +68,10 @@
import org.apache.xpath.objects.XObject;
import org.apache.xpath.objects.XString;
import org.apache.xpath.objects.XRTreeFrag;
+import org.apache.xml.dtm.*;
+import org.apache.xml.dtm.ref.DTMNodeIterator;
+import org.apache.xml.dtm.ref.DTMNodeList;
+import org.apache.xml.dtm.ref.DTMNodeProxy;
import javax.xml.transform.TransformerException;
@@ -348,7 +352,7 @@
Class[] paramTypes = method.getParameterTypes();
if ( (paramTypes.length == 2)
&& paramTypes[1].isAssignableFrom(org.apache.xalan.templates.ElemExtensionCall.class)
- && paramTypes[0].isAssignableFrom(org.apache.xalan.extensions.XSLProcessorContext.class) )
+ && paramTypes[0].isAssignableFrom(org.apache.xalan.extensions.XSLProcessorContext.class) )
{
if ( ++bestScoreCount == 1 )
bestMethod = method;
@@ -629,7 +633,7 @@
// whether this java method is a valid match for this extension function call.
// This approach eliminates the NullPointerException in the earlier implementation
// that resulted from passing an XObject encapsulating the null java object.
-
+
// TODO: This needs to be improved to assign relative scores to subclasses,
// etc.
@@ -747,20 +751,22 @@
if ( (javaClass == NodeIterator.class) ||
(javaClass == java.lang.Object.class) )
{
- return ((XRTreeFrag) xobj).asNodeIterator();
+ DTMIterator dtmIter = ((XRTreeFrag) xobj).asNodeIterator();
+ return new DTMNodeIterator(dtmIter);
}
- // %DTBD%
-// else if (javaClass == NodeList.class)
-// {
-// return ((XRTreeFrag) xobj).convertToNodeset();
-// }
+ else if (javaClass == NodeList.class)
+ {
+ return ((XRTreeFrag) xobj).convertToNodeset();
+ }
// Same comment as above
// else if(Node.class.isAssignableFrom(javaClass))
- // %DTBD%
-// else if(javaClass == Node.class)
-// {
-// return xobj.rtree().getFirstChild();
-// }
+ else if(javaClass == Node.class)
+ {
+ DTMIterator iter = ((XRTreeFrag) xobj).asNodeIterator();
+ int rootHandle = iter.nextNode();
+ DTM dtm = iter.getDTM(rootHandle);
+ return dtm.getNode(dtm.getFirstChild(rootHandle));
+ }
else if(javaClass == java.lang.String.class)
{
return xobj.str();
@@ -772,16 +778,19 @@
else if(javaClass.isPrimitive())
{
return convertDoubleToNumber(xobj.num(), javaClass);
+ }
+ else
+ {
+ DTMIterator iter = ((XRTreeFrag) xobj).asNodeIterator();
+ int rootHandle = iter.nextNode();
+ DTM dtm = iter.getDTM(rootHandle);
+ Node child = dtm.getNode(dtm.getFirstChild(rootHandle));
+
+ if(javaClass.isAssignableFrom(child.getClass()))
+ return child;
+ else
+ return null;
}
- // %DTBD%
-// else
-// {
-// Node child = xobj.rtree().getFirstChild();
-// if(javaClass.isAssignableFrom(child.getClass()))
-// return child;
-// else
-// return null;
-// }
}
// break; Unreachable
@@ -810,9 +819,9 @@
{
// Xalan ensures that nodeset() always returns an
// iterator positioned at the beginning.
- // %DTBD%
-// NodeIterator ni = xobj.nodeset();
-// return ni.nextNode(); // may be null.
+ DTMIterator ni = xobj.nodeset();
+ int handle = ni.nextNode();
+ return ni.getDTM(handle).getNode(handle); // may be null.
}
else if(javaClass == java.lang.String.class)
{
@@ -825,16 +834,18 @@
else if(javaClass.isPrimitive())
{
return convertDoubleToNumber(xobj.num(), javaClass);
+ }
+ else
+ {
+ DTMIterator iter = xobj.nodeset();
+ int childHandle = iter.nextNode();
+ DTM dtm = iter.getDTM(childHandle);
+ Node child = dtm.getNode(childHandle);
+ if(javaClass.isAssignableFrom(child.getClass()))
+ return child;
+ else
+ return null;
}
- // %DTBD%
-// else
-// {
-// Node child = xobj.nodeset().nextNode();
-// if(javaClass.isAssignableFrom(child.getClass()))
-// return child;
-// else
-// return null;
-// }
}
// break; Unreachable
@@ -867,7 +878,7 @@
// Just pass the object directly, and hope for the best.
return xsltObj;
}
- }
+ }
else
{
// Just pass the object directly, and hope for the best.
1.11 +303 -233 xml-xalan/java/src/org/apache/xalan/lib/Extensions.java
Index: Extensions.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/lib/Extensions.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Extensions.java 2001/06/12 19:14:36 1.10
+++ Extensions.java 2001/06/15 05:13:51 1.11
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2000 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
@@ -54,7 +54,6 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-
package org.apache.xalan.lib;
import org.w3c.dom.Node;
@@ -63,6 +62,7 @@
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
import org.w3c.dom.traversal.NodeIterator;
+
import org.apache.xpath.NodeSet;
import org.apache.xpath.objects.XObject;
import org.apache.xpath.objects.XBoolean;
@@ -70,12 +70,17 @@
import org.apache.xpath.XPath;
import org.apache.xpath.XPathContext;
import org.apache.xpath.DOMHelper;
+import org.apache.xml.dtm.DTMIterator;
+
import org.xml.sax.SAXNotSupportedException;
+
import java.util.Hashtable;
import java.util.StringTokenizer;
import org.apache.xalan.extensions.ExpressionContext;
+import javax.xml.parsers.*;
+
/**
* <meta name="usage" content="general"/>
* This class contains many of the Xalan-supplied extensions.
@@ -84,239 +89,304 @@
* xmlns:xalan="http://xml.apache.org/xalan"
* </pre>
*/
+public class Extensions
+{
+
+ /**
+ * Constructor Extensions
+ *
+ */
+ private Extensions(){} // Make sure class cannot be instantiated
+
+ /**
+ * This method is an extension that implements as a Xalan extension
+ * the node-set function also found in xt and saxon.
+ * If the argument is a Result Tree Fragment, then <code>nodeset</code>
+ * returns a node-set consisting of a single root node as described in
+ * section 11.1 of the XSLT 1.0 Recommendation. If the argument is a
+ * node-set, <code>nodeset</code> returns a node-set. If the argument
+ * is a string, number, or boolean, then <code>nodeset</code> returns
+ * a node-set consisting of a single root node with a single text node
+ * child that is the result of calling the XPath string() function on the
+ * passed parameter. If the argument is anything else, then a node-set
+ * is returned consisting of a single root node with a single text node
+ * child that is the result of calling the java <code>toString()</code>
+ * method on the passed argument.
+ * Most of the
+ * actual work here is done in <code>MethodResolver</code> and
+ * <code>XRTreeFrag</code>.
+ * @param myProcessor Context passed by the extension processor
+ * @param rtf Argument in the stylesheet to the nodeset extension function
+ *
+ * NEEDSDOC ($objectName$) @return
+ */
+ public static NodeSet nodeset(ExpressionContext myProcessor, Object rtf)
+ {
+
+ String textNodeValue;
+
+ if (rtf instanceof NodeIterator)
+ {
+ return new NodeSet((NodeIterator) rtf);
+ }
+ else
+ {
+ if (rtf instanceof String)
+ {
+ textNodeValue = (String) rtf;
+ }
+ else if (rtf instanceof Boolean)
+ {
+ textNodeValue = new XBoolean(((Boolean) rtf).booleanValue()).str();
+ }
+ else if (rtf instanceof Double)
+ {
+ textNodeValue = new XNumber(((Double) rtf).doubleValue()).str();
+ }
+ else
+ {
+ textNodeValue = rtf.toString();
+ }
+
+ // This no longer will work right since the DTM.
+ // Document myDoc = myProcessor.getContextNode().getOwnerDocument();
+ try
+ {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document myDoc = db.newDocument();
+
+ Text textNode = myDoc.createTextNode(textNodeValue);
+ DocumentFragment docFrag = myDoc.createDocumentFragment();
+
+ docFrag.appendChild(textNode);
+
+ return new NodeSet(docFrag);
+ }
+ catch(ParserConfigurationException pce)
+ {
+ throw new org.apache.xml.utils.WrappedRuntimeException(pce);
+ }
+ }
+ }
+
+ /**
+ * Returns the intersection of two node-sets.
+ * @param n1 NodeIterator for first node-set
+ *
+ * NEEDSDOC @param ni1
+ * @param ni2 NodeIterator for second node-set
+ * @return a NodeSet containing the nodes in ni1 that are also
+ * in ni2
+ *
+ * @throws javax.xml.transform.TransformerException
+ */
+ public static NodeSet intersection(NodeIterator ni1, NodeIterator ni2)
+ throws javax.xml.transform.TransformerException
+ {
+
+ NodeSet ns1 = new NodeSet(ni1);
+ NodeSet ns2 = new NodeSet(ni2);
+ NodeSet inter = new NodeSet();
+
+ inter.setShouldCacheNodes(true);
+
+ for (int i = 0; i < ns1.getLength(); i++)
+ {
+ Node n = ns1.elementAt(i);
+
+ if (ns2.contains(n))
+ inter.addElement(n);
+ }
+
+ return inter;
+ }
+
+ /**
+ * Returns the difference between two node-sets.
+ * @param n1 NodeIterator for first node-set
+ *
+ * NEEDSDOC @param ni1
+ * @param ni2 NodeIterator for second node-set
+ * @return a NodeSet containing the nodes in ni1 that are not
+ * in ni2
+ *
+ * @throws javax.xml.transform.TransformerException
+ */
+ public static NodeSet difference(NodeIterator ni1, NodeIterator ni2)
+ throws javax.xml.transform.TransformerException
+ {
+
+ NodeSet ns1 = new NodeSet(ni1);
+ NodeSet ns2 = new NodeSet(ni2);
+
+ // NodeSet inter= new NodeSet();
+ NodeSet diff = new NodeSet();
+
+ diff.setShouldCacheNodes(true);
+
+ for (int i = 0; i < ns1.getLength(); i++)
+ {
+ Node n = ns1.elementAt(i);
+
+ if (!ns2.contains(n))
+ diff.addElement(n);
+ }
+
+ return diff;
+ }
+
+ /**
+ * Returns node-set containing distinct string values.
+ * @param ni NodeIterator for node-set
+ * @return a NodeSet with nodes from ni containing distinct string values.
+ * In other words, if more than one node in ni contains the same string value,
+ * only include the first such node found.
+ *
+ * @throws javax.xml.transform.TransformerException
+ */
+ public static NodeSet distinct(NodeIterator ni)
+ throws javax.xml.transform.TransformerException
+ {
+
+ NodeSet ns = new NodeSet(ni);
+ NodeSet dist = new NodeSet();
+
+ dist.setShouldCacheNodes(true);
+
+ Hashtable stringTable = new Hashtable();
+
+ for (int i = 0; i < ns.getLength(); i++)
+ {
+ Node n = ns.elementAt(i);
+ String key = DOMHelper.getNodeData(n);
+
+ if (!stringTable.containsKey(key))
+ {
+ stringTable.put(key, n);
+ dist.addElement(n);
+ }
+ }
+
+ return dist;
+ }
+
+ /**
+ * Returns true of both node-sets contain the same set of nodes.
+ * @param n1 NodeIterator for first node-set
+ *
+ * NEEDSDOC @param ni1
+ * @param ni2 NodeIterator for second node-set
+ * @return true if ni1 and ni2 contain exactly the same set of nodes.
+ */
+ public static boolean hasSameNodes(NodeIterator ni1, NodeIterator ni2)
+ {
+
+ NodeSet ns1 = new NodeSet(ni1);
+ NodeSet ns2 = new NodeSet(ni2);
+
+ if (ns1.getLength() != ns2.getLength())
+ return false;
+
+ for (int i = 0; i < ns1.getLength(); i++)
+ {
+ Node n = ns1.elementAt(i);
+
+ if (!ns2.contains(n))
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Returns the result of evaluating the argument as a string containing
+ * an XPath expression. Used where the XPath expression is not known until
+ * run-time. The expression is evaluated as if the run-time value of the
+ * argument appeared in place of the evaluate function call at compile time.
+ * @param myContext an <code>ExpressionContext</code> passed in by the
+ * extension mechanism. This must be an XPathContext.
+ * @param xpathExtr The XPath expression to be evaluated.
+ * NEEDSDOC @param xpathExpr
+ * @return the XObject resulting from evaluating the XPath
+ *
+ * @throws Exception
+ * @throws SAXNotSupportedException
+ */
+ public static XObject evaluate(
+ ExpressionContext myContext, String xpathExpr)
+ throws SAXNotSupportedException, Exception
+ {
+
+ if (myContext instanceof XPathContext)
+ {
+ try
+ {
+ XPathContext xctxt = (XPathContext) myContext;
+ XPath dynamicXPath = new XPath(xpathExpr, xctxt.getSAXLocator(),
+ xctxt.getNamespaceContext(),
+ XPath.SELECT);
+
+ return dynamicXPath.execute(xctxt, myContext.getContextNode(),
+ xctxt.getNamespaceContext());
+ }
+ catch (Exception e)
+ {
+ throw e;
+ }
+ }
+ else
+ throw new SAXNotSupportedException("Invalid context passed to evaluate "
+ + myContext);
+ }
+
+ /**
+ * Returns a NodeSet containing one text node for each token in the first argument.
+ * Delimiters are specified in the second argument.
+ * Tokens are determined by a call to <code>StringTokenizer</code>.
+ * If the first argument is an empty string or contains only delimiters, the result
+ * will be an empty NodeSet.
+ * Contributed to XalanJ1 by <a href="mailto:benoit.cerrina@writeme.com">Benoit Cerrina</a>.
+ * @param myContext an <code>ExpressionContext</code> passed in by the
+ * extension mechanism. This must be an XPathContext.
+ * @param toTokenize The string to be split into text tokens.
+ * @param delims The delimiters to use.
+ * @return a NodeSet as described above.
+ *
+ */
+ public static NodeSet tokenize(ExpressionContext myContext,
+ String toTokenize, String delims)
+ {
-public class Extensions {
+ Document lDoc = myContext.getContextNode().getOwnerDocument();
+ StringTokenizer lTokenizer = new StringTokenizer(toTokenize, delims);
+ NodeSet resultSet = new NodeSet();
- private Extensions() {} // Make sure class cannot be instantiated
+ while (lTokenizer.hasMoreTokens())
+ {
+ resultSet.addNode(lDoc.createTextNode(lTokenizer.nextToken()));
+ }
-// /**
-// * This method is an extension that implements as a Xalan extension
-// * the node-set function also found in xt and saxon.
-// * If the argument is a Result Tree Fragment, then <code>nodeset</code>
-// * returns a node-set consisting of a single root node as described in
-// * section 11.1 of the XSLT 1.0 Recommendation. If the argument is a
-// * node-set, <code>nodeset</code> returns a node-set. If the argument
-// * is a string, number, or boolean, then <code>nodeset</code> returns
-// * a node-set consisting of a single root node with a single text node
-// * child that is the result of calling the XPath string() function on the
-// * passed parameter. If the argument is anything else, then a node-set
-// * is returned consisting of a single root node with a single text node
-// * child that is the result of calling the java <code>toString()</code>
-// * method on the passed argument.
-// * Most of the
-// * actual work here is done in <code>MethodResolver</code> and
-// * <code>XRTreeFrag</code>.
-// * @param myProcessor Context passed by the extension processor
-// * @param rtf Argument in the stylesheet to the nodeset extension function
-// */
-//
-// public static NodeSet nodeset(ExpressionContext myProcessor, Object rtf) {
-//
-// String textNodeValue;
-//
-// if (rtf instanceof NodeIterator)
-// {
-// return new NodeSet((NodeIterator) rtf);
-// }
-// else
-// {
-// if (rtf instanceof String)
-// {
-// textNodeValue = (String) rtf;
-// }
-// else if (rtf instanceof Boolean)
-// {
-// textNodeValue = new XBoolean(((Boolean) rtf).booleanValue()).str();
-// }
-// else if (rtf instanceof Double)
-// {
-// textNodeValue = new XNumber(((Double) rtf).doubleValue()).str();
-// }
-// else
-// {
-// textNodeValue = rtf.toString();
-// }
-// Document myDoc = myProcessor.getContextNode().getOwnerDocument();
-// Text textNode = myDoc.createTextNode(textNodeValue);
-// DocumentFragment docFrag = myDoc.createDocumentFragment();
-// docFrag.appendChild(textNode);
-// return new NodeSet(docFrag);
-// }
-// }
-//
-// /**
-// * Returns the intersection of two node-sets.
-// * @param n1 NodeIterator for first node-set
-// * @param ni2 NodeIterator for second node-set
-// * @return a NodeSet containing the nodes in ni1 that are also
-// * in ni2
-// */
-// public static NodeSet intersection(NodeIterator ni1, NodeIterator ni2)
-// throws javax.xml.transform.TransformerException
-// {
-// NodeSet ns1 = new NodeSet(ni1);
-// NodeSet ns2 = new NodeSet(ni2);
-// NodeSet inter= new NodeSet();
-// inter.setShouldCacheNodes(true);
-// for (int i=0; i < ns1.getLength(); i++)
-// {
-// Node n = ns1.elementAt(i);
-// if(ns2.contains(n))
-// inter.addElement(n);
-// }
-// return inter;
-// }
-//
-// /**
-// * Returns the difference between two node-sets.
-// * @param n1 NodeIterator for first node-set
-// * @param ni2 NodeIterator for second node-set
-// * @return a NodeSet containing the nodes in ni1 that are not
-// * in ni2
-// */
-// public static NodeSet difference(NodeIterator ni1, NodeIterator ni2)
-// throws javax.xml.transform.TransformerException
-// {
-// NodeSet ns1 = new NodeSet(ni1);
-// NodeSet ns2 = new NodeSet(ni2);
-// // NodeSet inter= new NodeSet();
-// NodeSet diff = new NodeSet();
-// diff.setShouldCacheNodes(true);
-// for (int i = 0; i < ns1.getLength(); i++)
-// {
-// Node n = ns1.elementAt(i);
-// if(!ns2.contains(n))
-// diff.addElement(n);
-// }
-// return diff;
-// }
-//
-// /**
-// * Returns node-set containing distinct string values.
-// * @param ni NodeIterator for node-set
-// * @return a NodeSet with nodes from ni containing distinct string values.
-// * In other words, if more than one node in ni contains the same string value,
-// * only include the first such node found.
-// */
-// public static NodeSet distinct(NodeIterator ni)
-// throws javax.xml.transform.TransformerException
-// {
-// NodeSet ns = new NodeSet(ni);
-// NodeSet dist = new NodeSet();
-// dist.setShouldCacheNodes(true);
-// Hashtable stringTable = new Hashtable();
-// for (int i = 0; i < ns.getLength(); i++)
-// {
-// Node n = ns.elementAt(i);
-// String key = DOMHelper.getNodeData(n);
-// if (!stringTable.containsKey(key))
-// {
-// stringTable.put(key, n);
-// dist.addElement(n);
-// }
-// }
-// return dist;
-// }
-//
-// /**
-// * Returns true of both node-sets contain the same set of nodes.
-// * @param n1 NodeIterator for first node-set
-// * @param ni2 NodeIterator for second node-set
-// * @return true if ni1 and ni2 contain exactly the same set of nodes.
-// */
-// public static boolean hasSameNodes(NodeIterator ni1, NodeIterator ni2)
-// {
-// NodeSet ns1 = new NodeSet(ni1);
-// NodeSet ns2 = new NodeSet(ni2);
-// if (ns1.getLength() != ns2.getLength())
-// return false;
-// for (int i = 0; i < ns1.getLength(); i++)
-// {
-// Node n = ns1.elementAt(i);
-// if(!ns2.contains(n))
-// return false;
-// }
-// return true;
-// }
-//
-// /**
-// * Returns the result of evaluating the argument as a string containing
-// * an XPath expression. Used where the XPath expression is not known until
-// * run-time. The expression is evaluated as if the run-time value of the
-// * argument appeared in place of the evaluate function call at compile time.
-// * @param myContext an <code>ExpressionContext</code> passed in by the
-// * extension mechanism. This must be an XPathContext.
-// * @param xpathExtr The XPath expression to be evaluated.
-// * @return the XObject resulting from evaluating the XPath
-// */
-// public static XObject evaluate(ExpressionContext myContext, String xpathExpr)
-// throws SAXNotSupportedException, Exception
-// {
-// if (myContext instanceof XPathContext)
-// {
-// try
-// {
-// XPathContext xctxt = (XPathContext) myContext;
-// XPath dynamicXPath = new XPath(xpathExpr,
-// xctxt.getSAXLocator(),
-// xctxt.getNamespaceContext(),
-// XPath.SELECT);
-// return dynamicXPath.execute(xctxt,
-// myContext.getContextNode(),
-// xctxt.getNamespaceContext());
-// }
-// catch (Exception e)
-// {
-// throw e;
-// }
-// }
-// else
-// throw new SAXNotSupportedException("Invalid context passed to evaluate " + myContext);
-// }
-//
-// /**
-// * Returns a NodeSet containing one text node for each token in the first argument.
-// * Delimiters are specified in the second argument.
-// * Tokens are determined by a call to <code>StringTokenizer</code>.
-// * If the first argument is an empty string or contains only delimiters, the result
-// * will be an empty NodeSet.
-// * Contributed to XalanJ1 by <a href="mailto:benoit.cerrina@writeme.com">Benoit Cerrina</a>.
-// * @param myContext an <code>ExpressionContext</code> passed in by the
-// * extension mechanism. This must be an XPathContext.
-// * @param toTokenize The string to be split into text tokens.
-// * @param delims The delimiters to use.
-// * @return a NodeSet as described above.
-// *
-// */
-// public static NodeSet tokenize(ExpressionContext myContext, String toTokenize, String delims)
-// {
-// Document lDoc = myContext.getContextNode().getOwnerDocument();
-// StringTokenizer lTokenizer = new StringTokenizer(toTokenize, delims);
-// NodeSet resultSet = new NodeSet();
-// while (lTokenizer.hasMoreTokens())
-// {
-// resultSet.addNode(lDoc.createTextNode(lTokenizer.nextToken()));
-// }
-// return resultSet;
-//}
-//
-// /**
-// * Returns a NodeSet containing one text node for each token in the first argument.
-// * Delimiters are whitespace. That is, the delimiters that are used are tab (	),
-// * linefeed (
), return (
), and space ( ).
-// * Tokens are determined by a call to <code>StringTokenizer</code>.
-// * If the first argument is an empty string or contains only delimiters, the result
-// * will be an empty NodeSet.
-// * Contributed to XalanJ1 by <a href="mailto:benoit.cerrina@writeme.com">Benoit Cerrina</a>.
-// * @param myContext an <code>ExpressionContext</code> passed in by the
-// * extension mechanism. This must be an XPathContext.
-// * @param toTokenize The string to be split into text tokens.
-// * @return a NodeSet as described above.
-// *
-// */
-// public static NodeSet tokenize(ExpressionContext myContext, String toTokenize)
-// {
-// return tokenize(myContext, toTokenize, " \t\n\r");
-// }
+ return resultSet;
+ }
+ /**
+ * Returns a NodeSet containing one text node for each token in the first argument.
+ * Delimiters are whitespace. That is, the delimiters that are used are tab (	),
+ * linefeed (
), return (
), and space ( ).
+ * Tokens are determined by a call to <code>StringTokenizer</code>.
+ * If the first argument is an empty string or contains only delimiters, the result
+ * will be an empty NodeSet.
+ * Contributed to XalanJ1 by <a href="mailto:benoit.cerrina@writeme.com">Benoit Cerrina</a>.
+ * @param myContext an <code>ExpressionContext</code> passed in by the
+ * extension mechanism. This must be an XPathContext.
+ * @param toTokenize The string to be split into text tokens.
+ * @return a NodeSet as described above.
+ *
+ */
+ public static NodeSet tokenize(ExpressionContext myContext,
+ String toTokenize)
+ {
+ return tokenize(myContext, toTokenize, " \t\n\r");
+ }
}
1.20 +6 -7 xml-xalan/java/src/org/apache/xalan/templates/ElemNumber.java
Index: ElemNumber.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemNumber.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- ElemNumber.java 2001/06/12 19:15:10 1.19
+++ ElemNumber.java 2001/06/15 05:13:54 1.20
@@ -957,7 +957,7 @@
throws javax.xml.transform.TransformerException
{
- NodeSet ancestors = new NodeSet();
+ NodeSetDTM ancestors = new NodeSetDTM();
XPath countMatchPattern = getCountMatchPattern(xctxt, node);
DTM dtm = xctxt.getDTM(node);
@@ -1016,8 +1016,8 @@
if (null != m_lang_avt)
{
- String langValue = m_lang_avt.evaluate(transformer.getXPathContext(),
- contextNode, this);
+ XPathContext xctxt = transformer.getXPathContext();
+ String langValue = m_lang_avt.evaluate(xctxt, contextNode, this);
if (null != langValue)
{
@@ -1030,10 +1030,9 @@
//Locale.getDefault().getDisplayCountry());
if (null == locale)
{
- // %DTBD%
-// transformer.getMsgMgr().warn(this, null, contextNode,
-// XSLTErrorResources.WG_LOCALE_NOT_FOUND,
-// new Object[]{ langValue }); //"Warning: Could not find locale for xml:lang="+langValue);
+ transformer.getMsgMgr().warn(this, null, xctxt.getDTM(contextNode).getNode(contextNode),
+ XSLTErrorResources.WG_LOCALE_NOT_FOUND,
+ new Object[]{ langValue }); //"Warning: Could not find locale for xml:lang="+langValue);
locale = Locale.getDefault();
}
1.11 +1 -2 xml-xalan/java/src/org/apache/xalan/templates/ElemPI.java
Index: ElemPI.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemPI.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ElemPI.java 2001/06/12 19:15:10 1.10
+++ ElemPI.java 2001/06/15 05:13:55 1.11
@@ -177,8 +177,7 @@
if (piName.equalsIgnoreCase("xml"))
{
- // %DTBD%
-// error(XSLTErrorResources.ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML); //"processing-instruction name can not be 'xml'");
+ error(XSLTErrorResources.ER_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML); //"processing-instruction name can not be 'xml'");
}
else if (!isValidNCName(piName))
{
1.41 +192 -202 xml-xalan/java/src/org/apache/xalan/templates/ElemTemplateElement.java
Index: ElemTemplateElement.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemTemplateElement.java,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- ElemTemplateElement.java 2001/06/14 22:44:47 1.40
+++ ElemTemplateElement.java 2001/06/15 05:13:56 1.41
@@ -82,10 +82,10 @@
import javax.xml.transform.SourceLocator;
// DOM Imports
-//import org.w3c.dom.Node;
-//import org.w3c.dom.NodeList;
-//import org.w3c.dom.DOMException;
-//import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
import org.apache.xml.dtm.DTM;
// SAX Imports
@@ -322,45 +322,44 @@
// Implemented DOM Element methods.
-// %DTBD%
-// /**
-// * Add a child to the child list.
-// * NOTE: This presumes the child did not previously have a parent.
-// * Making that assumption makes this a less expensive operation -- but
-// * requires that if you *do* want to reparent a node, you use removeChild()
-// * first to remove it from its previous context. Failing to do so will
-// * damage the tree.
-// *
-// * @param newChild Child to be added to child list
-// *
-// * @return Child just added to the child list
-// * @throws DOMException
-// */
-// public Node appendChild(Node newChild) throws DOMException
-// {
-//
-// if (null == newChild)
-// {
-// error(XSLTErrorResources.ER_NULL_CHILD, null); //"Trying to add a null child!");
-// }
-//
-// ElemTemplateElement elem = (ElemTemplateElement) newChild;
-//
-// if (null == m_firstChild)
-// {
-// m_firstChild = elem;
-// }
-// else
-// {
-// ElemTemplateElement last = (ElemTemplateElement) getLastChild();
-//
-// last.m_nextSibling = elem;
-// }
-//
-// elem.m_parentNode = this;
-//
-// return newChild;
-// }
+ /**
+ * Add a child to the child list.
+ * NOTE: This presumes the child did not previously have a parent.
+ * Making that assumption makes this a less expensive operation -- but
+ * requires that if you *do* want to reparent a node, you use removeChild()
+ * first to remove it from its previous context. Failing to do so will
+ * damage the tree.
+ *
+ * @param newChild Child to be added to child list
+ *
+ * @return Child just added to the child list
+ * @throws DOMException
+ */
+ public Node appendChild(Node newChild) throws DOMException
+ {
+
+ if (null == newChild)
+ {
+ error(XSLTErrorResources.ER_NULL_CHILD, null); //"Trying to add a null child!");
+ }
+
+ ElemTemplateElement elem = (ElemTemplateElement) newChild;
+
+ if (null == m_firstChild)
+ {
+ m_firstChild = elem;
+ }
+ else
+ {
+ ElemTemplateElement last = (ElemTemplateElement) getLastChild();
+
+ last.m_nextSibling = elem;
+ }
+
+ elem.m_parentNode = this;
+
+ return newChild;
+ }
/**
* Add a child to the child list.
@@ -419,16 +418,15 @@
return org.w3c.dom.Node.ELEMENT_NODE;
}
- // %DTBD%
-// /**
-// * Return the nodelist (same reference).
-// *
-// * @return The nodelist containing the child nodes (this)
-// */
-// public NodeList getChildNodes()
-// {
-// return this;
-// }
+ /**
+ * Return the nodelist (same reference).
+ *
+ * @return The nodelist containing the child nodes (this)
+ */
+ public NodeList getChildNodes()
+ {
+ return this;
+ }
/**
* Remove a child.
@@ -466,47 +464,46 @@
return childETE;
}
+
+ /**
+ * Replace the old child with a new child.
+ *
+ * @param newChild New child to replace with
+ * @param oldChild Old child to be replaced
+ *
+ * @return The new child
+ *
+ * @throws DOMException
+ */
+ public Node replaceChild(Node newChild, Node oldChild) throws DOMException
+ {
+
+ if (oldChild == null || oldChild.getParentNode() != this)
+ return null;
- // %DTBD%
-// /**
-// * Replace the old child with a new child.
-// *
-// * @param newChild New child to replace with
-// * @param oldChild Old child to be replaced
-// *
-// * @return The new child
-// *
-// * @throws DOMException
-// */
-// public Node replaceChild(Node newChild, Node oldChild) throws DOMException
-// {
-//
-// if (oldChild == null || oldChild.getParentNode() != this)
-// return null;
-//
-// ElemTemplateElement newChildElem = ((ElemTemplateElement) newChild);
-// ElemTemplateElement oldChildElem = ((ElemTemplateElement) oldChild);
-//
-// // Fix up previous sibling.
-// ElemTemplateElement prev =
-// (ElemTemplateElement) oldChildElem.getPreviousSibling();
-//
-// if (null != prev)
-// prev.m_nextSibling = newChildElem;
-//
-// // Fix up parent (this)
-// if (m_firstChild == oldChildElem)
-// m_firstChild = newChildElem;
-//
-// newChildElem.m_parentNode = this;
-// oldChildElem.m_parentNode = null;
-// newChildElem.m_nextSibling = oldChildElem.m_nextSibling;
-// oldChildElem.m_nextSibling = null;
-//
-// // newChildElem.m_stylesheet = oldChildElem.m_stylesheet;
-// // oldChildElem.m_stylesheet = null;
-// return newChildElem;
-// }
+ ElemTemplateElement newChildElem = ((ElemTemplateElement) newChild);
+ ElemTemplateElement oldChildElem = ((ElemTemplateElement) oldChild);
+
+ // Fix up previous sibling.
+ ElemTemplateElement prev =
+ (ElemTemplateElement) oldChildElem.getPreviousSibling();
+
+ if (null != prev)
+ prev.m_nextSibling = newChildElem;
+
+ // Fix up parent (this)
+ if (m_firstChild == oldChildElem)
+ m_firstChild = newChildElem;
+
+ newChildElem.m_parentNode = this;
+ oldChildElem.m_parentNode = null;
+ newChildElem.m_nextSibling = oldChildElem.m_nextSibling;
+ oldChildElem.m_nextSibling = null;
+
+ // newChildElem.m_stylesheet = oldChildElem.m_stylesheet;
+ // oldChildElem.m_stylesheet = null;
+ return newChildElem;
+ }
/**
* Replace the old child with a new child.
@@ -568,40 +565,38 @@
return count;
} // getLength():int
- // %TDB%
-// /**
-// * NodeList method: Return the Nth immediate child of this node, or
-// * null if the index is out of bounds.
-// *
-// * @param index Index of child to find
-// * @return org.w3c.dom.Node: the child node at given index
-// */
-// public Node item(int index)
-// {
-//
-// // It is assumed that the getChildNodes call synchronized
-// // the children. Therefore, we can access the first child
-// // reference directly.
-// ElemTemplateElement node = m_firstChild;
-//
-// for (int i = 0; i < index && node != null; i++)
-// {
-// node = node.m_nextSibling;
-// }
-//
-// return node;
-// } // item(int):Node
-
- // %DTBD%
-// /**
-// * Get the stylesheet owner.
-// *
-// * @return The stylesheet owner
-// */
-// public Document getOwnerDocument()
-// {
-// return getStylesheet();
-// }
+ /**
+ * NodeList method: Return the Nth immediate child of this node, or
+ * null if the index is out of bounds.
+ *
+ * @param index Index of child to find
+ * @return org.w3c.dom.Node: the child node at given index
+ */
+ public Node item(int index)
+ {
+
+ // It is assumed that the getChildNodes call synchronized
+ // the children. Therefore, we can access the first child
+ // reference directly.
+ ElemTemplateElement node = m_firstChild;
+
+ for (int i = 0; i < index && node != null; i++)
+ {
+ node = node.m_nextSibling;
+ }
+
+ return node;
+ } // item(int):Node
+
+ /**
+ * Get the stylesheet owner.
+ *
+ * @return The stylesheet owner
+ */
+ public Document getOwnerDocument()
+ {
+ return getStylesheet();
+ }
/**
* Return the element name.
@@ -1172,16 +1167,15 @@
*/
protected ElemTemplateElement m_parentNode;
- // %DTBD%
-// /**
-// * Get the parent as a Node.
-// *
-// * @return This node's parent node
-// */
-// public Node getParentNode()
-// {
-// return m_parentNode;
-// }
+ /**
+ * Get the parent as a Node.
+ *
+ * @return This node's parent node
+ */
+ public Node getParentNode()
+ {
+ return m_parentNode;
+ }
/**
* Get the parent as an ElemTemplateElement.
@@ -1209,42 +1203,15 @@
*/
ElemTemplateElement m_nextSibling;
- // %DTBD%
-// /**
-// * Get the next sibling (as a Node) or return null.
-// *
-// * @return this node's next sibling or null
-// */
-// public Node getNextSibling()
-// {
-// return m_nextSibling;
-// }
-
- // %DTBD%
-// /**
-// * Get the previous sibling (as a Node) or return null.
-// * Note that this may be expensive if the parent has many kids;
-// * we accept that price in exchange for avoiding the prev pointer
-// * TODO: If we were sure parents and sibs are always ElemTemplateElements,
-// * we could hit the fields directly rather than thru accessors.
-// *
-// * @return This node's previous sibling or null
-// */
-// public Node getPreviousSibling()
-// {
-//
-// Node walker = getParentNode(), prev = null;
-//
-// if (walker != null)
-// for (walker = walker.getFirstChild(); walker != null;
-// prev = walker, walker = walker.getNextSibling())
-// {
-// if (walker == this)
-// return prev;
-// }
-//
-// return null;
-// }
+ /**
+ * Get the next sibling (as a Node) or return null.
+ *
+ * @return this node's next sibling or null
+ */
+ public Node getNextSibling()
+ {
+ return m_nextSibling;
+ }
/**
* Get the previous sibling (as a Node) or return null.
@@ -1255,6 +1222,31 @@
*
* @return This node's previous sibling or null
*/
+ public Node getPreviousSibling()
+ {
+
+ Node walker = getParentNode(), prev = null;
+
+ if (walker != null)
+ for (walker = walker.getFirstChild(); walker != null;
+ prev = walker, walker = walker.getNextSibling())
+ {
+ if (walker == this)
+ return prev;
+ }
+
+ return null;
+ }
+
+ /**
+ * Get the previous sibling (as a Node) or return null.
+ * Note that this may be expensive if the parent has many kids;
+ * we accept that price in exchange for avoiding the prev pointer
+ * TODO: If we were sure parents and sibs are always ElemTemplateElements,
+ * we could hit the fields directly rather than thru accessors.
+ *
+ * @return This node's previous sibling or null
+ */
public ElemTemplateElement getPreviousSiblingElem()
{
@@ -1300,16 +1292,15 @@
*/
ElemTemplateElement m_firstChild;
- // %DTBD%
-// /**
-// * Get the first child as a Node.
-// *
-// * @return This node's first child or null
-// */
-// public Node getFirstChild()
-// {
-// return m_firstChild;
-// }
+ /**
+ * Get the first child as a Node.
+ *
+ * @return This node's first child or null
+ */
+ public Node getFirstChild()
+ {
+ return m_firstChild;
+ }
/**
* Get the first child as a ElemTemplateElement.
@@ -1321,25 +1312,24 @@
return m_firstChild;
}
- // %DTBD%
-// /**
-// * Get the last child.
-// *
-// * @return This node's last child
-// */
-// public Node getLastChild()
-// {
-//
-// ElemTemplateElement lastChild = null;
-//
-// for (ElemTemplateElement node = m_firstChild; node != null;
-// node = node.m_nextSibling)
-// {
-// lastChild = node;
-// }
-//
-// return lastChild;
-// }
+ /**
+ * Get the last child.
+ *
+ * @return This node's last child
+ */
+ public Node getLastChild()
+ {
+
+ ElemTemplateElement lastChild = null;
+
+ for (ElemTemplateElement node = m_firstChild; node != null;
+ node = node.m_nextSibling)
+ {
+ lastChild = node;
+ }
+
+ return lastChild;
+ }
/**
* Get the last child.
1.21 +2 -2 xml-xalan/java/src/org/apache/xalan/templates/FuncDocument.java
Index: FuncDocument.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/FuncDocument.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- FuncDocument.java 2001/06/12 19:15:12 1.20
+++ FuncDocument.java 2001/06/15 05:13:57 1.21
@@ -66,7 +66,7 @@
import org.apache.xml.dtm.DTMIterator;
import org.apache.xml.dtm.DTMManager;
-import org.apache.xpath.NodeSet;
+import org.apache.xpath.NodeSetDTM;
import org.apache.xpath.functions.Function;
import org.apache.xpath.functions.Function2Args;
import org.apache.xpath.functions.WrongNumberArgsException;
@@ -183,7 +183,7 @@
}
XNodeSet nodes = new XNodeSet(xctxt.getDTMManager());
- NodeSet mnl = nodes.mutableNodeset();
+ NodeSetDTM mnl = nodes.mutableNodeset();
DTMIterator iterator = (XObject.CLASS_NODESET == arg.getType())
? arg.nodeset() : null;
int pos = DTM.NULL;
1.10 +4 -4 xml-xalan/java/src/org/apache/xalan/templates/FuncKey.java
Index: FuncKey.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/FuncKey.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- FuncKey.java 2001/06/12 19:15:13 1.9
+++ FuncKey.java 2001/06/15 05:13:59 1.10
@@ -115,10 +115,10 @@
String xkeyname = getArg0().execute(xctxt).str();
QName keyname = new QName(xkeyname, xctxt.getNamespaceContext());
XObject arg = getArg1().execute(xctxt);
- boolean argIsNodeSet = (XObject.CLASS_NODESET == arg.getType());
+ boolean argIsNodeSetDTM = (XObject.CLASS_NODESET == arg.getType());
KeyManager kmgr = transformer.getKeyManager();
- if (argIsNodeSet)
+ if (argIsNodeSetDTM)
{
Hashtable usedrefs = null;
DTMIterator ni = arg.nodeset();
@@ -148,7 +148,7 @@
}
LocPathIterator nl =
- kmgr.getNodeSetByKey(xctxt, docContext, keyname, ref,
+ kmgr.getNodeSetDTMByKey(xctxt, docContext, keyname, ref,
xctxt.getNamespaceContext());
try
@@ -170,7 +170,7 @@
else
{
XMLString ref = arg.xstr();
- LocPathIterator nl = kmgr.getNodeSetByKey(xctxt, docContext, keyname,
+ LocPathIterator nl = kmgr.getNodeSetDTMByKey(xctxt, docContext, keyname,
ref,
xctxt.getNamespaceContext());
1.9 +4 -4 xml-xalan/java/src/org/apache/xalan/transformer/Counter.java
Index: Counter.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/Counter.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Counter.java 2001/06/12 19:15:25 1.8
+++ Counter.java 2001/06/15 05:14:05 1.9
@@ -60,12 +60,12 @@
import org.apache.xml.dtm.DTM;
import org.apache.xml.utils.NodeVector;
-import org.apache.xpath.NodeSet; // for isNodeAfter support
+import org.apache.xpath.NodeSetDTM; // for isNodeAfter support
import org.apache.xpath.XPathContext;
import javax.xml.transform.TransformerException;
-import org.apache.xpath.NodeSet;
+import org.apache.xpath.NodeSetDTM;
import org.apache.xpath.XPath;
import org.apache.xalan.templates.ElemNumber;
@@ -96,7 +96,7 @@
/**
* A vector of all nodes counted so far.
*/
- NodeSet m_countNodes = new NodeSet();
+ NodeSetDTM m_countNodes = new NodeSetDTM();
/**
* The node from where the counting starts. This is needed to
@@ -125,7 +125,7 @@
*
* @throws TransformerException
*/
- Counter(ElemNumber numberElem, NodeSet countNodes) throws TransformerException
+ Counter(ElemNumber numberElem, NodeSetDTM countNodes) throws TransformerException
{
m_countNodes = countNodes;
m_numberElem = numberElem;
1.8 +3 -3 xml-xalan/java/src/org/apache/xalan/transformer/CountersTable.java
Index: CountersTable.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/CountersTable.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- CountersTable.java 2001/06/12 19:15:25 1.7
+++ CountersTable.java 2001/06/15 05:14:06 1.8
@@ -66,7 +66,7 @@
import org.apache.xpath.XPathContext;
import org.apache.xpath.XPath;
-import org.apache.xpath.NodeSet;
+import org.apache.xpath.NodeSetDTM;
import org.apache.xalan.templates.ElemNumber;
/**
@@ -123,7 +123,7 @@
/**
* Place to collect new counters.
*/
- transient private NodeSet m_newFound = new NodeSet();
+ transient private NodeSetDTM m_newFound = new NodeSetDTM();
/**
* Add a list of counted nodes that were built in backwards document
@@ -133,7 +133,7 @@
* @param flist Vector of nodes built in forwards document order
* @param blist Vector of nodes built in backwards document order
*/
- void appendBtoFList(NodeSet flist, NodeSet blist)
+ void appendBtoFList(NodeSetDTM flist, NodeSetDTM blist)
{
int n = blist.size();
1.12 +3 -3 xml-xalan/java/src/org/apache/xalan/transformer/KeyManager.java
Index: KeyManager.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/KeyManager.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- KeyManager.java 2001/06/12 19:15:25 1.11
+++ KeyManager.java 2001/06/15 05:14:07 1.12
@@ -94,7 +94,7 @@
*
* @throws javax.xml.transform.TransformerException
*/
- public LocPathIterator getNodeSetByKey(
+ public LocPathIterator getNodeSetDTMByKey(
XPathContext xctxt, int doc, QName name, XMLString ref, PrefixResolver nscontext)
throws javax.xml.transform.TransformerException
{
@@ -121,7 +121,7 @@
if (kt.getKeyTableName().equals(name) && doc == kt.getDocKey())
{
- nl = kt.getNodeSetByKey(name, ref);
+ nl = kt.getNodeSetDTMByKey(name, ref);
if (nl != null)
{
@@ -145,7 +145,7 @@
if (doc == kt.getDocKey())
{
foundDoc = true;
- nl = kt.getNodeSetByKey(name, ref);
+ nl = kt.getNodeSetDTMByKey(name, ref);
}
}
}
1.8 +4 -4 xml-xalan/java/src/org/apache/xalan/transformer/KeyRefIterator.java
Index: KeyRefIterator.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/KeyRefIterator.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- KeyRefIterator.java 2001/06/12 19:15:25 1.7
+++ KeyRefIterator.java 2001/06/15 05:14:08 1.8
@@ -62,7 +62,7 @@
import org.apache.xml.utils.QName;
import org.apache.xml.utils.XMLString;
import org.apache.xalan.templates.KeyDeclaration;
-import org.apache.xpath.NodeSet;
+import org.apache.xpath.NodeSetDTM;
//import org.w3c.dom.Node;
//import org.w3c.dom.DOMException;
@@ -139,9 +139,9 @@
// If the cache is on, and the node has already been found, then
// just return from the list.
- NodeSet m_cachedNodes = getCachedNodes();
+ NodeSetDTM m_cachedNodes = getCachedNodes();
- // We are not using the NodeSet methods getCurrentPos() and nextNode()
+ // We are not using the NodeSetDTM methods getCurrentPos() and nextNode()
// in this case because the nodeset is not cloned and therefore
// the positions it indicates may not be associated with the
// current iterator.
@@ -241,7 +241,7 @@
*/
public void addNode(int node)
{
- NodeSet m_cachedNodes = getCachedNodes();
+ NodeSetDTM m_cachedNodes = getCachedNodes();
if (null != m_cachedNodes)
{
if(!m_cachedNodes.contains(node))
1.10 +2 -2 xml-xalan/java/src/org/apache/xalan/transformer/KeyTable.java
Index: KeyTable.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/KeyTable.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- KeyTable.java 2001/06/12 19:15:25 1.9
+++ KeyTable.java 2001/06/15 05:14:09 1.10
@@ -66,7 +66,7 @@
import java.util.Vector;
import java.util.Enumeration;
-import org.apache.xpath.NodeSet;
+import org.apache.xpath.NodeSetDTM;
import org.apache.xpath.objects.XObject;
import org.apache.xpath.XPathContext;
import org.apache.xpath.XPathContext;
@@ -152,7 +152,7 @@
* if the identifier is not found, it will return null,
* otherwise it will return a LocPathIterator instance.
*/
- public LocPathIterator getNodeSetByKey(QName name, XMLString ref)
+ public LocPathIterator getNodeSetDTMByKey(QName name, XMLString ref)
{
KeyIterator ki;
1.11 +1 -1 xml-xalan/java/src/org/apache/xalan/transformer/NodeSorter.java
Index: NodeSorter.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/NodeSorter.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- NodeSorter.java 2001/06/12 19:15:26 1.10
+++ NodeSorter.java 2001/06/15 05:14:09 1.11
@@ -68,7 +68,7 @@
import org.apache.xpath.axes.ContextNodeList;
import org.apache.xpath.XPathContext;
-import org.apache.xpath.NodeSet;
+import org.apache.xpath.NodeSetDTM;
import org.apache.xpath.objects.XObject;
import org.apache.xpath.objects.XNodeSet;
import org.apache.xml.utils.NodeVector;
1.98 +1 -1 xml-xalan/java/src/org/apache/xalan/transformer/TransformerImpl.java
Index: TransformerImpl.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/TransformerImpl.java,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -r1.97 -r1.98
--- TransformerImpl.java 2001/06/12 19:15:28 1.97
+++ TransformerImpl.java 2001/06/15 05:14:10 1.98
@@ -99,7 +99,7 @@
import org.apache.xml.utils.ObjectPool;
import org.apache.xml.utils.SAXSourceLocator;
import org.apache.xpath.XPathContext;
-import org.apache.xpath.NodeSet;
+import org.apache.xpath.NodeSetDTM;
import org.apache.xpath.objects.XObject;
import org.apache.xpath.objects.XNodeSet;
import org.apache.xpath.XPath;
1.2 +3 -3 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AbsoluteLocationPath.java
Index: AbsoluteLocationPath.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AbsoluteLocationPath.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbsoluteLocationPath.java 2001/04/17 18:51:17 1.1
+++ AbsoluteLocationPath.java 2001/06/15 05:14:17 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: AbsoluteLocationPath.java,v 1.1 2001/04/17 18:51:17 sboag Exp $
+ * @(#)$Id: AbsoluteLocationPath.java,v 1.2 2001/06/15 05:14:17 sboag Exp $
*
* The Apache Software License, Version 1.1
*
@@ -101,10 +101,10 @@
if (_path != null) {
final Type ptype = _path.typeCheck(stable);
if (ptype instanceof NodeType) { // promote to node-set
- _path = new CastExpr(_path, Type.NodeSet);
+ _path = new CastExpr(_path, Type.NodeSetDTM);
}
}
- return _type = Type.NodeSet;
+ return _type = Type.NodeSetDTM;
}
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
1.4 +4 -4 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ApplyImports.java
Index: ApplyImports.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ApplyImports.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ApplyImports.java 2001/06/06 10:44:34 1.3
+++ ApplyImports.java 2001/06/15 05:14:18 1.4
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: ApplyImports.java,v 1.3 2001/06/06 10:44:34 morten Exp $
+ * @(#)$Id: ApplyImports.java,v 1.4 2001/06/15 05:14:18 sboag Exp $
*
* The Apache Software License, Version 1.1
*
@@ -120,10 +120,10 @@
Type tselect = _select.typeCheck(stable);
if (tselect instanceof NodeType ||
tselect instanceof ReferenceType) {
- _select = new CastExpr(_select, Type.NodeSet);
- tselect = Type.NodeSet;
+ _select = new CastExpr(_select, Type.NodeSetDTM);
+ tselect = Type.NodeSetDTM;
}
- if (tselect instanceof NodeSetType) {
+ if (tselect instanceof NodeSetDTMType) {
typeCheckContents(stable); // with-params
return Type.Void;
}
1.4 +4 -4 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ApplyTemplates.java 2001/06/06 10:44:35 1.3
+++ ApplyTemplates.java 2001/06/15 05:14:19 1.4
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: ApplyTemplates.java,v 1.3 2001/06/06 10:44:35 morten Exp $
+ * @(#)$Id: ApplyTemplates.java,v 1.4 2001/06/15 05:14:19 sboag Exp $
*
* The Apache Software License, Version 1.1
*
@@ -119,10 +119,10 @@
Type tselect = _select.typeCheck(stable);
if (tselect instanceof NodeType ||
tselect instanceof ReferenceType) {
- _select = new CastExpr(_select, Type.NodeSet);
- tselect = Type.NodeSet;
+ _select = new CastExpr(_select, Type.NodeSetDTM);
+ tselect = Type.NodeSetDTM;
}
- if (tselect instanceof NodeSetType) {
+ if (tselect instanceof NodeSetDTMType) {
typeCheckContents(stable); // with-params
return Type.Void;
}
1.2 +10 -10 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/CastExpr.java
Index: CastExpr.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/CastExpr.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- CastExpr.java 2001/04/17 18:51:22 1.1
+++ CastExpr.java 2001/06/15 05:14:20 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: CastExpr.java,v 1.1 2001/04/17 18:51:22 sboag Exp $
+ * @(#)$Id: CastExpr.java,v 1.2 2001/06/15 05:14:20 sboag Exp $
*
* The Apache Software License, Version 1.1
*
@@ -100,25 +100,25 @@
InternalTypeMap.put(Type.String, Type.Real);
InternalTypeMap.put(Type.String, Type.Reference);
- InternalTypeMap.put(Type.NodeSet, Type.NodeSet);
- InternalTypeMap.put(Type.NodeSet, Type.Boolean);
- InternalTypeMap.put(Type.NodeSet, Type.Real);
- InternalTypeMap.put(Type.NodeSet, Type.String);
- InternalTypeMap.put(Type.NodeSet, Type.Node);
- InternalTypeMap.put(Type.NodeSet, Type.Reference);
+ InternalTypeMap.put(Type.NodeSetDTM, Type.NodeSetDTM);
+ InternalTypeMap.put(Type.NodeSetDTM, Type.Boolean);
+ InternalTypeMap.put(Type.NodeSetDTM, Type.Real);
+ InternalTypeMap.put(Type.NodeSetDTM, Type.String);
+ InternalTypeMap.put(Type.NodeSetDTM, Type.Node);
+ InternalTypeMap.put(Type.NodeSetDTM, Type.Reference);
InternalTypeMap.put(Type.Node, Type.Node);
InternalTypeMap.put(Type.Node, Type.Boolean);
InternalTypeMap.put(Type.Node, Type.Real);
InternalTypeMap.put(Type.Node, Type.String);
- InternalTypeMap.put(Type.Node, Type.NodeSet);
+ InternalTypeMap.put(Type.Node, Type.NodeSetDTM);
InternalTypeMap.put(Type.Node, Type.Reference);
InternalTypeMap.put(Type.ResultTree, Type.ResultTree);
InternalTypeMap.put(Type.ResultTree, Type.Boolean);
InternalTypeMap.put(Type.ResultTree, Type.Real);
InternalTypeMap.put(Type.ResultTree, Type.String);
- InternalTypeMap.put(Type.ResultTree, Type.NodeSet);
+ InternalTypeMap.put(Type.ResultTree, Type.NodeSetDTM);
InternalTypeMap.put(Type.ResultTree, Type.Reference);
InternalTypeMap.put(Type.Reference, Type.Reference);
@@ -126,7 +126,7 @@
InternalTypeMap.put(Type.Reference, Type.Int);
InternalTypeMap.put(Type.Reference, Type.Real);
InternalTypeMap.put(Type.Reference, Type.String);
- InternalTypeMap.put(Type.Reference, Type.NodeSet);
+ InternalTypeMap.put(Type.Reference, Type.NodeSetDTM);
InternalTypeMap.put(Type.Void, Type.String);
}
1.4 +3 -3 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/CopyOf.java
Index: CopyOf.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/CopyOf.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CopyOf.java 2001/06/06 10:44:50 1.3
+++ CopyOf.java 2001/06/15 05:14:20 1.4
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: CopyOf.java,v 1.3 2001/06/06 10:44:50 morten Exp $
+ * @(#)$Id: CopyOf.java,v 1.4 2001/06/15 05:14:20 sboag Exp $
*
* The Apache Software License, Version 1.1
*
@@ -94,7 +94,7 @@
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
final Type tselect = _select.typeCheck(stable);
if (tselect instanceof NodeType ||
- tselect instanceof NodeSetType ||
+ tselect instanceof NodeSetDTMType ||
tselect instanceof ReferenceType ||
tselect instanceof ResultTreeType) {
// falls through
@@ -113,7 +113,7 @@
- if (tselect instanceof NodeSetType) {
+ if (tselect instanceof NodeSetDTMType) {
il.append(methodGen.loadDOM());
// push NodeIterator
1.3 +5 -5 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/DocumentCall.java
Index: DocumentCall.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/DocumentCall.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DocumentCall.java 2001/06/06 10:44:53 1.2
+++ DocumentCall.java 2001/06/15 05:14:22 1.3
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: DocumentCall.java,v 1.2 2001/06/06 10:44:53 morten Exp $
+ * @(#)$Id: DocumentCall.java,v 1.3 2001/06/15 05:14:22 sboag Exp $
*
* The Apache Software License, Version 1.1
*
@@ -116,21 +116,21 @@
}
_uriType = _uri.typeCheck(stable);
- if ((_uriType != Type.NodeSet) && (_uriType != Type.String)) {
+ if ((_uriType != Type.NodeSetDTM) && (_uriType != Type.String)) {
_uri = new CastExpr(_uri, Type.String);
}
// Parse the second argument - the document URI base
if (ac == 2) {
_base = argument(1);
- if (!_base.typeCheck(stable).identicalTo(Type.NodeSet)) {
+ if (!_base.typeCheck(stable).identicalTo(Type.NodeSetDTM)) {
ErrorMsg msg = new ErrorMsg("Second argument to document() "+
"function must be a node-set.");
throw new TypeCheckError(msg);
}
}
- return _type = Type.NodeSet;
+ return _type = Type.NodeSetDTM;
}
/**
@@ -157,7 +157,7 @@
// The URI can be either a node-set or something else cast to a string
_uri.translate(classGen, methodGen);
- if (_uriType == Type.NodeSet)
+ if (_uriType == Type.NodeSetDTM)
_uri.startResetIterator(classGen, methodGen);
// The base of the URI may be given as a second argument (a node-set)
1.2 +11 -11 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/EqualityExpr.java
Index: EqualityExpr.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/EqualityExpr.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- EqualityExpr.java 2001/04/17 18:51:26 1.1
+++ EqualityExpr.java 2001/06/15 05:14:22 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: EqualityExpr.java,v 1.1 2001/04/17 18:51:26 sboag Exp $
+ * @(#)$Id: EqualityExpr.java,v 1.2 2001/06/15 05:14:22 sboag Exp $
*
* The Apache Software License, Version 1.1
*
@@ -140,27 +140,27 @@
_left = new CastExpr(_left, Type.String);
_right = new CastExpr(_right, Type.String);
}
- else if (tleft instanceof NodeType && tright instanceof NodeSetType) {
- // compare(Node, NodeSet) will be invoked
+ else if (tleft instanceof NodeType && tright instanceof NodeSetDTMType) {
+ // compare(Node, NodeSetDTM) will be invoked
}
- else if (tleft instanceof NodeSetType && tright instanceof NodeType) {
- swapArguments(); // for compare(Node, NodeSet)
+ else if (tleft instanceof NodeSetDTMType && tright instanceof NodeType) {
+ swapArguments(); // for compare(Node, NodeSetDTM)
}
else {
// At least one argument is of type node, node-set or result-tree
// Promote an expression of type node to node-set
if (tleft instanceof NodeType) {
- _left = new CastExpr(_left, Type.NodeSet);
+ _left = new CastExpr(_left, Type.NodeSetDTM);
}
if (tright instanceof NodeType) {
- _right = new CastExpr(_right, Type.NodeSet);
+ _right = new CastExpr(_right, Type.NodeSetDTM);
}
// If one arg is a node-set then make it the left one
if (tleft.isSimple() ||
tleft instanceof ResultTreeType &&
- tright instanceof NodeSetType) {
+ tright instanceof NodeSetDTMType) {
swapArguments();
}
@@ -284,10 +284,10 @@
return;
}
- if (tleft instanceof NodeSetType && tright instanceof BooleanType) {
+ if (tleft instanceof NodeSetDTMType && tright instanceof BooleanType) {
_left.translate(classGen, methodGen);
_left.startResetIterator(classGen, methodGen);
- Type.NodeSet.translateTo(classGen, methodGen, Type.Boolean);
+ Type.NodeSetDTM.translateTo(classGen, methodGen, Type.Boolean);
_right.translate(classGen, methodGen);
il.append(IXOR); // x != y <-> x xor y
@@ -298,7 +298,7 @@
return;
}
- if (tleft instanceof NodeSetType && tright instanceof StringType) {
+ if (tleft instanceof NodeSetDTMType && tright instanceof StringType) {
_left.translate(classGen, methodGen);
_left.startResetIterator(classGen, methodGen); // needed ?
_right.translate(classGen, methodGen);
1.3 +2 -2 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Expression.java
Index: Expression.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Expression.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Expression.java 2001/06/06 10:44:54 1.2
+++ Expression.java 2001/06/15 05:14:23 1.3
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Expression.java,v 1.2 2001/06/06 10:44:54 morten Exp $
+ * @(#)$Id: Expression.java,v 1.3 2001/06/15 05:14:23 sboag Exp $
*
* The Apache Software License, Version 1.1
*
@@ -155,7 +155,7 @@
}
_startReset = true;
- if (_type instanceof NodeSetType == false) {
+ if (_type instanceof NodeSetDTMType == false) {
return; // nothing to do
}
1.2 +4 -4 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FilterExpr.java
Index: FilterExpr.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FilterExpr.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FilterExpr.java 2001/04/17 18:51:27 1.1
+++ FilterExpr.java 2001/06/15 05:14:24 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: FilterExpr.java,v 1.1 2001/04/17 18:51:27 sboag Exp $
+ * @(#)$Id: FilterExpr.java,v 1.2 2001/06/15 05:14:24 sboag Exp $
*
* The Apache Software License, Version 1.1
*
@@ -106,9 +106,9 @@
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
Type ptype = _primary.typeCheck(stable);
- if (ptype instanceof NodeSetType == false) {
+ if (ptype instanceof NodeSetDTMType == false) {
if (ptype instanceof ReferenceType) {
- _primary = new CastExpr(_primary, Type.NodeSet);
+ _primary = new CastExpr(_primary, Type.NodeSetDTM);
}
else {
throw new TypeCheckError(this);
@@ -120,7 +120,7 @@
Expression pred = (Expression)_predicates.elementAt(i);
pred.typeCheck(stable);
}
- return _type = Type.NodeSet;
+ return _type = Type.NodeSetDTM;
}
/**
1.2 +7 -7 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FilterParentPath.java
Index: FilterParentPath.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FilterParentPath.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FilterParentPath.java 2001/04/17 18:51:28 1.1
+++ FilterParentPath.java 2001/06/15 05:14:24 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: FilterParentPath.java,v 1.1 2001/04/17 18:51:28 sboag Exp $
+ * @(#)$Id: FilterParentPath.java,v 1.2 2001/06/15 05:14:24 sboag Exp $
*
* The Apache Software License, Version 1.1
*
@@ -94,12 +94,12 @@
*/
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
final Type ftype = _filterExpr.typeCheck(stable);
- if (ftype instanceof NodeSetType == false) {
+ if (ftype instanceof NodeSetDTMType == false) {
if (ftype instanceof ReferenceType) {
- _filterExpr = new CastExpr(_filterExpr, Type.NodeSet);
+ _filterExpr = new CastExpr(_filterExpr, Type.NodeSetDTM);
}
else if (ftype instanceof NodeType) {
- _filterExpr = new CastExpr(_filterExpr, Type.NodeSet);
+ _filterExpr = new CastExpr(_filterExpr, Type.NodeSetDTM);
}
else {
throw new TypeCheckError(this);
@@ -108,11 +108,11 @@
// Wrap single node path in a node set
final Type ptype = _path.typeCheck(stable);
- if (!(ptype instanceof NodeSetType)) {
- _path = new CastExpr(_path, Type.NodeSet);
+ if (!(ptype instanceof NodeSetDTMType)) {
+ _path = new CastExpr(_path, Type.NodeSetDTM);
}
- return _type = Type.NodeSet;
+ return _type = Type.NodeSetDTM;
}
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
1.5 +3 -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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ForEach.java 2001/06/12 13:51:22 1.4
+++ ForEach.java 2001/06/15 05:14:25 1.5
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: ForEach.java,v 1.4 2001/06/12 13:51:22 morten Exp $
+ * @(#)$Id: ForEach.java,v 1.5 2001/06/15 05:14:25 sboag Exp $
*
* The Apache Software License, Version 1.1
*
@@ -103,11 +103,11 @@
Type tselect = _select.typeCheck(stable);
if (tselect instanceof ReferenceType || tselect instanceof NodeType) {
- _select = new CastExpr(_select, Type.NodeSet);
+ _select = new CastExpr(_select, Type.NodeSetDTM);
typeCheckContents(stable);
return Type.Void;
}
- else if (tselect instanceof NodeSetType) {
+ else if (tselect instanceof NodeSetDTMType) {
typeCheckContents(stable);
return Type.Void;
}
1.4 +3 -3 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FunctionCall.java 2001/06/07 15:15:52 1.3
+++ FunctionCall.java 2001/06/15 05:14:26 1.4
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: FunctionCall.java,v 1.3 2001/06/07 15:15:52 morten Exp $
+ * @(#)$Id: FunctionCall.java,v 1.4 2001/06/15 05:14:26 sboag Exp $
*
* The Apache Software License, Version 1.1
*
@@ -128,8 +128,8 @@
InternalToJava.put(Type.Node, nodeClass);
InternalToJava.put(Type.Node, nodeListClass);
- InternalToJava.put(Type.NodeSet, nodeClass);
- InternalToJava.put(Type.NodeSet, nodeListClass);
+ InternalToJava.put(Type.NodeSetDTM, nodeClass);
+ InternalToJava.put(Type.NodeSetDTM, nodeListClass);
InternalToJava.put(Type.ResultTree, nodeClass);
InternalToJava.put(Type.ResultTree, nodeListClass);
1.2 +2 -2 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/IdKeyPattern.java
Index: IdKeyPattern.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/IdKeyPattern.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- IdKeyPattern.java 2001/04/17 18:51:31 1.1
+++ IdKeyPattern.java 2001/06/15 05:14:27 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: IdKeyPattern.java,v 1.1 2001/04/17 18:51:31 sboag Exp $
+ * @(#)$Id: IdKeyPattern.java,v 1.2 2001/06/15 05:14:27 sboag Exp $
*
* The Apache Software License, Version 1.1
*
@@ -84,7 +84,7 @@
}
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
- return Type.NodeSet;
+ return Type.NodeSetDTM;
}
public boolean isWildcard() {
1.4 +4 -4 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Key.java 2001/06/06 10:45:05 1.3
+++ Key.java 2001/06/15 05:14:28 1.4
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Key.java,v 1.3 2001/06/06 10:45:05 morten Exp $
+ * @(#)$Id: Key.java,v 1.4 2001/06/15 05:14:28 sboag Exp $
*
* The Apache Software License, Version 1.1
*
@@ -131,7 +131,7 @@
_use = new CastExpr(_use, Type.String);
}
// ...or a node-set.
- else if (!(_useType instanceof NodeSetType)) {
+ else if (!(_useType instanceof NodeSetDTMType)) {
throw new TypeCheckError(this);
}
}
@@ -143,7 +143,7 @@
* 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.
*/
- public void traverseNodeSet(ClassGenerator classGen,
+ public void traverseNodeSetDTM(ClassGenerator classGen,
MethodGenerator methodGen,
int buildKeyIndex) {
final ConstantPoolGen cpg = classGen.getConstantPool();
@@ -260,7 +260,7 @@
else {
// Pass current node as parameter (we're indexing on that node)
il.append(methodGen.loadCurrentNode());
- traverseNodeSet(classGen,methodGen,key);
+ traverseNodeSetDTM(classGen,methodGen,key);
}
// Get the next node from the iterator and do loop again...
1.2 +4 -4 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- KeyCall.java 2001/04/17 18:51:33 1.1
+++ KeyCall.java 2001/06/15 05:14:28 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: KeyCall.java,v 1.1 2001/04/17 18:51:33 sboag Exp $
+ * @(#)$Id: KeyCall.java,v 1.2 2001/06/15 05:14:28 sboag Exp $
*
* The Apache Software License, Version 1.1
*
@@ -77,7 +77,7 @@
/**
* Get the parameters passed to function:
* key(String name, String value)
- * key(String name, NodeSet value)
+ * key(String name, NodeSetDTM value)
*/
public KeyCall(QName fname, Vector arguments) {
super(fname, arguments);
@@ -118,7 +118,7 @@
// be added to the resulting node-set.
_valueType = _value.typeCheck(stable);
- if ((_valueType != Type.NodeSet) &&
+ if ((_valueType != Type.NodeSetDTM) &&
(_valueType != Type.ResultTree) &&
(_valueType != Type.String)) {
_value = new CastExpr(_value,Type.String);
@@ -180,7 +180,7 @@
// If the second paramter is a node-set we need to go through each
// node in the set, convert each one to a string and do a look up in
// the named index, and then merge all the resulting node sets.
- if (_valueType == Type.NodeSet || _valueType == Type.ResultTree) {
+ if (_valueType == Type.NodeSetDTM || _valueType == Type.ResultTree) {
// Save current node and current iterator on the stack
il.append(methodGen.loadCurrentNode());
il.append(methodGen.loadIterator());
1.2 +2 -2 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/NameBase.java
Index: NameBase.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/NameBase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NameBase.java 2001/04/17 18:51:36 1.1
+++ NameBase.java 2001/06/15 05:14:29 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: NameBase.java,v 1.1 2001/04/17 18:51:36 sboag Exp $
+ * @(#)$Id: NameBase.java,v 1.2 2001/06/15 05:14:29 sboag Exp $
*
* The Apache Software License, Version 1.1
*
@@ -107,7 +107,7 @@
throw new TypeCheckError(this);
}
- if ((_type != Type.NodeSet) && (_type != Type.Node))
+ if ((_type != Type.NodeSetDTM) && (_type != Type.Node))
throw new TypeCheckError(this);
return Type.String;
1.2 +2 -2 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ParentLocationPath.java
Index: ParentLocationPath.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ParentLocationPath.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ParentLocationPath.java 2001/04/17 18:51:42 1.1
+++ ParentLocationPath.java 2001/06/15 05:14:30 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: ParentLocationPath.java,v 1.1 2001/04/17 18:51:42 sboag Exp $
+ * @(#)$Id: ParentLocationPath.java,v 1.2 2001/06/15 05:14:30 sboag Exp $
*
* The Apache Software License, Version 1.1
*
@@ -110,7 +110,7 @@
if (descendantAxis() && _path.descendantAxis())
_orderNodes = true;
- return _type = Type.NodeSet;
+ return _type = Type.NodeSetDTM;
}
public boolean descendantAxis() {
1.12 +11 -11 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.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Parser.java 2001/06/11 14:09:02 1.11
+++ Parser.java 2001/06/15 05:14:31 1.12
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Parser.java,v 1.11 2001/06/11 14:09:02 tmiller Exp $
+ * @(#)$Id: Parser.java,v 1.12 2001/06/15 05:14:31 sboag Exp $
*
* The Apache Software License, Version 1.1
*
@@ -584,25 +584,25 @@
MethodType I_V = new MethodType(Type.Int, Type.Void);
MethodType I_R = new MethodType(Type.Int, Type.Real);
MethodType I_S = new MethodType(Type.Int, Type.String);
- MethodType I_D = new MethodType(Type.Int, Type.NodeSet);
+ MethodType I_D = new MethodType(Type.Int, Type.NodeSetDTM);
MethodType R_I = new MethodType(Type.Real, Type.Int);
MethodType R_V = new MethodType(Type.Real, Type.Void);
MethodType R_R = new MethodType(Type.Real, Type.Real);
- MethodType R_D = new MethodType(Type.Real, Type.NodeSet);
+ MethodType R_D = new MethodType(Type.Real, Type.NodeSetDTM);
MethodType R_O = new MethodType(Type.Real, Type.Reference);
MethodType I_I = new MethodType(Type.Int, Type.Int);
- MethodType D_O = new MethodType(Type.NodeSet, Type.Reference);
- MethodType D_SS = new MethodType(Type.NodeSet,
+ MethodType D_O = new MethodType(Type.NodeSetDTM, Type.Reference);
+ MethodType D_SS = new MethodType(Type.NodeSetDTM,
Type.String, Type.String);
- MethodType D_SD = new MethodType(Type.NodeSet,
- Type.String, Type.NodeSet);
- MethodType D_S = new MethodType(Type.NodeSet, Type.String);
- MethodType D_D = new MethodType(Type.NodeSet, Type.NodeSet);
+ MethodType D_SD = new MethodType(Type.NodeSetDTM,
+ Type.String, Type.NodeSetDTM);
+ MethodType D_S = new MethodType(Type.NodeSetDTM, Type.String);
+ MethodType D_D = new MethodType(Type.NodeSetDTM, Type.NodeSetDTM);
MethodType A_V = new MethodType(Type.Node, Type.Void);
MethodType S_V = new MethodType(Type.String, Type.Void);
MethodType S_S = new MethodType(Type.String, Type.String);
MethodType S_A = new MethodType(Type.String, Type.Node);
- MethodType S_D = new MethodType(Type.String, Type.NodeSet);
+ MethodType S_D = new MethodType(Type.String, Type.NodeSetDTM);
MethodType S_O = new MethodType(Type.String, Type.Reference);
MethodType B_O = new MethodType(Type.Boolean, Type.Reference);
MethodType B_V = new MethodType(Type.Boolean, Type.Void);
@@ -619,7 +619,7 @@
MethodType S_SS = new MethodType(Type.String, Type.String,
Type.String);
MethodType S_SD = new MethodType(Type.String, Type.String,
- Type.NodeSet);
+ Type.NodeSetDTM);
MethodType S_DS = new MethodType(Type.String, Type.Real, Type.String);
MethodType S_DSS = new MethodType(Type.String, Type.Real, Type.String,
Type.String);
1.2 +3 -3 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Predicate.java 2001/04/17 18:51:43 1.1
+++ Predicate.java 2001/06/15 05:14:31 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Predicate.java,v 1.1 2001/04/17 18:51:43 sboag Exp $
+ * @(#)$Id: Predicate.java,v 1.2 2001/06/15 05:14:31 sboag Exp $
*
* The Apache Software License, Version 1.1
*
@@ -190,11 +190,11 @@
(parent instanceof AbsoluteLocationPath)) {
// TODO: Special case for "//*[n]" pattern....
_nthDescendant = true;
- return _type = Type.NodeSet;
+ return _type = Type.NodeSetDTM;
}
}
_nthPositionFilter = true;
- return _type = Type.NodeSet;
+ return _type = Type.NodeSetDTM;
}
}
else if (texp instanceof BooleanType == false) {
1.4 +9 -9 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/RelationalExpr.java
Index: RelationalExpr.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/RelationalExpr.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- RelationalExpr.java 2001/06/07 15:15:59 1.3
+++ RelationalExpr.java 2001/06/15 05:14:32 1.4
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: RelationalExpr.java,v 1.3 2001/06/07 15:15:59 morten Exp $
+ * @(#)$Id: RelationalExpr.java,v 1.4 2001/06/15 05:14:32 sboag Exp $
*
* The Apache Software License, Version 1.1
*
@@ -95,9 +95,9 @@
_right.getType() instanceof NodeType;
}
- public boolean hasNodeSetArgs() {
- return _left.getType() instanceof NodeSetType ||
- _right.getType() instanceof NodeSetType;
+ public boolean hasNodeSetDTMArgs() {
+ return _left.getType() instanceof NodeSetDTMType ||
+ _right.getType() instanceof NodeSetDTMType;
}
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
@@ -116,9 +116,9 @@
return _type = Type.Boolean;
}
- if (hasNodeSetArgs()) {
+ if (hasNodeSetDTMArgs()) {
// Ensure that the node-set is the left argument
- if (tright instanceof NodeSetType) {
+ if (tright instanceof NodeSetDTMType) {
final Expression temp = _right; _right = _left; _left = temp;
_op = (_op == Operators.GT) ? Operators.LT :
(_op == Operators.LT) ? Operators.GT :
@@ -128,7 +128,7 @@
// Promote nodes to node sets
if (tright instanceof NodeType) {
- _right = new CastExpr(_right, Type.NodeSet);
+ _right = new CastExpr(_right, Type.NodeSetDTM);
}
// Promote integer to doubles to have fewer compares
@@ -170,7 +170,7 @@
}
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
- if (hasNodeSetArgs() || hasReferenceArgs()) {
+ if (hasNodeSetDTMArgs() || hasReferenceArgs()) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
@@ -202,7 +202,7 @@
public void translateDesynthesized(ClassGenerator classGen,
MethodGenerator methodGen) {
- if (hasNodeSetArgs() || hasReferenceArgs()) {
+ if (hasNodeSetDTMArgs() || hasReferenceArgs()) {
translate(classGen, methodGen);
desynthesize(classGen, methodGen);
}
1.2 +4 -4 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Step.java 2001/04/17 18:51:47 1.1
+++ Step.java 2001/06/15 05:14:33 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Step.java,v 1.1 2001/04/17 18:51:47 sboag Exp $
+ * @(#)$Id: Step.java,v 1.2 2001/06/15 05:14:33 sboag Exp $
*
* The Apache Software License, Version 1.1
*
@@ -202,7 +202,7 @@
_type = Type.Node;
}
else if (isAbbreviatedDDot()) {
- _type = Type.NodeSet;
+ _type = Type.NodeSetDTM;
}
else {
// Special case for '@attr' with no parent or predicates
@@ -213,7 +213,7 @@
_type = Type.Node;
}
else {
- _type = Type.NodeSet;
+ _type = Type.NodeSetDTM;
}
}
if (_predicates != null) {
@@ -254,7 +254,7 @@
il.append(new INVOKEVIRTUAL(gattr));
// If it is the case '@attr[P_1]...[P_k]'
- if (_type instanceof NodeSetType) {
+ if (_type instanceof NodeSetDTMType) {
Type.Node.translateTo(classGen, methodGen, _type);
}
return;
1.2 +4 -4 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/UnionPathExpr.java
Index: UnionPathExpr.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/UnionPathExpr.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- UnionPathExpr.java 2001/04/17 18:51:50 1.1
+++ UnionPathExpr.java 2001/06/15 05:14:33 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: UnionPathExpr.java,v 1.1 2001/04/17 18:51:50 sboag Exp $
+ * @(#)$Id: UnionPathExpr.java,v 1.2 2001/06/15 05:14:33 sboag Exp $
*
* The Apache Software License, Version 1.1
*
@@ -98,11 +98,11 @@
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
final int length = _components.length;
for (int i = 0; i < length; i++) {
- if (_components[i].typeCheck(stable) != Type.NodeSet) {
- _components[i] = new CastExpr(_components[i], Type.NodeSet);
+ if (_components[i].typeCheck(stable) != Type.NodeSetDTM) {
+ _components[i] = new CastExpr(_components[i], Type.NodeSetDTM);
}
}
- return _type = Type.NodeSet;
+ return _type = Type.NodeSetDTM;
}
public String toString() {
1.2 +3 -3 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/NodeSetType.java
Index: NodeSetType.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/NodeSetType.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NodeSetType.java 2001/04/17 18:52:18 1.1
+++ NodeSetType.java 2001/06/15 05:14:47 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: NodeSetType.java,v 1.1 2001/04/17 18:52:18 sboag Exp $
+ * @(#)$Id: NodeSetType.java,v 1.2 2001/06/15 05:14:47 sboag Exp $
*
* The Apache Software License, Version 1.1
*
@@ -68,8 +68,8 @@
import org.apache.xalan.xsltc.compiler.Parser;
import org.apache.xalan.xsltc.compiler.FlowList;
-public final class NodeSetType extends Type {
- protected NodeSetType() {}
+public final class NodeSetDTMType extends Type {
+ protected NodeSetDTMType() {}
public String toString() {
return "node-set";
1.2 +4 -4 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/NodeType.java
Index: NodeType.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/NodeType.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NodeType.java 2001/04/17 18:52:18 1.1
+++ NodeType.java 2001/06/15 05:14:49 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: NodeType.java,v 1.1 2001/04/17 18:52:18 sboag Exp $
+ * @(#)$Id: NodeType.java,v 1.2 2001/06/15 05:14:49 sboag Exp $
*
* The Apache Software License, Version 1.1
*
@@ -122,8 +122,8 @@
else if (type == Type.Real) {
translateTo(classGen, methodGen, (RealType) type);
}
- else if (type == Type.NodeSet) {
- translateTo(classGen, methodGen, (NodeSetType) type);
+ else if (type == Type.NodeSetDTM) {
+ translateTo(classGen, methodGen, (NodeSetDTMType) type);
}
else if (type == Type.Reference) {
translateTo(classGen, methodGen, (ReferenceType) type);
@@ -210,7 +210,7 @@
* @see org.apache.xalan.xsltc.compiler.util.Type#translateTo
*/
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
- NodeSetType type) {
+ NodeSetDTMType type) {
ConstantPoolGen cpg = classGen.getConstantPool();
InstructionList il = methodGen.getInstructionList();
1.2 +5 -5 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ReferenceType.java
Index: ReferenceType.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ReferenceType.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ReferenceType.java 2001/04/17 18:52:20 1.1
+++ ReferenceType.java 2001/06/15 05:14:49 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: ReferenceType.java,v 1.1 2001/04/17 18:52:20 sboag Exp $
+ * @(#)$Id: ReferenceType.java,v 1.2 2001/06/15 05:14:49 sboag Exp $
*
* The Apache Software License, Version 1.1
*
@@ -105,8 +105,8 @@
else if (type == Type.Boolean) {
translateTo(classGen, methodGen, (BooleanType) type);
}
- else if (type == Type.NodeSet) {
- translateTo(classGen, methodGen, (NodeSetType) type);
+ else if (type == Type.NodeSetDTM) {
+ translateTo(classGen, methodGen, (NodeSetDTMType) type);
}
else {
classGen.getParser().internalError(); // undefined
@@ -178,10 +178,10 @@
* @see org.apache.xalan.xsltc.compiler.util.Type#translateTo
*/
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
- NodeSetType type) {
+ NodeSetDTMType type) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
- int index = cpg.addMethodref(BASIS_LIBRARY_CLASS, "referenceToNodeSet",
+ int index = cpg.addMethodref(BASIS_LIBRARY_CLASS, "referenceToNodeSetDTM",
"("
+ OBJECT_SIG
+ ")"
1.2 +6 -6 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ResultTreeType.java
Index: ResultTreeType.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ResultTreeType.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ResultTreeType.java 2001/04/17 18:52:20 1.1
+++ ResultTreeType.java 2001/06/15 05:14:50 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: ResultTreeType.java,v 1.1 2001/04/17 18:52:20 sboag Exp $
+ * @(#)$Id: ResultTreeType.java,v 1.2 2001/06/15 05:14:50 sboag Exp $
*
* The Apache Software License, Version 1.1
*
@@ -123,8 +123,8 @@
else if (type == Type.Real) {
translateTo(classGen, methodGen, (RealType)type);
}
- else if (type == Type.NodeSet) {
- translateTo(classGen, methodGen, (NodeSetType)type);
+ else if (type == Type.NodeSetDTM) {
+ translateTo(classGen, methodGen, (NodeSetDTMType)type);
}
else if (type == Type.Reference) {
translateTo(classGen, methodGen, (ReferenceType)type);
@@ -312,7 +312,7 @@
* @see org.apache.xalan.xsltc.compiler.util.Type#translateTo
*/
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
- NodeSetType type) {
+ NodeSetDTMType type) {
classGen.getParser().notYetImplemented("result-tree -> node-set conversion");
}
@@ -343,8 +343,8 @@
final String className = clazz.getName();
if (className.equals("org.w3c.dom.Node") ||
className.equals("org.w3c.dom.NodeList")) {
- translateTo(classGen, methodGen, Type.NodeSet);
- Type.NodeSet.translateTo(classGen, methodGen, clazz);
+ translateTo(classGen, methodGen, Type.NodeSetDTM);
+ Type.NodeSetDTM.translateTo(classGen, methodGen, clazz);
}
else {
classGen.getParser().internalError(); // undefined
1.2 +2 -2 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/Type.java
Index: Type.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/Type.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Type.java 2001/04/17 18:52:21 1.1
+++ Type.java 2001/06/15 05:14:51 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Type.java,v 1.1 2001/04/17 18:52:21 sboag Exp $
+ * @(#)$Id: Type.java,v 1.2 2001/06/15 05:14:51 sboag Exp $
*
* The Apache Software License, Version 1.1
*
@@ -74,7 +74,7 @@
public static final Type Int = new IntType();
public static final Type Real = new RealType();
public static final Type Boolean = new BooleanType();
- public static final Type NodeSet = new NodeSetType();
+ public static final Type NodeSetDTM = new NodeSetDTMType();
public static final Type String = new StringType();
public static final Type ResultTree = new ResultTreeType();
public static final Type Reference = new ReferenceType();
1.2 +2 -2 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- UnionIterator.java 2001/04/17 18:52:36 1.1
+++ UnionIterator.java 2001/06/15 05:14:57 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: UnionIterator.java,v 1.1 2001/04/17 18:52:36 sboag Exp $
+ * @(#)$Id: UnionIterator.java,v 1.2 2001/06/15 05:14:57 sboag Exp $
*
* The Apache Software License, Version 1.1
*
@@ -69,7 +69,7 @@
/**
* UnionIterator takes a set of NodeIterators and produces
- * a merged NodeSet in document order with duplicates removed
+ * a merged NodeSetDTM in document order with duplicates removed
* The individual iterators are supposed to generate nodes
* in document order
*/
1.4 +2 -2 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- BasisLibrary.java 2001/06/12 09:40:20 1.3
+++ BasisLibrary.java 2001/06/15 05:15:00 1.4
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: BasisLibrary.java,v 1.3 2001/06/12 09:40:20 morten Exp $
+ * @(#)$Id: BasisLibrary.java,v 1.4 2001/06/15 05:15:00 sboag Exp $
*
* The Apache Software License, Version 1.1
*
@@ -818,7 +818,7 @@
* Utility function: used to convert references to node-sets. If the
* obj is an instanceof Node then create a singleton iterator.
*/
- public static NodeIterator referenceToNodeSet(Object obj) {
+ public static NodeIterator referenceToNodeSetDTM(Object obj) {
try {
return (obj instanceof Node == false)
? (NodeIterator) obj
1.3 +2 -2 xml-xalan/java/src/org/apache/xml/dtm/DTMIterator.java
Index: DTMIterator.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/DTMIterator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DTMIterator.java 2001/06/12 19:15:40 1.2
+++ DTMIterator.java 2001/06/15 05:15:03 1.3
@@ -245,7 +245,7 @@
public int getCurrentNode();
/**
- * Tells if this NodeSet is "fresh", in other words, if
+ * Tells if this NodeSetDTM is "fresh", in other words, if
* the first nextNode() that is called will return the
* first node in the set.
*
@@ -285,7 +285,7 @@
public int getCurrentPos();
/**
- * If an index is requested, NodeSet will call this method
+ * If an index is requested, NodeSetDTM will call this method
* to run the iterator to the index. By default this sets
* m_next to the index. If the index argument is -1, this
* signals that the iterator should be run to the end and
1.4 +1 -1 xml-xalan/java/src/org/apache/xml/dtm/ref/DTMManagerDefault.java
Index: DTMManagerDefault.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMManagerDefault.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DTMManagerDefault.java 2001/06/13 00:58:07 1.3
+++ DTMManagerDefault.java 2001/06/15 05:15:06 1.4
@@ -449,7 +449,7 @@
// Current solution: Generate a new DOM2DTM with this node as root.
// %REVIEW% Maybe the best I can do??
DTM dtm = getDTM(new javax.xml.transform.dom.DOMSource(node), false,
- null, true, false);
+ null, true, true);
return dtm.getDocument();
}
1.3 +2 -2 xml-xalan/java/src/org/apache/xml/dtm/ref/DTMNodeIterator.java
Index: DTMNodeIterator.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMNodeIterator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DTMNodeIterator.java 2001/06/12 19:15:47 1.2
+++ DTMNodeIterator.java 2001/06/15 05:15:07 1.3
@@ -107,7 +107,7 @@
/** Access the wrapped DTMIterator. I'm not sure whether anyone will
* need this or not, but let's write it and think about it.
* */
- DTMIterator getDTMIterator()
+ public DTMIterator getDTMIterator()
{
return dtm_iter;
}
@@ -187,7 +187,7 @@
int handle=dtm_iter.nextNode();
if (handle==-1)
- return null;
+ return null;
return dtm_iter.getDTM(handle).getNode(handle);
}
1.3 +9 -2 xml-xalan/java/src/org/apache/xml/dtm/ref/DTMNodeList.java
Index: DTMNodeList.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMNodeList.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DTMNodeList.java 2001/06/12 19:15:47 1.2
+++ DTMNodeList.java 2001/06/15 05:15:08 1.3
@@ -104,8 +104,15 @@
* */
public DTMNodeList(DTMIterator dtmIterator)
{
- dtm_iter=dtmIterator;
+ int pos = dtmIterator.getCurrentPos();
+ try
+ {
+ dtm_iter=(DTMIterator)dtmIterator.cloneWithReset();
+ }
+ catch(CloneNotSupportedException cnse) {}
dtm_iter.setShouldCacheNodes(true);
+ dtm_iter.runTo(-1);
+ dtm_iter.setCurrentPos(pos);
}
/** Access the wrapped DTMIterator. I'm not sure whether anyone will
@@ -141,6 +148,6 @@
*/
public int getLength()
{
- return dtm_iter.getLength();
+ return dtm_iter.getLength();
}
}
1.3 +2 -2 xml-xalan/java/src/org/apache/xml/utils/StringBufferPool.java
Index: StringBufferPool.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/utils/StringBufferPool.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- StringBufferPool.java 2000/11/28 15:01:24 1.2
+++ StringBufferPool.java 2001/06/15 05:15:12 1.3
@@ -75,7 +75,7 @@
*
* @return A string buffer ready for use.
*/
- public static FastStringBuffer get()
+ public synchronized static FastStringBuffer get()
{
return (FastStringBuffer) m_stringBufPool.getInstance();
}
@@ -85,7 +85,7 @@
*
* @param sb Must be a non-null reference to a string buffer.
*/
- public static void free(FastStringBuffer sb)
+ public synchronized static void free(FastStringBuffer sb)
{
// Since this isn't synchronized, setLength must be
// done before the instance is freed.
1.16 +3 -3 xml-xalan/java/src/org/apache/xpath/DOM2Helper.java
Index: DOM2Helper.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/DOM2Helper.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- DOM2Helper.java 2001/06/12 19:16:05 1.15
+++ DOM2Helper.java 2001/06/15 05:15:15 1.16
@@ -268,7 +268,7 @@
* You can think of this as
* <code>(node1.documentOrderPosition <= node2.documentOrderPosition)</code>.
*/
- public boolean isNodeAfter(Node node1, Node node2)
+ public static boolean isNodeAfter(Node node1, Node node2)
{
// Assume first that the nodes are DTM nodes, since discovering node
@@ -285,7 +285,7 @@
// isNodeAfter will return true if node is after countedNode
// in document order. The base isNodeAfter is sloooow (relatively).
- return super.isNodeAfter(node1, node2);
+ return DOMHelper.isNodeAfter(node1, node2);
}
}
@@ -301,7 +301,7 @@
* ownerElement if the input node is an Attr, or null if the node is
* a Document, a DocumentFragment, or an orphan.
*/
- public Node getParentOfNode(Node node)
+ public static Node getParentOfNode(Node node)
{
Node parent=node.getParentNode();
if(parent==null && (Node.ATTRIBUTE_NODE == node.getNodeType()) )
1.28 +3 -3 xml-xalan/java/src/org/apache/xpath/DOMHelper.java
Index: DOMHelper.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/DOMHelper.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- DOMHelper.java 2001/06/12 19:16:06 1.27
+++ DOMHelper.java 2001/06/15 05:15:17 1.28
@@ -202,7 +202,7 @@
* You can think of this as
* <code>(node1.documentOrderPosition <= node2.documentOrderPosition)</code>.
*/
- public boolean isNodeAfter(Node node1, Node node2)
+ public static boolean isNodeAfter(Node node1, Node node2)
{
if (node1 == node2)
return true;
@@ -993,7 +993,7 @@
* via the DOM Level 2 factory methods, but is possible if other
* mechanisms were used to obtain it
*/
- public Node getParentOfNode(Node node) throws RuntimeException
+ public static Node getParentOfNode(Node node) throws RuntimeException
{
Node parent;
short nodeType = node.getNodeType();
@@ -1177,7 +1177,7 @@
* DOMs had some hope that Attrs might be sharable, but this idea has
* been abandoned.)
*/
- private Node locateAttrParent(Element elem, Node attr)
+ private static Node locateAttrParent(Element elem, Node attr)
{
Node parent = null;
1.12 +727 -523 xml-xalan/java/src/org/apache/xpath/NodeSet.java
Index: NodeSet.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/NodeSet.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- NodeSet.java 2001/06/12 19:16:07 1.11
+++ NodeSet.java 2001/06/15 05:15:18 1.12
@@ -56,17 +56,12 @@
*/
package org.apache.xpath;
-//import org.w3c.dom.Node;
-//import org.w3c.dom.NodeList;
-//import org.w3c.dom.NamedNodeMap;
-//import org.w3c.dom.traversal.NodeIterator;
-//import org.w3c.dom.traversal.NodeFilter;
-//import org.w3c.dom.DOMException;
-
-import org.apache.xml.dtm.DTM;
-import org.apache.xml.dtm.DTMFilter;
-import org.apache.xml.dtm.DTMIterator;
-import org.apache.xml.dtm.DTMManager;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.traversal.NodeIterator;
+import org.w3c.dom.traversal.NodeFilter;
+import org.w3c.dom.DOMException;
import org.apache.xml.utils.NodeVector;
import org.apache.xpath.axes.ContextNodeList;
@@ -95,9 +90,8 @@
* to the same calls; the disadvantage is that some of them may return
* less-than-enlightening results when you do so.</p>
*/
-public class NodeSet extends NodeVector
- implements /* NodeList, NodeIterator, */ DTMIterator,
- Cloneable
+public class NodeSet
+ implements NodeList, NodeIterator, Cloneable, ContextNodeList
{
/**
@@ -105,34 +99,34 @@
*/
public NodeSet()
{
- super();
+ m_blocksize = 32;
+ m_mapSize = 0;
}
/**
* Create an empty, using the given block size.
*
* @param blocksize Size of blocks to allocate
- * @param dummy pass zero for right now...
*/
- public NodeSet(int blocksize, int dummy)
+ public NodeSet(int blocksize)
{
- super(blocksize);
+ m_blocksize = blocksize;
+ m_mapSize = 0;
}
- // %TBD%
-// /**
-// * Create a NodeSet, and copy the members of the
-// * given nodelist into it.
-// *
-// * @param nodelist List of Nodes to be made members of the new set.
-// */
-// public NodeSet(NodeList nodelist)
-// {
-//
-// super();
-//
-// addNodes(nodelist);
-// }
+ /**
+ * Create a NodeSet, and copy the members of the
+ * given nodelist into it.
+ *
+ * @param nodelist List of Nodes to be made members of the new set.
+ */
+ public NodeSet(NodeList nodelist)
+ {
+
+ this(32);
+
+ addNodes(nodelist);
+ }
/**
* Create a NodeSet, and copy the members of the
@@ -143,21 +137,21 @@
public NodeSet(NodeSet nodelist)
{
- super();
+ this(32);
- addNodes((DTMIterator) nodelist);
+ addNodes((NodeIterator) nodelist);
}
/**
* Create a NodeSet, and copy the members of the
- * given DTMIterator into it.
+ * given NodeIterator into it.
*
* @param ni Iterator which yields Nodes to be made members of the new set.
*/
- public NodeSet(DTMIterator ni)
+ public NodeSet(NodeIterator ni)
{
- super();
+ this(32);
addNodes(ni);
}
@@ -167,73 +161,21 @@
*
* @param node Single node to be added to the new set.
*/
- public NodeSet(int node)
+ public NodeSet(Node node)
{
- super();
+ this(32);
addNode(node);
}
-
- /**
- * Set the environment in which this iterator operates, which should provide:
- * a node (the context node... same value as "root" defined below)
- * a pair of non-zero positive integers (the context position and the context size)
- * a set of variable bindings
- * a function library
- * the set of namespace declarations in scope for the expression.
- *
- * <p>At this time the exact implementation of this environment is application
- * dependent. Probably a proper interface will be created fairly soon.</p>
- *
- * @param environment The environment object.
- */
- public void setEnvironment(Object environment)
- {
- // no-op
- }
-
/**
* @return The root node of the Iterator, as specified when it was created.
* For non-Iterator NodeSets, this will be null.
- */
- public int getRoot()
- {
- // %TBD%?
- return DTM.NULL;
- }
-
- /**
- * Initialize the context values for this expression
- * after it is cloned.
- *
- * @param execContext The XPath runtime context for this
- * transformation.
- */
- public void setRoot(int context, Object environment)
- {
- // no-op, I guess... (-sb)
- }
-
- /**
- * Clone this NodeSet.
- * At this time, we only expect this to be used with LocPathIterators;
- * it may not work with other kinds of NodeSets.
- *
- * @return a new NodeSet of the same type, having the same state...
- * though unless overridden in the subclasses, it may not copy all
- * the state information.
- *
- * @throws CloneNotSupportedException if this subclass of NodeSet
- * does not support the clone() operation.
*/
- public Object clone() throws CloneNotSupportedException
+ public Node getRoot()
{
-
- NodeSet clone = (NodeSet) super.clone();
-
- return clone;
+ return null;
}
/**
@@ -246,7 +188,7 @@
* @throws CloneNotSupportedException if this subclass of NodeSet
* does not support the clone() operation.
*/
- public DTMIterator cloneWithReset() throws CloneNotSupportedException
+ public NodeIterator cloneWithReset() throws CloneNotSupportedException
{
NodeSet clone = (NodeSet) clone();
@@ -267,26 +209,26 @@
/**
* This attribute determines which node types are presented via the
* iterator. The available set of constants is defined in the
- * <code>DTMFilter</code> interface. For NodeSets, the mask has been
+ * <code>NodeFilter</code> interface. For NodeSets, the mask has been
* hardcoded to show all nodes except EntityReference nodes, which have
* no equivalent in the XPath data model.
*
* @return integer used as a bit-array, containing flags defined in
- * the DOM's DTMFilter class. The value will be
+ * the DOM's NodeFilter class. The value will be
* <code>SHOW_ALL & ~SHOW_ENTITY_REFERENCE</code>, meaning that
* only entity references are suppressed.
*/
public int getWhatToShow()
{
- return DTMFilter.SHOW_ALL & ~DTMFilter.SHOW_ENTITY_REFERENCE;
+ return NodeFilter.SHOW_ALL & ~NodeFilter.SHOW_ENTITY_REFERENCE;
}
/**
* The filter object used to screen nodes. Filters are applied to
- * further reduce (and restructure) the DTMIterator's view of the
+ * further reduce (and restructure) the NodeIterator's view of the
* document. In our case, we will be using hardcoded filters built
* into our iterators... but getFilter() is part of the DOM's
- * DTMIterator interface, so we have to support it.
+ * NodeIterator interface, so we have to support it.
*
* @return null, which is slightly misleading. True, there is no
* user-written filter object, but in fact we are doing some very
@@ -294,7 +236,7 @@
* returning a placeholder object just to indicate that this is
* not going to return all nodes selected by whatToShow.
*/
- public DTMFilter getFilter()
+ public NodeFilter getFilter()
{
return null;
}
@@ -319,38 +261,10 @@
{
return true;
}
-
- /**
- * Get an instance of a DTM that "owns" a node handle. Since a node
- * iterator may be passed without a DTMManager, this allows the
- * caller to easily get the DTM using just the iterator.
- *
- * @param nodeHandle the nodeHandle.
- *
- * @return a non-null DTM reference.
- */
- public DTM getDTM(int nodeHandle)
- {
- // %TBD%
- return null;
- }
-
- /**
- * Get an instance of the DTMManager. Since a node
- * iterator may be passed without a DTMManager, this allows the
- * caller to easily get the DTMManager using just the iterator.
- *
- * @return a non-null DTMManager reference.
- */
- public DTMManager getDTMManager()
- {
- // %TBD%
- return null;
- }
/**
* Returns the next node in the set and advances the position of the
- * iterator in the set. After a DTMIterator is created, the first call
+ * iterator in the set. After a NodeIterator is created, the first call
* to nextNode() returns the first node in the set.
* @return The next <code>Node</code> in the set being iterated over, or
* <code>null</code> if there are no more members in that set.
@@ -358,19 +272,19 @@
* INVALID_STATE_ERR: Raised if this method is called after the
* <code>detach</code> method was invoked.
*/
- public int nextNode()
+ public Node nextNode() throws DOMException
{
if ((m_next) < this.size())
{
- int next = this.elementAt(m_next);
+ Node next = this.elementAt(m_next);
m_next++;
return next;
}
else
- return DTM.NULL;
+ return null;
}
/**
@@ -384,7 +298,7 @@
* @throws RuntimeException thrown if this NodeSet is not of
* a cached type, and hence doesn't know what the previous node was.
*/
- public int previousNode()
+ public Node previousNode() throws DOMException
{
if (!m_cacheNodes)
@@ -398,7 +312,7 @@
return this.elementAt(m_next);
}
else
- return DTM.NULL;
+ return null;
}
/**
@@ -413,18 +327,6 @@
* </p>
*/
public void detach(){}
-
- /**
- * Specify if it's OK for detach to release the iterator for reuse.
- *
- * @param allowRelease true if it is OK for detach to release this iterator
- * for pooling.
- */
- public void allowDetachToRelease(boolean allowRelease)
- {
- // no action for right now.
- }
-
/**
* Tells if this NodeSet is "fresh", in other words, if
@@ -476,12 +378,12 @@
* <code>NodeList</code>, or <code>null</code> if that is not a valid
* index.
*/
- public int item(int index)
+ public Node item(int index)
{
runTo(index);
- return this.elementAt(index);
+ return (Node) this.elementAt(index);
}
/**
@@ -508,7 +410,7 @@
* @throws RuntimeException thrown if this NodeSet is not of
* a mutable type.
*/
- public void addNode(int n)
+ public void addNode(Node n)
{
if (!m_mutable)
@@ -526,7 +428,7 @@
* @throws RuntimeException thrown if this NodeSet is not of
* a mutable type.
*/
- public void insertNode(int n, int pos)
+ public void insertNode(Node n, int pos)
{
if (!m_mutable)
@@ -542,7 +444,7 @@
* @throws RuntimeException thrown if this NodeSet is not of
* a mutable type.
*/
- public void removeNode(int n)
+ public void removeNode(Node n)
{
if (!m_mutable)
@@ -550,76 +452,74 @@
this.removeElement(n);
}
+
+ /**
+ * Copy NodeList members into this nodelist, adding in
+ * document order. If a node is null, don't add it.
+ *
+ * @param nodelist List of nodes which should now be referenced by
+ * this NodeSet.
+ * @throws RuntimeException thrown if this NodeSet is not of
+ * a mutable type.
+ */
+ public void addNodes(NodeList nodelist)
+ {
+
+ if (!m_mutable)
+ throw new RuntimeException("This NodeSet is not mutable!");
+
+ if (null != nodelist) // defensive to fix a bug that Sanjiva reported.
+ {
+ int nChildren = nodelist.getLength();
+
+ for (int i = 0; i < nChildren; i++)
+ {
+ Node obj = nodelist.item(i);
+
+ if (null != obj)
+ {
+ addElement(obj);
+ }
+ }
+ }
+
+ // checkDups();
+ }
+
+ /**
+ * <p>Copy NodeList members into this nodelist, adding in
+ * document order. Only genuine node references will be copied;
+ * nulls appearing in the source NodeSet will
+ * not be added to this one. </p>
+ *
+ * <p> In case you're wondering why this function is needed: NodeSet
+ * implements both NodeIterator and NodeList. If this method isn't
+ * provided, Java can't decide which of those to use when addNodes()
+ * is invoked. Providing the more-explicit match avoids that
+ * ambiguity.)</p>
+ *
+ * @param ns NodeSet whose members should be merged into this NodeSet.
+ * @throws RuntimeException thrown if this NodeSet is not of
+ * a mutable type.
+ */
+ public void addNodes(NodeSet ns)
+ {
- // %TBD%
-// /**
-// * Copy NodeList members into this nodelist, adding in
-// * document order. If a node is null, don't add it.
-// *
-// * @param nodelist List of nodes which should now be referenced by
-// * this NodeSet.
-// * @throws RuntimeException thrown if this NodeSet is not of
-// * a mutable type.
-// */
-// public void addNodes(NodeList nodelist)
-// {
-//
-// if (!m_mutable)
-// throw new RuntimeException("This NodeSet is not mutable!");
-//
-// if (null != nodelist) // defensive to fix a bug that Sanjiva reported.
-// {
-// int nChildren = nodelist.getLength();
-//
-// for (int i = 0; i < nChildren; i++)
-// {
-// int obj = nodelist.item(i);
-//
-// if (null != obj)
-// {
-// addElement(obj);
-// }
-// }
-// }
-//
-// // checkDups();
-// }
-
- // %TBD%
-// /**
-// * <p>Copy NodeList members into this nodelist, adding in
-// * document order. Only genuine node references will be copied;
-// * nulls appearing in the source NodeSet will
-// * not be added to this one. </p>
-// *
-// * <p> In case you're wondering why this function is needed: NodeSet
-// * implements both DTMIterator and NodeList. If this method isn't
-// * provided, Java can't decide which of those to use when addNodes()
-// * is invoked. Providing the more-explicit match avoids that
-// * ambiguity.)</p>
-// *
-// * @param ns NodeSet whose members should be merged into this NodeSet.
-// * @throws RuntimeException thrown if this NodeSet is not of
-// * a mutable type.
-// */
-// public void addNodes(NodeSet ns)
-// {
-//
-// if (!m_mutable)
-// throw new RuntimeException("This NodeSet is not mutable!");
-//
-// addNodes((DTMIterator) ns);
-// }
+ if (!m_mutable)
+ throw new RuntimeException("This NodeSet is not mutable!");
+
+ addNodes((NodeIterator) ns);
+ }
/**
* Copy NodeList members into this nodelist, adding in
* document order. Null references are not added.
*
- * @param iterator DTMIterator which yields the nodes to be added.
+ * @param iterator NodeIterator which yields the nodes to be added.
* @throws RuntimeException thrown if this NodeSet is not of
* a mutable type.
*/
- public void addNodes(DTMIterator iterator)
+ public void addNodes(NodeIterator iterator)
{
if (!m_mutable)
@@ -627,9 +527,9 @@
if (null != iterator) // defensive to fix a bug that Sanjiva reported.
{
- int obj;
+ Node obj;
- while (DTM.NULL != (obj = iterator.nextNode()))
+ while (null != (obj = iterator.nextNode()))
{
addElement(obj);
}
@@ -638,123 +538,121 @@
// checkDups();
}
- // %TBD%
-// /**
-// * Copy NodeList members into this nodelist, adding in
-// * document order. If a node is null, don't add it.
-// *
-// * @param nodelist List of nodes to be added
-// * @param support The XPath runtime context.
-// * @throws RuntimeException thrown if this NodeSet is not of
-// * a mutable type.
-// */
-// public void addNodesInDocOrder(NodeList nodelist, XPathContext support)
-// {
-//
-// if (!m_mutable)
-// throw new RuntimeException("This NodeSet is not mutable!");
-//
-// int nChildren = nodelist.getLength();
-//
-// for (int i = 0; i < nChildren; i++)
-// {
-// int node = nodelist.item(i);
-//
-// if (null != node)
-// {
-// addNodeInDocOrder(node, support);
-// }
-// }
-// }
+ /**
+ * Copy NodeList members into this nodelist, adding in
+ * document order. If a node is null, don't add it.
+ *
+ * @param nodelist List of nodes to be added
+ * @param support The XPath runtime context.
+ * @throws RuntimeException thrown if this NodeSet is not of
+ * a mutable type.
+ */
+ public void addNodesInDocOrder(NodeList nodelist, XPathContext support)
+ {
+
+ if (!m_mutable)
+ throw new RuntimeException("This NodeSet is not mutable!");
+
+ int nChildren = nodelist.getLength();
+
+ for (int i = 0; i < nChildren; i++)
+ {
+ Node node = nodelist.item(i);
+
+ if (null != node)
+ {
+ addNodeInDocOrder(node, support);
+ }
+ }
+ }
/**
* Copy NodeList members into this nodelist, adding in
* document order. If a node is null, don't add it.
*
- * @param iterator DTMIterator which yields the nodes to be added.
+ * @param iterator NodeIterator which yields the nodes to be added.
* @param support The XPath runtime context.
* @throws RuntimeException thrown if this NodeSet is not of
* a mutable type.
*/
- public void addNodesInDocOrder(DTMIterator iterator, XPathContext support)
+ public void addNodesInDocOrder(NodeIterator iterator, XPathContext support)
{
if (!m_mutable)
throw new RuntimeException("This NodeSet is not mutable!");
- int node;
+ Node node;
- while (DTM.NULL != (node = iterator.nextNode()))
+ while (null != (node = iterator.nextNode()))
{
addNodeInDocOrder(node, support);
}
}
+
+ /**
+ * Add the node list to this node set in document order.
+ *
+ * @param start index.
+ * @param end index.
+ * @param testIndex index.
+ * @param nodelist The nodelist to add.
+ * @param support The XPath runtime context.
+ *
+ * @return false always.
+ * @throws RuntimeException thrown if this NodeSet is not of
+ * a mutable type.
+ */
+ private boolean addNodesInDocOrder(int start, int end, int testIndex,
+ NodeList nodelist, XPathContext support)
+ {
+
+ if (!m_mutable)
+ throw new RuntimeException("This NodeSet is not mutable!");
- // %TBD%
-// /**
-// * Add the node list to this node set in document order.
-// *
-// * @param start index.
-// * @param end index.
-// * @param testIndex index.
-// * @param nodelist The nodelist to add.
-// * @param support The XPath runtime context.
-// *
-// * @return false always.
-// * @throws RuntimeException thrown if this NodeSet is not of
-// * a mutable type.
-// */
-// private boolean addNodesInDocOrder(int start, int end, int testIndex,
-// NodeList nodelist, XPathContext support)
-// {
-//
-// if (!m_mutable)
-// throw new RuntimeException("This NodeSet is not mutable!");
-//
-// boolean foundit = false;
-// int i;
-// int node = nodelist.item(testIndex);
-//
-// for (i = end; i >= start; i--)
-// {
-// int child = elementAt(i);
-//
-// if (child == node)
-// {
-// i = -2; // Duplicate, suppress insert
-//
-// break;
-// }
-//
-// if (!support.getDOMHelper().isNodeAfter(node, child))
-// {
-// insertElementAt(node, i + 1);
-//
-// testIndex--;
-//
-// if (testIndex > 0)
-// {
-// boolean foundPrev = addNodesInDocOrder(0, i, testIndex, nodelist,
-// support);
-//
-// if (!foundPrev)
-// {
-// addNodesInDocOrder(i, size() - 1, testIndex, nodelist, support);
-// }
-// }
-//
-// break;
-// }
-// }
-//
-// if (i == -1)
-// {
-// insertElementAt(node, 0);
-// }
-//
-// return foundit;
-// }
+ boolean foundit = false;
+ int i;
+ Node node = nodelist.item(testIndex);
+ for (i = end; i >= start; i--)
+ {
+ Node child = (Node) elementAt(i);
+
+ if (child == node)
+ {
+ i = -2; // Duplicate, suppress insert
+
+ break;
+ }
+
+ if (!DOM2Helper.isNodeAfter(node, child))
+ {
+ insertElementAt(node, i + 1);
+
+ testIndex--;
+
+ if (testIndex > 0)
+ {
+ boolean foundPrev = addNodesInDocOrder(0, i, testIndex, nodelist,
+ support);
+
+ if (!foundPrev)
+ {
+ addNodesInDocOrder(i, size() - 1, testIndex, nodelist, support);
+ }
+ }
+
+ break;
+ }
+ }
+
+ if (i == -1)
+ {
+ insertElementAt(node, 0);
+ }
+
+ return foundit;
+ }
+
/**
* Add the node into a vector of nodes where it should occur in
* document order.
@@ -768,7 +666,7 @@
* @throws RuntimeException thrown if this NodeSet is not of
* a mutable type.
*/
- public int addNodeInDocOrder(int node, boolean test, XPathContext support)
+ public int addNodeInDocOrder(Node node, boolean test, XPathContext support)
{
if (!m_mutable)
@@ -786,7 +684,7 @@
for (i = size - 1; i >= 0; i--)
{
- int child = elementAt(i);
+ Node child = (Node) elementAt(i);
if (child == node)
{
@@ -795,8 +693,7 @@
break;
}
- DTM dtm = support.getDTM(node);
- if (!dtm.isNodeAfter(node, child))
+ if (!DOM2Helper.isNodeAfter(node, child))
{
break;
}
@@ -817,7 +714,7 @@
for (int i = 0; i < insertIndex; i++)
{
- if (i == node)
+ if (this.item(i).equals(node))
{
foundit = true;
@@ -846,7 +743,7 @@
* @throws RuntimeException thrown if this NodeSet is not of
* a mutable type.
*/
- public int addNodeInDocOrder(int node, XPathContext support)
+ public int addNodeInDocOrder(Node node, XPathContext support)
{
if (!m_mutable)
@@ -855,347 +752,654 @@
return addNodeInDocOrder(node, true, support);
} // end addNodeInDocOrder(Vector v, Object obj)
- /**
- * Get the length of the list.
- *
- * @return The size of this node set.
- */
- public int size()
- {
- return super.size();
- }
+
+ /** If this node is being used as an iterator, the next index that nextNode()
+ * will return. */
+ transient protected int m_next = 0;
/**
- * Append a Node onto the vector.
+ * Get the current position, which is one less than
+ * the next nextNode() call will retrieve. i.e. if
+ * you call getCurrentPos() and the return is 0, the next
+ * fetch will take place at index 1.
*
- * @param value The node to be added.
- * @throws RuntimeException thrown if this NodeSet is not of
- * a mutable type.
+ * @return The the current position index.
*/
- public void addElement(int value)
+ public int getCurrentPos()
{
-
- if (!m_mutable)
- throw new RuntimeException("This NodeSet is not mutable!");
-
- super.addElement(value);
+ return m_next;
}
/**
- * Inserts the specified node in this vector at the specified index.
- * Each component in this vector with an index greater or equal to
- * the specified index is shifted upward to have an index one greater
- * than the value it had previously.
- *
- * @param value The node to be inserted.
- * @param at The index where the insert should occur.
+ * Set the current position in the node set.
+ * @param i Must be a valid index.
* @throws RuntimeException thrown if this NodeSet is not of
- * a mutable type.
+ * a cached type, and thus doesn't permit indexed access.
*/
- public void insertElementAt(int value, int at)
+ public void setCurrentPos(int i)
{
- if (!m_mutable)
- throw new RuntimeException("This NodeSet is not mutable!");
+ if (!m_cacheNodes)
+ throw new RuntimeException(
+ "This NodeSet can not do indexing or counting functions!");
- super.insertElementAt(value, at);
+ m_next = i;
}
/**
- * Append the nodes to the list.
+ * Return the last fetched node. Needed to support the UnionPathIterator.
*
- * @param nodes The nodes to be appended to this node set.
+ * @return the last fetched node.
* @throws RuntimeException thrown if this NodeSet is not of
- * a mutable type.
+ * a cached type, and thus doesn't permit indexed access.
*/
- public void appendNodes(NodeVector nodes)
+ public Node getCurrentNode()
{
- if (!m_mutable)
- throw new RuntimeException("This NodeSet is not mutable!");
+ if (!m_cacheNodes)
+ throw new RuntimeException(
+ "This NodeSet can not do indexing or counting functions!");
- super.appendNodes(nodes);
+ int saved = m_next;
+ Node n = elementAt(m_next-1);
+ m_next = saved; // HACK: I think this is a bit of a hack. -sb
+ return n;
}
-
- /**
- * Inserts the specified node in this vector at the specified index.
- * Each component in this vector with an index greater or equal to
- * the specified index is shifted upward to have an index one greater
- * than the value it had previously.
- * @throws RuntimeException thrown if this NodeSet is not of
- * a mutable type.
- */
- public void removeAllElements()
- {
- if (!m_mutable)
- throw new RuntimeException("This NodeSet is not mutable!");
+ /** True if this list can be mutated. */
+ transient protected boolean m_mutable = true;
- super.removeAllElements();
- }
+ /** True if this list is cached.
+ * @serial */
+ transient protected boolean m_cacheNodes = true;
/**
- * Removes the first occurrence of the argument from this vector.
- * If the object is found in this vector, each component in the vector
- * with an index greater or equal to the object's index is shifted
- * downward to have an index one smaller than the value it had
- * previously.
+ * Get whether or not this is a cached node set.
*
- * @param s The node to be removed.
*
- * @return True if the node was successfully removed
- * @throws RuntimeException thrown if this NodeSet is not of
- * a mutable type.
+ * @return True if this list is cached.
*/
- public boolean removeElement(int s)
+ public boolean getShouldCacheNodes()
{
-
- if (!m_mutable)
- throw new RuntimeException("This NodeSet is not mutable!");
-
- return super.removeElement(s);
+ return m_cacheNodes;
}
/**
- * Deletes the component at the specified index. Each component in
- * this vector with an index greater or equal to the specified
- * index is shifted downward to have an index one smaller than
- * the value it had previously.
+ * If setShouldCacheNodes(true) is called, then nodes will
+ * be cached. They are not cached by default. This switch must
+ * be set before the first call to nextNode is made, to ensure
+ * that all nodes are cached.
*
- * @param i The index of the node to be removed.
- * @throws RuntimeException thrown if this NodeSet is not of
- * a mutable type.
- */
- public void removeElementAt(int i)
+ * @param b true if this node set should be cached.
+ * @throws RuntimeException thrown if an attempt is made to
+ * request caching after we've already begun stepping through the
+ * nodes in this set.
+ */
+ public void setShouldCacheNodes(boolean b)
{
- if (!m_mutable)
- throw new RuntimeException("This NodeSet is not mutable!");
+ if (!isFresh())
+ throw new RuntimeException(
+ "Can not call setShouldCacheNodes after nextNode has been called!");
- super.removeElementAt(i);
+ m_cacheNodes = b;
+ m_mutable = true;
}
+
+
+ transient private int m_last = 0;
+
+ public int getLast()
+ {
+ return m_last;
+ }
+
+ public void setLast(int last)
+ {
+ m_last = last;
+ }
+
+ /** Size of blocks to allocate.
+ * @serial */
+ private int m_blocksize;
+
+ /** Array of nodes this points to.
+ * @serial */
+ Node m_map[];
+
+ /** Number of nodes in this NodeVector.
+ * @serial */
+ protected int m_firstFree = 0;
+ /** Size of the array this points to.
+ * @serial */
+ private int m_mapSize; // lazy initialization
+
/**
- * Sets the component at the specified index of this vector to be the
- * specified object. The previous component at that position is discarded.
+ * Get a cloned LocPathIterator.
*
- * The index must be a value greater than or equal to 0 and less
- * than the current size of the vector.
+ * @return A clone of this
*
- * @param node The node to be set.
- * @param index The index of the node to be replaced.
- * @throws RuntimeException thrown if this NodeSet is not of
- * a mutable type.
+ * @throws CloneNotSupportedException
*/
- public void setElementAt(int node, int index)
+ public Object clone() throws CloneNotSupportedException
{
- if (!m_mutable)
- throw new RuntimeException("This NodeSet is not mutable!");
+ NodeSet clone = (NodeSet) super.clone();
- super.setElementAt(node, index);
+ if ((null != this.m_map) && (this.m_map == clone.m_map))
+ {
+ clone.m_map = new Node[this.m_map.length];
+
+ System.arraycopy(this.m_map, 0, clone.m_map, 0, this.m_map.length);
+ }
+
+ return clone;
}
-
+
/**
- * Same as setElementAt.
+ * Get the length of the list.
*
- * @param node The node to be set.
- * @param index The index of the node to be replaced.
- * @throws RuntimeException thrown if this NodeSet is not of
- * a mutable type.
+ * @return Number of nodes in this NodeVector
*/
- public void setItem(int node, int index)
+ public int size()
{
+ return m_firstFree;
+ }
+ /**
+ * Append a Node onto the vector.
+ *
+ * @param value Node to add to the vector
+ */
+ public void addElement(Node value)
+ {
if (!m_mutable)
throw new RuntimeException("This NodeSet is not mutable!");
+
+ if ((m_firstFree + 1) >= m_mapSize)
+ {
+ if (null == m_map)
+ {
+ m_map = new Node[m_blocksize];
+ m_mapSize = m_blocksize;
+ }
+ else
+ {
+ m_mapSize += m_blocksize;
+
+ Node newMap[] = new Node[m_mapSize];
- super.setElementAt(node, index);
+ System.arraycopy(m_map, 0, newMap, 0, m_firstFree + 1);
+
+ m_map = newMap;
+ }
+ }
+
+ m_map[m_firstFree] = value;
+
+ m_firstFree++;
}
/**
- * Get the nth element.
- *
- * @param i The index of the requested node.
+ * Append a Node onto the vector.
*
- * @return Node at specified index.
+ * @param value Node to add to the vector
*/
- public int elementAt(int i)
+ public final void push(Node value)
{
- runTo(i);
+ int ff = m_firstFree;
- return super.elementAt(i);
+ if ((ff + 1) >= m_mapSize)
+ {
+ if (null == m_map)
+ {
+ m_map = new Node[m_blocksize];
+ m_mapSize = m_blocksize;
+ }
+ else
+ {
+ m_mapSize += m_blocksize;
+
+ Node newMap[] = new Node[m_mapSize];
+
+ System.arraycopy(m_map, 0, newMap, 0, ff + 1);
+
+ m_map = newMap;
+ }
+ }
+
+ m_map[ff] = value;
+
+ ff++;
+
+ m_firstFree = ff;
}
-
+
/**
- * Tell if the table contains the given node.
+ * Pop a node from the tail of the vector and return the result.
*
- * @param s Node to look for
+ * @return the node at the tail of the vector
+ */
+ public final Node pop()
+ {
+
+ m_firstFree--;
+
+ Node n = m_map[m_firstFree];
+
+ m_map[m_firstFree] = null;
+
+ return n;
+ }
+
+ /**
+ * Pop a node from the tail of the vector and return the
+ * top of the stack after the pop.
*
- * @return True if the given node was found.
+ * @return The top of the stack after it's been popped
*/
- public boolean contains(int s)
+ public final Node popAndTop()
{
- runTo(-1);
+ m_firstFree--;
- return super.contains(s);
+ m_map[m_firstFree] = null;
+
+ return (m_firstFree == 0) ? null : m_map[m_firstFree - 1];
}
/**
- * Searches for the first occurence of the given argument,
- * beginning the search at index, and testing for equality
- * using the equals method.
+ * Pop a node from the tail of the vector.
+ */
+ public final void popQuick()
+ {
+
+ m_firstFree--;
+
+ m_map[m_firstFree] = null;
+ }
+
+ /**
+ * Return the node at the top of the stack without popping the stack.
+ * Special purpose method for TransformerImpl, pushElemTemplateElement.
+ * Performance critical.
*
- * @param elem Node to look for
- * @param index Index of where to start the search
- * @return the index of the first occurrence of the object
- * argument in this vector at position index or later in the
- * vector; returns -1 if the object is not found.
+ * @return Node at the top of the stack or null if stack is empty.
*/
- public int indexOf(int elem, int index)
+ public final Node peepOrNull()
{
+ return ((null != m_map) && (m_firstFree > 0))
+ ? m_map[m_firstFree - 1] : null;
+ }
- runTo(-1);
+ /**
+ * Push a pair of nodes into the stack.
+ * Special purpose method for TransformerImpl, pushElemTemplateElement.
+ * Performance critical.
+ *
+ * @param v1 First node to add to vector
+ * @param v2 Second node to add to vector
+ */
+ public final void pushPair(Node v1, Node v2)
+ {
+
+ if (null == m_map)
+ {
+ m_map = new Node[m_blocksize];
+ m_mapSize = m_blocksize;
+ }
+ else
+ {
+ if ((m_firstFree + 2) >= m_mapSize)
+ {
+ m_mapSize += m_blocksize;
+
+ Node newMap[] = new Node[m_mapSize];
+
+ System.arraycopy(m_map, 0, newMap, 0, m_firstFree);
+
+ m_map = newMap;
+ }
+ }
- return super.indexOf(elem, index);
+ m_map[m_firstFree] = v1;
+ m_map[m_firstFree + 1] = v2;
+ m_firstFree += 2;
}
/**
- * Searches for the first occurence of the given argument,
- * beginning the search at index, and testing for equality
- * using the equals method.
+ * Pop a pair of nodes from the tail of the stack.
+ * Special purpose method for TransformerImpl, pushElemTemplateElement.
+ * Performance critical.
+ */
+ public final void popPair()
+ {
+
+ m_firstFree -= 2;
+ m_map[m_firstFree] = null;
+ m_map[m_firstFree + 1] = null;
+ }
+
+ /**
+ * Set the tail of the stack to the given node.
+ * Special purpose method for TransformerImpl, pushElemTemplateElement.
+ * Performance critical.
*
- * @param elem Node to look for
- * @return the index of the first occurrence of the object
- * argument in this vector at position index or later in the
- * vector; returns -1 if the object is not found.
+ * @param n Node to set at the tail of vector
*/
- public int indexOf(int elem)
+ public final void setTail(Node n)
{
+ m_map[m_firstFree - 1] = n;
+ }
- runTo(-1);
+ /**
+ * Set the given node one position from the tail.
+ * Special purpose method for TransformerImpl, pushElemTemplateElement.
+ * Performance critical.
+ *
+ * @param n Node to set
+ */
+ public final void setTailSub1(Node n)
+ {
+ m_map[m_firstFree - 2] = n;
+ }
- return super.indexOf(elem);
+ /**
+ * Return the node at the tail of the vector without popping
+ * Special purpose method for TransformerImpl, pushElemTemplateElement.
+ * Performance critical.
+ *
+ * @return Node at the tail of the vector
+ */
+ public final Node peepTail()
+ {
+ return m_map[m_firstFree - 1];
}
- /** If this node is being used as an iterator, the next index that nextNode()
- * will return. */
- transient protected int m_next = 0;
+ /**
+ * Return the node one position from the tail without popping.
+ * Special purpose method for TransformerImpl, pushElemTemplateElement.
+ * Performance critical.
+ *
+ * @return Node one away from the tail
+ */
+ public final Node peepTailSub1()
+ {
+ return m_map[m_firstFree - 2];
+ }
/**
- * Get the current position, which is one less than
- * the next nextNode() call will retrieve. i.e. if
- * you call getCurrentPos() and the return is 0, the next
- * fetch will take place at index 1.
+ * Inserts the specified node in this vector at the specified index.
+ * Each component in this vector with an index greater or equal to
+ * the specified index is shifted upward to have an index one greater
+ * than the value it had previously.
*
- * @return The the current position index.
+ * @param value Node to insert
+ * @param at Position where to insert
*/
- public int getCurrentPos()
+ public void insertElementAt(Node value, int at)
{
- return m_next;
+ if (!m_mutable)
+ throw new RuntimeException("This NodeSet is not mutable!");
+
+ if (null == m_map)
+ {
+ m_map = new Node[m_blocksize];
+ m_mapSize = m_blocksize;
+ }
+ else if ((m_firstFree + 1) >= m_mapSize)
+ {
+ m_mapSize += m_blocksize;
+
+ Node newMap[] = new Node[m_mapSize];
+
+ System.arraycopy(m_map, 0, newMap, 0, m_firstFree + 1);
+
+ m_map = newMap;
+ }
+
+ if (at <= (m_firstFree - 1))
+ {
+ System.arraycopy(m_map, at, m_map, at + 1, m_firstFree - at);
+ }
+
+ m_map[at] = value;
+
+ m_firstFree++;
}
/**
- * Set the current position in the node set.
- * @param i Must be a valid index.
- * @throws RuntimeException thrown if this NodeSet is not of
- * a cached type, and thus doesn't permit indexed access.
+ * Append the nodes to the list.
+ *
+ * @param nodes NodeVector to append to this list
*/
- public void setCurrentPos(int i)
+ public void appendNodes(NodeSet nodes)
{
- if (!m_cacheNodes)
- throw new RuntimeException(
- "This NodeSet can not do indexing or counting functions!");
+ int nNodes = nodes.size();
- m_next = i;
+ if (null == m_map)
+ {
+ m_mapSize = nNodes + m_blocksize;
+ m_map = new Node[m_mapSize];
+ }
+ else if ((m_firstFree + nNodes) >= m_mapSize)
+ {
+ m_mapSize += (nNodes + m_blocksize);
+
+ Node newMap[] = new Node[m_mapSize];
+
+ System.arraycopy(m_map, 0, newMap, 0, m_firstFree + nNodes);
+
+ m_map = newMap;
+ }
+
+ System.arraycopy(nodes.m_map, 0, m_map, m_firstFree, nNodes);
+
+ m_firstFree += nNodes;
}
/**
- * Return the last fetched node. Needed to support the UnionPathIterator.
+ * Inserts the specified node in this vector at the specified index.
+ * Each component in this vector with an index greater or equal to
+ * the specified index is shifted upward to have an index one greater
+ * than the value it had previously.
+ */
+ public void removeAllElements()
+ {
+
+ if (null == m_map)
+ return;
+
+ for (int i = 0; i < m_firstFree; i++)
+ {
+ m_map[i] = null;
+ }
+
+ m_firstFree = 0;
+ }
+
+ /**
+ * Removes the first occurrence of the argument from this vector.
+ * If the object is found in this vector, each component in the vector
+ * with an index greater or equal to the object's index is shifted
+ * downward to have an index one smaller than the value it had
+ * previously.
*
- * @return the last fetched node.
- * @throws RuntimeException thrown if this NodeSet is not of
- * a cached type, and thus doesn't permit indexed access.
+ * @param s Node to remove from the list
+ *
+ * @return True if the node was successfully removed
*/
- public int getCurrentNode()
+ public boolean removeElement(Node s)
{
+ if (!m_mutable)
+ throw new RuntimeException("This NodeSet is not mutable!");
- if (!m_cacheNodes)
- throw new RuntimeException(
- "This NodeSet can not do indexing or counting functions!");
+ if (null == m_map)
+ return false;
- int saved = m_next;
- int n = elementAt(m_next-1);
- m_next = saved; // HACK: I think this is a bit of a hack. -sb
- return n;
+ for (int i = 0; i < m_firstFree; i++)
+ {
+ Node node = m_map[i];
+
+ if ((null != node) && node.equals(s))
+ {
+ if (i > m_firstFree)
+ System.arraycopy(m_map, i + 1, m_map, i - 1, m_firstFree - i);
+ else
+ m_map[i] = null;
+
+ m_firstFree--;
+
+ return true;
+ }
+ }
+
+ return false;
}
- /** True if this list can be mutated. */
- transient protected boolean m_mutable = true;
+ /**
+ * Deletes the component at the specified index. Each component in
+ * this vector with an index greater or equal to the specified
+ * index is shifted downward to have an index one smaller than
+ * the value it had previously.
+ *
+ * @param i Index of node to remove
+ */
+ public void removeElementAt(int i)
+ {
- /** True if this list is cached.
- * @serial */
- transient protected boolean m_cacheNodes = true;
+ if (null == m_map)
+ return;
+
+ if (i > m_firstFree)
+ System.arraycopy(m_map, i + 1, m_map, i - 1, m_firstFree - i);
+ else
+ m_map[i] = null;
+ }
/**
- * Get whether or not this is a cached node set.
+ * Sets the component at the specified index of this vector to be the
+ * specified object. The previous component at that position is discarded.
*
+ * The index must be a value greater than or equal to 0 and less
+ * than the current size of the vector.
*
- * @return True if this list is cached.
+ * @param node Node to set
+ * @param index Index of where to set the node
*/
- public boolean getShouldCacheNodes()
+ public void setElementAt(Node node, int index)
{
- return m_cacheNodes;
+ if (!m_mutable)
+ throw new RuntimeException("This NodeSet is not mutable!");
+
+ if (null == m_map)
+ {
+ m_map = new Node[m_blocksize];
+ m_mapSize = m_blocksize;
+ }
+
+ m_map[index] = node;
}
/**
- * If setShouldCacheNodes(true) is called, then nodes will
- * be cached. They are not cached by default. This switch must
- * be set before the first call to nextNode is made, to ensure
- * that all nodes are cached.
+ * Get the nth element.
*
- * @param b true if this node set should be cached.
- * @throws RuntimeException thrown if an attempt is made to
- * request caching after we've already begun stepping through the
- * nodes in this set.
- */
- public void setShouldCacheNodes(boolean b)
+ * @param i Index of node to get
+ *
+ * @return Node at specified index
+ */
+ public Node elementAt(int i)
{
- if (!isFresh())
- throw new RuntimeException(
- "Can not call setShouldCacheNodes after nextNode has been called!");
+ if (null == m_map)
+ return null;
- m_cacheNodes = b;
- m_mutable = true;
+ return m_map[i];
}
-
+
/**
- * Tells if this iterator can have nodes added to it or set via
- * the <code>setItem(int node, int index)</code> method.
- *
- * @return True if the nodelist can be mutated.
+ * Tell if the table contains the given node.
+ *
+ * @param s Node to look for
+ *
+ * @return True if the given node was found.
*/
- public boolean isMutable()
+ public boolean contains(Node s)
{
- return m_mutable;
+ runTo(-1);
+
+ if (null == m_map)
+ return false;
+
+ for (int i = 0; i < m_firstFree; i++)
+ {
+ Node node = m_map[i];
+
+ if ((null != node) && node.equals(s))
+ return true;
+ }
+
+ return false;
}
-
- transient private int m_last = 0;
-
- public int getLast()
+
+ /**
+ * Searches for the first occurence of the given argument,
+ * beginning the search at index, and testing for equality
+ * using the equals method.
+ *
+ * @param elem Node to look for
+ * @param index Index of where to start the search
+ * @return the index of the first occurrence of the object
+ * argument in this vector at position index or later in the
+ * vector; returns -1 if the object is not found.
+ */
+ public int indexOf(Node elem, int index)
{
- return m_last;
+ runTo(-1);
+
+ if (null == m_map)
+ return -1;
+
+ for (int i = index; i < m_firstFree; i++)
+ {
+ Node node = m_map[i];
+
+ if ((null != node) && node.equals(elem))
+ return i;
+ }
+
+ return -1;
}
-
- public void setLast(int last)
+
+ /**
+ * Searches for the first occurence of the given argument,
+ * beginning the search at index, and testing for equality
+ * using the equals method.
+ *
+ * @param elem Node to look for
+ * @return the index of the first occurrence of the object
+ * argument in this vector at position index or later in the
+ * vector; returns -1 if the object is not found.
+ */
+ public int indexOf(Node elem)
{
- m_last = last;
+ runTo(-1);
+
+ if (null == m_map)
+ return -1;
+
+ for (int i = 0; i < m_firstFree; i++)
+ {
+ Node node = m_map[i];
+
+ if ((null != node) && node.equals(elem))
+ return i;
+ }
+
+ return -1;
}
-
-
}
1.11 +2 -2 xml-xalan/java/src/org/apache/xpath/XPathAPI.java
Index: XPathAPI.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/XPathAPI.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- XPathAPI.java 2001/06/12 19:16:08 1.10
+++ XPathAPI.java 2001/06/15 05:15:19 1.11
@@ -122,7 +122,7 @@
throws TransformerException
{
- // Have the XObject return its result as a NodeSet.
+ // Have the XObject return its result as a NodeSetDTM.
NodeIterator nl = selectNodeIterator(contextNode, str, namespaceNode);
// Return the first node, or null
@@ -164,7 +164,7 @@
// Execute the XPath, and have it return the result
XObject list = eval(contextNode, str, namespaceNode);
- // Have the XObject return its result as a NodeSet.
+ // Have the XObject return its result as a NodeSetDTM.
// %TBD% Convert to DOM nodeset
return new DTMNodeIterator(list.nodeset());
1.24 +13 -4 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.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- XPathContext.java 2001/06/13 01:07:19 1.23
+++ XPathContext.java 2001/06/15 05:15:20 1.24
@@ -135,7 +135,7 @@
*/
public DTMManager getDTMManager()
{
- return this;
+ return m_dtmManager;
}
/**
@@ -1037,8 +1037,18 @@
return expressionContext;
}
- class XPathExpressionContext implements ExpressionContext
+ public class XPathExpressionContext implements ExpressionContext
{
+ /**
+ * Return the DTMManager object. Though XPathContext context extends
+ * the DTMManager, it really is a proxy for the real DTMManager. If a
+ * caller needs to make a lot of calls to the DTMManager, it is faster
+ * if it gets the real one from this function.
+ */
+ public DTMManager getDTMManager()
+ {
+ return m_dtmManager;
+ }
/**
* Get the current context node.
@@ -1058,8 +1068,7 @@
*/
public org.w3c.dom.traversal.NodeIterator getContextNodes()
{
- // %TBD%
- return null;
+ return new org.apache.xml.dtm.ref.DTMNodeIterator(getContextNodeList());
}
/**
1.1 xml-xalan/java/src/org/apache/xpath/NodeSetDTM.java
Index: NodeSetDTM.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.xpath;
import org.w3c.dom.Node;
//import org.w3c.dom.NodeList;
//import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.traversal.NodeIterator;
//import org.w3c.dom.traversal.NodeFilter;
//import org.w3c.dom.DOMException;
import org.apache.xml.dtm.DTM;
import org.apache.xml.dtm.DTMFilter;
import org.apache.xml.dtm.DTMIterator;
import org.apache.xml.dtm.DTMManager;
import org.apache.xml.utils.NodeVector;
import org.apache.xpath.axes.ContextNodeList;
/**
* <meta name="usage" content="advanced"/>
* <p>The NodeSetDTM class can act as either a NodeVector,
* NodeList, or NodeIterator. However, in order for it to
* act as a NodeVector or NodeList, it's required that
* setShouldCacheNodes(true) be called before the first
* nextNode() is called, in order that nodes can be added
* as they are fetched. Derived classes that implement iterators
* must override runTo(int index), in order that they may
* run the iteration to the given index. </p>
*
* <p>Note that we directly implement the DOM's NodeIterator
* interface. We do not emulate all the behavior of the
* standard NodeIterator. In particular, we do not guarantee
* to present a "live view" of the document ... but in XSLT,
* the source document should never be mutated, so this should
* never be an issue.</p>
*
* <p>Thought: Should NodeSetDTM really implement NodeList and NodeIterator,
* or should there be specific subclasses of it which do so? The
* advantage of doing it all here is that all NodeSetDTMs will respond
* to the same calls; the disadvantage is that some of them may return
* less-than-enlightening results when you do so.</p>
*/
public class NodeSetDTM extends NodeVector
implements /* NodeList, NodeIterator, */ DTMIterator,
Cloneable
{
/**
* Create an empty nodelist.
*/
public NodeSetDTM()
{
super();
}
/**
* Create an empty, using the given block size.
*
* @param blocksize Size of blocks to allocate
* @param dummy pass zero for right now...
*/
public NodeSetDTM(int blocksize, int dummy)
{
super(blocksize);
}
// %TBD%
// /**
// * Create a NodeSetDTM, and copy the members of the
// * given nodelist into it.
// *
// * @param nodelist List of Nodes to be made members of the new set.
// */
// public NodeSetDTM(NodeList nodelist)
// {
//
// super();
//
// addNodes(nodelist);
// }
/**
* Create a NodeSetDTM, and copy the members of the
* given NodeSetDTM into it.
*
* @param nodelist Set of Nodes to be made members of the new set.
*/
public NodeSetDTM(NodeSetDTM nodelist)
{
super();
addNodes((DTMIterator) nodelist);
}
/**
* Create a NodeSetDTM, and copy the members of the
* given DTMIterator into it.
*
* @param ni Iterator which yields Nodes to be made members of the new set.
*/
public NodeSetDTM(DTMIterator ni)
{
super();
addNodes(ni);
}
/**
* Create a NodeSetDTM, and copy the members of the
* given DTMIterator into it.
*
* @param ni Iterator which yields Nodes to be made members of the new set.
*/
public NodeSetDTM(NodeIterator iterator, XPathContext xctxt)
{
super();
Node node;
while (null != (node = iterator.nextNode()))
{
int handle = xctxt.getDTMHandleFromNode(node);
addNodeInDocOrder(handle, xctxt);
}
}
/**
* Create a NodeSetDTM which contains the given Node.
*
* @param node Single node to be added to the new set.
*/
public NodeSetDTM(int node)
{
super();
addNode(node);
}
/**
* Set the environment in which this iterator operates, which should provide:
* a node (the context node... same value as "root" defined below)
* a pair of non-zero positive integers (the context position and the context size)
* a set of variable bindings
* a function library
* the set of namespace declarations in scope for the expression.
*
* <p>At this time the exact implementation of this environment is application
* dependent. Probably a proper interface will be created fairly soon.</p>
*
* @param environment The environment object.
*/
public void setEnvironment(Object environment)
{
// no-op
}
/**
* @return The root node of the Iterator, as specified when it was created.
* For non-Iterator NodeSetDTMs, this will be null.
*/
public int getRoot()
{
// %TBD%?
return DTM.NULL;
}
/**
* Initialize the context values for this expression
* after it is cloned.
*
* @param execContext The XPath runtime context for this
* transformation.
*/
public void setRoot(int context, Object environment)
{
// no-op, I guess... (-sb)
}
/**
* Clone this NodeSetDTM.
* At this time, we only expect this to be used with LocPathIterators;
* it may not work with other kinds of NodeSetDTMs.
*
* @return a new NodeSetDTM of the same type, having the same state...
* though unless overridden in the subclasses, it may not copy all
* the state information.
*
* @throws CloneNotSupportedException if this subclass of NodeSetDTM
* does not support the clone() operation.
*/
public Object clone() throws CloneNotSupportedException
{
NodeSetDTM clone = (NodeSetDTM) super.clone();
return clone;
}
/**
* Get a cloned Iterator, and reset its state to the beginning of the
* iteration.
*
* @return a new NodeSetDTM of the same type, having the same state...
* except that the reset() operation has been called.
*
* @throws CloneNotSupportedException if this subclass of NodeSetDTM
* does not support the clone() operation.
*/
public DTMIterator cloneWithReset() throws CloneNotSupportedException
{
NodeSetDTM clone = (NodeSetDTM) clone();
clone.reset();
return clone;
}
/**
* Reset the iterator. May have no effect on non-iterator Nodesets.
*/
public void reset()
{
m_next = 0;
}
/**
* This attribute determines which node types are presented via the
* iterator. The available set of constants is defined in the
* <code>DTMFilter</code> interface. For NodeSetDTMs, the mask has been
* hardcoded to show all nodes except EntityReference nodes, which have
* no equivalent in the XPath data model.
*
* @return integer used as a bit-array, containing flags defined in
* the DOM's DTMFilter class. The value will be
* <code>SHOW_ALL & ~SHOW_ENTITY_REFERENCE</code>, meaning that
* only entity references are suppressed.
*/
public int getWhatToShow()
{
return DTMFilter.SHOW_ALL & ~DTMFilter.SHOW_ENTITY_REFERENCE;
}
/**
* The filter object used to screen nodes. Filters are applied to
* further reduce (and restructure) the DTMIterator's view of the
* document. In our case, we will be using hardcoded filters built
* into our iterators... but getFilter() is part of the DOM's
* DTMIterator interface, so we have to support it.
*
* @return null, which is slightly misleading. True, there is no
* user-written filter object, but in fact we are doing some very
* sophisticated custom filtering. A DOM purist might suggest
* returning a placeholder object just to indicate that this is
* not going to return all nodes selected by whatToShow.
*/
public DTMFilter getFilter()
{
return null;
}
/**
* The value of this flag determines whether the children of entity
* reference nodes are visible to the iterator. If false, they will be
* skipped over.
* <br> To produce a view of the document that has entity references
* expanded and does not expose the entity reference node itself, use the
* whatToShow flags to hide the entity reference node and set
* expandEntityReferences to true when creating the iterator. To produce
* a view of the document that has entity reference nodes but no entity
* expansion, use the whatToShow flags to show the entity reference node
* and set expandEntityReferences to false.
*
* @return true for all iterators based on NodeSetDTM, meaning that the
* contents of EntityRefrence nodes may be returned (though whatToShow
* says that the EntityReferences themselves are not shown.)
*/
public boolean getExpandEntityReferences()
{
return true;
}
/**
* Get an instance of a DTM that "owns" a node handle. Since a node
* iterator may be passed without a DTMManager, this allows the
* caller to easily get the DTM using just the iterator.
*
* @param nodeHandle the nodeHandle.
*
* @return a non-null DTM reference.
*/
public DTM getDTM(int nodeHandle)
{
// %TBD%
return null;
}
/**
* Get an instance of the DTMManager. Since a node
* iterator may be passed without a DTMManager, this allows the
* caller to easily get the DTMManager using just the iterator.
*
* @return a non-null DTMManager reference.
*/
public DTMManager getDTMManager()
{
// %TBD%
return null;
}
/**
* Returns the next node in the set and advances the position of the
* iterator in the set. After a DTMIterator is created, the first call
* to nextNode() returns the first node in the set.
* @return The next <code>Node</code> in the set being iterated over, or
* <code>null</code> if there are no more members in that set.
* @throws DOMException
* INVALID_STATE_ERR: Raised if this method is called after the
* <code>detach</code> method was invoked.
*/
public int nextNode()
{
if ((m_next) < this.size())
{
int next = this.elementAt(m_next);
m_next++;
return next;
}
else
return DTM.NULL;
}
/**
* Returns the previous node in the set and moves the position of the
* iterator backwards in the set.
* @return The previous <code>Node</code> in the set being iterated over,
* or<code>null</code> if there are no more members in that set.
* @throws DOMException
* INVALID_STATE_ERR: Raised if this method is called after the
* <code>detach</code> method was invoked.
* @throws RuntimeException thrown if this NodeSetDTM is not of
* a cached type, and hence doesn't know what the previous node was.
*/
public int previousNode()
{
if (!m_cacheNodes)
throw new RuntimeException(
"This NodeSetDTM can not iterate to a previous node!");
if ((m_next - 1) > 0)
{
m_next--;
return this.elementAt(m_next);
}
else
return DTM.NULL;
}
/**
* Detaches the iterator from the set which it iterated over, releasing
* any computational resources and placing the iterator in the INVALID
* state. After<code>detach</code> has been invoked, calls to
* <code>nextNode</code> or<code>previousNode</code> will raise the
* exception INVALID_STATE_ERR.
* <p>
* This operation is a no-op in NodeSetDTM, and will not cause
* INVALID_STATE_ERR to be raised by later operations.
* </p>
*/
public void detach(){}
/**
* Specify if it's OK for detach to release the iterator for reuse.
*
* @param allowRelease true if it is OK for detach to release this iterator
* for pooling.
*/
public void allowDetachToRelease(boolean allowRelease)
{
// no action for right now.
}
/**
* Tells if this NodeSetDTM is "fresh", in other words, if
* the first nextNode() that is called will return the
* first node in the set.
*
* @return true if nextNode() would return the first node in the set,
* false if it would return a later one.
*/
public boolean isFresh()
{
return (m_next == 0);
}
/**
* If an index is requested, NodeSetDTM will call this method
* to run the iterator to the index. By default this sets
* m_next to the index. If the index argument is -1, this
* signals that the iterator should be run to the end.
*
* @param index Position to advance (or retreat) to, with
* 0 requesting the reset ("fresh") position and -1 (or indeed
* any out-of-bounds value) requesting the final position.
* @throws RuntimeException thrown if this NodeSetDTM is not
* one of the types which supports indexing/counting.
*/
public void runTo(int index)
{
if (!m_cacheNodes)
throw new RuntimeException(
"This NodeSetDTM can not do indexing or counting functions!");
if ((index >= 0) && (m_next < m_firstFree))
m_next = index;
else
m_next = m_firstFree - 1;
}
/**
* Returns the <code>index</code>th item in the collection. If
* <code>index</code> is greater than or equal to the number of nodes in
* the list, this returns <code>null</code>.
*
* TODO: What happens if index is out of range?
*
* @param index Index into the collection.
* @return The node at the <code>index</code>th position in the
* <code>NodeList</code>, or <code>null</code> if that is not a valid
* index.
*/
public int item(int index)
{
runTo(index);
return this.elementAt(index);
}
/**
* The number of nodes in the list. The range of valid child node indices is
* 0 to <code>length-1</code> inclusive. Note that this operation requires
* finding all the matching nodes, which may defeat attempts to defer
* that work.
*
* @return integer indicating how many nodes are represented by this list.
*/
public int getLength()
{
runTo(-1);
return this.size();
}
/**
* Add a node to the NodeSetDTM. Not all types of NodeSetDTMs support this
* operation
*
* @param n Node to be added
* @throws RuntimeException thrown if this NodeSetDTM is not of
* a mutable type.
*/
public void addNode(int n)
{
if (!m_mutable)
throw new RuntimeException("This NodeSetDTM is not mutable!");
this.addElement(n);
}
/**
* Insert a node at a given position.
*
* @param n Node to be added
* @param pos Offset at which the node is to be inserted,
* with 0 being the first position.
* @throws RuntimeException thrown if this NodeSetDTM is not of
* a mutable type.
*/
public void insertNode(int n, int pos)
{
if (!m_mutable)
throw new RuntimeException("This NodeSetDTM is not mutable!");
insertElementAt(n, pos);
}
/**
* Remove a node.
*
* @param n Node to be added
* @throws RuntimeException thrown if this NodeSetDTM is not of
* a mutable type.
*/
public void removeNode(int n)
{
if (!m_mutable)
throw new RuntimeException("This NodeSetDTM is not mutable!");
this.removeElement(n);
}
// %TBD%
// /**
// * Copy NodeList members into this nodelist, adding in
// * document order. If a node is null, don't add it.
// *
// * @param nodelist List of nodes which should now be referenced by
// * this NodeSetDTM.
// * @throws RuntimeException thrown if this NodeSetDTM is not of
// * a mutable type.
// */
// public void addNodes(NodeList nodelist)
// {
//
// if (!m_mutable)
// throw new RuntimeException("This NodeSetDTM is not mutable!");
//
// if (null != nodelist) // defensive to fix a bug that Sanjiva reported.
// {
// int nChildren = nodelist.getLength();
//
// for (int i = 0; i < nChildren; i++)
// {
// int obj = nodelist.item(i);
//
// if (null != obj)
// {
// addElement(obj);
// }
// }
// }
//
// // checkDups();
// }
// %TBD%
// /**
// * <p>Copy NodeList members into this nodelist, adding in
// * document order. Only genuine node references will be copied;
// * nulls appearing in the source NodeSetDTM will
// * not be added to this one. </p>
// *
// * <p> In case you're wondering why this function is needed: NodeSetDTM
// * implements both DTMIterator and NodeList. If this method isn't
// * provided, Java can't decide which of those to use when addNodes()
// * is invoked. Providing the more-explicit match avoids that
// * ambiguity.)</p>
// *
// * @param ns NodeSetDTM whose members should be merged into this NodeSetDTM.
// * @throws RuntimeException thrown if this NodeSetDTM is not of
// * a mutable type.
// */
// public void addNodes(NodeSetDTM ns)
// {
//
// if (!m_mutable)
// throw new RuntimeException("This NodeSetDTM is not mutable!");
//
// addNodes((DTMIterator) ns);
// }
/**
* Copy NodeList members into this nodelist, adding in
* document order. Null references are not added.
*
* @param iterator DTMIterator which yields the nodes to be added.
* @throws RuntimeException thrown if this NodeSetDTM is not of
* a mutable type.
*/
public void addNodes(DTMIterator iterator)
{
if (!m_mutable)
throw new RuntimeException("This NodeSetDTM is not mutable!");
if (null != iterator) // defensive to fix a bug that Sanjiva reported.
{
int obj;
while (DTM.NULL != (obj = iterator.nextNode()))
{
addElement(obj);
}
}
// checkDups();
}
// %TBD%
// /**
// * Copy NodeList members into this nodelist, adding in
// * document order. If a node is null, don't add it.
// *
// * @param nodelist List of nodes to be added
// * @param support The XPath runtime context.
// * @throws RuntimeException thrown if this NodeSetDTM is not of
// * a mutable type.
// */
// public void addNodesInDocOrder(NodeList nodelist, XPathContext support)
// {
//
// if (!m_mutable)
// throw new RuntimeException("This NodeSetDTM is not mutable!");
//
// int nChildren = nodelist.getLength();
//
// for (int i = 0; i < nChildren; i++)
// {
// int node = nodelist.item(i);
//
// if (null != node)
// {
// addNodeInDocOrder(node, support);
// }
// }
// }
/**
* Copy NodeList members into this nodelist, adding in
* document order. If a node is null, don't add it.
*
* @param iterator DTMIterator which yields the nodes to be added.
* @param support The XPath runtime context.
* @throws RuntimeException thrown if this NodeSetDTM is not of
* a mutable type.
*/
public void addNodesInDocOrder(DTMIterator iterator, XPathContext support)
{
if (!m_mutable)
throw new RuntimeException("This NodeSetDTM is not mutable!");
int node;
while (DTM.NULL != (node = iterator.nextNode()))
{
addNodeInDocOrder(node, support);
}
}
// %TBD%
// /**
// * Add the node list to this node set in document order.
// *
// * @param start index.
// * @param end index.
// * @param testIndex index.
// * @param nodelist The nodelist to add.
// * @param support The XPath runtime context.
// *
// * @return false always.
// * @throws RuntimeException thrown if this NodeSetDTM is not of
// * a mutable type.
// */
// private boolean addNodesInDocOrder(int start, int end, int testIndex,
// NodeList nodelist, XPathContext support)
// {
//
// if (!m_mutable)
// throw new RuntimeException("This NodeSetDTM is not mutable!");
//
// boolean foundit = false;
// int i;
// int node = nodelist.item(testIndex);
//
// for (i = end; i >= start; i--)
// {
// int child = elementAt(i);
//
// if (child == node)
// {
// i = -2; // Duplicate, suppress insert
//
// break;
// }
//
// if (!support.getDOMHelper().isNodeAfter(node, child))
// {
// insertElementAt(node, i + 1);
//
// testIndex--;
//
// if (testIndex > 0)
// {
// boolean foundPrev = addNodesInDocOrder(0, i, testIndex, nodelist,
// support);
//
// if (!foundPrev)
// {
// addNodesInDocOrder(i, size() - 1, testIndex, nodelist, support);
// }
// }
//
// break;
// }
// }
//
// if (i == -1)
// {
// insertElementAt(node, 0);
// }
//
// return foundit;
// }
/**
* Add the node into a vector of nodes where it should occur in
* document order.
* @param v Vector of nodes, presumably containing Nodes
* @param obj Node object.
*
* @param node The node to be added.
* @param test true if we should test for doc order
* @param support The XPath runtime context.
* @return insertIndex.
* @throws RuntimeException thrown if this NodeSetDTM is not of
* a mutable type.
*/
public int addNodeInDocOrder(int node, boolean test, XPathContext support)
{
if (!m_mutable)
throw new RuntimeException("This NodeSetDTM is not mutable!");
int insertIndex = -1;
if (test)
{
// This needs to do a binary search, but a binary search
// is somewhat tough because the sequence test involves
// two nodes.
int size = size(), i;
for (i = size - 1; i >= 0; i--)
{
int child = elementAt(i);
if (child == node)
{
i = -2; // Duplicate, suppress insert
break;
}
DTM dtm = support.getDTM(node);
if (!dtm.isNodeAfter(node, child))
{
break;
}
}
if (i != -2)
{
insertIndex = i + 1;
insertElementAt(node, insertIndex);
}
}
else
{
insertIndex = this.size();
boolean foundit = false;
for (int i = 0; i < insertIndex; i++)
{
if (i == node)
{
foundit = true;
break;
}
}
if (!foundit)
addElement(node);
}
// checkDups();
return insertIndex;
} // end addNodeInDocOrder(Vector v, Object obj)
/**
* Add the node into a vector of nodes where it should occur in
* document order.
* @param v Vector of nodes, presumably containing Nodes
* @param obj Node object.
*
* @param node The node to be added.
* @param support The XPath runtime context.
*
* @return The index where it was inserted.
* @throws RuntimeException thrown if this NodeSetDTM is not of
* a mutable type.
*/
public int addNodeInDocOrder(int node, XPathContext support)
{
if (!m_mutable)
throw new RuntimeException("This NodeSetDTM is not mutable!");
return addNodeInDocOrder(node, true, support);
} // end addNodeInDocOrder(Vector v, Object obj)
/**
* Get the length of the list.
*
* @return The size of this node set.
*/
public int size()
{
return super.size();
}
/**
* Append a Node onto the vector.
*
* @param value The node to be added.
* @throws RuntimeException thrown if this NodeSetDTM is not of
* a mutable type.
*/
public void addElement(int value)
{
if (!m_mutable)
throw new RuntimeException("This NodeSetDTM is not mutable!");
super.addElement(value);
}
/**
* Inserts the specified node in this vector at the specified index.
* Each component in this vector with an index greater or equal to
* the specified index is shifted upward to have an index one greater
* than the value it had previously.
*
* @param value The node to be inserted.
* @param at The index where the insert should occur.
* @throws RuntimeException thrown if this NodeSetDTM is not of
* a mutable type.
*/
public void insertElementAt(int value, int at)
{
if (!m_mutable)
throw new RuntimeException("This NodeSetDTM is not mutable!");
super.insertElementAt(value, at);
}
/**
* Append the nodes to the list.
*
* @param nodes The nodes to be appended to this node set.
* @throws RuntimeException thrown if this NodeSetDTM is not of
* a mutable type.
*/
public void appendNodes(NodeVector nodes)
{
if (!m_mutable)
throw new RuntimeException("This NodeSetDTM is not mutable!");
super.appendNodes(nodes);
}
/**
* Inserts the specified node in this vector at the specified index.
* Each component in this vector with an index greater or equal to
* the specified index is shifted upward to have an index one greater
* than the value it had previously.
* @throws RuntimeException thrown if this NodeSetDTM is not of
* a mutable type.
*/
public void removeAllElements()
{
if (!m_mutable)
throw new RuntimeException("This NodeSetDTM is not mutable!");
super.removeAllElements();
}
/**
* Removes the first occurrence of the argument from this vector.
* If the object is found in this vector, each component in the vector
* with an index greater or equal to the object's index is shifted
* downward to have an index one smaller than the value it had
* previously.
*
* @param s The node to be removed.
*
* @return True if the node was successfully removed
* @throws RuntimeException thrown if this NodeSetDTM is not of
* a mutable type.
*/
public boolean removeElement(int s)
{
if (!m_mutable)
throw new RuntimeException("This NodeSetDTM is not mutable!");
return super.removeElement(s);
}
/**
* Deletes the component at the specified index. Each component in
* this vector with an index greater or equal to the specified
* index is shifted downward to have an index one smaller than
* the value it had previously.
*
* @param i The index of the node to be removed.
* @throws RuntimeException thrown if this NodeSetDTM is not of
* a mutable type.
*/
public void removeElementAt(int i)
{
if (!m_mutable)
throw new RuntimeException("This NodeSetDTM is not mutable!");
super.removeElementAt(i);
}
/**
* Sets the component at the specified index of this vector to be the
* specified object. The previous component at that position is discarded.
*
* The index must be a value greater than or equal to 0 and less
* than the current size of the vector.
*
* @param node The node to be set.
* @param index The index of the node to be replaced.
* @throws RuntimeException thrown if this NodeSetDTM is not of
* a mutable type.
*/
public void setElementAt(int node, int index)
{
if (!m_mutable)
throw new RuntimeException("This NodeSetDTM is not mutable!");
super.setElementAt(node, index);
}
/**
* Same as setElementAt.
*
* @param node The node to be set.
* @param index The index of the node to be replaced.
* @throws RuntimeException thrown if this NodeSetDTM is not of
* a mutable type.
*/
public void setItem(int node, int index)
{
if (!m_mutable)
throw new RuntimeException("This NodeSetDTM is not mutable!");
super.setElementAt(node, index);
}
/**
* Get the nth element.
*
* @param i The index of the requested node.
*
* @return Node at specified index.
*/
public int elementAt(int i)
{
runTo(i);
return super.elementAt(i);
}
/**
* Tell if the table contains the given node.
*
* @param s Node to look for
*
* @return True if the given node was found.
*/
public boolean contains(int s)
{
runTo(-1);
return super.contains(s);
}
/**
* Searches for the first occurence of the given argument,
* beginning the search at index, and testing for equality
* using the equals method.
*
* @param elem Node to look for
* @param index Index of where to start the search
* @return the index of the first occurrence of the object
* argument in this vector at position index or later in the
* vector; returns -1 if the object is not found.
*/
public int indexOf(int elem, int index)
{
runTo(-1);
return super.indexOf(elem, index);
}
/**
* Searches for the first occurence of the given argument,
* beginning the search at index, and testing for equality
* using the equals method.
*
* @param elem Node to look for
* @return the index of the first occurrence of the object
* argument in this vector at position index or later in the
* vector; returns -1 if the object is not found.
*/
public int indexOf(int elem)
{
runTo(-1);
return super.indexOf(elem);
}
/** If this node is being used as an iterator, the next index that nextNode()
* will return. */
transient protected int m_next = 0;
/**
* Get the current position, which is one less than
* the next nextNode() call will retrieve. i.e. if
* you call getCurrentPos() and the return is 0, the next
* fetch will take place at index 1.
*
* @return The the current position index.
*/
public int getCurrentPos()
{
return m_next;
}
/**
* Set the current position in the node set.
* @param i Must be a valid index.
* @throws RuntimeException thrown if this NodeSetDTM is not of
* a cached type, and thus doesn't permit indexed access.
*/
public void setCurrentPos(int i)
{
if (!m_cacheNodes)
throw new RuntimeException(
"This NodeSetDTM can not do indexing or counting functions!");
m_next = i;
}
/**
* Return the last fetched node. Needed to support the UnionPathIterator.
*
* @return the last fetched node.
* @throws RuntimeException thrown if this NodeSetDTM is not of
* a cached type, and thus doesn't permit indexed access.
*/
public int getCurrentNode()
{
if (!m_cacheNodes)
throw new RuntimeException(
"This NodeSetDTM can not do indexing or counting functions!");
int saved = m_next;
int n = elementAt(m_next-1);
m_next = saved; // HACK: I think this is a bit of a hack. -sb
return n;
}
/** True if this list can be mutated. */
transient protected boolean m_mutable = true;
/** True if this list is cached.
* @serial */
transient protected boolean m_cacheNodes = true;
/**
* Get whether or not this is a cached node set.
*
*
* @return True if this list is cached.
*/
public boolean getShouldCacheNodes()
{
return m_cacheNodes;
}
/**
* If setShouldCacheNodes(true) is called, then nodes will
* be cached. They are not cached by default. This switch must
* be set before the first call to nextNode is made, to ensure
* that all nodes are cached.
*
* @param b true if this node set should be cached.
* @throws RuntimeException thrown if an attempt is made to
* request caching after we've already begun stepping through the
* nodes in this set.
*/
public void setShouldCacheNodes(boolean b)
{
if (!isFresh())
throw new RuntimeException(
"Can not call setShouldCacheNodes after nextNode has been called!");
m_cacheNodes = b;
m_mutable = true;
}
/**
* Tells if this iterator can have nodes added to it or set via
* the <code>setItem(int node, int index)</code> method.
*
* @return True if the nodelist can be mutated.
*/
public boolean isMutable()
{
return m_mutable;
}
transient private int m_last = 0;
public int getLast()
{
return m_last;
}
public void setLast(int last)
{
m_last = last;
}
}
1.6 +2 -2 xml-xalan/java/src/org/apache/xpath/axes/ContextNodeList.java
Index: ContextNodeList.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/ContextNodeList.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ContextNodeList.java 2000/12/17 17:40:00 1.5
+++ ContextNodeList.java 2001/06/15 05:15:30 1.6
@@ -102,7 +102,7 @@
public void setShouldCacheNodes(boolean b);
/**
- * If an index is requested, NodeSet will call this method
+ * If an index is requested, NodeSetDTM will call this method
* to run the iterator to the index. By default this sets
* m_next to the index. If the index argument is -1, this
* signals that the iterator should be run to the end.
@@ -126,7 +126,7 @@
public int size();
/**
- * Tells if this NodeSet is "fresh", in other words, if
+ * Tells if this NodeSetDTM is "fresh", in other words, if
* the first nextNode() that is called will return the
* first node in the set.
*
1.26 +9 -9 xml-xalan/java/src/org/apache/xpath/axes/LocPathIterator.java
Index: LocPathIterator.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/LocPathIterator.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- LocPathIterator.java 2001/06/12 19:16:18 1.25
+++ LocPathIterator.java 2001/06/15 05:15:31 1.26
@@ -72,7 +72,7 @@
import org.apache.xpath.compiler.Compiler;
import org.apache.xpath.compiler.OpCodes;
import org.apache.xpath.compiler.PsuedoNames;
-import org.apache.xpath.NodeSet;
+import org.apache.xpath.NodeSetDTM;
import org.apache.xpath.Expression;
import org.apache.xpath.XPathContext;
import org.apache.xpath.objects.XObject;
@@ -85,7 +85,7 @@
/**
* <meta name="usage" content="advanced"/>
- * This class extends NodeSet, which implements NodeIterator,
+ * This class extends NodeSetDTM, which implements NodeIterator,
* and fetches nodes one at a time in document order based on a XPath
* <a href="http://www.w3.org/TR/xpath#NT-LocationPath>LocationPath</a>.
*
@@ -394,7 +394,7 @@
{
if (b)
- m_cachedNodes = new NodeSet();
+ m_cachedNodes = new NodeSetDTM();
else
m_cachedNodes = null;
}
@@ -416,7 +416,7 @@
*
* @return Cached nodes.
*/
- public NodeSet getCachedNodes()
+ public NodeSetDTM getCachedNodes()
{
return m_cachedNodes;
}
@@ -433,7 +433,7 @@
// System.out.println("setCurrentPos: "+i);
if (null == m_cachedNodes)
throw new RuntimeException(
- "This NodeSet can not do indexing or counting functions!");
+ "This NodeSetDTM can not do indexing or counting functions!");
setNextPosition(i);
m_cachedNodes.setCurrentPos(i);
@@ -535,7 +535,7 @@
}
/**
- * Tells if this NodeSet is "fresh", in other words, if
+ * Tells if this NodeSetDTM is "fresh", in other words, if
* the first nextNode() that is called will return the
* first node in the set.
*
@@ -557,7 +557,7 @@
if (null == m_cachedNodes)
throw new RuntimeException(
- "This NodeSet can not iterate to a previous node!");
+ "This NodeSetDTM can not iterate to a previous node!");
return m_cachedNodes.previousNode();
}
@@ -754,7 +754,7 @@
}
/**
- * If an index is requested, NodeSet will call this method
+ * If an index is requested, NodeSetDTM will call this method
* to run the iterator to the index. By default this sets
* m_next to the index. If the index argument is -1, this
* signals that the iterator should be run to the end.
@@ -978,7 +978,7 @@
* If this iterator needs to cache nodes that are fetched, they
* are stored here.
*/
- transient NodeSet m_cachedNodes;
+ transient NodeSetDTM m_cachedNodes;
/** This is true if nextNode returns null. */
transient protected boolean m_foundLast = false;
1.18 +8 -8 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.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- UnionPathIterator.java 2001/06/13 03:36:56 1.17
+++ UnionPathIterator.java 2001/06/15 05:15:32 1.18
@@ -70,7 +70,7 @@
import org.apache.xml.dtm.DTMIterator;
// Xalan Imports
-import org.apache.xpath.NodeSet;
+import org.apache.xpath.NodeSetDTM;
import org.apache.xpath.Expression;
import org.apache.xpath.XPath;
import org.apache.xpath.XPathContext;
@@ -81,7 +81,7 @@
/**
* <meta name="usage" content="advanced"/>
- * This class extends NodeSet, which implements DTMIterator,
+ * This class extends NodeSetDTM, which implements DTMIterator,
* and fetches nodes one at a time in document order based on a XPath
* <a href="http://www.w3.org/TR/xpath#NT-UnionExpr">UnionExpr</a>.
* As each node is iterated via nextNode(), the node is also stored
@@ -223,7 +223,7 @@
/** If this iterator needs to cache nodes that are fetched, they
* are stored here. */
- transient NodeSet m_cachedNodes = null;
+ transient NodeSetDTM m_cachedNodes = null;
/** The index of the next node to be fetched. Useful if this
* is a cached iterator, and is being used as random access
@@ -240,7 +240,7 @@
{
if (b)
- m_cachedNodes = new NodeSet();
+ m_cachedNodes = new NodeSetDTM();
else
m_cachedNodes = null;
}
@@ -265,7 +265,7 @@
if (null == m_cachedNodes)
throw new RuntimeException(
- "This NodeSet can not do indexing or counting functions!");
+ "This NodeSetDTM can not do indexing or counting functions!");
m_next = i;
@@ -287,7 +287,7 @@
}
/**
- * Tells if this NodeSet is "fresh", in other words, if
+ * Tells if this NodeSetDTM is "fresh", in other words, if
* the first nextNode() that is called will return the
* first node in the set.
*
@@ -309,7 +309,7 @@
if (null == m_cachedNodes)
throw new RuntimeException(
- "This NodeSet can not iterate to a previous node!");
+ "This NodeSetDTM can not iterate to a previous node!");
return m_cachedNodes.previousNode();
}
@@ -687,7 +687,7 @@
}
/**
- * If an index is requested, NodeSet will call this method
+ * If an index is requested, NodeSetDTM will call this method
* to run the iterator to the index. By default this sets
* m_next to the index. If the index argument is -1, this
* signals that the iterator should be run to the end.
1.3 +1 -1 xml-xalan/java/src/org/apache/xpath/axes/WalkingIterator.java
Index: WalkingIterator.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/WalkingIterator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- WalkingIterator.java 2001/06/12 19:16:24 1.2
+++ WalkingIterator.java 2001/06/15 05:15:33 1.3
@@ -12,7 +12,7 @@
import org.apache.xpath.compiler.Compiler;
import org.apache.xpath.compiler.OpCodes;
import org.apache.xpath.compiler.PsuedoNames;
-import org.apache.xpath.NodeSet;
+import org.apache.xpath.NodeSetDTM;
import org.apache.xpath.Expression;
import org.apache.xpath.XPathContext;
import org.apache.xpath.objects.XObject;
1.11 +56 -47 xml-xalan/java/src/org/apache/xpath/functions/FuncExtFunction.java
Index: FuncExtFunction.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FuncExtFunction.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- FuncExtFunction.java 2001/06/12 19:16:33 1.10
+++ FuncExtFunction.java 2001/06/15 05:15:41 1.11
@@ -62,7 +62,6 @@
import org.apache.xpath.XPathContext;
import org.apache.xpath.objects.*;
import org.apache.xalan.extensions.ExtensionsTable;
-
import org.apache.xml.dtm.DTMIterator;
//import org.w3c.dom.Node;
@@ -71,66 +70,76 @@
/**
* <meta name="usage" content="advanced"/>
- * An object of this class represents an extension call expression. When
- * the expression executes, it calls ExtensionsTable#extFunction, and then
+ * An object of this class represents an extension call expression. When
+ * the expression executes, it calls ExtensionsTable#extFunction, and then
* converts the result to the appropriate XObject.
*/
public class FuncExtFunction extends Function
{
- /** The namespace for the extension function, which should not normally
+ /**
+ * The namespace for the extension function, which should not normally
* be null or empty.
- * @serial */
+ * @serial
+ */
String m_namespace;
- /** The local name of the extension.
- * @serial */
+ /**
+ * The local name of the extension.
+ * @serial
+ */
String m_extensionName;
- /** Unique method key, which is passed to ExtensionsTable#extFunction in
- * order to allow caching of the method.
- * @serial */
+ /**
+ * Unique method key, which is passed to ExtensionsTable#extFunction in
+ * order to allow caching of the method.
+ * @serial
+ */
Object m_methodKey;
- /** Array of static expressions which represent the parameters to the
+ /**
+ * Array of static expressions which represent the parameters to the
* function.
- * @serial */
+ * @serial
+ */
Vector m_argVec = new Vector();
-
+
/**
- * This function is used to fixup variables from QNames to stack frame
+ * This function is used to fixup variables from QNames to stack frame
* indexes at stylesheet build time.
- * @param vars List of QNames that correspond to variables. This list
- * should be searched backwards for the first qualified name that
- * corresponds to the variable reference qname. The position of the
- * QName in the vector from the start of the vector will be its position
- * in the stack frame (but variables above the globalsTop value will need
+ * @param vars List of QNames that correspond to variables. This list
+ * should be searched backwards for the first qualified name that
+ * corresponds to the variable reference qname. The position of the
+ * QName in the vector from the start of the vector will be its position
+ * in the stack frame (but variables above the globalsTop value will need
* to be offset to the current stack frame).
+ * NEEDSDOC @param globalsSize
*/
public void fixupVariables(java.util.Vector vars, int globalsSize)
{
- if(null != m_argVec)
+
+ if (null != m_argVec)
{
int nArgs = m_argVec.size();
-
+
for (int i = 0; i < nArgs; i++)
{
Expression arg = (Expression) m_argVec.elementAt(i);
+
arg.fixupVariables(vars, globalsSize);
}
}
}
-
/**
- * Create a new FuncExtFunction based on the qualified name of the extension,
+ * Create a new FuncExtFunction based on the qualified name of the extension,
* and a unique method key.
*
- * @param namespace The namespace for the extension function, which should
- * not normally be null or empty.
+ * @param namespace The namespace for the extension function, which should
+ * not normally be null or empty.
* @param extensionName The local name of the extension.
- * @param methodKey Unique method key, which is passed to
- * ExtensionsTable#extFunction in order to allow caching
+ * @param methodKey Unique method key, which is passed to
+ * ExtensionsTable#extFunction in order to allow caching
* of the method.
*/
public FuncExtFunction(java.lang.String namespace,
@@ -150,7 +159,8 @@
*
* @throws javax.xml.transform.TransformerException
*/
- public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
+ public XObject execute(XPathContext xctxt)
+ throws javax.xml.transform.TransformerException
{
XObject result;
@@ -166,7 +176,8 @@
ExtensionsTable etable = xctxt.getExtensionsTable();
Object val = etable.extFunction(m_namespace, m_extensionName, argVec,
- m_methodKey, xctxt.getExpressionContext());
+ m_methodKey,
+ xctxt.getExpressionContext());
if (null != val)
{
@@ -174,14 +185,6 @@
{
result = (XObject) val;
}
-
- // else if(val instanceof XLocator)
- // {
- // XLocator locator = (XLocator)val;
- // opPos = getNextOpPos(opPos+1);
- // result = locator.connectToNodes(this, opPos, argVec);
- // System.out.println("nodeset len: "+result.nodeset().getLength());
- // }
else if (val instanceof String)
{
result = new XString((String) val);
@@ -195,19 +198,25 @@
{
result = new XNumber(((Number) val).doubleValue());
}
- // %TBD%
- // else if (val instanceof DocumentFragment)
- // {
- // result = new XRTreeFrag(val, xctxt);
- // }
+ else if (val instanceof DocumentFragment)
+ {
+ int handle = xctxt.getDTMHandleFromNode((DocumentFragment)val);
+
+ result = new XRTreeFrag(handle, xctxt);
+ }
else if (val instanceof DTMIterator)
{
result = new XNodeSet((DTMIterator) val);
}
+ else if (val instanceof NodeIterator)
+ {
+ result = new XNodeSet(new org.apache.xpath.NodeSetDTM(((NodeIterator)val), xctxt));
+ }
else if (val instanceof org.w3c.dom.Node)
{
- result = new XNodeSet(xctxt.getDTMHandleFromNode((org.w3c.dom.Node)val),
- xctxt.getDTMManager());
+ result =
+ new XNodeSet(xctxt.getDTMHandleFromNode((org.w3c.dom.Node) val),
+ xctxt.getDTMManager());
}
else
{
@@ -223,13 +232,13 @@
}
/**
- * Set an argument expression for a function. This method is called by the
+ * Set an argument expression for a function. This method is called by the
* XPath compiler.
*
* @param arg non-null expression that represents the argument.
* @param argNum The argument number index.
*
- * @throws WrongNumberArgsException If the argNum parameter is beyond what
+ * @throws WrongNumberArgsException If the argNum parameter is beyond what
* is specified for this function.
*/
public void setArg(Expression arg, int argNum)
@@ -239,7 +248,7 @@
}
/**
- * Check that the number of arguments passed to this function is correct.
+ * Check that the number of arguments passed to this function is correct.
*
*
* @param argNum The number of arguments that is being passed to the function.
1.8 +3 -3 xml-xalan/java/src/org/apache/xpath/functions/FuncId.java
Index: FuncId.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FuncId.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- FuncId.java 2001/06/12 19:16:35 1.7
+++ FuncId.java 2001/06/15 05:15:42 1.8
@@ -71,7 +71,7 @@
import org.apache.xpath.XPathContext;
import org.apache.xpath.DOMHelper;
import org.apache.xpath.XPath;
-import org.apache.xpath.NodeSet;
+import org.apache.xpath.NodeSetDTM;
import org.apache.xpath.objects.XObject;
import org.apache.xpath.objects.XNodeSet;
import org.apache.xml.utils.StringVector;
@@ -98,7 +98,7 @@
*/
private StringVector getNodesByID(XPathContext xctxt, int docContext,
String refval, StringVector usedrefs,
- NodeSet nodeSet, boolean mayBeMore)
+ NodeSetDTM nodeSet, boolean mayBeMore)
{
if (null != refval)
@@ -160,7 +160,7 @@
XObject arg = m_arg0.execute(xctxt);
int argType = arg.getType();
XNodeSet nodes = new XNodeSet(xctxt.getDTMManager());
- NodeSet nodeSet = nodes.mutableNodeset();
+ NodeSetDTM nodeSet = nodes.mutableNodeset();
if (XObject.CLASS_NODESET == argType)
{
1.9 +1 -1 xml-xalan/java/src/org/apache/xpath/functions/FuncLast.java
Index: FuncLast.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FuncLast.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- FuncLast.java 2001/06/12 19:16:36 1.8
+++ FuncLast.java 2001/06/15 05:15:43 1.9
@@ -67,7 +67,7 @@
import org.apache.xpath.XPath;
import org.apache.xpath.objects.XObject;
import org.apache.xpath.objects.XNumber;
-import org.apache.xpath.NodeSet;
+import org.apache.xpath.NodeSetDTM;
import org.apache.xpath.axes.LocPathIterator;
import org.apache.xpath.axes.ContextNodeList;
import org.apache.xpath.axes.SubContextList;
1.6 +1 -1 xml-xalan/java/src/org/apache/xpath/functions/FuncPosition.java
Index: FuncPosition.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FuncPosition.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- FuncPosition.java 2001/06/12 19:16:37 1.5
+++ FuncPosition.java 2001/06/15 05:15:43 1.6
@@ -69,7 +69,7 @@
import org.apache.xpath.objects.XNumber;
import org.apache.xpath.axes.SubContextList;
import org.apache.xpath.axes.ContextNodeList;
-import org.apache.xpath.NodeSet;
+import org.apache.xpath.NodeSetDTM;
/**
* <meta name="usage" content="advanced"/>
1.12 +10 -10 xml-xalan/java/src/org/apache/xpath/objects/XNodeSet.java
Index: XNodeSet.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/objects/XNodeSet.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- XNodeSet.java 2001/06/12 19:16:52 1.11
+++ XNodeSet.java 2001/06/15 05:15:49 1.12
@@ -67,7 +67,7 @@
import org.apache.xpath.DOMHelper;
import org.apache.xpath.XPathContext;
-import org.apache.xpath.NodeSet;
+import org.apache.xpath.NodeSetDTM;
import org.apache.xpath.axes.ContextNodeList;
import org.apache.xml.utils.StringVector;
import org.apache.xml.utils.XMLString;
@@ -103,7 +103,7 @@
*/
public XNodeSet(DTMManager dtmMgr)
{
- super(new NodeSet());
+ super(new NodeSetDTM());
m_dtmMgr = dtmMgr;
}
@@ -115,12 +115,12 @@
public XNodeSet(int n, DTMManager dtmMgr)
{
- super(new NodeSet());
+ super(new NodeSetDTM());
m_dtmMgr = dtmMgr;
if (DTM.NULL != n)
{
- ((NodeSet) m_obj).addNode(n);
+ ((NodeSetDTM) m_obj).addNode(n);
}
}
@@ -162,7 +162,7 @@
* Cast result object to a number.
*
* @return numeric value of the string conversion from the
- * next node in the NodeSet, or NAN if no node was found
+ * next node in the NodeSetDTM, or NAN if no node was found
*/
public double num()
{
@@ -330,18 +330,18 @@
*
* @return The nodeset as a mutableNodeset
*/
- public NodeSet mutableNodeset()
+ public NodeSetDTM mutableNodeset()
{
- NodeSet mnl;
+ NodeSetDTM mnl;
- if(m_obj instanceof NodeSet)
+ if(m_obj instanceof NodeSetDTM)
{
- mnl = (NodeSet) m_obj;
+ mnl = (NodeSetDTM) m_obj;
}
else
{
- mnl = new NodeSet(nodeset());
+ mnl = new NodeSetDTM(nodeset());
m_obj = mnl;
}
1.7 +1 -1 xml-xalan/java/src/org/apache/xpath/objects/XNull.java
Index: XNull.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/objects/XNull.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- XNull.java 2001/06/12 19:16:52 1.6
+++ XNull.java 2001/06/15 05:15:52 1.7
@@ -63,7 +63,7 @@
import org.apache.xml.dtm.DTMIterator;
import org.apache.xpath.XPathContext;
-import org.apache.xpath.NodeSet;
+import org.apache.xpath.NodeSetDTM;
/**
* <meta name="usage" content="general"/>
1.11 +5 -5 xml-xalan/java/src/org/apache/xpath/objects/XObject.java
Index: XObject.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/objects/XObject.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- XObject.java 2001/06/12 19:16:52 1.10
+++ XObject.java 2001/06/15 05:15:53 1.11
@@ -67,7 +67,7 @@
import org.apache.xpath.res.XPATHErrorResources;
import org.apache.xpath.XPathContext;
-import org.apache.xpath.NodeSet;
+import org.apache.xpath.NodeSetDTM;
import org.apache.xpath.XPathException;
import org.apache.xalan.res.XSLMessages;
import org.apache.xpath.Expression;
@@ -402,18 +402,18 @@
/**
* Cast result object to a nodelist. Always issues an error.
*
- * @return The object as a NodeSet.
+ * @return The object as a NodeSetDTM.
*
* @throws javax.xml.transform.TransformerException
*/
- public NodeSet mutableNodeset()
+ public NodeSetDTM mutableNodeset()
throws javax.xml.transform.TransformerException
{
error(XPATHErrorResources.ER_CANT_CONVERT_TO_MUTABLENODELIST,
- new Object[]{ getTypeString() }); //"Can not convert "+getTypeString()+" to a NodeSet!");
+ new Object[]{ getTypeString() }); //"Can not convert "+getTypeString()+" to a NodeSetDTM!");
- return (NodeSet) m_obj;
+ return (NodeSetDTM) m_obj;
}
/**
1.15 +26 -14 xml-xalan/java/src/org/apache/xpath/objects/XRTreeFrag.java
Index: XRTreeFrag.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/objects/XRTreeFrag.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- XRTreeFrag.java 2001/06/12 19:16:53 1.14
+++ XRTreeFrag.java 2001/06/15 05:15:54 1.15
@@ -56,6 +56,8 @@
*/
package org.apache.xpath.objects;
+import org.w3c.dom.NodeList;
+
import org.apache.xml.dtm.DTM;
import org.apache.xml.dtm.DTMIterator;
import org.apache.xml.dtm.DTMFilter;
@@ -107,6 +109,17 @@
}
/**
+ * Return a java object that's closest to the representation
+ * that should be handed to an extension.
+ *
+ * @return The object that this class wraps
+ */
+ public Object object()
+ {
+ return new org.apache.xml.dtm.ref.DTMNodeIterator((DTMIterator)(new org.apache.xpath.NodeSetDTM(m_dtmRoot)));
+ }
+
+ /**
* Create an XRTreeFrag Object.
*
* @param frag Document fragment this will wrap
@@ -288,20 +301,19 @@
return m_xctxt.createDTMIterator(m_dtmRoot);
}
- // %TBD%
-// /**
-// * Cast result object to a nodelist. (special function).
-// *
-// * @return The document fragment as a nodelist
-// */
-// public NodeList convertToNodeset()
-// {
-//
-// if (m_obj instanceof NodeList)
-// return (NodeList) m_obj;
-// else
-// return null;
-// }
+ /**
+ * Cast result object to a nodelist. (special function).
+ *
+ * @return The document fragment as a nodelist
+ */
+ public NodeList convertToNodeset()
+ {
+
+ if (m_obj instanceof NodeList)
+ return (NodeList) m_obj;
+ else
+ return new org.apache.xml.dtm.ref.DTMNodeList(asNodeIterator());
+ }
/**
* Tell if two objects are functionally equal.
1.8 +1 -1 xml-xalan/java/src/org/apache/xpath/res/XPATHErrorResources.java
Index: XPATHErrorResources.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/res/XPATHErrorResources.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XPATHErrorResources.java 2001/01/07 06:24:41 1.7
+++ XPATHErrorResources.java 2001/06/15 05:15:59 1.8
@@ -311,7 +311,7 @@
static
{
contents[ER_CANT_CONVERT_TO_MUTABLENODELIST][1] =
- "Can not convert {0} to a NodeSet!";
+ "Can not convert {0} to a NodeSetDTM!";
}
/** Field ER_CANT_CONVERT_TO_TYPE */
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org