mkwan 2002/09/16 08:54:45
Modified: java/src/org/apache/xalan/lib Extensions.java
Log:
Make the tokenize extension function different from the one in the
EXSLT strings extension. Reuse the Document object to reduce
memory consumption.
Revision Changes Path
1.21 +24 -9 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.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- Extensions.java 6 Sep 2002 16:28:20 -0000 1.20
+++ Extensions.java 16 Sep 2002 15:54:45 -0000 1.21
@@ -70,6 +70,7 @@
import org.xml.sax.SAXNotSupportedException;
import java.util.Hashtable;
+import java.util.StringTokenizer;
import org.apache.xalan.extensions.ExpressionContext;
import org.apache.xalan.res.XSLMessages;
@@ -91,6 +92,9 @@
public class Extensions
{
+ // Reuse the Document object to reduce memory usage.
+ private static Document lDoc = null;
+
/**
* Constructor Extensions
*
@@ -282,14 +286,29 @@
* @param toTokenize The string to be split into text tokens.
* @param delims The delimiters to use.
* @return a NodeSet as described above.
- *
- * Note: The usage of this extension function in the xalan namespace
- * is deprecated. Please use the same function in the EXSLT strings
extension
- * (http://exslt.org/strings).
*/
public static NodeList tokenize(String toTokenize, String delims)
{
- return ExsltStrings.tokenize(toTokenize, delims);
+
+ try
+ {
+ if (lDoc == null)
+ lDoc =
DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+ }
+ catch(ParserConfigurationException pce)
+ {
+ throw new org.apache.xml.utils.WrappedRuntimeException(pce);
+ }
+
+ StringTokenizer lTokenizer = new StringTokenizer(toTokenize, delims);
+ NodeSet resultSet = new NodeSet();
+
+ while (lTokenizer.hasMoreTokens())
+ {
+ resultSet.addNode(lDoc.createTextNode(lTokenizer.nextToken()));
+ }
+
+ return resultSet;
}
/**
@@ -306,10 +325,6 @@
* extension mechanism. This must be an XPathContext.
* @param toTokenize The string to be split into text tokens.
* @return a NodeSet as described above.
- *
- * Note: The usage of this extension function in the xalan namespace
- * is deprecated. Please use the same function in the EXSLT strings
extension
- * (http://exslt.org/strings).
*/
public static NodeList tokenize(String toTokenize)
{
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]