santiagopg 02/04/24 13:50:14
Modified: java/src/org/apache/xalan/xsltc/cmdline Compile.java
java/src/org/apache/xalan/xsltc/compiler XSLTC.java
java/src/org/apache/xalan/xsltc/compiler/util
ErrorMessages.java
java/src/org/apache/xalan/xsltc/trax
TransformerFactoryImpl.java
Log:
Added -n option to disable template inlining. This is useful to avoid
getting very long methods (the limit set by the JVM is 64K). The same
option can be passed to a TransformationFactory via Trax using
the "disable-inlining" attribute.
Revision Changes Path
1.9 +5 -2
xml-xalan/java/src/org/apache/xalan/xsltc/cmdline/Compile.java
Index: Compile.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/cmdline/Compile.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Compile.java 30 Oct 2001 14:57:53 -0000 1.8
+++ Compile.java 24 Apr 2002 20:50:14 -0000 1.9
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Compile.java,v 1.8 2001/10/30 14:57:53 morten Exp $
+ * @(#)$Id: Compile.java,v 1.9 2002/04/24 20:50:14 santiagopg Exp $
*
* The Apache Software License, Version 1.1
*
@@ -104,7 +104,7 @@
boolean useStdIn = false;
boolean classNameSet = false;
- final GetOpt getopt = new GetOpt(args, "o:d:j:p:uxhsi");
+ final GetOpt getopt = new GetOpt(args, "o:d:j:p:uxhsin");
if (args.length < 1) printUsage();
final XSLTC xsltc = new XSLTC();
@@ -137,6 +137,9 @@
break;
case 's':
_allowExit = false;
+ break;
+ case 'n':
+ xsltc.setTemplateInlining(false);
break;
case 'h':
default:
1.37 +15 -1
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XSLTC.java
Index: XSLTC.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XSLTC.java,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- XSLTC.java 24 Apr 2002 17:03:15 -0000 1.36
+++ XSLTC.java 24 Apr 2002 20:50:14 -0000 1.37
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: XSLTC.java,v 1.36 2002/04/24 17:03:15 santiagopg Exp $
+ * @(#)$Id: XSLTC.java,v 1.37 2002/04/24 20:50:14 santiagopg Exp $
*
* The Apache Software License, Version 1.1
*
@@ -141,6 +141,7 @@
private Vector _classes;
private boolean _callsNodeset = false;
private boolean _multiDocument = false;
+ private boolean _templateInlining = true;
/**
* XSLTC compiler constructor
@@ -208,6 +209,16 @@
}
/**
+ * Set a flag indicating if templates are to be inlined or not. The
+ * default is to do inlining, but this causes problems when the
+ * stylesheets have a large number of templates (e.g. branch targets
+ * exceeding 64K or a length of a method exceeding 64K).
+ */
+ public void setTemplateInlining(boolean templateInlining) {
+ _templateInlining = templateInlining;
+ }
+
+ /**
* Set the parameters to use to locate the correct <?xml-stylesheet ...?>
* processing instruction in the case where the input document to the
* compiler (and parser) is an XML document.
@@ -312,6 +323,9 @@
_stylesheet.setSourceLoader(_loader);
_stylesheet.setSystemId(systemId);
_stylesheet.setParentStylesheet(null);
+ if (!_templateInlining) {
+ _stylesheet.compileTemplatesAsMethods();
+ }
_parser.setCurrentStylesheet(_stylesheet);
// Create AST under the Stylesheet element (parse & type-check)
_parser.createAST(_stylesheet);
1.7 +3 -2
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ErrorMessages.java
Index: ErrorMessages.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ErrorMessages.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ErrorMessages.java 24 Apr 2002 17:03:16 -0000 1.6
+++ ErrorMessages.java 24 Apr 2002 20:50:14 -0000 1.7
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: ErrorMessages.java,v 1.6 2002/04/24 17:03:16 santiagopg Exp $
+ * @(#)$Id: ErrorMessages.java,v 1.7 2002/04/24 20:50:14 santiagopg Exp $
*
* The Apache Software License, Version 1.1
*
@@ -221,7 +221,7 @@
// COMPILE_USAGE_STR
"Usage:\n" +
" java org.apache.xalan.xsltc.cmdline.Compile [-o <output>] [-d
<directory>] [-j <jarfile>]\n"+
- " [-p <package name>] [-x] [-s] [-u] { <stylesheet> | -i }\n\n"+
+ " [-p <package name>] [-n] [-x] [-s] [-u] { <stylesheet> | -i
}\n\n"+
" Where <output> is the name to give the the generated translet.\n"+
" <stylesheet> is one or more stylesheet file names, or if\n"+
" the -u options is specified, one or more stylesheet URLs.\n"+
@@ -232,6 +232,7 @@
" The -i options forces the compiler to read from stdin\n"+
" The -o option is ignored if compiling multiple stylesheets\n"+
" The -x option switches on debug messages.\n"+
+ " The -n disable template inlining to reduce method length.\n"+
" The -s option disables calling System.exit.",
// TRANSFORM_USAGE_STR
"Usage: \n" +
1.36 +9 -2
xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerFactoryImpl.java
Index: TransformerFactoryImpl.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerFactoryImpl.java,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- TransformerFactoryImpl.java 24 Apr 2002 17:03:17 -0000 1.35
+++ TransformerFactoryImpl.java 24 Apr 2002 20:50:14 -0000 1.36
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: TransformerFactoryImpl.java,v 1.35 2002/04/24 17:03:17
santiagopg Exp $
+ * @(#)$Id: TransformerFactoryImpl.java,v 1.36 2002/04/24 20:50:14
santiagopg Exp $
*
* The Apache Software License, Version 1.1
*
@@ -140,8 +140,10 @@
}
}
- // This flag is passed to the compiler - will produce stack traces etc.
+ // This flags are passed to the compiler
private boolean _debug = false;
+ private boolean _disableInlining = false;
+
/**
* javax.xml.transform.sax.TransformerFactory implementation.
@@ -215,6 +217,9 @@
else if (name.equals("debug")) {
_debug = true;
}
+ else if (name.equals("disable-inlining") && value instanceof Boolean) {
+ _disableInlining = ((Boolean) value).booleanValue();
+ }
else {
// Throw an exception for all other attributes
ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_INVALID_ATTR_ERR, name);
@@ -320,6 +325,7 @@
XSLTC xsltc = new XSLTC();
if (_debug) xsltc.setDebug(true);
+ if (_disableInlining) xsltc.setTemplateInlining(false);
xsltc.init();
// Compile the default copy-stylesheet
@@ -478,6 +484,7 @@
// Create and initialize a stylesheet compiler
final XSLTC xsltc = new XSLTC();
if (_debug) xsltc.setDebug(true);
+ if (_disableInlining) xsltc.setTemplateInlining(false);
xsltc.init();
// Set a document loader (for xsl:include/import) if defined
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]