You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by cu...@apache.org on 2001/02/08 22:02:21 UTC
cvs commit: xml-xalan/test/java/src/org/apache/qetest/xslwrapper LotusXSLWrapper.java
curcuru 01/02/08 13:02:19
Modified: test/java/src/org/apache/qetest/xslwrapper
LotusXSLWrapper.java
Log:
Updates for testing with Xalan-J 2.0.0 compatibility layer
Revision Changes Path
1.3 +85 -17 xml-xalan/test/java/src/org/apache/qetest/xslwrapper/LotusXSLWrapper.java
Index: LotusXSLWrapper.java
===================================================================
RCS file: /home/cvs/xml-xalan/test/java/src/org/apache/qetest/xslwrapper/LotusXSLWrapper.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- LotusXSLWrapper.java 2000/12/12 16:00:27 1.2
+++ LotusXSLWrapper.java 2001/02/08 21:02:12 1.3
@@ -63,7 +63,7 @@
package org.apache.qetest.xslwrapper;
import java.util.Vector;
-
+import java.lang.reflect.Field;
import java.io.PrintWriter;
// The LotusXSL implementation
@@ -71,13 +71,10 @@
import com.lotus.xsl.XSLTInputSource;
import com.lotus.xsl.XSLTResultTarget;
-// For the versioning string from Xalan
-import org.apache.xalan.xslt.XSLProcessorVersion;
-
/**
* Implementation of a ProcessorWrapper for LotusXSL.
* @author Shane Curcuru
- * @version $Id: LotusXSLWrapper.java,v 1.2 2000/12/12 16:00:27 curcuru Exp $
+ * @version $Id: LotusXSLWrapper.java,v 1.3 2001/02/08 21:02:12 curcuru Exp $
*/
public class LotusXSLWrapper extends ProcessorWrapper
{
@@ -88,6 +85,18 @@
/** Reference to current processor - LotusXSL flavor - convenience method. */
protected com.lotus.xsl.XSLProcessor processor = null;
+ /** FQCN of Xalan-J 1.x's version file. */
+ public static final String XALAN1_VERSION_CLASS = "org.apache.xalan.xslt.XSLProcessorVersion";
+
+ /** FQCN of Xalan-J 2.x's version file, when using the compatibility layer. */
+ public static final String XALAN2_VERSION_CLASS = "org.apache.xalan.processor.XSLProcessorVersion";
+
+ /** Marker string added to getDescription, when using the compatibility layer. */
+ public static final String XALAN2_MARKER = "-compat1";
+
+ /** FQCN of Xerces-J 1.x's version file, for convenience. */
+ public static final String XERCES1_VERSION_CLASS = "org.apache.xerces.framework.Version";
+
/**
* NEEDSDOC Method getLotusXSLProcessor
*
@@ -147,17 +156,72 @@
}
else
{
-
- // StringBuffer buf = new StringBuffer(XSLProcessorVersion.PRODUCT);
- StringBuffer buf = new StringBuffer("LotusXSL"); // Note that LotusXSL does not override the PRODUCT field
-
- buf.append(";");
- buf.append(XSLProcessorVersion.LANGUAGE);
- buf.append(";");
- buf.append(XSLProcessorVersion.S_VERSION);
- buf.append(";");
- buf.append(processor.getXMLProcessorLiaison());
-
+ StringBuffer buf = new StringBuffer("No Xalan version info found");
+ String parserVersion = new String("no-parser-info-avail");
+ Class clazz = null;
+ Field f = null;
+
+ // As a convenience, see if we can find the version
+ // of the parser we're using as well
+ try
+ {
+ // Currently, only check for Xerces versions
+ clazz = Class.forName(XERCES1_VERSION_CLASS);
+ // Found 1.x, grab it's version fields
+ f = clazz.getField("fVersion");
+ parserVersion = (String)f.get(null);
+ }
+ catch (Exception e2)
+ {
+ // no-op, leave value as-is
+ }
+
+ // Check for either 1.x or 2.x compatibility layer
+ try
+ {
+ clazz = Class.forName(XALAN1_VERSION_CLASS);
+ // Found 1.x, grab it's version fields
+ buf = new StringBuffer();
+ f = clazz.getField("PRODUCT");
+ buf.append(f.get(null));
+ buf.append(";");
+ f = clazz.getField("LANGUAGE");
+ buf.append(f.get(null));
+ buf.append(";");
+ f = clazz.getField("S_VERSION");
+ buf.append(f.get(null));
+ buf.append(";");
+ buf.append(processor.getXMLProcessorLiaison());
+ buf.append(";");
+ buf.append(parserVersion);
+ }
+ catch (Exception e1)
+ {
+ // Can't find 1.x, look for 2.x compat layer
+ try
+ {
+ clazz = Class.forName(XALAN2_VERSION_CLASS);
+ // Found 2.x, grab it's version fields
+ buf = new StringBuffer();
+ f = clazz.getField("PRODUCT");
+ buf.append(f.get(null));
+ buf.append(XALAN2_MARKER); // so user knows we're doing compatibility layer
+ buf.append(";");
+ f = clazz.getField("LANGUAGE");
+ buf.append(f.get(null));
+ buf.append(";");
+ f = clazz.getField("S_VERSION");
+ buf.append(f.get(null));
+ buf.append(";");
+ // Liaison info not applicable
+ buf.append(";");
+ buf.append(parserVersion);
+ }
+ catch (Exception e2)
+ {
+ // Can't find 2.x either, just bail
+ }
+ }
return buf.toString();
}
}
@@ -350,7 +414,11 @@
throw new java.lang.IllegalStateException(
"You must call createNewProcessor first!");
- processor.getXMLProcessorLiaison().setIndent(i);
+ // HACK: functionality not present in 2.x compat,
+ // just comment out for now: we should really try
+ // to dynamically load this for 1.x and/or replace the
+ // functionality for 2.x later on
+ //processor.getXMLProcessorLiaison().setIndent(i);
}
/**