Extensions.java revision 286
325N/A * reserved comment block 325N/A * DO NOT REMOVE OR ALTER! 325N/A * Copyright 1999-2004 The Apache Software Foundation. 325N/A * Licensed under the Apache License, Version 2.0 (the "License"); 325N/A * you may not use this file except in compliance with the License. 325N/A * You may obtain a copy of the License at 325N/A * Unless required by applicable law or agreed to in writing, software 325N/A * distributed under the License is distributed on an "AS IS" BASIS, 325N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 325N/A * See the License for the specific language governing permissions and 325N/A * limitations under the License. 325N/A * This class contains many of the Xalan-supplied extensions. 325N/A * It is accessed by specifying a namespace URI as follows: 325N/A * Constructor Extensions 325N/A * This method is an extension that implements as a Xalan extension 325N/A * the node-set function also found in xt and saxon. 325N/A * If the argument is a Result Tree Fragment, then <code>nodeset</code> 325N/A * returns a node-set consisting of a single root node as described in 325N/A * section 11.1 of the XSLT 1.0 Recommendation. If the argument is a 325N/A * node-set, <code>nodeset</code> returns a node-set. If the argument 325N/A * is a string, number, or boolean, then <code>nodeset</code> returns 325N/A * a node-set consisting of a single root node with a single text node 325N/A * child that is the result of calling the XPath string() function on the 325N/A * passed parameter. If the argument is anything else, then a node-set 325N/A * is returned consisting of a single root node with a single text node 325N/A * child that is the result of calling the java <code>toString()</code> 325N/A * method on the passed argument. 325N/A * actual work here is done in <code>MethodResolver</code> and 325N/A * <code>XRTreeFrag</code>. 325N/A * @param myProcessor Context passed by the extension processor 325N/A * @param rtf Argument in the stylesheet to the nodeset extension function 325N/A * NEEDSDOC ($objectName$) @return // This no longer will work right since the DTM. // Document myDoc = myProcessor.getContextNode().getOwnerDocument(); * Returns the intersection of two node-sets. * @param nl1 NodeList for first node-set * @param nl2 NodeList for second node-set * @return a NodeList containing the nodes in nl1 that are also in nl2 * Note: The usage of this extension function in the xalan namespace * is deprecated. Please use the same function in the EXSLT sets extension * Returns the difference between two node-sets. * @param nl1 NodeList for first node-set * @param nl2 NodeList for second node-set * @return a NodeList containing the nodes in nl1 that are not in nl2 * Note: The usage of this extension function in the xalan namespace * is deprecated. Please use the same function in the EXSLT sets extension * Returns node-set containing distinct string values. * @param nl NodeList for node-set * @return a NodeList with nodes from nl containing distinct string values. * In other words, if more than one node in nl contains the same string value, * only include the first such node found. * Note: The usage of this extension function in the xalan namespace * is deprecated. Please use the same function in the EXSLT sets extension * Returns true if both node-sets contain the same set of nodes. * @param nl1 NodeList for first node-set * @param nl2 NodeList for second node-set * @return true if nl1 and nl2 contain exactly the same set of nodes. * 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 xpathExpr The XPath expression to be evaluated. * @return the XObject resulting from evaluating the XPath * @throws SAXNotSupportedException * Note: The usage of this extension function in the xalan namespace * is deprecated. Please use the same function in the EXSLT dynamic extension * 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 toTokenize The string to be split into text tokens. * @param delims The delimiters to use. * @return a NodeSet as described above. * 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 toTokenize The string to be split into text tokens. * @return a NodeSet as described above. * Return a Node of basic debugging information from the * EnvironmentCheck utility about the Java environment. * <p>Simply calls the {@link com.sun.org.apache.xalan.internal.xslt.EnvironmentCheck} * utility to grab info about the Java environment and CLASSPATH, * etc., and then returns the resulting Node. Stylesheets can * then maniuplate this data or simply xsl:copy-of the Node. Note * that we first attempt to load the more advanced * org.apache.env.Which utility by reflection; only if that fails * to we still use the internal version. Which is available from * <p>We throw a WrappedRuntimeException in the unlikely case * that reading information from the environment throws us an * exception. (Is this really the best thing to do?)</p> * @param myContext an <code>ExpressionContext</code> passed in by the * extension mechanism. This must be an XPathContext. * @return a Node as described above. // First use reflection to try to load Which, which is a // better version of EnvironmentCheck // If reflection failed, fallback to our internal EnvironmentCheck * Private worker method to attempt to use org.apache.env.Which. * @param myContext an <code>ExpressionContext</code> passed in by the * extension mechanism. This must be an XPathContext. * @param factoryDocument providing createElement services, etc. * @return a Node with environment info; null if any error // Use reflection to try to find xml-commons utility 'Which' // Fully qualify names since this is the only method they're used in // Call the method with our Hashtable, common options, and ignore return value // Create a parent to hold the report and append hash to it // Simply return null; no need to report error * This class is not loaded until first referenced (see Java Language * The static members are created when this class is first referenced, as a * lazy initialization not needing checking against null or any // Reuse the Document object to reduce memory usage.