gpt4 book ai didi

xml - 如何简化这个 xproc 管道?

转载 作者:数据小太阳 更新时间:2023-10-29 02:05:45 28 4
gpt4 key购买 nike

我刚刚开始研究 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>

最佳答案

我转向了 xproc-dev邮件列表寻求帮助,很快就有了解决方案proposedimplemented为了我。这使我能够将上述管道简化为这样(更改命名空间以保护无辜者):

<?xml version="1.0"?>
<p:pipeline
version="1.0"
xmlns:p="http://www.w3.org/ns/xproc"
xmlns:ex="http://example.com">

<p:declare-step type="ex:xslt" name="xslt">
<p:input port="source" sequence="true" primary="true"/>
<p:input port="parameters" kind="parameter"/>
<p:output port="result" primary="true"/>
<p:option name="stylesheet" required="true"/>

<p:load name="load-stylesheet">
<p:with-option name="href" select="$stylesheet"/>
</p:load>

<p:xslt>
<p:input port="stylesheet">
<p:pipe port="result" step="load-stylesheet"/>
</p:input>
<p:input port="source">
<p:pipe port="source" step="xslt"/>
</p:input>
</p:xslt>
</p:declare-step>

<ex:xslt stylesheet="remove-locations.xsl"/>
<ex:xslt stylesheet="divisions-1.xsl"/>
<ex:xslt stylesheet="divisions-2.xsl"/>
<ex:xslt stylesheet="subjects-1.xsl"/>
<ex:xslt stylesheet="subjects-2.xsl"/>
<ex:xslt stylesheet="types-1.xsl"/>
<ex:xslt stylesheet="types-2.xsl"/>
<ex:xslt stylesheet="core.xsl"/>
<ex:xslt stylesheet="consolidate-descriptions.xsl" />
</p:pipeline>

(我实际上将 step out 分离到它自己的文件和 <p:import> 中,所以主管道文件比那个更简单。)

关于xml - 如何简化这个 xproc 管道?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3893442/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com