|
| 1 | +<?xml version="1.0" encoding="UTF-8"?> |
| 2 | +<project name="xslt.extensions" basedir="." |
| 3 | + xmlns:if="ant:if" |
| 4 | + xmlns:unless="ant:unless"> |
| 5 | + <description>Run PPLCG XSLT extensions.</description> |
| 6 | + |
| 7 | + <dirname property="xslt.extensions.basedir" |
| 8 | + file="${ant.file.xslt.extensions}" /> |
| 9 | + |
| 10 | + <pathconvert property="xslt.extensions.basedir.converted" dirsep="/"> |
| 11 | + <path location="${xslt.extensions.basedir}" /> |
| 12 | + <!-- Ant under cygwin uses a lowercase drive letter, which some |
| 13 | + Java programs don't recognise as a drive letter, so |
| 14 | + translate. --> |
| 15 | + <map from="c:" to="C:" /> |
| 16 | + <map from="d:" to="D:" /> |
| 17 | + <map from="e:" to="E:" /> |
| 18 | + </pathconvert> |
| 19 | + |
| 20 | + <pathconvert property="basedir.converted" dirsep="/"> |
| 21 | + <path location="${basedir}" /> |
| 22 | + <!-- Ant under cygwin uses a lowercase drive letter, which some |
| 23 | + Java programs don't recognise as a drive letter, so |
| 24 | + translate. --> |
| 25 | + <map from="c:" to="C:" /> |
| 26 | + <map from="d:" to="D:" /> |
| 27 | + <map from="e:" to="E:" /> |
| 28 | + </pathconvert> |
| 29 | + |
| 30 | + <tstamp> |
| 31 | + <format property="timestamp" pattern="yyyyMMdd" /> |
| 32 | + </tstamp> |
| 33 | + |
| 34 | + <!-- XML file of properties determining or describing local |
| 35 | + system configuration. --> |
| 36 | + <property |
| 37 | + name="xslt.extensions.system.local.properties.xml" |
| 38 | + location="${xslt.extensions.basedir}/properties.local.xml"/> |
| 39 | + <property file="${xslt.extensions.system.local.properties.xml}" /> |
| 40 | + <!-- Local file of properties determining or describing system |
| 41 | + configuration. --> |
| 42 | + <property |
| 43 | + name="xslt.extensions.system.local.properties" |
| 44 | + location="${xslt.extensions.basedir}/system.local.properties" /> |
| 45 | + <property file="${xslt.extensions.system.local.properties}" /> |
| 46 | + |
| 47 | + <!-- XML file of properties determining or describing system |
| 48 | + configuration. --> |
| 49 | + <property |
| 50 | + name="xslt.extensions.system.properties.xml" |
| 51 | + location="${xslt.extensions.basedir}/properties.xml"/> |
| 52 | + <property file="${xslt.extensions.system.properties.xml}" /> |
| 53 | + <!-- File of properties determining or describing system |
| 54 | + configuration. --> |
| 55 | + <property |
| 56 | + name="xslt.extensions.system.properties" |
| 57 | + location="${xslt.extensions.basedir}/system.properties" /> |
| 58 | + <property file="${xslt.extensions.system.properties}" /> |
| 59 | + |
| 60 | + <!-- Environment variables as properties prefixed with 'env.'. --> |
| 61 | + <property environment="env" /> |
| 62 | + |
| 63 | + <property name="force" value="false" /> |
| 64 | + <property name="tagged" value="false" /> |
| 65 | + <property name="verbose" value="false" /> |
| 66 | + |
| 67 | + <!-- Directory containing PPLCG XSLT Extensions jar file. --> |
| 68 | + <property name="xslt.extensions.dist.dir" |
| 69 | + value="${xslt.extensions.basedir.converted}/dist" /> |
| 70 | + |
| 71 | + <property name="saxon.basename" value="saxon9he" /> |
| 72 | + <!-- saxon.jar location depends on OS. --> |
| 73 | + <property name="saxon.jar.windows" |
| 74 | + value="${saxon.lib.windows}/${saxon.basename}.jar" /> |
| 75 | + <condition property="saxon.jar" value="${saxon.jar.windows}"> |
| 76 | + <and> |
| 77 | + <os family="windows" /> |
| 78 | + <available file="${saxon.jar.windows}"/> |
| 79 | + </and> |
| 80 | + </condition> |
| 81 | + <property name="saxon.jar.mac" |
| 82 | + value="${saxon.lib.mac}/${saxon.basename}.jar" /> |
| 83 | + <condition property="saxon.jar" value="${saxon.jar.mac}"> |
| 84 | + <and> |
| 85 | + <os family="mac" /> |
| 86 | + <available file="${saxon.jar.mac}"/> |
| 87 | + </and> |
| 88 | + </condition> |
| 89 | + <property name="saxon.jar.unix" |
| 90 | + value="${saxon.lib.unix}/${saxon.basename}.jar" /> |
| 91 | + <condition property="saxon.jar" value="${saxon.jar.unix}"> |
| 92 | + <and> |
| 93 | + <os family="unix" /> |
| 94 | + <available file="${saxon.jar.unix}"/> |
| 95 | + </and> |
| 96 | + </condition> |
| 97 | + <property name="saxon.jar" value="${saxon.jar.unix}" /> |
| 98 | + <!-- Fallback to something that almost certainly won't work. --> |
| 99 | + <property name="saxon.jar" value="saxon.jar" /> |
| 100 | + |
| 101 | + <property name="fop.basename" value="fop" /> |
| 102 | + <!-- fop.jar location depends on OS. --> |
| 103 | + <property name="fop.jar.windows" |
| 104 | + value="${fop.dir.windows}/build/${fop.basename}.jar" /> |
| 105 | + <condition property="fop.jar" value="${fop.jar.windows}"> |
| 106 | + <and> |
| 107 | + <os family="windows" /> |
| 108 | + <available file="${fop.jar.windows}"/> |
| 109 | + </and> |
| 110 | + </condition> |
| 111 | + <property name="fop.jar.mac" |
| 112 | + value="${fop.dir.mac}/build/${fop.basename}.jar" /> |
| 113 | + <condition property="fop.jar" value="${fop.jar.mac}"> |
| 114 | + <and> |
| 115 | + <os family="mac" /> |
| 116 | + <available file="${fop.jar.mac}"/> |
| 117 | + </and> |
| 118 | + </condition> |
| 119 | + <property name="fop.jar.unix" |
| 120 | + value="${fop.dir.unix}/build/${fop.basename}.jar" /> |
| 121 | + <condition property="fop.jar" value="${fop.jar.unix}"> |
| 122 | + <and> |
| 123 | + <os family="unix" /> |
| 124 | + <available file="${fop.jar.unix}"/> |
| 125 | + </and> |
| 126 | + </condition> |
| 127 | + <property name="fop.jar" value="${fop.jar.unix}" /> |
| 128 | + <!-- Fallback to something that almost certainly won't work. --> |
| 129 | + <property name="fop.jar" value="fop.jar" /> |
| 130 | + |
| 131 | + <!-- Prebuilt lib location depends on OS. --> |
| 132 | + <condition property="prebuilt.lib" value="${prebuilt.lib.windows}"> |
| 133 | + <and> |
| 134 | + <os family="windows" /> |
| 135 | + <available file="${prebuilt.lib.windows}"/> |
| 136 | + </and> |
| 137 | + </condition> |
| 138 | + <condition property="prebuilt.lib" value="${prebuilt.lib.mac}"> |
| 139 | + <and> |
| 140 | + <os family="mac" /> |
| 141 | + <available file="${prebuilt.lib.mac}"/> |
| 142 | + </and> |
| 143 | + </condition> |
| 144 | + <condition property="prebuilt.lib" value="${prebuilt.lib.unix}"> |
| 145 | + <and> |
| 146 | + <os family="unix" /> |
| 147 | + <available file="${prebuilt.lib.unix}"/> |
| 148 | + </and> |
| 149 | + </condition> |
| 150 | + |
| 151 | + <property name="xslt.extensions.basename" value="FOPRunXSLTExt" /> |
| 152 | + <property |
| 153 | + name="xslt.extensions.jar" |
| 154 | + value="${xslt.extensions.dist.dir}/${xslt.extensions.basename}.jar" /> |
| 155 | + <!-- XSL Formatter to use: 'ahf' or 'fop' --> |
| 156 | + <property name="xslt.extensions.formatter" value="ahf" /> |
| 157 | + |
| 158 | + <!-- AH Formatter location, for when using AH Formatter. --> |
| 159 | + <condition property="ahf.dir" value="${env.AHF65_64_HOME}"> |
| 160 | + <available file="${env.AHF65_64_HOME}" type="dir" /> |
| 161 | + </condition> |
| 162 | + <condition property="ahf.dir" value="${env.AHF64_64_HOME}"> |
| 163 | + <available file="${env.AHF64_64_HOME}" type="dir" /> |
| 164 | + </condition> |
| 165 | + <condition property="ahf.dir" value="${env.AHF63_64_HOME}"> |
| 166 | + <available file="${env.AHF63_64_HOME}" type="dir" /> |
| 167 | + </condition> |
| 168 | + |
| 169 | + <!-- AH Formatter 'lib' directory --> |
| 170 | + <property name="ahf.lib.dir" value="${ahf.dir}/lib" /> |
| 171 | + <!-- Basename of AH Formatter Java interface jar --> |
| 172 | + <property name="xfojavactl.basename" value="XfoJavaCtl" /> |
| 173 | + <!-- Location of AH Formatter jar file --> |
| 174 | + <property name="xfojavactl.jar" |
| 175 | + value="${ahf.lib.dir}/${xfojavactl.basename}.jar" /> |
| 176 | + |
| 177 | + <macrodef name="xslt.extensions.saxon" |
| 178 | + description="Run Saxon with PPLCG XSLT extensions"> |
| 179 | + <attribute name="formatter" default="${xslt.extensions.formatter}" |
| 180 | + description="XSL Formatter: 'ahf' or 'fop'" /> |
| 181 | + <attribute name="in" |
| 182 | + description="Single XML document to be styled" /> |
| 183 | + <attribute name="xsl" |
| 184 | + description="Location of XSLT stylesheet" /> |
| 185 | + <attribute name="out" |
| 186 | + description="Output name for the styled result" /> |
| 187 | + <attribute name="fop.jar" default="${fop.jar}" |
| 188 | + description="Location of FOP jar file" /> |
| 189 | + <attribute name="prebuilt.lib" default="${prebuilt.lib}" |
| 190 | + description="Location of library jar files" /> |
| 191 | + <attribute name="saxon.jar" default="${saxon.jar}" |
| 192 | + description="Location of Saxon jar file" /> |
| 193 | + <attribute name="xslt.extensions.jar" default="${xslt.extensions.jar}" |
| 194 | + description="Location of PPLCG XSLT Extensions jar file" /> |
| 195 | + <attribute name="xfojavactl.jar" default="${xfojavactl.jar}" |
| 196 | + description="Location of AH Formatter jar file" /> |
| 197 | + <attribute name="verbose" default="${verbose}" |
| 198 | + description="Whether to be verbose" /> |
| 199 | + <element name="args" implicit="yes" optional="yes" |
| 200 | + description="Arguments" /> |
| 201 | + <sequential> |
| 202 | + <local name="isfop" /> |
| 203 | + <condition property="isfop"> |
| 204 | + <equals |
| 205 | + arg1="${xslt.extensions.formatter}" |
| 206 | + arg2="fop" /> |
| 207 | + </condition> |
| 208 | + <java classname="net.sf.saxon.Transform" |
| 209 | + fork="yes"> |
| 210 | + <classpath> |
| 211 | + <pathelement location="@{fop.jar}" if:set="isfop" /> |
| 212 | + <pathelement |
| 213 | + location="@{prebuilt.lib}/xmlgraphics-commons-2.0.1.jar" |
| 214 | + if:set="isfop" /> |
| 215 | + <pathelement |
| 216 | + location="@{prebuilt.lib}/commons-logging-1.0.4.jar" |
| 217 | + if:set="isfop" /> |
| 218 | + <pathelement |
| 219 | + location="@{prebuilt.lib}/commons-io-1.3.1.jar" |
| 220 | + if:set="isfop" /> |
| 221 | + <pathelement |
| 222 | + location="@{prebuilt.lib}/avalon-framework-4.2.0.jar" |
| 223 | + if:set="isfop" /> |
| 224 | + <pathelement |
| 225 | + location="@{prebuilt.lib}/batik-all-1.8.jar" |
| 226 | + if:set="isfop" /> |
| 227 | + <pathelement |
| 228 | + location="@{prebuilt.lib}/serializer-2.7.0.jar" |
| 229 | + if:set="isfop" /> |
| 230 | + <pathelement |
| 231 | + location="@{prebuilt.lib}/xalan-2.7.0.jar" |
| 232 | + if:set="isfop" /> |
| 233 | + <pathelement |
| 234 | + location="@{prebuilt.lib}/xercesImpl-2.7.1.jar" |
| 235 | + if:set="isfop" /> |
| 236 | + <pathelement |
| 237 | + location="@{saxon.jar}" /> |
| 238 | + <pathelement location="@{xslt.extensions.jar}" /> |
| 239 | + <pathelement |
| 240 | + location="@{xfojavactl.jar}" unless:set="isfop" /> |
| 241 | + </classpath> |
| 242 | + <arg value="-init:org.w3c.ppl.xslt.ext.fop.saxon.RunFOPExtInitializer" if:set="isfop" /> |
| 243 | + <arg value="-init:org.w3c.ppl.xslt.ext.ahf.saxon.RunAHFExtInitializer" unless:set="isfop" /> |
| 244 | + <arg value="-s:@{in}" /> |
| 245 | + <arg value="-xsl:@{xsl}" /> |
| 246 | + <arg value="-o:@{out}" /> |
| 247 | + <arg value="ppl-formatter=@{formatter}" /> |
| 248 | + <args /> |
| 249 | + </java> |
| 250 | + </sequential> |
| 251 | + </macrodef> |
| 252 | + |
| 253 | + <!-- Utility targets. --> |
| 254 | + |
| 255 | + <target name="echoproperties"> |
| 256 | + <echoproperties /> |
| 257 | + </target> |
| 258 | + |
| 259 | +</project> |
0 commit comments