Committing fix for XALANJ-2206
Patch from Vadim Gritsenko.
Patch was modified slightly and approved by Brian Minchau.

The fix lets users set the "enable-inlining" feature specifically
in the case of TemplatesHandler,
where the default value in Stylesheet class was wreaking havoc.
diff --git a/src/org/apache/xalan/xsltc/compiler/Stylesheet.java b/src/org/apache/xalan/xsltc/compiler/Stylesheet.java
index c07981a..b8e3dd5 100644
--- a/src/org/apache/xalan/xsltc/compiler/Stylesheet.java
+++ b/src/org/apache/xalan/xsltc/compiler/Stylesheet.java
@@ -21,9 +21,6 @@
 
 package org.apache.xalan.xsltc.compiler;
 
-import java.net.URL;
-import java.net.MalformedURLException;
-
 import java.util.Vector;
 import java.util.Enumeration;
 import java.util.Hashtable;
@@ -198,8 +195,9 @@
     
     /**
      * Set to true to enable template inlining optimization.
+     * @see XSLTC#_templateInlining
      */
-    private boolean _templateInlining = true;
+    private boolean _templateInlining = false;
 
     /**
      * A reference to the last xsl:output object found in the styleshet.
@@ -462,11 +460,11 @@
 	    for (int i = 0; i < n; i++) {
 		final Template template = (Template)templates.elementAt(i);
 		if (template.hasParams()) {
-		    _hasLocalParams = new Boolean(true);
+		    _hasLocalParams = Boolean.TRUE;
 		    return true;
 		}
 	    }
-	    _hasLocalParams = new Boolean(false);
+	    _hasLocalParams = Boolean.FALSE;
 	    return false;
 	}
 	else {
diff --git a/src/org/apache/xalan/xsltc/compiler/XSLTC.java b/src/org/apache/xalan/xsltc/compiler/XSLTC.java
index cf49500..2cd314c 100644
--- a/src/org/apache/xalan/xsltc/compiler/XSLTC.java
+++ b/src/org/apache/xalan/xsltc/compiler/XSLTC.java
@@ -238,6 +238,13 @@
     }
 
     /**
+     * Return the state of the template inlining feature.
+     */
+    public boolean getTemplateInlining() {
+        return _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.
diff --git a/src/org/apache/xalan/xsltc/trax/TemplatesHandlerImpl.java b/src/org/apache/xalan/xsltc/trax/TemplatesHandlerImpl.java
index 8982984..8088c7d 100644
--- a/src/org/apache/xalan/xsltc/trax/TemplatesHandlerImpl.java
+++ b/src/org/apache/xalan/xsltc/trax/TemplatesHandlerImpl.java
@@ -96,7 +96,12 @@
         XSLTC xsltc = new XSLTC();
         if (tfactory.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING))
             xsltc.setSecureProcessing(true);
-       
+
+        if ("true".equals(tfactory.getAttribute(TransformerFactoryImpl.ENABLE_INLINING)))
+            xsltc.setTemplateInlining(true);
+        else
+            xsltc.setTemplateInlining(false);
+
         _parser = xsltc.getParser();
     }
 
@@ -186,7 +191,7 @@
             XSLTC xsltc = _parser.getXSLTC();
 
             // Set the translet class name if not already set
-            String transletName = null;
+            String transletName;
             if (_systemId != null) {
                 transletName = Util.baseName(_systemId);
             }
@@ -208,6 +213,11 @@
                 stylesheet.setSystemId(_systemId);
                 stylesheet.setParentStylesheet(null);
 
+                if (xsltc.getTemplateInlining())
+                   stylesheet.setTemplateInlining(true);
+                else
+                   stylesheet.setTemplateInlining(false);
+
                 // Set a document loader (for xsl:include/import) if defined
                 if (_uriResolver != null) {
                     stylesheet.setSourceLoader(this);
diff --git a/src/org/apache/xalan/xsltc/trax/TransformerFactoryImpl.java b/src/org/apache/xalan/xsltc/trax/TransformerFactoryImpl.java
index 868dfef..1dbbf38 100644
--- a/src/org/apache/xalan/xsltc/trax/TransformerFactoryImpl.java
+++ b/src/org/apache/xalan/xsltc/trax/TransformerFactoryImpl.java
@@ -260,6 +260,12 @@
 	else if (name.equals(AUTO_TRANSLET)) {
 	    return new Boolean(_autoTranslet);
 	}
+	else if (name.equals(ENABLE_INLINING)) {
+	    if (_enableInlining)
+	      return Boolean.TRUE;
+	    else
+	      return Boolean.FALSE;
+	}
 
 	// Throw an exception for all other attributes
 	ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_INVALID_ATTR_ERR, name);
@@ -735,7 +741,10 @@
 	// Create and initialize a stylesheet compiler
 	final XSLTC xsltc = new XSLTC();
 	if (_debug) xsltc.setDebug(true);
-	if (_enableInlining) xsltc.setTemplateInlining(true);
+	if (_enableInlining) 
+		xsltc.setTemplateInlining(true);
+	else
+		xsltc.setTemplateInlining(false);
 	if (_isSecureProcessing) xsltc.setSecureProcessing(true);
 	xsltc.init();