garyp 01/07/10 16:23:52
Modified: java/src/org/apache/xalan/lib Extensions.java
Log:
Modify distinct() extension so that it no longer relies on DOMHelper which is
deprecated but uses ExpressionContext.toString().
Revision Changes Path
1.13 +13 -8 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.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- Extensions.java 2001/07/10 08:38:21 1.12
+++ Extensions.java 2001/07/10 23:23:49 1.13
@@ -71,6 +71,8 @@
import org.apache.xpath.XPathContext;
import org.apache.xpath.DOMHelper;
import org.apache.xml.dtm.DTMIterator;
+import org.apache.xml.dtm.ref.DTMNodeIterator;
+import org.apache.xml.utils.XMLString;
import org.xml.sax.SAXNotSupportedException;
@@ -245,27 +247,30 @@
*
* @throws javax.xml.transform.TransformerException
*/
- public static NodeSet distinct(NodeIterator ni)
+ public static NodeSet distinct(ExpressionContext myContext, NodeIterator
ni)
throws javax.xml.transform.TransformerException
{
- NodeSet ns = new NodeSet(ni);
- NodeSet dist = new NodeSet();
+ // Set up our resulting NodeSet and the hashtable we use to keep track
of duplicate
+ // strings.
+ NodeSet dist = new NodeSet();
dist.setShouldCacheNodes(true);
Hashtable stringTable = new Hashtable();
+
+ Node currNode = ni.nextNode();
- for (int i = 0; i < ns.getLength(); i++)
+ while (currNode != null)
{
- Node n = ns.elementAt(i);
- String key = DOMHelper.getNodeData(n); // TODO: Fix this to use DTM
+ String key = myContext.toString(currNode);
if (!stringTable.containsKey(key))
{
- stringTable.put(key, n);
- dist.addElement(n);
+ stringTable.put(key, currNode);
+ dist.addElement(currNode);
}
+ currNode = ni.nextNode();
}
return dist;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]