zongaro 2002/11/26 12:26:28
Modified: java Tag: XSLTC_DTM build.xml
java/src/org/apache/xalan/extensions Tag: XSLTC_DTM
ExtensionHandler.java ExtensionHandlerGeneral.java
ExtensionHandlerJavaClass.java
ExtensionHandlerJavaPackage.java
ExtensionsTable.java
java/src/org/apache/xalan/lib Tag: XSLTC_DTM
ExsltCommon.java Extensions.java
java/src/org/apache/xalan/processor Tag: XSLTC_DTM
StylesheetHandler.java
java/src/org/apache/xalan/serialize Tag: XSLTC_DTM
Encodings.java
java/src/org/apache/xalan/templates Tag: XSLTC_DTM
OutputProperties.java
java/src/org/apache/xalan/transformer Tag: XSLTC_DTM
TransformerImpl.java
java/src/org/apache/xalan/xsltc/compiler Tag: XSLTC_DTM
Constants.java Sort.java
java/src/org/apache/xalan/xsltc/dom Tag: XSLTC_DTM
NodeSortRecord.java
java/src/org/apache/xalan/xsltc/runtime Tag: XSLTC_DTM
SAXAdapter.java
java/src/org/apache/xpath/axes Tag: XSLTC_DTM
OneStepIterator.java PredicatedNodeTest.java
java/src/org/apache/xpath/functions Tag: XSLTC_DTM
FuncExtFunction.java
test Tag: XSLTC_DTM build.xml
Log:
Bringing XSLTC_DTM branch up-to-date with changes from MAIN branch.
Revision Changes Path
No revision
No revision
1.176.2.3 +8 -3 xml-xalan/java/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/xml-xalan/java/build.xml,v
retrieving revision 1.176.2.2
retrieving revision 1.176.2.3
diff -u -r1.176.2.2 -r1.176.2.3
--- build.xml 5 Nov 2002 10:41:31 -0000 1.176.2.2
+++ build.xml 26 Nov 2002 20:26:24 -0000 1.176.2.3
@@ -639,7 +639,12 @@
destdir="${build.samples}" excludes="${exclude}"
debug="${build.debug}" bootclasspathref="xslt.boot.class.path" >
<classpath refid="samples.class.path" />
- </javac>
+ </javac>
+ <javac srcdir="${samples.dir}/ApplyXPathDOM"
+ destdir="${build.samples}" excludes="${exclude}"
+ debug="${build.debug}" bootclasspathref="xslt.boot.class.path" >
+ <classpath refid="samples.class.path" />
+ </javac>
<javac srcdir="${samples.dir}/trax"
destdir="${build.samples}" excludes="${exclude}"
debug="${build.debug}" bootclasspathref="xslt.boot.class.path" >
No revision
No revision
1.14.12.1 +16 -0
xml-xalan/java/src/org/apache/xalan/extensions/ExtensionHandler.java
Index: ExtensionHandler.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/extensions/ExtensionHandler.java,v
retrieving revision 1.14
retrieving revision 1.14.12.1
diff -u -r1.14 -r1.14.12.1
--- ExtensionHandler.java 12 Jun 2001 19:14:32 -0000 1.14
+++ ExtensionHandler.java 26 Nov 2002 20:26:25 -0000 1.14.12.1
@@ -69,6 +69,7 @@
import org.apache.xalan.templates.Stylesheet;
import org.apache.xalan.templates.ElemTemplateElement;
import org.apache.xml.utils.QName;
+import org.apache.xpath.functions.FuncExtFunction;
// Temp??
import org.apache.xalan.transformer.TransformerImpl;
@@ -193,6 +194,21 @@
*/
public abstract Object callFunction(
String funcName, Vector args, Object methodKey,
+ ExpressionContext exprContext) throws TransformerException;
+
+ /**
+ * Process a call to a function.
+ *
+ * @param extFunction The XPath extension function.
+ * @param args The arguments of the function call.
+ * @param exprContext The context in which this expression is being
executed.
+ *
+ * @return the return value of the function evaluation.
+ *
+ * @throws TransformerException if parsing trouble
+ */
+ public abstract Object callFunction(
+ FuncExtFunction extFunction, Vector args,
ExpressionContext exprContext) throws TransformerException;
/**
1.15.10.1 +19 -0
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.15
retrieving revision 1.15.10.1
diff -u -r1.15 -r1.15.10.1
--- ExtensionHandlerGeneral.java 31 Jul 2001 21:33:14 -0000 1.15
+++ ExtensionHandlerGeneral.java 26 Nov 2002 20:26:25 -0000
1.15.10.1
@@ -81,6 +81,7 @@
// Temp??
import org.apache.xalan.transformer.TransformerImpl;
import org.apache.xpath.objects.XObject;
+import org.apache.xpath.functions.FuncExtFunction;
import org.apache.xpath.XPathProcessorException;
import org.apache.xml.utils.StringVector;
@@ -385,6 +386,24 @@
//+ " because of: " + e);
}
}
+ }
+
+ /**
+ * Process a call to an XPath extension function
+ *
+ * @param extFunction The XPath extension function
+ * @param args The arguments of the function call.
+ * @param exprContext The context in which this expression is being
executed.
+ * @return the return value of the function evaluation.
+ * @throws TransformerException
+ */
+ public Object callFunction(FuncExtFunction extFunction,
+ Vector args,
+ ExpressionContext exprContext)
+ throws TransformerException
+ {
+ return callFunction(extFunction.getFunctionName(), args,
+ extFunction.getMethodKey(), exprContext);
}
/**
1.10.12.4 +19 -2
xml-xalan/java/src/org/apache/xalan/extensions/ExtensionHandlerJavaClass.java
Index: ExtensionHandlerJavaClass.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/extensions/ExtensionHandlerJavaClass.java,v
retrieving revision 1.10.12.3
retrieving revision 1.10.12.4
diff -u -r1.10.12.3 -r1.10.12.4
--- ExtensionHandlerJavaClass.java 5 Nov 2002 10:41:31 -0000
1.10.12.3
+++ ExtensionHandlerJavaClass.java 26 Nov 2002 20:26:25 -0000
1.10.12.4
@@ -72,6 +72,7 @@
import org.apache.xml.utils.QName;
import org.apache.xpath.objects.XObject;
+import org.apache.xpath.functions.FuncExtFunction;
import javax.xml.transform.TransformerException;
/**
@@ -178,8 +179,7 @@
}
return false;
}
-
-
+
/**
* Process a call to a function in the java class represented by
* this <code>ExtensionHandlerJavaClass<code>.
@@ -377,6 +377,23 @@
}
}
+ /**
+ * Process a call to an XPath extension function
+ *
+ * @param extFunction The XPath extension function
+ * @param args The arguments of the function call.
+ * @param exprContext The context in which this expression is being
executed.
+ * @return the return value of the function evaluation.
+ * @throws TransformerException
+ */
+ public Object callFunction(FuncExtFunction extFunction,
+ Vector args,
+ ExpressionContext exprContext)
+ throws TransformerException
+ {
+ return callFunction(extFunction.getFunctionName(), args,
+ extFunction.getMethodKey(), exprContext);
+ }
/**
* Process a call to this extension namespace via an element. As a side
1.11.10.3 +18 -0
xml-xalan/java/src/org/apache/xalan/extensions/ExtensionHandlerJavaPackage.java
Index: ExtensionHandlerJavaPackage.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/extensions/ExtensionHandlerJavaPackage.java,v
retrieving revision 1.11.10.2
retrieving revision 1.11.10.3
diff -u -r1.11.10.2 -r1.11.10.3
--- ExtensionHandlerJavaPackage.java 5 Nov 2002 10:41:31 -0000
1.11.10.2
+++ ExtensionHandlerJavaPackage.java 26 Nov 2002 20:26:25 -0000
1.11.10.3
@@ -77,6 +77,7 @@
import org.apache.xml.utils.QName;
import org.apache.xpath.objects.XObject;
+import org.apache.xpath.functions.FuncExtFunction;
import javax.xml.transform.TransformerException;
/**
@@ -412,6 +413,23 @@
}
}
+ /**
+ * Process a call to an XPath extension function
+ *
+ * @param extFunction The XPath extension function
+ * @param args The arguments of the function call.
+ * @param exprContext The context in which this expression is being
executed.
+ * @return the return value of the function evaluation.
+ * @throws TransformerException
+ */
+ public Object callFunction(FuncExtFunction extFunction,
+ Vector args,
+ ExpressionContext exprContext)
+ throws TransformerException
+ {
+ return callFunction(extFunction.getFunctionName(), args,
+ extFunction.getMethodKey(), exprContext);
+ }
/**
* Process a call to this extension namespace via an element. As a side
1.18.2.2 +47 -0
xml-xalan/java/src/org/apache/xalan/extensions/ExtensionsTable.java
Index: ExtensionsTable.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/extensions/ExtensionsTable.java,v
retrieving revision 1.18.2.1
retrieving revision 1.18.2.2
diff -u -r1.18.2.1 -r1.18.2.2
--- ExtensionsTable.java 29 Jul 2002 00:01:17 -0000 1.18.2.1
+++ ExtensionsTable.java 26 Nov 2002 20:26:25 -0000 1.18.2.2
@@ -62,6 +62,7 @@
import org.apache.xpath.objects.XNull;
import org.apache.xpath.XPathProcessorException;
+import org.apache.xpath.functions.FuncExtFunction;
import org.apache.xalan.res.XSLMessages;
import org.apache.xalan.res.XSLTErrorResources;
@@ -243,5 +244,51 @@
}
}
return result;
+ }
+
+ /**
+ * Handle an extension function.
+ * @param extFunction the extension function
+ * @param argVec arguments to the function in a vector
+ * @param exprContext a context which may be passed to an extension
function
+ * and provides callback functions to access various
+ * areas in the environment
+ *
+ * @return result of executing the function
+ *
+ * @throws javax.xml.transform.TransformerException
+ */
+ public Object extFunction(FuncExtFunction extFunction, Vector argVec,
+ ExpressionContext exprContext)
+ throws javax.xml.transform.TransformerException
+ {
+ Object result = null;
+ String ns = extFunction.getNamespace();
+ if (null != ns)
+ {
+ ExtensionHandler extNS =
+ (ExtensionHandler) m_extensionFunctionNamespaces.get(ns);
+ if (null != extNS)
+ {
+ try
+ {
+ result = extNS.callFunction(extFunction, argVec, exprContext);
+ }
+ catch (javax.xml.transform.TransformerException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ throw new javax.xml.transform.TransformerException(e);
+ }
+ }
+ else
+ {
+ throw new
XPathProcessorException(XSLMessages.createMessage(XSLTErrorResources.ER_EXTENSION_FUNC_UNKNOWN,
+ new Object[]{ns,
extFunction.getFunctionName()}));
+ }
+ }
+ return result;
}
}
No revision
No revision
1.2.2.3 +1 -29 xml-xalan/java/src/org/apache/xalan/lib/ExsltCommon.java
Index: ExsltCommon.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/lib/ExsltCommon.java,v
retrieving revision 1.2.2.2
retrieving revision 1.2.2.3
diff -u -r1.2.2.2 -r1.2.2.3
--- ExsltCommon.java 1 Aug 2002 19:55:30 -0000 1.2.2.2
+++ ExsltCommon.java 26 Nov 2002 20:26:25 -0000 1.2.2.3
@@ -56,38 +56,10 @@
*/
package org.apache.xalan.lib;
-import org.w3c.dom.Node;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentFragment;
-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;
-import org.apache.xpath.objects.XNumber;
-import org.apache.xpath.objects.XRTreeFrag;
-
-import org.apache.xpath.XPath;
-import org.apache.xpath.XPathContext;
-import org.apache.xpath.DOMHelper;
import org.apache.xml.dtm.DTMIterator;
-import org.apache.xml.dtm.DTM;
import org.apache.xml.dtm.ref.DTMNodeIterator;
-import org.apache.xml.utils.XMLString;
-
-import org.xml.sax.SAXNotSupportedException;
-
-import java.util.Hashtable;
-import java.util.StringTokenizer;
-
+import org.apache.xpath.NodeSet;
import org.apache.xalan.extensions.ExpressionContext;
-import org.apache.xalan.res.XSLMessages;
-import org.apache.xalan.res.XSLTErrorResources;
-import org.apache.xalan.xslt.EnvironmentCheck;
-
-import javax.xml.parsers.*;
/**
* <meta name="usage" content="general"/>
1.17.2.5 +16 -6 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.17.2.4
retrieving revision 1.17.2.5
diff -u -r1.17.2.4 -r1.17.2.5
--- Extensions.java 18 Sep 2002 13:31:51 -0000 1.17.2.4
+++ Extensions.java 26 Nov 2002 20:26:25 -0000 1.17.2.5
@@ -93,7 +93,8 @@
{
// Reuse the Document object to reduce memory usage.
- private static Document lDoc = null;
+ private static Document m_doc = null;
+ private static Extensions m_instance = new Extensions();
/**
* Constructor Extensions
@@ -289,11 +290,17 @@
*/
public static NodeList tokenize(String toTokenize, String delims)
{
-
try
{
- if (lDoc == null)
- lDoc =
DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+ // Lock the instance to ensure thread safety
+ if (m_doc == null)
+ {
+ synchronized (m_instance)
+ {
+ if (m_doc == null)
+ m_doc =
DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+ }
+ }
}
catch(ParserConfigurationException pce)
{
@@ -303,9 +310,12 @@
StringTokenizer lTokenizer = new StringTokenizer(toTokenize, delims);
NodeSet resultSet = new NodeSet();
- while (lTokenizer.hasMoreTokens())
+ synchronized (m_doc)
{
- resultSet.addNode(lDoc.createTextNode(lTokenizer.nextToken()));
+ while (lTokenizer.hasMoreTokens())
+ {
+ resultSet.addNode(m_doc.createTextNode(lTokenizer.nextToken()));
+ }
}
return resultSet;
No revision
No revision
1.50.2.3 +13 -30
xml-xalan/java/src/org/apache/xalan/processor/StylesheetHandler.java
Index: StylesheetHandler.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/processor/StylesheetHandler.java,v
retrieving revision 1.50.2.2
retrieving revision 1.50.2.3
diff -u -r1.50.2.2 -r1.50.2.3
--- StylesheetHandler.java 22 Oct 2002 14:52:34 -0000 1.50.2.2
+++ StylesheetHandler.java 26 Nov 2002 20:26:26 -0000 1.50.2.3
@@ -117,6 +117,19 @@
implements TemplatesHandler, PrefixResolver, NodeConsumer
{
+
+ static {
+ Function func = new org.apache.xalan.templates.FuncDocument();
+
+ FunctionTable.installFunction("document", func);
+
+ // func = new org.apache.xalan.templates.FuncKey();
+ // FunctionTable.installFunction("key", func);
+ func = new org.apache.xalan.templates.FuncFormatNumb();
+
+ FunctionTable.installFunction("format-number", func);
+
+ }
/**
* Create a StylesheetHandler object, creating a root stylesheet
* as the target.
@@ -135,42 +148,12 @@
}
/**
- * Static flag to let us know if the XPath functions table
- * has been initialized.
- */
- private static boolean m_xpathFunctionsInited = false;
-
- /**
* Do common initialization.
*
* @param processor non-null reference to the transformer factory that
owns this handler.
*/
void init(TransformerFactoryImpl processor)
{
-
- // Not sure about double-check of this flag, but
- // it seems safe...
- if (false == m_xpathFunctionsInited)
- {
- synchronized (this)
- {
- if (false == m_xpathFunctionsInited)
- {
- m_xpathFunctionsInited = true;
-
- Function func = new org.apache.xalan.templates.FuncDocument();
-
- FunctionTable.installFunction("document", func);
-
- // func = new org.apache.xalan.templates.FuncKey();
- // FunctionTable.installFunction("key", func);
- func = new org.apache.xalan.templates.FuncFormatNumb();
-
- FunctionTable.installFunction("format-number", func);
- }
- }
- }
-
m_stylesheetProcessor = processor;
// Set the initial content handler.
No revision
No revision
1.8.10.4 +23 -8
xml-xalan/java/src/org/apache/xalan/serialize/Encodings.java
Index: Encodings.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/serialize/Encodings.java,v
retrieving revision 1.8.10.3
retrieving revision 1.8.10.4
diff -u -r1.8.10.3 -r1.8.10.4
--- Encodings.java 5 Nov 2002 10:41:33 -0000 1.8.10.3
+++ Encodings.java 26 Nov 2002 20:26:26 -0000 1.8.10.4
@@ -66,6 +66,7 @@
import java.util.Enumeration;
import java.util.Properties;
+import java.util.StringTokenizer;
/**
* Provides information about encodings. Depends on the Java runtime
@@ -382,8 +383,20 @@
}
int totalEntries = props.size();
- EncodingInfo[] ret = new EncodingInfo[totalEntries];
+ int totalMimeNames = 0;
Enumeration keys = props.keys();
+ for (int i = 0; i < totalEntries; ++i) {
+ String javaName = (String) keys.nextElement();
+ String val = props.getProperty(javaName);
+ totalMimeNames++;
+ int pos = val.indexOf(' ');
+ for (int j = 0; j < pos; ++j)
+ if (val.charAt(j) == ',')
+ totalMimeNames++;
+ }
+ EncodingInfo[] ret = new EncodingInfo[totalMimeNames];
+ int j = 0;
+ keys = props.keys();
for (int i = 0; i < totalEntries; ++i) {
String javaName = (String) keys.nextElement();
String val = props.getProperty(javaName);
@@ -399,12 +412,14 @@
lastPrintable = 0x00FF;
}
else
- {
- mimeName = val.substring(0, pos);
- lastPrintable =
-
Integer.decode(val.substring(pos).trim()).intValue();
- }
- ret [i] = new EncodingInfo (mimeName, javaName, lastPrintable);
+ {
+ lastPrintable =
Integer.decode(val.substring(pos).trim()).intValue();
+ StringTokenizer st = new StringTokenizer(val.substring(0,
pos),",");
+ while (st.hasMoreTokens()) {
+ mimeName = st.nextToken();
+ ret [j++] = new EncodingInfo (mimeName, javaName,
lastPrintable);
+ }
+ }
}
return ret;
} catch (java.net.MalformedURLException mue) {
No revision
No revision
1.20.10.3 +61 -7
xml-xalan/java/src/org/apache/xalan/templates/OutputProperties.java
Index: OutputProperties.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/OutputProperties.java,v
retrieving revision 1.20.10.2
retrieving revision 1.20.10.3
diff -u -r1.20.10.2 -r1.20.10.3
--- OutputProperties.java 4 Oct 2002 09:24:45 -0000 1.20.10.2
+++ OutputProperties.java 26 Nov 2002 20:26:26 -0000 1.20.10.3
@@ -189,7 +189,7 @@
* @param resourceName non-null reference to resource name.
* @param defaults Default properties, which may be null.
*/
- static private Properties loadPropertiesFile(String resourceName,
Properties defaults)
+ static private Properties loadPropertiesFile(final String resourceName,
Properties defaults)
throws IOException
{
@@ -201,19 +201,73 @@
InputStream is = null;
BufferedInputStream bis = null;
+ Class accessControllerClass = null;
try {
try {
- java.lang.reflect.Method getCCL =
Thread.class.getMethod("getContextClassLoader", NO_CLASSES);
- if (getCCL != null) {
- ClassLoader contextClassLoader = (ClassLoader)
getCCL.invoke(Thread.currentThread(), NO_OBJS);
- is =
contextClassLoader.getResourceAsStream("org/apache/xalan/templates/" +
resourceName);
- }
+ try {
+
+ // This Class was introduced in JDK 1.2. With the re-architecture of
+ // security mechanism ( starting in JDK 1.2 ), we have option of
+ // giving privileges to certain part of code using doPrivileged block.
+ // In JDK1.1.X applications won't be having security manager and if
+ // there is security manager ( in applets ), code need to be signed
+ // and trusted for having access to resources.
+
+
accessControllerClass=Class.forName("java.security.AccessController");
+
+ // If we are here means user is using JDK >= 1.2.
+ // Using doPrivileged to be able to read property file without opening
+ // up secured container permissions like J2EE container
+
+ is =(InputStream)java.security.AccessController.doPrivileged (
+ new java.security.PrivilegedAction() {
+
+ public Object run() {
+ try {
+ java.lang.reflect.Method getCCL = Thread.class.getMethod(
+ "getContextClassLoader", NO_CLASSES);
+ if (getCCL != null) {
+ ClassLoader contextClassLoader = (ClassLoader)
+ getCCL.invoke(Thread.currentThread(), NO_OBJS);
+ return ( contextClassLoader.getResourceAsStream (
+ "org/apache/xalan/templates/" + resourceName) );
+ }
+ } catch ( Exception e ) { }
+
+ return null;
+
+ }
+ });
+ } catch ( ClassNotFoundException e ) {
+ //User may be using older JDK ( JDK <1.2 ). Allow him/her to use it.
+ // But don't try to use doPrivileged
+ try {
+ java.lang.reflect.Method getCCL = Thread.class.getMethod(
+ "getContextClassLoader", NO_CLASSES);
+ if (getCCL != null) {
+ ClassLoader contextClassLoader = (ClassLoader)
+ getCCL.invoke(Thread.currentThread(), NO_OBJS);
+ is = contextClassLoader.getResourceAsStream (
+ "org/apache/xalan/templates/" + resourceName );
+ }
+ } catch ( Exception exception ) { }
+ }
}
catch (Exception e) {}
if ( is == null ) {
- is = OutputProperties.class.getResourceAsStream(resourceName);
+ if ( accessControllerClass != null ) {
+ is=(InputStream)java.security.AccessController.doPrivileged(
+ new java.security.PrivilegedAction(){
+ public Object run() {
+ return
OutputProperties.class.getResourceAsStream(resourceName);
+ }
+ });
+ } else {
+ // User may be using older JDK ( JDK < 1.2 )
+ is = OutputProperties.class.getResourceAsStream(resourceName);
+ }
}
bis = new BufferedInputStream(is);
No revision
No revision
1.131.2.5 +8 -0
xml-xalan/java/src/org/apache/xalan/transformer/TransformerImpl.java
Index: TransformerImpl.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/TransformerImpl.java,v
retrieving revision 1.131.2.4
retrieving revision 1.131.2.5
diff -u -r1.131.2.4 -r1.131.2.5
--- TransformerImpl.java 5 Nov 2002 10:41:34 -0000 1.131.2.4
+++ TransformerImpl.java 26 Nov 2002 20:26:26 -0000 1.131.2.5
@@ -134,6 +134,7 @@
//dml
import org.apache.xpath.ExtensionsProvider;
import org.apache.xalan.extensions.ExtensionsTable;
+import org.apache.xpath.functions.FuncExtFunction;
/**
* <meta name="usage" content="advanced"/>
@@ -461,6 +462,13 @@
return getExtensionsTable().extFunction(ns, funcName,
argVec, methodKey,
getXPathContext().getExpressionContext());
+ }
+
+ public Object extFunction(FuncExtFunction extFunction, Vector argVec)
+ throws javax.xml.transform.TransformerException
+ {
+ return getExtensionsTable().extFunction(extFunction, argVec,
+
getXPathContext().getExpressionContext());
}
//=========================
No revision
No revision
1.19.2.9 +3 -1
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Constants.java
Index: Constants.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Constants.java,v
retrieving revision 1.19.2.8
retrieving revision 1.19.2.9
diff -u -r1.19.2.8 -r1.19.2.9
--- Constants.java 13 Nov 2002 17:03:13 -0000 1.19.2.8
+++ Constants.java 26 Nov 2002 20:26:27 -0000 1.19.2.9
@@ -169,6 +169,8 @@
= "Lorg/apache/xalan/xsltc/dom/NodeSortRecord;";
public static final String NODE_SORT_FACTORY_SIG
= "Lorg/apache/xalan/xsltc/dom/NodeSortRecordFactory;";
+ public static final String LOCALE_SIG
+ = "Ljava/util/Locale;";
public static final String STRING_VALUE_HANDLER
= "org.apache.xalan.xsltc.runtime.StringValueHandler";
public static final String STRING_VALUE_HANDLER_SIG
1.14.6.4 +38 -69
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Sort.java
Index: Sort.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Sort.java,v
retrieving revision 1.14.6.3
retrieving revision 1.14.6.4
diff -u -r1.14.6.3 -r1.14.6.4
--- Sort.java 5 Nov 2002 10:41:38 -0000 1.14.6.3
+++ Sort.java 26 Nov 2002 20:26:27 -0000 1.14.6.4
@@ -560,46 +560,38 @@
}
}
- Method clinit = compileClassInit(sortObjects, sortRecord,
+ Method init = compileInit(sortObjects, sortRecord,
cpg, className);
Method extract = compileExtract(sortObjects, sortRecord,
cpg, className);
- sortRecord.addMethod(clinit);
- sortRecord.addEmptyConstructor(ACC_PUBLIC);
+ sortRecord.addMethod(init);
sortRecord.addMethod(extract);
- // Overload NodeSortRecord.getCollator() only if needed
- for (int i = 0; i < sortObjects.size(); i++) {
- if (((Sort)(sortObjects.elementAt(i)))._lang != null) {
- sortRecord.addMethod(compileGetCollator(sortObjects,
- sortRecord,
- cpg,
- className));
- i = sortObjects.size();
- }
- }
-
xsltc.dumpClass(sortRecord.getJavaClass());
return className;
}
/**
- * Create a class constructor for the new class. All this constructor
does
- * is to initialize a couple of tables that contain information on sort
- * order and sort type. These static tables cannot be in the parent
class.
+ * Create a constructor for the new class. Updates the reference to the
+ * collator in the super calls only when the stylesheet specifies a new
+ * language in xsl:sort.
*/
- private static Method compileClassInit(Vector sortObjects,
+ private static Method compileInit(Vector sortObjects,
NodeSortRecordGenerator sortRecord,
ConstantPoolGen cpg,
- String className) {
- // Class initializer - void NodeSortRecord.<clinit>();
+ String className)
+ {
final InstructionList il = new InstructionList();
- final CompareGenerator classInit =
- new CompareGenerator(ACC_PUBLIC | ACC_STATIC,
- org.apache.bcel.generic.Type.VOID,
- new org.apache.bcel.generic.Type[] { },
- new String[] { },
- "<clinit>", className, il, cpg);
+ final MethodGenerator init =
+ new MethodGenerator(ACC_PUBLIC,
+ org.apache.bcel.generic.Type.VOID,
+ null, null, "<init>", className,
+ il, cpg);
+
+ // Call the constructor in the NodeSortRecord superclass
+ il.append(ALOAD_0);
+ il.append(new INVOKESPECIAL(cpg.addMethodref(NODE_SORT_RECORD,
+ "<init>", "()V")));
final int initLocale = cpg.addMethodref("java/util/Locale",
"<init>",
@@ -628,41 +620,50 @@
Sort sort = (Sort)sortObjects.elementAt(0);
for (int level = 0; level < levels; level++) {
- if (language == null && sort._lang != null)
+ if (language == null && sort._lang != null) {
language = sort._lang;
- if (country == null && sort._country != null)
+ }
+ if (country == null && sort._country != null) {
country = sort._country;
+ }
}
- // Get index to private static reference in NodeSortRecrd
final int collator =
cpg.addFieldref(className, "_collator", COLLATOR_SIG);
+ final int locale =
+ cpg.addFieldref(className, "_locale", LOCALE_SIG);
if (language != null) {
// Create new Locale object on stack
il.append(new NEW(cpg.addClass("java/util/Locale")));
il.append(DUP);
+ il.append(DUP);
il.append(new PUSH(cpg, language));
il.append(new PUSH(cpg, (country != null ? country : EMPTYSTRING)));
il.append(new INVOKESPECIAL(initLocale));
+ il.append(ALOAD_0);
+ il.append(SWAP);
+ il.append(new PUTFIELD(locale));
// Use that Locale object to get the required Collator object
il.append(new INVOKESTATIC(getCollator));
- il.append(new PUTSTATIC(collator));
+ il.append(ALOAD_0);
+ il.append(SWAP);
+ il.append(new PUTFIELD(collator));
}
- il.append(new GETSTATIC(collator));
+ il.append(ALOAD_0);
+ il.append(new GETFIELD(collator));
il.append(new ICONST(Collator.TERTIARY));
il.append(new INVOKEVIRTUAL(setStrength));
il.append(RETURN);
- classInit.stripAttributes(true);
- classInit.setMaxLocals();
- classInit.setMaxStack();
- classInit.removeNOPs();
+ init.stripAttributes(true);
+ init.setMaxLocals();
+ init.setMaxStack();
- return classInit.getMethod();
+ return init.getMethod();
}
@@ -732,37 +733,5 @@
extractMethod.removeNOPs();
return extractMethod.getMethod();
- }
-
- /**
- * Compiles a method that overloads NodeSortRecord.getCollator()
- * This method is only compiled if the "lang" attribute is used.
- */
- private static Method compileGetCollator(Vector sortObjects,
- NodeSortRecordGenerator sortRecord,
- ConstantPoolGen cpg,
- String className) {
- final InstructionList il = new InstructionList();
- // Collator NodeSortRecord.getCollator();
- final MethodGenerator getCollator =
- new MethodGenerator(ACC_PUBLIC | ACC_FINAL,
- Util.getJCRefType(COLLATOR_SIG),
- new org.apache.bcel.generic.Type[] {},
- new String[] { },
- "getCollator", className, il, cpg);
-
- // Get index to private static reference in NodeSortRecrd
- final int collator =
- cpg.addFieldref(className, "collator", COLLATOR_SIG);
- // Feck the Collator object on the stack and return it
- il.append(new GETSTATIC(collator));
- il.append(ARETURN);
-
- getCollator.stripAttributes(true);
- getCollator.setMaxLocals();
- getCollator.setMaxStack();
- getCollator.removeNOPs();
-
- return getCollator.getMethod();
}
}
No revision
No revision
1.8.10.1 +13 -2
xml-xalan/java/src/org/apache/xalan/xsltc/dom/NodeSortRecord.java
Index: NodeSortRecord.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/NodeSortRecord.java,v
retrieving revision 1.8
retrieving revision 1.8.10.1
diff -u -r1.8 -r1.8.10.1
--- NodeSortRecord.java 29 Nov 2001 09:49:35 -0000 1.8
+++ NodeSortRecord.java 26 Nov 2002 20:26:27 -0000 1.8.10.1
@@ -65,6 +65,7 @@
package org.apache.xalan.xsltc.dom;
import java.util.Vector;
+import java.util.Locale;
import java.text.Collator;
import java.text.CollationKey;
@@ -81,7 +82,17 @@
public static int COMPARE_ASCENDING = 0;
public static int COMPARE_DESCENDING = 1;
- protected static Collator _collator = Collator.getInstance();
+ /**
+ * A reference to a locale. May be updated by subclass if the stylesheet
+ * specifies a different language.
+ */
+ protected Locale _locale = Locale.getDefault();
+
+ /**
+ * A reference to a collator. May be updated by subclass if the
stylesheet
+ * specifies a different language (will be updated iff _locale is
updated).
+ */
+ protected Collator _collator = Collator.getInstance();
protected int _levels = 1;
protected int[] _compareType;
No revision
No revision
1.10.2.6 +20 -4
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/SAXAdapter.java
Index: SAXAdapter.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/SAXAdapter.java,v
retrieving revision 1.10.2.5
retrieving revision 1.10.2.6
diff -u -r1.10.2.5 -r1.10.2.6
--- SAXAdapter.java 5 Nov 2002 10:41:47 -0000 1.10.2.5
+++ SAXAdapter.java 26 Nov 2002 20:26:27 -0000 1.10.2.6
@@ -72,9 +72,19 @@
public final class SAXAdapter implements TransletOutputHandler {
+ /**
+ * Reference to DOMBuilder that receives the SAX2 events.
+ */
private final DOMBuilder _domBuilder;
+
+ /**
+ * AttributeList object reused for each element.
+ */
private final AttributeList _attributes = new AttributeList();
+ /**
+ * Name of last element seen but not yet reported.
+ */
private String _openElementName;
public SAXAdapter(DOMBuilder domBuilder) {
@@ -159,9 +169,15 @@
}
}
- public void namespace(String prefix, String uri)
- throws TransletException {
- // ???
+ public void namespace(String prefix, String uri) throws
TransletException
+ {
+ try {
+ // TODO: housekeeping necessary to emit endPrefixMapping()
+ _domBuilder.startPrefixMapping(prefix, uri);
+ }
+ catch (SAXException e) {
+ throw new TransletException(e);
+ }
}
public void comment(String comment) throws TransletException {
No revision
No revision
1.8.2.1 +57 -0
xml-xalan/java/src/org/apache/xpath/axes/OneStepIterator.java
Index: OneStepIterator.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xpath/axes/OneStepIterator.java,v
retrieving revision 1.8
retrieving revision 1.8.2.1
diff -u -r1.8 -r1.8.2.1
--- OneStepIterator.java 22 Mar 2002 01:04:43 -0000 1.8
+++ OneStepIterator.java 26 Nov 2002 20:26:27 -0000 1.8.2.1
@@ -196,6 +196,63 @@
}
/**
+ * The number of nodes in the list. The range of valid child node indices
+ * is 0 to <code>length-1</code> inclusive.
+ *
+ * @return The number of nodes in the list, always greater or equal to
zero.
+ */
+ public int getLength()
+ {
+ if(!isReverseAxes())
+ return super.getLength();
+
+ // Tell if this is being called from within a predicate.
+ boolean isPredicateTest = (this == m_execContext.getSubContextList());
+
+ // And get how many total predicates are part of this step.
+ int predCount = getPredicateCount();
+
+ // If we have already calculated the length, and the current predicate
+ // is the first predicate, then return the length. We don't cache
+ // the anything but the length of the list to the first predicate.
+ if (-1 != m_length && isPredicateTest && m_predicateIndex < 1)
+ return m_length;
+
+ int count = 0;
+
+ XPathContext xctxt = getXPathContext();
+ try
+ {
+ OneStepIterator clone = (OneStepIterator) this.cloneWithReset();
+
+ int root = getRoot();
+ xctxt.pushCurrentNode(root);
+ clone.setRoot(root, xctxt);
+
+ clone.m_predCount = m_predicateIndex;
+
+ int next;
+
+ while (DTM.NULL != (next = clone.nextNode()))
+ {
+ count++;
+ }
+ }
+ catch (CloneNotSupportedException cnse)
+ {
+ // can't happen
+ }
+ finally
+ {
+ xctxt.popCurrentNode();
+ }
+ if (isPredicateTest && m_predicateIndex < 1)
+ m_length = count;
+
+ return count;
+ }
+
+ /**
* Count backwards one proximity position.
*
* @param i The predicate index.
1.10.2.2 +6 -1
xml-xalan/java/src/org/apache/xpath/axes/PredicatedNodeTest.java
Index: PredicatedNodeTest.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xpath/axes/PredicatedNodeTest.java,v
retrieving revision 1.10.2.1
retrieving revision 1.10.2.2
diff -u -r1.10.2.1 -r1.10.2.2
--- PredicatedNodeTest.java 29 Jul 2002 00:01:32 -0000 1.10.2.1
+++ PredicatedNodeTest.java 26 Nov 2002 20:26:27 -0000 1.10.2.2
@@ -361,7 +361,12 @@
// course of itteration, then we know there can be no more true
// occurances of this predicate, so flag that we're done after
// this.
- if(m_predicates[i].isStableNumber())
+ //
+ // bugzilla 14365
+ // We can't set m_foundLast = true unless we're sure that -all-
+ // remaining parameters are stable, or else last() fails. Fixed so
+ // only sets m_foundLast if on the last predicate
+ if(m_predicates[i].isStableNumber() && i == nPredicates - 1)
{
m_foundLast = true;
}
No revision
No revision
1.14.2.4 +11 -4
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.14.2.3
retrieving revision 1.14.2.4
diff -u -r1.14.2.3 -r1.14.2.4
--- FuncExtFunction.java 4 Oct 2002 09:24:47 -0000 1.14.2.3
+++ FuncExtFunction.java 26 Nov 2002 20:26:27 -0000 1.14.2.4
@@ -65,8 +65,6 @@
import org.apache.xpath.XPathVisitor;
import org.apache.xpath.ExtensionsProvider;
import org.apache.xpath.objects.*;
-import org.apache.xalan.transformer.TransformerImpl;
-import org.apache.xalan.extensions.ExtensionsTable;
import org.apache.xml.dtm.DTMIterator;
//import org.w3c.dom.Node;
@@ -160,6 +158,16 @@
{
return m_extensionName;
}
+
+ /**
+ * Return the method key of the extension function.
+ *
+ * @return The method key of the extension function.
+ */
+ public Object getMethodKey()
+ {
+ return m_methodKey;
+ }
/**
* Return the nth argument passed to the extension function.
@@ -230,8 +238,7 @@
}
//dml
ExtensionsProvider extProvider =
(ExtensionsProvider)xctxt.getOwnerObject();
- Object val = extProvider.extFunction(m_namespace, m_extensionName,
- argVec, m_methodKey);
+ Object val = extProvider.extFunction(this, argVec);
if (null != val)
{
No revision
No revision
1.53.2.4 +23 -2 xml-xalan/test/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/xml-xalan/test/build.xml,v
retrieving revision 1.53.2.3
retrieving revision 1.53.2.4
diff -u -r1.53.2.3 -r1.53.2.4
--- build.xml 5 Nov 2002 10:41:50 -0000 1.53.2.3
+++ build.xml 26 Nov 2002 20:26:27 -0000 1.53.2.4
@@ -151,6 +151,16 @@
<pathelement location="${jtidy.jar}" />
</path>
+ <!-- Boot class path for JDK 1.4. Order is important to ensure
+ GUMP builds work correctly, and people who don't use the
+ build.bat/build.sh can still build on JDK 1.4 as normal. -->
+ <path id="boot.class.path">
+ <pathelement location="${xalan.jar}" />
+ <pathelement location="${java.class.path}" />
+ <pathelement location="${xml-apis.jar}" />
+ <pathelement location="${parserjar}" />
+ </path>
+
<!-- Classpath used when running perf or performance tests -->
<path id="perf.class.path">
<path refid="conf.class.path" />
@@ -247,6 +257,7 @@
<xalantest test="${testClass}"
testType="${testType}"
classpathref="conf.class.path"
+ bootclasspathref="boot.class.path"
fork="${fork-tests}"
failonerror="${fail-on-error}" />
<antcall target="scan">
@@ -283,6 +294,7 @@
<xalantest test="${testClass}"
testType="${testType}"
classpathref="conf.class.path"
+ bootclasspathref="boot.class.path"
fork="${fork-tests}"
failonerror="${fail-on-error}" />
<antcall target="scan">
@@ -301,6 +313,7 @@
<xalantest test="${testClass}"
testType="${testType}"
classpathref="perf.class.path"
+ bootclasspathref="boot.class.path"
fork="${fork-tests}"
failonerror="${fail-on-error}" />
<antcall target="scan">
@@ -319,6 +332,7 @@
<xalantest test="${testClass}"
testType="${testType}"
classpathref="contrib.class.path"
+ bootclasspathref="boot.class.path"
fork="${fork-tests}"
failonerror="${fail-on-error}" />
<antcall target="scan">
@@ -338,6 +352,7 @@
<xalantest test="${testClass}"
testType="${testType}"
classpathref="api.class.path"
+ bootclasspathref="boot.class.path"
fork="${fork-tests}"
failonerror="${fail-on-error}" />
</target>
@@ -354,6 +369,7 @@
<xalantest test="${testClass}"
testType="${testType}"
classpathref="api.class.path"
+ bootclasspathref="boot.class.path"
fork="${fork-tests}"
failonerror="${fail-on-error}" />
<antcall target="scan">
@@ -388,6 +404,7 @@
<xalantest test="${testClass}"
testType="${testType}"
classpathref="bugzilla.class.path"
+ bootclasspathref="boot.class.path"
fork="${fork-tests}"
failonerror="${fail-on-error}" />
<echo message="If you got ClassNotFound, did you 'build
bugzilla.classes' first?" />
@@ -407,6 +424,7 @@
<xalantest test="${testClass}"
testType="${testType}"
classpathref="extensions.class.path"
+ bootclasspathref="boot.class.path"
fork="${fork-tests}"
failonerror="${fail-on-error}" />
<echo message="If you got ClassNotFound, did you 'build
extensions.classes' first?" />
@@ -1163,6 +1181,7 @@
<xalantest test="${testClass}"
testType="${testType}"
classpathref="xsltc.runtime.class.path"
+ bootclasspathref="boot.class.path"
fork="${fork-tests}"
failonerror="${fail-on-error}">
<!-- Explicitly set TransformerFactory property to use xsltc -->
@@ -1182,6 +1201,7 @@
<xalantest test="${testClass}"
testType="${testType}"
classpathref="xsltc.runtime.class.path"
+ bootclasspathref="boot.class.path"
fork="${fork-tests}"
failonerror="${fail-on-error}">
<!-- Explicitly set TransformerFactory property to use xsltc -->
@@ -1224,6 +1244,7 @@
<xalantest test="${testClass}"
testType="${testType}"
classpathref="xsltc.compile.class.path"
+ bootclasspathref="boot.class.path"
fork="${fork-tests}"
failonerror="${fail-on-error}">
<!-- Explicitly set TransformerFactory property to use xsltc -->
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]