Index: src/main/org/apache/tools/ant/taskdefs/XSLTLiaison4.java =================================================================== --- src/main/org/apache/tools/ant/taskdefs/XSLTLiaison4.java (revision 0) +++ src/main/org/apache/tools/ant/taskdefs/XSLTLiaison4.java (working copy) @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.tools.ant.taskdefs; + +/** + * Extends Proxy interface for XSLT processors: adds support for XSLT parameters + * of various types (not only String) + * + * + * @see XSLTProcess + * @author Frantisek Kucera (xkucf03) + * @since Ant 1.9.2 + */ +public interface XSLTLiaison4 extends XSLTLiaison3 { + + /** + * Add a parameter to be set during the XSL transformation. + * + * @param name the parameter name. + * @param value the parameter value as String, Boolean, int, etc. + * @throws Exception thrown if any problems happens. + * @since Ant 1.9.2 + * @see Transformer#setParameter(java.lang.String, java.lang.Object) + */ + void addParam(String name, Object value) throws Exception; +} Index: src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java =================================================================== --- src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java (revision 1532335) +++ src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java (working copy) @@ -47,7 +47,7 @@ import javax.xml.transform.TransformerConfigurationException; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; -import org.apache.tools.ant.taskdefs.XSLTLiaison3; +import org.apache.tools.ant.taskdefs.XSLTLiaison4; import org.apache.tools.ant.taskdefs.XSLTLogger; import org.apache.tools.ant.taskdefs.XSLTLoggerAware; import org.apache.tools.ant.taskdefs.XSLTProcess; @@ -68,7 +68,7 @@ * * @since Ant 1.3 */ -public class TraXLiaison implements XSLTLiaison3, ErrorListener, XSLTLoggerAware { +public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware { /** * Helper for transforming filenames to URIs. @@ -118,7 +118,7 @@ private Vector outputProperties = new Vector(); /** stylesheet parameters */ - private Hashtable params = new Hashtable(); + private Hashtable params = new Hashtable(); /** factory attributes */ private Vector attributes = new Vector(); @@ -369,7 +369,7 @@ for (final Enumeration enumeration = params.keys(); enumeration.hasMoreElements();) { final String name = (String) enumeration.nextElement(); - final String value = (String) params.get(name); + final Object value = params.get(name); transformer.setParameter(name, value); } } @@ -505,6 +505,15 @@ public void addParam(String name, String value) { params.put(name, value); } + + /** + * Add a parameter. + * @param name the name of the parameter + * @param value the value of the parameter + */ + public void addParam(String name, Object value) { + params.put(name, value); + } /** * Set a logger. Index: src/main/org/apache/tools/ant/taskdefs/XSLTLiaison.java =================================================================== --- src/main/org/apache/tools/ant/taskdefs/XSLTLiaison.java (revision 1532335) +++ src/main/org/apache/tools/ant/taskdefs/XSLTLiaison.java (working copy) @@ -51,6 +51,7 @@ * @param name the parameter name. * @param expression the parameter value as an expression string. * @throws Exception thrown if any problems happens. + * @see XSLTLiaison4#addParam(java.lang.String, java.lang.Object) * @since Ant 1.3 */ void addParam(String name, String expression) throws Exception; Index: src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java =================================================================== --- src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java (revision 1532335) +++ src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java (working copy) @@ -18,8 +18,20 @@ package org.apache.tools.ant.taskdefs; import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.EnumMap; import java.util.Enumeration; +import java.util.List; +import java.util.Map; import java.util.Vector; +import javax.xml.namespace.QName; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathExpression; +import javax.xml.xpath.XPathExpressionException; +import javax.xml.xpath.XPathFactory; +import javax.xml.xpath.XPathVariableResolver; import org.apache.tools.ant.AntClassLoader; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; @@ -76,7 +88,7 @@ private String fileDirParameter = null; /** additional parameters to be passed to the stylesheets */ - private Vector params = new Vector(); + private List params = new ArrayList(); /** Input XML document to be used */ private File inFile = null; @@ -196,6 +208,19 @@ * @since Ant 1.8.0 */ private boolean failOnNoResources = true; + + /** + * For evaluating template params + * + * @since Ant 1.9.2 + */ + private XPathFactory xpathFactory; + /** + * For evaluating template params + * + * @since Ant 1.9.2 + */ + private XPath xpath; /** * System properties to set during transformation. @@ -305,8 +330,9 @@ * Executes the task. * * @exception BuildException if there is an execution problem. - * @todo validate that if either in or our is defined, then both are + * @todo validate that if either in or out is defined, then both are */ + @Override public void execute() throws BuildException { if ("style".equals(getTaskType())) { log("Warning: the task name