Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/354.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在ant中指定要使用资源集合转换的xml文档?_Java_Ant_Xslt - Fatal编程技术网

Java 如何在ant中指定要使用资源集合转换的xml文档?

Java 如何在ant中指定要使用资源集合转换的xml文档?,java,ant,xslt,Java,Ant,Xslt,我正在尝试使用ant来使用XSLT预处理项目中的三个特定样式表。声明它应该能够接受任何资源集合。具体来说,它说: 使用资源集合指定样式表应应用于的资源。使用嵌套映射器和任务的destdir属性指定输出文件 因此,我尝试使用文件集指定这些样式表,并将文件集用作xslt任务中的嵌套元素,但到目前为止,这还没有起作用。相反,它要做的似乎是忽略指定的文件集,扫描整个项目中以.xsl结尾的文件,对这些文件应用样式表,并根据映射器中指定的逻辑命名输出 <fileset id="stylesheets-

我正在尝试使用ant来使用XSLT预处理项目中的三个特定样式表。声明它应该能够接受任何资源集合。具体来说,它说:

使用资源集合指定样式表应应用于的资源。使用嵌套映射器和任务的destdir属性指定输出文件

因此,我尝试使用文件集指定这些样式表,并将文件集用作xslt任务中的嵌套元素,但到目前为止,这还没有起作用。相反,它要做的似乎是忽略指定的文件集,扫描整个项目中以.xsl结尾的文件,对这些文件应用样式表,并根据映射器中指定的逻辑命名输出

<fileset id="stylesheets-to-preprocess" dir="${basedir}">
    <filename name="src/xslt/backends/js/StatePatternStatechartGenerator.xsl"/>
    <filename name="src/xslt/backends/js/StateTableStatechartGenerator.xsl"/>
    <filename name="src/xslt/backends/js/SwitchyardStatechartGenerator.xsl"/>
</fileset>

<!-- ... -->

<target name="preprocess-stylesheets" depends="init">

    <xslt 
        classpathref="xslt-processor-classpath" 
        style="src/xslt/util/preprocess_import.xsl" 
        destdir="build"
        scanincludeddirectories="false">

        <fileset refid="stylesheets-to-preprocess"/>
        <mapper>
            <chainedmapper>
                <flattenmapper/>
                <globmapper from="*.xsl" to="*_combined.xsl"/>
            </chainedmapper>
        </mapper>
    </xslt>

</target>

我想限制它,以便只处理文件集中指定的那些文件

删除映射器,使文件集成为唯一的嵌套元素,将导致ant尝试将转换应用于每个文件,即使是没有xsl扩展名的文件,这在尝试转换非xml文档时不可避免地失败


我使用的是Ant1.7.1。任何指导都将不胜感激。

您的问题是由隐式文件集功能引起的。要使用嵌套文件集参数,需要关闭此功能

我还建议在文件集中使用一个“include”参数,这个参数要简单得多,并且避免使用复杂的mapper元素(您必须指定生成文件的扩展名,否则它将默认为.html)


<target name="preprocess-stylesheets" depends="init">

    <xslt 
        classpathref="xslt-processor-classpath" 
        style="src/xslt/util/preprocess_import.xsl" 
        destdir="build"
        extension=".xsl"
        useImplicitFileset="false"
        >

        <fileset dir="src/xslt/backends">
            <include name="StatePatternStatechartGenerator.xsl"/>
            <include name="StateTableStatechartGenerator.xsl"/>
            <include name="SwitchyardStatechartGenerator.xsl"/>
        </fileset>
    </xslt>

</target>