4

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>
4

2 に答える 2

5

私は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>

(実際には、ステップアウトを独自のファイルと<p:import>それに分けたので、メインのパイプラインファイルはそれよりもさらに単純です。)

于 2010-10-12T17:40:47.620 に答える
0

スタイルシート自体を変更しない限り、パイプラインを単純化する方法がわかりません。たとえば、他のすべてをインポートし、1つの出力を次の入力に渡し続ける1つのスタイルシートを作成します。(これには、XSLT 2.0またはexsl:nodeset拡張機能が必要です。)

しかし、いいえ、他のものを変更せずにXProcパイプラインを単純化する方法がわかりません。

于 2010-10-08T19:55:18.330 に答える