首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何简化这个xproc管道?

如何简化这个xproc管道?
EN

Stack Overflow用户
提问于 2010-10-09 02:50:09
回答 2查看 1.1K关注 0票数 4

我刚刚开始研究XProc (使用Calabash)。我想对一个输入文档应用一系列XSLT转换,以生成一个输出文档。我以前使用一个简单的Python脚本来驱动转换,但是看起来XProc可能是一个很好的选择。

下面的管道似乎对我很有效。它本质上只是需要按正确顺序应用的XSLT转换的列表。问题是,它看起来非常多余。我希望有一些方法可以减少这一点,但(到目前为止)我自己还不能解决这个问题。

代码语言:javascript
运行
复制
<?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>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-10-13 01:40:48

我向xproc-dev邮件列表寻求帮助,一个解决方案很快就是proposedimplemented。这使我可以将上面的流水线简化为以下内容(更改名称空间以保护无辜者):

代码语言:javascript
运行
复制
<?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>

(实际上,我将步骤分离到自己的文件中并对其进行<p:import>,因此主管道文件甚至比这更简单。)

票数 5
EN

Stack Overflow用户

发布于 2010-10-09 03:55:18

我看不到简化管道的方法..。除非您修改样式表本身。例如,创建一个样式表,导入所有其他样式表,并不断将一个样式表的输出传递给下一个样式表的输入。(这需要XSLT 2.0或exsl:nodeset扩展。)

但是,我没有看到一种不修改其他东西就可以简化XProc管道的方法。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3893442

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档