将document()参数传递给XProc管道中的xslt

时间:2016-11-09 17:36:38

标签: xslt xproc

我已经设置了一个XProc管道,其中我有一个<p:xslt>步骤。在这个样式表的参数中,我有一个参数,它是一个document()节点:

这是km_to_dita.xsl样式表:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dctm="http://www.documentum.com" xmlns:ale="http://www.amplexor.com/alcatel"
    exclude-result-prefixes="xs dctm ale" version="2.0">

    <xsl:param name="conf-base" select="'file:/D:/Temp/ALE_config/'" />

    <xsl:param name="output-base" select="''"/>

    <xsl:param name="lang" select="/element()[1]/@language"/>

    <xsl:param name="graphics-reference-names" as="document-node()*" />

    <!-- my templates stuff... -->
</xsl:stylesheet>

因此,我在我的管道中使用以下步骤调用此XSLT(出于演示目的,它使用<p:inline>进行设置,但目标是绑定到步骤的结果端口):

<p:xslt name="km-dm-to-dita">
    <p:input port="source">
        <p:pipe port="list-dm" step="list-csv"/>
    </p:input>
    <p:input port="stylesheet">
        <p:document href="km_to_dita.xsl"/>
    </p:input>
    <p:with-param name="output-base" select="$dita.data-dir"/>
    <p:with-param name="conf-base" select="$config-dir"/>
    <!--<p:with-param name="graphics-reference-names">
        <p:pipe port="result" step="get-figure-references"/>
    </p:with-param>-->
    <p:with-param name="graphics-reference-names">
        <p:inline>
            <graphic-ids>
                <reference type="symbol" document="dm09011b0281121ef3.xml#G4" filename="g09011b0281d9c449.gif"/>
                <reference type="symbol" document="dm09011b0281121ef3.xml#G3" filename="g09011b0281d9c449.gif"/>
                <reference type="figure" document="dm09011b0281121ef3.xml#F33" filename="g09011b0281d9c44d.gif"/>
                <reference type="symbol" document="dm09011b0281121ef3.xml#G5" filename="g09011b0281d9c451.gif"/>
                <reference type="figure" document="dm09011b0281121ef5.xml#F116" filename="g09011b0281d9c458.gif"/>
            </graphic-ids>
        </p:inline>
    </p:with-param>

    <p:with-option name="output-base-uri" select="$dita.data-dir"/>
</p:xslt>

但是当使用XML Calabash(在oXygenXML中)运行它时失败了,引发的错误是(对不起,这是我所拥有的所有信息)但是已经确定它是导致此错误的<p:with-param name="graphics-reference-names">:< / p>

  

有什么想法吗?

2 个答案:

答案 0 :(得分:1)

我终于找到了它出了什么问题...首先,<p:with-param>缺少必需的@select属性,如上所述in the XProc,但奇怪的是oXygen没有提出我的管道的任何验证错误。

因此管道可以这样固定:

<p:with-param name="graphics-reference-names" select="/">
    <p:inline>
        <graphic-ids>
            <reference type="symbol" document="dm09011b0281121ef3.xml#G4" filename="g09011b0281d9c449.gif"/>
            <reference type="symbol" document="dm09011b0281121ef3.xml#G3" filename="g09011b0281d9c449.gif"/>
            <reference type="figure" document="dm09011b0281121ef3.xml#F33" filename="g09011b0281d9c44d.gif"/>
            <reference type="symbol" document="dm09011b0281121ef3.xml#G5" filename="g09011b0281d9c451.gif"/>
            <reference type="figure" document="dm09011b0281121ef5.xml#F116" filename="g09011b0281d9c458.gif"/>
        </graphic-ids>
    </p:inline>
</p:with-param>

使用上述解决方案,XSLT失败,因为参数已转换为字符串:

  

变量$ graphics-reference-names的必需项类型值是document-node();提供的值具有项类型xs:string

这是使问题无法解决的另一个问题:XProc只允许将参数设置为原子值,如XSLT with XProc - parameter binding in the required type中所述。

答案 1 :(得分:0)

如果您使用

<p:input port="source">
    <p:pipe port="list-dm" step="list-csv"/>
    <p:pipe port="result" step="your-other-step"/>
</p:input>

在XProc 1中先使用p:xslt version="2.0",然后

<xsl:param name="graphics-reference-names" as="document-node()*" select="subsequence(collection(), 2)" />

在XSLT代码中,我认为应该将第二步的结果作为辅助输入文档(作为默认集合的一部分进行访问)可用。

相关问题