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

Re: Difficulty overriding parameter values

From: Kevin Flynn <kevin@escenic.com>
Date: Fri, 27 Nov 2009 09:51:16 +0100
Message-ID: <4B0F9304.8080105@escenic.com>
To: "xproc-dev@w3.org" <xproc-dev@w3.org>
I received the following request from alex.g.muir@gmail.com:

  I was looking over your posts at the following link regarding Xproc 
and using and xml file
  to drive the processing. I'm looking to do something similar I was 
wondering if you could
  share some solution on the xproc dev list to show how you ended up 
solving what you were doing.


So here goes:
It's still a work in (intermittent) progress, but what I currently do is 
use the http://www.w3.org/ns/xproc-step param-set element for making 
configuration files. For example:

<c:param-set xmlns:c="http://www.w3.org/ns/xproc-step">

  <!-- run this pipeline... -->
  <c:param name="pipeline" value="xyz"/>

  <!-- with these parameters... -->
  <c:param name="input-file" value="file:///some/input/file.ext"/>
  <c:param name="output-file" value="file:///some/output/file.ext"/>
  <c:param name="abc" value="def"/>


A configuration file always contains one "master" parameter, "pipeline" 
that names the actual pipeline to be run. All the other parameters are 
the parameters required by that pipeline.

This parameter file is submitted as the only input to a master pipeline 
(called run-pipe.xpl) which just contains a big choose element that runs 
the specified pipeline and passes on all the specified parameters.

<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"

      <p:input port="source"/>
      <p:input port="par" kind="parameter"/>

      <!-- output port not needed, but this will output the URL of the 
saved file -->
      <p:output port="result">
        <p:pipe step="end-of-pipe" port="result"/>

  <p:import href="pipes.xpl"/>

  <p:variable name="pipeline" 
    <p:pipe step="run-pipe" port="par"/>

    <p:when test="$pipeline='abc'">
      <pipes:abc name="abc">
        <p:input port="par" kind="parameter">
          <p:pipe step="run-pipe" port="par"/>
    <!-- ...lots more "whens"... -->
        <p:input port="source">
            <ebd:message>Pipe not found</ebd:message>

  <p:identity name="end-of-pipe"/>


pipes.xpl contains all the actual pipelines, each of which has the 
following basic structure:

  <p:declare-step type="pipes:abc" name="pipe-abc">

        <p:input port="source"/>
        <p:input port="par" kind="parameter"/>
        <p:output port="result">
          <p:pipe step="store" port="result"/>

    <p:import href="library.xpl"/>

    <p:variable name="input-file" 
      <p:pipe step="pipe-abc" port="par"/>
    <p:variable name="output-file" 
      <p:pipe step="pipe-abc" port="par"/>

    <p:load name="load">
      <p:with-option name="href" select="$input-file"/>

    <lib:some-basic-pipe name="some-basic-pipe">
      <p:input port="par" kind="parameter">
        <p:pipe step="pipe-abc" port="par"/>

    <!-- ...more pipes from library.xpl... -->

    <p:store name="store">
      <p:with-option name="href" select="$output-file"/>


The pipelines in pipes.xpl extract the parameters they need to "load" 
input files and "store" output files, and otherwise just call a sequence 
of simpler pipelines from library.xpl.

The pipelines in library.xpl are mostly just sequences of xslt and other 
atomic steps:

  <p:declare-step type="lib:some-basic-pipe" name="lib-some-basic-pipe">
        <p:input port="source"/>
        <p:input port="par" kind="parameter"/>
        <p:output port="result">
          <p:pipe step="trf2" port="result"/>
    <p:xslt name="trf1">
      <p:input port="stylesheet">
          <p:document href="xsl/trf1.xsl"/>

    <p:xslt name="trf2">
      <p:input port="stylesheet">
        <p:document href="xsl/trf2.xsl"/>
All the parameters specified in the configuration file are passed in to 
all the transformations, which can use the ones they need. trf1.xsl, for 
example, might contain:

    <xsl:param name="abc"/>

and would therefore use the setting 'def' specified in the configuration 

This structure means you can build up a library.xpl containing basic 
pipes that can be re-used in various ways, and a higher-level pipes.xpl 
that slots them together in more complex ways and deals with reading and 
writing files. It's all accessible in a uniform way - one pipe to call 
them all, plus a configuration file. Since I'm using the standard 
http://www.w3.org/ns/xproc-step param-set element for the configuration 
file, you can alternatively specify parameters on the command line.

In order to make this framework really useable, two things are needed:

- strict naming conventions for parameters
- an automated means of exposing all the parameters used by a particular 

What I am thinking of doing is defining a standard way of documenting 
all parameters, wherever they appear - in XSLT transformations or pipes 
- most likely using a namespace. It would then be possible to make an 
XSLT transformation that, given the name of one of the top-level pipes 
in pipes.xpl, could drill down through all the called sub-pipes and 
transformations, find all the parameters used and generate a complete, 
fully-documented configuration file.

Any advice, suggestions, offers of help etc. are more than welcome.

If this list is an inappropriate forum for this kind of discussion (most 
posts seem to be focused on the specification, rather than 
applications), maybe somebody can suggest an alternative?


Kevin Flynn
Received on Friday, 27 November 2009 08:51:52 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:03:06 UTC