You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mi...@apache.org on 2007/09/20 23:35:21 UTC

svn commit: r577935 - in /xalan/java/trunk/src/org/apache/xalan/xsltc: compiler/Stylesheet.java compiler/XSLTC.java trax/TemplatesHandlerImpl.java trax/TransformerFactoryImpl.java

Author: minchau
Date: Thu Sep 20 14:35:20 2007
New Revision: 577935

URL: http://svn.apache.org/viewvc?rev=577935&view=rev
Log:
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.

Modified:
    xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/Stylesheet.java
    xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/XSLTC.java
    xalan/java/trunk/src/org/apache/xalan/xsltc/trax/TemplatesHandlerImpl.java
    xalan/java/trunk/src/org/apache/xalan/xsltc/trax/TransformerFactoryImpl.java

Modified: xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/Stylesheet.java
URL: http://svn.apache.org/viewvc/xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/Stylesheet.java?rev=577935&r1=577934&r2=577935&view=diff
==============================================================================
--- xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/Stylesheet.java (original)
+++ xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/Stylesheet.java Thu Sep 20 14:35:20 2007
@@ -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 {

Modified: xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/XSLTC.java
URL: http://svn.apache.org/viewvc/xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/XSLTC.java?rev=577935&r1=577934&r2=577935&view=diff
==============================================================================
--- xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/XSLTC.java (original)
+++ xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/XSLTC.java Thu Sep 20 14:35:20 2007
@@ -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.

Modified: xalan/java/trunk/src/org/apache/xalan/xsltc/trax/TemplatesHandlerImpl.java
URL: http://svn.apache.org/viewvc/xalan/java/trunk/src/org/apache/xalan/xsltc/trax/TemplatesHandlerImpl.java?rev=577935&r1=577934&r2=577935&view=diff
==============================================================================
--- xalan/java/trunk/src/org/apache/xalan/xsltc/trax/TemplatesHandlerImpl.java (original)
+++ xalan/java/trunk/src/org/apache/xalan/xsltc/trax/TemplatesHandlerImpl.java Thu Sep 20 14:35:20 2007
@@ -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);
             }
@@ -207,6 +212,11 @@
                 stylesheet = _parser.makeStylesheet(root);
                 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) {

Modified: xalan/java/trunk/src/org/apache/xalan/xsltc/trax/TransformerFactoryImpl.java
URL: http://svn.apache.org/viewvc/xalan/java/trunk/src/org/apache/xalan/xsltc/trax/TransformerFactoryImpl.java?rev=577935&r1=577934&r2=577935&view=diff
==============================================================================
--- xalan/java/trunk/src/org/apache/xalan/xsltc/trax/TransformerFactoryImpl.java (original)
+++ xalan/java/trunk/src/org/apache/xalan/xsltc/trax/TransformerFactoryImpl.java Thu Sep 20 14:35:20 2007
@@ -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();
 



---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org