带有XProc的XSLT-所需类型的参数绑定 [英] XSLT with XProc - parameter binding in the required type

查看:89
本文介绍了带有XProc的XSLT-所需类型的参数绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将名为Saxon(版本8.9)的批处理文件转换为XProc管道(Calabash). 这是我的批处理电话:

I'm trying to translate my batch file calling the Saxon (version 8.9) into a XProc pipeline (Calabash). This is my batch call:

java -jar saxon8.jar -o out.xml in.xml style.xsl +config=config-file.cfg

参数config是通过以下方式在样式表中定义的:

The parameter config is defined in the stylesheet in this way:

<xsl:param name="config" as="document-node()"/>

XProc部分如下所示:

The XProc part looks like this:

<p:load name="configLoad">
    <p:with-option name="href" select="'config-file.cfg'"/>
</p:load>
<p:xslt name="config">
    <p:input port="source">
        <p:document href="in.xml"/>
    </p:input>
    <p:input port="parameters">
        <p:inline>
            <c:param name="config">
                <p:pipe port="result" step="configLoad"/>
            </c:param>
        </p:inline>
    </p:input>
    <p:input port="stylesheet">
        <p:document href="style.xsl"/>
    </p:input>
</p:xslt>

错误消息是这样的:

变量$ config的必需项目类型为document-node();提供的值的项目类型为xs:string

Required item type of value of variable $config is document-node(); supplied value has item type xs:string

我知道<p:exec>步骤,但是我不想使用它,因为配置文件将在以后由其他XSLT转换生成. XProc的其他步骤也应重用它.

I know the <p:exec> step but i don't want to use it, because the config-file shall be generated by other XSLT tranformations later. It shall also be reused by other XProc steps.

是否可以使用正确的参数类型调用XSLT样式表? 感谢您的帮助!

Is there a possibility to call the XSLT stylesheet with the correct parameter type? Thanks for your help!

推荐答案

看起来您对当前的XProc标准不走运.它指出参数是名称/值对,其中值必须的数据类型必须是untypedAtomic的字符串.不要问我为什么.

Looks like you are out of luck with the current XProc standard. It states that parameters are name/value pairs where the data type of the values must be string of untypedAtomic. Don't ask me why..

http://www.w3.org/TR/xproc/#parameters

如果您不是动态地构成配置的内容,而只是传递固定文件的内容,则可以仅传递到相应配置文件的路径,然后使用fn:doc()读取它从XSLT文件中.

If you won't be composing the contents of your configuration dynamically, but are merely passing around contents of fixed files, you could pass through just a path to the appropriate config file, and use fn:doc() to read it from within the XSLT files.

我建议不要动态写入配置文件. XProc中的执行顺序可能不如您预期的顺序.

I'd recommend against writing config files on the fly. Execution order within XProc may not be as sequentially as you might expect..

另一种选择是将每个配置设置作为单独的参数传递,但随后每个设置仍必须符合平面参数值类型.

Alternative would be to pass through each config setting as a separate parameter, but then each setting would still have to comply to the flat parameter value type..

HTH!

这篇关于带有XProc的XSLT-所需类型的参数绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆