| <?xml version="1.0"?> |
| <!-- |
| 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. |
| --> |
| |
| <project name="xslt-test" basedir="." default="nothing"> |
| |
| <property name="out.dir" value="out"/> |
| |
| |
| <target name="setup"> |
| </target> |
| |
| <target name="teardown"> |
| <delete dir="${out.dir}" failonerror="false" /> |
| </target> |
| |
| |
| <target name="testStyleIsSet"> |
| <xslt in="data.xml" out="${out.dir}/out.xml"/> |
| </target> |
| |
| <target name="testTransferParameterSet"> |
| <property name="value" value="myvalue"/> |
| <xslt in="data.xml" out="${out.dir}/out.xml" style="printParams.xsl"> |
| <param name="set" expression="${value}"/> |
| </xslt> |
| </target> |
| |
| <target name="testTransferParameterEmpty"> |
| <property name="value" value=""/> |
| <xslt in="data.xml" out="${out.dir}/out.xml" style="printParams.xsl"> |
| <param name="empty" expression="${value}"/> |
| </xslt> |
| </target> |
| |
| <target name="testTransferParameterUnset"> |
| <xslt in="data.xml" out="${out.dir}/out.xml" style="printParams.xsl"> |
| <param name="undefined" expression="${value}"/> |
| </xslt> |
| </target> |
| |
| <target name="testTransferParameterUnsetWithIf"> |
| <xslt in="data.xml" out="${out.dir}/out.xml" style="printParams.xsl"> |
| <param name="undefined" expression="${value}" if="value" /> |
| </xslt> |
| </target> |
| |
| <target name="testDefaultMapper"> |
| <property name="value" value="myvalue"/> |
| <xslt style="printParams.xsl" destDir="${out.dir}" basedir="."> |
| <param name="set" expression="${value}"/> |
| </xslt> |
| </target> |
| |
| <target name="testCustomMapper"> |
| <property name="value" value="myvalue"/> |
| <xslt style="printParams.xsl" destDir="${out.dir}" basedir="."> |
| <param name="set" expression="${value}"/> |
| <mapper type="glob" from="data.*" to="out.*"/> |
| </xslt> |
| </target> |
| |
| <target name="testTypedMapper"> |
| <property name="value" value="myvalue"/> |
| <xslt style="printParams.xsl" destDir="${out.dir}" basedir="."> |
| <param name="set" expression="${value}"/> |
| <globmapper from="data.*" to="out.*"/> |
| </xslt> |
| </target> |
| |
| <target name="testExplicitFileset"> |
| <property name="value" value="myvalue"/> |
| <xslt style="printParams.xsl" destDir="${out.dir}" |
| useImplicitFileset="false" basedir=".."> |
| <param name="set" expression="${value}"/> |
| <fileset dir="."/> |
| </xslt> |
| </target> |
| |
| <target name="testNewerStylesheet"> |
| <antcall target="copyXsl"> |
| <param name="xsl.value" value="old-value"/> |
| </antcall> |
| <xslt in="data.xml" out="${out.dir}/out.xml" style="tmp.xsl"/> |
| |
| <antcall target="copyXsl"> |
| <param name="xsl.value" value="new-value"/> |
| </antcall> |
| <xslt in="data.xml" out="${out.dir}/out.xml" style="tmp.xsl"/> |
| <delete file="tmp.xsl"/> |
| </target> |
| |
| <target name="testDirectoryHierarchyWithDirMatching"> |
| <mkdir dir="${out.dir}/src/level1/"/> |
| <copy file="data.xml" todir="${out.dir}/src/level1/"/> |
| <xslt basedir="${out.dir}/src" destdir="${out.dir}/dest" |
| style="printParams.xsl"/> |
| </target> |
| |
| <target name="testDirsWithSpaces"> |
| <mkdir dir="${out.dir}/s rc/"/> |
| <copy file="data.xml" todir="${out.dir}/s rc/"/> |
| <xslt basedir="${out.dir}/s rc" destdir="${out.dir}/d est" |
| style="printParams.xsl"/> |
| </target> |
| |
| <target name="copyXsl" if="xsl.value"> |
| <copy file="testNewerStylesheet.xsl" tofile="tmp.xsl" overwrite="true"> |
| <filterchain><expandproperties/></filterchain> |
| </copy> |
| </target> |
| |
| <target name="testWithStyleAttrAndResource"> |
| <!-- also testing style as resources, with refid --> |
| <file id="xslFile" file="printParams.xsl"/> |
| <xslt in="data.xml" out="${out.dir}/out.xml" style="printParams.xsl"> |
| <style refid="xslFile" /> |
| </xslt> |
| </target> |
| |
| <target name="testWithFileResource"> |
| <xslt in="data.xml" out="${out.dir}/out.xml"> |
| <style> |
| <file file="printParams.xsl"/> |
| </style> |
| <param name="set" expression="value"/> |
| </xslt> |
| </target> |
| |
| <target name="testWithUrlResource"> |
| <makeurl file="printParams.xsl" property="printParams.xsl.url"/> |
| <xslt in="data.xml" out="${out.dir}/out.xml"> |
| <style> |
| <url url="${printParams.xsl.url}"/> |
| </style> |
| <param name="set" expression="value"/> |
| </xslt> |
| </target> |
| |
| <target name="testFilenameAndFiledirAsParam"> |
| <mkdir dir="${out.dir}/xml/dir"/> |
| <mkdir dir="${out.dir}/out"/> |
| <copy file="data.xml" tofile="${out.dir}/xml/one.xml"/> |
| <copy file="data.xml" tofile="${out.dir}/xml/two.xml"/> |
| <copy file="data.xml" tofile="${out.dir}/xml/three.xml"/> |
| <copy file="data.xml" tofile="${out.dir}/xml/dir/four.xml"/> |
| <xslt style="printFilename.xsl" |
| destdir="${out.dir}/out" |
| basedir="${out.dir}/xml" |
| includes="**/*.xml" |
| extension=".txt" |
| |
| filenameparameter="filename" |
| filedirparameter="filedir" |
| /> |
| </target> |
| |
| <target name="testFilenameAsParam"> |
| <mkdir dir="${out.dir}/xml/dir"/> |
| <mkdir dir="${out.dir}/out"/> |
| <copy file="data.xml" tofile="${out.dir}/xml/one.xml"/> |
| <copy file="data.xml" tofile="${out.dir}/xml/two.xml"/> |
| <copy file="data.xml" tofile="${out.dir}/xml/three.xml"/> |
| <copy file="data.xml" tofile="${out.dir}/xml/dir/four.xml"/> |
| <xslt style="printFilename.xsl" |
| destdir="${out.dir}/out" |
| basedir="${out.dir}/xml" |
| includes="**/*.xml" |
| extension=".txt" |
| |
| filenameparameter="filename" |
| /> |
| </target> |
| |
| <target name="testFilenameAsParamNoSetting"> |
| <mkdir dir="${out.dir}/xml/dir"/> |
| <mkdir dir="${out.dir}/out"/> |
| <copy file="data.xml" tofile="${out.dir}/xml/one.xml"/> |
| <copy file="data.xml" tofile="${out.dir}/xml/two.xml"/> |
| <copy file="data.xml" tofile="${out.dir}/xml/three.xml"/> |
| <copy file="data.xml" tofile="${out.dir}/xml/dir/four.xml"/> |
| <xslt style="printFilename.xsl" |
| destdir="${out.dir}/out" |
| basedir="${out.dir}/xml" |
| includes="**/*.xml" |
| extension=".txt" |
| /> <!-- without 'filenameparameter' to check, that the xsl:param is NOT set --> |
| </target> |
| |
| </project> |