Re: [xsl] Simple XSL Pipelines

Subject: Re: [xsl] Simple XSL Pipelines
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 09 Mar 2010 18:14:18 -0500
Hi,

At 05:09 PM 3/9/2010, Liam wrote:
On Tue, 2010-03-09 at 23:03 +0200, Jacobus Reyneke wrote:

> The idea is something like:
> data.xml -> filter.xls -> layout.xls -> targetmedia.xsl ->
> data_for_mobile_phone.svg

XProc, the XML Pipelining Language, is probably what you want.
It's not yet a W3C Recommendation, but is likely to be one soon,
and in any case the language should be very stable at this point.
See e.g. http://xmlcalabash.com/ for an implementation.

I agree that XProc is an excellent way to go, it being a standardized mechanism.


On the other hand, one might also have:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:saxon="http://saxon.sf.net/";
  version="2.0"
  extension-element-prefixes="saxon">

<xsl:variable name="document" select="/" saxon:assignable="yes"/>

  <xsl:variable name="processes">
    <step>filter.xsl</step>
    <step>layout.xsl</step>
    <step>targetmedia.xsl</step>
  </xsl:variable>

  <xsl:template match="/">
    <xsl:for-each select="$processes/step">
      <xsl:message>
        <xsl:text>&#xA;... Applying </xsl:text>
        <xsl:value-of select="."/>
      </xsl:message>
      <saxon:assign name="document"
        select="saxon:transform(
                  saxon:compile-stylesheet(doc(.)),
                  $document)"/>
      <!-- A third argument to saxon:transform can specify
           runtime parameters for any (or all) steps;
           see the documentation -->
    </xsl:for-each>
    <xsl:sequence select="$document"/>
    <xsl:message>&#xA;... Done</xsl:message>
  </xsl:template>

</xsl:stylesheet>

I've used this or the equivalent in a number of projects (sometimes the $processes variable is declared in a different module, calling this in, which makes it somewhat easier to deploy). Some of its refinements (such as using saxon:assign in order to manage the memory footprint) are at the kind suggestion of Sam Wilmott.

Cheers,
Wendell



======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================

Current Thread