Ant XSLT 2.0 与 saxon9 加载样式表非常非常慢
我最近刚刚通过 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现通过网络加载 DTD 定义会影响我的性能。
我创建了一个空的 .dtd 文件,并使用 ant xmlcatalog 将 DTD 公共 ID 引用给它,如下所示(在我的任务中):
这将构建时间从 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):
This took build times down from 22 minutes (many documents) to 3 seconds!