Ant XSLT 2.0 与 saxon9 加载样式表非常非常慢

发布于 2024-10-29 07:48:32 字数 1950 浏览 2 评论 0原文

我最近刚刚通过 ant 使用 xslt2.0。我有一个如下所示的构建文件:

<project name="TranformXml" default="TransformFile">
    <target name="TransformFile">
        <xslt in="input.xml"
            out="student.html"
            style="transform.xsl"
            processor="trax" classpath="./lib/saxon/saxon9he.jar">

            <factory name="net.sf.saxon.TransformerFactoryImpl"/>

        </xslt>  
    </target>
</project>

一个输入文档 input.xml:

<student_list>
    <student>
        <name>George Washington</name>
        <major>Politics</major>
        <phone>312-123-4567</phone>
        <email>[email protected]</email>
    </student>

</student_list>

和样式表、transform.xsl

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
    <xsl:output method="html"/>

    <xsl:template match="/">
    <html>
        <head>
            <title>Student Directory</title>
        </head>
        <body>
        <xsl:apply-templates />
        </body>

    </html>
    </xsl:template>


</xsl:stylesheet>

以及我的 ant 构建的输出:

ant -f build.xml 
Buildfile: /home/casey/Development/ant-tests/xslt-transform/build.xml

TransformFile:
     [xslt] Processing /home/casey/Development/ant-tests/xslt-transform/input.xml to /home/casey/Development/ant-tests/xslt-transform/student.html
     [xslt] Loading stylesheet /home/casey/Development/ant-tests/xslt-transform/transform.xsl

BUILD SUCCESSFUL
Total time: 9 seconds

我发现很难相信完成这一切需要 9 秒。在生产中,样式表将变得更加复杂,输入也将变得更大。实际上,我希望将整个转换过程保持在几秒钟之内。

有什么想法吗?

谢谢,

凯西

I have just recently been working with xslt2.0 via ant. I have a build file that looks like so:

<project name="TranformXml" default="TransformFile">
    <target name="TransformFile">
        <xslt in="input.xml"
            out="student.html"
            style="transform.xsl"
            processor="trax" classpath="./lib/saxon/saxon9he.jar">

            <factory name="net.sf.saxon.TransformerFactoryImpl"/>

        </xslt>  
    </target>
</project>

an input document input.xml:

<student_list>
    <student>
        <name>George Washington</name>
        <major>Politics</major>
        <phone>312-123-4567</phone>
        <email>[email protected]</email>
    </student>

</student_list>

and stylesheet, transform.xsl

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
    <xsl:output method="html"/>

    <xsl:template match="/">
    <html>
        <head>
            <title>Student Directory</title>
        </head>
        <body>
        <xsl:apply-templates />
        </body>

    </html>
    </xsl:template>


</xsl:stylesheet>

and output from my ant build:

ant -f build.xml 
Buildfile: /home/casey/Development/ant-tests/xslt-transform/build.xml

TransformFile:
     [xslt] Processing /home/casey/Development/ant-tests/xslt-transform/input.xml to /home/casey/Development/ant-tests/xslt-transform/student.html
     [xslt] Loading stylesheet /home/casey/Development/ant-tests/xslt-transform/transform.xsl

BUILD SUCCESSFUL
Total time: 9 seconds

I find it hard to believe that it should take 9 seconds to do all this. When in production the stylesheets are going to be alot more complex and the input much larger. Realistically I'd like to keep the whole transform process to less than a few seconds.

Any ideas?

Thanks,

Casey

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空‖城人不在 2024-11-05 07:48:32

我发现通过网络加载 DTD 定义会影响我的性能。

我创建了一个空的 .dtd 文件,并使用 ant xmlcatalog 将 DTD 公共 ID 引用给它,如下所示(在我的任务中):

<xmlcatalog>
  <dtd publicid="-//W3C//DTD XHTML 1.0 Transitional//EN" location="empty.dtd"/>
<xmlcatalog>

这将构建时间从 22 分钟(许多文档)缩短到 3 秒!

What I found was killing my performance, was loading the DTD definitions over the web.

I created an empty .dtd file, and referred the DTD public ID's to it using an ant xmlcatalog, like this (inside my <xslt/> task):

<xmlcatalog>
  <dtd publicid="-//W3C//DTD XHTML 1.0 Transitional//EN" location="empty.dtd"/>
<xmlcatalog>

This took build times down from 22 minutes (many documents) to 3 seconds!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文