Wil*_*hen 4 xml pipeline saxon 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>
Run Code Online (Sandbox Code Playgroud)
我转向xproc-dev邮件列表寻求帮助,我很快就提出并实施了一个解决方案.这允许我将上面的管道简化为此(更改名称空间以保护无辜者):
<?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>
Run Code Online (Sandbox Code Playgroud)
(我实际上将步骤分成了自己的文件<p:import>,因此主流水线文件甚至更简单.)
| 归档时间: |
|
| 查看次数: |
1013 次 |
| 最近记录: |