Source port with default fallback value?

◇◆丶佛笑我妖孽 提交于 2019-12-25 16:45:08

问题


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?


回答1:


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!



来源:https://stackoverflow.com/questions/22645973/source-port-with-default-fallback-value

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!