我有一个XSL样式表,可以通过这种方式合并外部文档
<xsl:copy-of select="document('snippets.xml')/snippets/xxxx/form"/>
如果文件或其任何依赖项发生更改,我希望XSLT Ant构建任务进行重新构建。
当前的Ant任务如下所示
<xslt basedir="xxxx/pages/${doc.locale}"
`destdir="xxxx/dir/${doc.locale}"`includes="*.xml"
excludes="snippets.xml"
style="build/xxxx/${doc.locale}/myStyle.xsl">
`<param name="lang" expression="${doc.locale}"/>` `<xmlcatalog refid="docDTDs"/>` 基本上,如果snippets.xml文档发生更改,我会重新构建。
发布于 2011-05-16 11:31:07
Ant有一个uptodate任务,可以从一组源文件中检查目标文件是否为最新的。我不完全清楚您的依赖项是什么,因为XSLT任务可能会创建多个文件(导致多个目标),或者它是否会创建单个文件。您的其中一个注释暗示了单个文件。
以下是使用uptodate的一种方法。您基本上使用任务来设置一个属性,然后可以将该属性放入目标的unless属性中:
<property name="file.that.depends.on.snippets"
location="some/path"/>
<property name="snippets.file"
location="xxxx/pages/${doc.locale}/snippets.xml"/>
<target name="process-snippets"
unless="snippets.uptodate"
depends="snippets-uptodate-check">
<xslt basedir="xxxx/pages/${doc.locale}"
destdir="xxxx/dir/${doc.locale}"
includes="*.xml"
excludes="snippets.xml"
style="build/xxxx/${doc.locale}/myStyle.xsl">
<param name="lang" expression="${doc.locale}"/>
<xmlcatalog refid="docDTDs"/>
</xslt>
</target>
<target name="snippets-uptodate-check">
<uptodate property="snippets.uptodate"
targetfile="$file.that.depends.on.snippets">
<srcfiles dir="xxxx/pages/${doc.locale}"
includes="*.xml"
excludes="snippets.xml"/>
</uptodate>
</target>发布于 2011-05-15 05:38:55
默认情况下,XSLT task应该会为您执行此操作。它有一个可选的"force“属性
重新创建目标文件,即使它们比相应的源文件或样式表新
默认情况下为false。因此,默认情况下,除非使用"force“属性进行覆盖,否则依赖项将由XSLT任务检查。
https://stackoverflow.com/questions/6001526
复制相似问题