W3C home > Mailing lists > Public > xproc-dev@w3.org > October 2010

RE: Simplifying a series of simple p:xslt steps

From: <vojtech.toman@emc.com>
Date: Tue, 12 Oct 2010 03:44:54 -0400
Message-ID: <997C307BEB90984EBE935699389EC41C026A5A14@CORPUSMX70C.corp.emc.com>
To: <xproc-dev@w3.org>
Just for completeness, the recursive pipeline below can be used for applying a sequence of XSL transformations to the source document. The pipeline takes an XML document, a sequence of XSLT stylesheets, and zero or more parameters for the transformations. It's not really less verbose and is probably also harder to read than the original pipeline, but it shows how you can use XProc to deal with sequences of operations whose number is not fixed or known in advance.

<p:declare-step version="1.0"
                type="ex:transform" name="main">

  <p:input port="source" primary="true"/>
  <p:input port="stylesheets" sequence="true"/>
  <p:input port="parameters" kind="parameter"/>
  <p:output port="result"/>

    <p:pipe step="main" port="stylesheets"/>
    <p:when test="/c:result = 0">
      <!-- no more stylesheets: return the source document unchanged -->
        <p:input port="source">
          <p:pipe step="main" port="source"/>
      <p:split-sequence test="position() = 1" initial-only="true" name="split">
        <p:input port="source">
          <p:pipe step="main" port="stylesheets"/>

      <!-- apply the first stylesheet -->
      <p:xslt name="xslt">
        <p:input port="source">
          <p:pipe step="main" port="source"/>
        <p:input port="stylesheet">
          <p:pipe step="split" port="matched"/>

      <!-- apply the remaining stylesheets recursively -->
        <p:input port="source">
          <p:pipe step="xslt" port="result"/>
        <p:input port="stylesheets">
          <p:pipe step="split" port="not-matched"/>


Vojtech Toman
Consultant Software Engineer
EMC | Information Intelligence Group

Received on Tuesday, 12 October 2010 07:47:56 UTC

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