stefano 02/04/10 05:55:41 Modified: src/java/org/apache/cocoon/transformation TraxTransformer.java Log: Removed the 'xslt-processor-role' parameter and added the 'transformer-factory' parameter, the same used by the XSLTProcessor Avalon Component that this class uses Revision Changes Path 1.22 +54 -44 xml-cocoon2/src/java/org/apache/cocoon/transformation/TraxTransformer.java Index: TraxTransformer.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/TraxTransformer.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- TraxTransformer.java 5 Apr 2002 11:58:09 -0000 1.21 +++ TraxTransformer.java 10 Apr 2002 12:55:41 -0000 1.22 @@ -94,7 +94,7 @@ * <use-request-parameters>false</use-request-parameters> * <use-browser-capabilities-db>false</use-browser-capabilities-db> * <use-session-info>false</use-session-info> - * <xslt-processor-role>org.apache.cocoon.components.xslt.XSLTProcessor</xslt-processor-role> + * <transformer-factory>org.apache.xalan.processor.TransformerFactoryImpl</transformer-factory> * </map:transformer> * </pre> * @@ -132,12 +132,14 @@ * cacheability of the generated output of this transformer.<br> * * - * The <xslt-processor> configuration allows to specify the XSLT processor that will be - * used by its role name. This allows to have several XSLT processors in the configuration - * (e.g. Xalan and Saxon) and choose one or the other depending on the needs of stylesheet + * The <transformer-factory> configuration allows to specify the TrAX transformer factory + * implementation that willbe used to obtain the XSLT processor. This allows to have + * several XSLT processors in the configuration + * (e.g. Xalan, XSTLC, Saxon, ...) and choose one or the other depending on the needs of stylesheet * specificities.<br> - * This property defaults to "org.apache.cocoon.components.xslt.XSLTProcessor" which is the - * standard role name for an XSLTProcessor. + * If no factory is specified, this transformer will use the XSLT implementation + * that Cocoon uses internally. + * * <p> * <b>In a map:sitemap/map:pipelines/map:pipeline:</b><br> * <pre> @@ -148,20 +150,18 @@ * All <parameter> declarations will be made available in the XSLT stylesheet as * xsl:variables. * - * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a> - * (Apache Software Foundation, Exoffice Technologies) + * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a> * @author <a href="mailto:[EMAIL PROTECTED]">Davanum Srinivas</a> * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a> * @author <a href="mailto:[EMAIL PROTECTED]">Ovidiu Predescu</a> * @author <a href="mailto:[EMAIL PROTECTED]">Mark H. Butler</a> - * @version CVS $Id: TraxTransformer.java,v 1.21 2002/04/05 11:58:09 cziegeler Exp $ + * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a> + * @version CVS $Id: TraxTransformer.java,v 1.22 2002/04/10 12:55:41 stefano Exp $ */ public class TraxTransformer extends AbstractTransformer implements Transformer, Composable, Configurable, Cacheable, Disposable { - private static final String FILE = "file:"; - /** The Browser service instance */ private Browser browser = null; @@ -186,8 +186,12 @@ private ComponentManager manager; + /** The trax TransformerFactory classname */ + private String traxFactory; + /** The trax TransformerHandler */ TransformerHandler transformerHandler; + /** The Source */ private Source inputSource; /** The parameters */ @@ -207,37 +211,42 @@ public void configure(Configuration conf) throws ConfigurationException { if (conf != null) { - Configuration child; - - child = conf.getChild("use-request-parameters"); - this.useParameters = child.getValueAsBoolean(false); - this._useParameters = this.useParameters; - - child = conf.getChild("use-cookies"); - this.useCookies = child.getValueAsBoolean(false); - this._useCookies = this.useCookies; - - child = conf.getChild("use-browser-capabilities-db"); - this.useBrowserCap = child.getValueAsBoolean(false); - this._useBrowserCap = this.useBrowserCap; - - child = conf.getChild("use-session-info"); - this.useSessionInfo = child.getValueAsBoolean(false); - this._useSessionInfo = this.useSessionInfo; - - child = conf.getChild("xslt-processor-role"); - String xsltRole = child.getValue(XSLTProcessor.ROLE); + Configuration child; + + child = conf.getChild("use-request-parameters"); + this.useParameters = child.getValueAsBoolean(false); + this._useParameters = this.useParameters; + + child = conf.getChild("use-cookies"); + this.useCookies = child.getValueAsBoolean(false); + this._useCookies = this.useCookies; + + child = conf.getChild("use-browser-capabilities-db"); + this.useBrowserCap = child.getValueAsBoolean(false); + this._useBrowserCap = this.useBrowserCap; + + child = conf.getChild("use-session-info"); + this.useSessionInfo = child.getValueAsBoolean(false); + this._useSessionInfo = this.useSessionInfo; + + child = conf.getChild("transformer-factory"); + this.traxFactory = child.getValue(XSLTProcessor.DEFAULT_FACTORY); if (this.getLogger().isDebugEnabled()) { this.getLogger().debug("Use parameters is " + this.useParameters + " for " + this); this.getLogger().debug("Use cookies is " + this.useCookies + " for " + this); this.getLogger().debug("Use browser capabilities is " + this.useBrowserCap + " for " + this); this.getLogger().debug("Use session info is " + this.useSessionInfo + " for " + this); - this.getLogger().debug("Use XSLTProcessor of role " + xsltRole); + if (this.traxFactory == XSLTProcessor.DEFAULT_FACTORY) { + this.getLogger().debug("Use default TrAX Transformer Factory."); + } else { + this.getLogger().debug("Use TrAX Transformer Factory " + this.traxFactory); + } } try { - this.xsltProcessor = (XSLTProcessor)this.manager.lookup(xsltRole); + this.xsltProcessor = (XSLTProcessor) this.manager.lookup(XSLTProcessor.ROLE); + this.xsltProcessor.setTransformerFactory(this.traxFactory); } catch (ComponentException e) { throw new ConfigurationException("Cannot load XSLT processor", e); } @@ -257,14 +266,12 @@ this.browser = (Browser) manager.lookup(Browser.ROLE); if (this.manager.hasComponent(Deli.ROLE)) { - try { - if (this.getLogger().isDebugEnabled()) { - getLogger().debug("Looking up " + Deli.ROLE); - } - this.deli = (Deli) this.manager.lookup(Deli.ROLE); - } catch (ComponentException e) { - getLogger().debug("Deli is not available"); - } catch (NoClassDefFoundError e) { + if (this.getLogger().isDebugEnabled()) { + getLogger().debug("Looking up " + Deli.ROLE); + } + this.deli = (Deli) this.manager.lookup(Deli.ROLE); + } else { + if (this.getLogger().isDebugEnabled()) { getLogger().debug("Deli is not available"); } } @@ -278,10 +285,10 @@ public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) throws SAXException, ProcessingException, IOException { - // Check the stylesheet uri if (src == null) { throw new ProcessingException("Stylesheet URI can't be null"); } + this.par = par; this.objectModel = objectModel; this.inputSource = resolver.resolve(src); @@ -290,12 +297,13 @@ _useBrowserCap = par.getParameterAsBoolean("use-browser-capabilities-db", this.useBrowserCap); _useCookies = par.getParameterAsBoolean("use-cookies", this.useCookies); _useSessionInfo = par.getParameterAsBoolean("use-session-info", this.useSessionInfo); + if (this.getLogger().isDebugEnabled()) { - this.getLogger().debug("Using stylesheet: '"+this.inputSource.getSystemId()+"' in " + this + ", last modified: " + this.inputSource.getLastModified()); + this.getLogger().debug("Using stylesheet: '" + this.inputSource.getSystemId() + "' in " + this + ", last modified: " + this.inputSource.getLastModified()); } /** Get a Transformer Handler */ - this.transformerHandler = this.xsltProcessor.getTransformerHandler(inputSource); + this.transformerHandler = this.xsltProcessor.getTransformerHandler(inputSource, null); } /** @@ -511,11 +519,13 @@ static boolean isValidXSLTParameterName(String name) { StringCharacterIterator iter = new StringCharacterIterator(name); char c = iter.first(); + if (!(Character.isLetter(c) || c == '_')) { return false; } else { c = iter.next(); } + while (c != iter.DONE) { if (!(Character.isLetterOrDigit(c) || c == '-' ||
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]