W3C home > Mailing lists > Public > xproc-dev@w3.org > May 2009

RE: xproc as an alternative to Apache ant

From: <Toman_Vojtech@emc.com>
Date: Mon, 25 May 2009 03:15:11 -0400
Message-ID: <6E216CCE0679B5489A61125D0EFEC7870FABAC2E@CORPUSMX10A.corp.emc.com>
To: <xproc-dev@w3.org>
> >> As per xslt params/variables? So I could import them
> >> from an external file and use them?
> >
> > Absolutely, at least the parameters. If you store your 
> parameters in a c:param-set document, you can pass this 
> document to the parameter input port of your pipeline. Or you 
> can load it using the p:parameters step.
> 
> Could you point to any examples please?

For example, consider this params.xml document:

<c:param-set xmlns:c='http://www.w3.org/ns/xproc-step'>
  <c:param name='testname1' value='testvalue1'/>
  <c:param name='testname2' namespace="http://foo.bar"
value='testvalue2'/>
</c:param-set>


You can then pass it to the parameter input port of this pipeline:

<p:declare-step name="main" xmlns:p="http://www.w3.org/ns/xproc">
  <p:input port="parameters" kind="parameter"/>
  <p:output port="result" sequence="true"/>

  <p:parameters name="parameters">
    <p:input port="parameters">
      <p:pipe step="main" port="parameters"/>
    </p:input>
  </p:parameters>
  
  <!-- "result" is not primary on p:parameters -->
  <p:identity>
    <p:input port="source">
      <p:pipe step="parameters" port="result"/>
    </p:input>
  </p:identity>
</p:declare-step>


Or, you can read it in the pipeline using the p:document binding:

<p:declare-step xmlns:p="http://www.w3.org/ns/xproc">
  <p:output port="result" sequence="true"/>

  <p:parameters name="parameters">
    <p:input port="parameters">
      <p:document href="params.xml"/>
    </p:input>
  </p:parameters>
  
  <!-- "result" is not primary on p:parameters -->
  <p:identity>
    <p:input port="source">
      <p:pipe step="parameters" port="result"/>
    </p:input>
  </p:identity>
</p:declare-step>

-

An interesting thing about parameters in XProc is that if you provide
the same parameter multiple times, only the last value will be used. You
could use this mechanism for overriding the previous
(default/inherited/...) parameter value if you want:

<p:parameters name="parameters">
  <p:input port="parameters">
    <p:document href="params.xml"/>
  </p:input>
  <!-- this will override the value of testparam1 in params.xml -->
  <p:with-param name="testname1" select="'newvalue'" port="parameters">
    <p:empty/>
  </p:with-param>
</p:parameters>

Regards,
Vojtech
Received on Monday, 25 May 2009 07:16:02 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 25 May 2009 07:16:03 GMT