Source port with default fallback value?

2019-09-01 08:51发布

I have an XProc step where I would like the input source to work like this:

  • if a URL is provided on the command line using -isource=foo.xml, then the document at that URL is used as the source document;
  • if no URL is provided, then the document default.xml should be used.

Is it possible to obtain this behaviour in XProc?

标签: xproc
1条回答
Evening l夕情丶
2楼-- · 2019-09-01 09:32

As suggested by Florent on the XProc mailing list, using a p:document inside the p:input works just fine as a default. Specifying something else from outside simply overrides it:

<p:declare-step version="1.0" xmlns:p="http://www.w3.org/ns/xproc"
    name="main">

    <p:input port="source">
        <p:document href="default.xml"/>
    </p:input>
    <p:output port="result"/>

    <p:identity/>

</p:declare-step>

Run it with:

calabash test.xpl

and:

calabash --input source=myinput.xml test.xpl

to see the difference..

HTH!

查看更多
登录 后发表回答