如何简化这个 xproc 管道?
我刚刚开始深入研究 XProc(使用 Calabash)。我想将一系列 XSLT 转换应用于单个输入文档以生成单个输出文档。我之前使用一个简单的 Python 脚本来驱动转换,但看起来 XProc 可能是一个不错的选择。
下面的管道似乎对我有用。它本质上只是需要按正确顺序应用的 XSLT 转换的列表。问题是,这似乎非常多余。我希望有某种方法可以减少这种情况,但是(到目前为止)我自己无法弄清楚。
<?xml version="1.0"?>
<p:pipeline version="1.0" xmlns:p="http://www.w3.org/ns/xproc">
<p:xslt name="remove-locations">
<p:input port="stylesheet">
<p:document href="preprocessors/remove-locations.xsl"/>
</p:input>
</p:xslt>
<p:xslt name="divisions-1">
<p:input port="stylesheet">
<p:document href="preprocessors/divisions-1.xsl"/>
</p:input>
</p:xslt>
<p:xslt name="divisions-2">
<p:input port="stylesheet">
<p:document href="preprocessors/divisions-2.xsl"/>
</p:input>
</p:xslt>
<p:xslt name="subjects-1">
<p:input port="stylesheet">
<p:document href="preprocessors/subjects-1.xsl"/>
</p:input>
</p:xslt>
<p:xslt name="subjects-2">
<p:input port="stylesheet">
<p:document href="preprocessors/subjects-2.xsl"/>
</p:input>
</p:xslt>
<p:xslt name="types-1">
<p:input port="stylesheet">
<p:document href="preprocessors/types-1.xsl"/>
</p:input>
</p:xslt>
<p:xslt name="types-2">
<p:input port="stylesheet">
<p:document href="preprocessors/types-2.xsl"/>
</p:input>
</p:xslt>
<p:xslt name="core">
<p:input port="stylesheet">
<p:document href="preprocessors/core.xsl"/>
</p:input>
</p:xslt>
<p:xslt name="consolidate-descriptions">
<p:input port="stylesheet">
<p:document href="preprocessors/consolidate-descriptions.xsl"/>
</p:input>
</p:xslt>
</p:pipeline>
I've just started digging into XProc (using Calabash). I have a series of XSLT transformations I want to apply to a single input document to produce a single output document. I was previously using a simple Python script to drive the transformations, but it seemed like XProc might be a good fit.
The pipeline below seems to work for me. It's essentially just a list of the XSLT transformations that need to be applied, in the correct order. The problem is, it seems mighty redundant. I'm hoping there's some way to cut down on that, but (so far) I can't figure it out on my own.
<?xml version="1.0"?>
<p:pipeline version="1.0" xmlns:p="http://www.w3.org/ns/xproc">
<p:xslt name="remove-locations">
<p:input port="stylesheet">
<p:document href="preprocessors/remove-locations.xsl"/>
</p:input>
</p:xslt>
<p:xslt name="divisions-1">
<p:input port="stylesheet">
<p:document href="preprocessors/divisions-1.xsl"/>
</p:input>
</p:xslt>
<p:xslt name="divisions-2">
<p:input port="stylesheet">
<p:document href="preprocessors/divisions-2.xsl"/>
</p:input>
</p:xslt>
<p:xslt name="subjects-1">
<p:input port="stylesheet">
<p:document href="preprocessors/subjects-1.xsl"/>
</p:input>
</p:xslt>
<p:xslt name="subjects-2">
<p:input port="stylesheet">
<p:document href="preprocessors/subjects-2.xsl"/>
</p:input>
</p:xslt>
<p:xslt name="types-1">
<p:input port="stylesheet">
<p:document href="preprocessors/types-1.xsl"/>
</p:input>
</p:xslt>
<p:xslt name="types-2">
<p:input port="stylesheet">
<p:document href="preprocessors/types-2.xsl"/>
</p:input>
</p:xslt>
<p:xslt name="core">
<p:input port="stylesheet">
<p:document href="preprocessors/core.xsl"/>
</p:input>
</p:xslt>
<p:xslt name="consolidate-descriptions">
<p:input port="stylesheet">
<p:document href="preprocessors/consolidate-descriptions.xsl"/>
</p:input>
</p:xslt>
</p:pipeline>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我向 xproc-dev 邮件列表寻求帮助,解决方案是快速提议和为我实现。这使我能够将上述管道简化为这样(更改命名空间以保护无辜者):(
实际上,我将步骤分离到其自己的文件中,并将其
,所以主要管道文件比这更简单。)I turned to the xproc-dev mailing list for help, and a solution was quickly proposed and implemented for me. This allowed me to simplify the above pipeline down to this (namespaces changed to protect the innocent):
(I actually separated the step out into its own file and
<p:import>
it, so the main pipeline file is even simpler than that.)我看不到简化管道的方法......除非您自己修改样式表。例如,制作一个样式表,导入所有其他样式表,并不断将一个样式表的输出传递到下一个样式表的输入。 (这需要 XSLT 2.0 或 exsl:nodeset 扩展。)
但是不,我没有找到一种方法可以在不修改其他内容的情况下简化 XProc 管道。
I can't see a way to simplify the pipeline... unless you modify the stylesheets themselves. E.g. make one stylesheet that imports all the others and keeps passing the output of one to the input of the next. (This would require XSLT 2.0 or the exsl:nodeset extension.)
But no, I don't see a way to simplify the XProc pipeline without modifying other things.