[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Dynamic pipelining in XSLT 2.0 w/ Saxon extensions

Subject: Re: Dynamic pipelining in XSLT 2.0 w/ Saxon extensions
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Tue, 19 Jun 2007 05:25:40 -0700
Re:  Dynamic pipelining in XSLT 2.0 w/ Saxon extensions
Why not simply use FXSL and its support for the composition of a given
list of functions?

Once we have an implementation of a library of XSLT functions, one
would simply use the compiled version of FXSL or whatever else. Then
no need for caching/re-compilation would exist.

We need only to conserve memory used with the document() or like
functions, but hopefully the underlying garbage collector will do this

As for new extension functions, right now I see just two of them that are really important:

 memo-apply(pFun, pArg1,...,pArgN)  -- this is sufficient to make any
FXSL function a memo-function -- just pass it as the first parameter
to memo-apply()

 cc-link(pFun, pArg1,...,pArgN)  -- this would implement
continuation-passing style efficiently (something similar can be done
with FXSL, but I am not sure it will be efficient)

Dimitre Novatchev
Truly great madness cannot be achieved without significant intelligence.
To invent, you need a good imagination and a pile of junk
You've achieved success in your field when you don't know whether what
you're doing is work or play

On 6/18/07, Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> wrote:

One of the niftier extensions available in the Saxon library is one
that allows a stylesheet to be compiled and applied dynamically.

As its designer undoubtedly anticipated, it can even provide the
basis for at least a lightweight pipelining infrastructure. The
stylesheet below allows the specification of a set of stylesheets to
be run in sequence over the input. Presently the stylesheets are
named in a top-level variable, though of course this spec could also
be external (and more fully-featured). Given the variable

  <xsl:variable name="processes">

the stylesheets "stylesheets/one.xsl", "stylesheets/two.xsl" and
"stylesheets/three.xsl" (relative to the pipelining stylesheet) are
run in series over the input document, until either a "done" element
is encountered, or there are no more steps. (The "path" element may
be omitted; if used it must currently appear first.)

My questions:

* This runs (tested under the current Saxon 8.9), but how will it
scale? In particular, Mike Kay may be able to say whether compiled
stylesheets are be cached when this is run over a set of documents.
If not, wouldn't compiling each stylesheet anew for each input
document be an impediment?

* Are there any obvious pitfalls or problems with this approach? (Or
any not so obvious?) How does it compare to other methods?

(So far I can say only that it's really easy to use, but again I'm
not sure it will scale as well as other methods. It does have the
advantage, it appears, of avoiding serialization altogether until the
last step.)

The stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

<xsl:output method="xml"/>

<!-- Saxon pipelining stylesheet:

Takes document input and passes it through a chain of transformations

       The steps will run in order until a "done" element is
encountered or they run out


  <xsl:variable name="processes">

  <xsl:template match="/">
    <xsl:apply-templates select="$processes/m:step[1]">
      <xsl:with-param name="in" select="/"/>

  <xsl:template match="m:step">
    <xsl:param name="in"/>
    <xsl:param name="stylesheet" select="concat($processes/m:path,.)"/>
    <xsl:variable name="out">
      <xsl:variable name="process"
      <xsl:apply-templates select="saxon:transform($process,$in)"
        <!-- 'annotate' mode will provide the result with local
annotations -->
        <xsl:with-param name="stylesheet" select="$stylesheet"/>
      <!-- If you don't want the result annotated, simply use
           <xsl:copy-of select="saxon:transform($process,$in)"/> -->
    <xsl:if test="empty(following-sibling::*[1])">
      <xsl:copy-of select="$in"/>
    <xsl:apply-templates select="following-sibling::*[1]">
      <xsl:with-param name="in" select="$out"/>

  <xsl:template match="m:done">
    <xsl:param name="in"/>
    <xsl:copy-of select="$in"/>

  <xsl:template match="/" mode="annotate">
    <xsl:param name="stylesheet" select="'not given'"/>
      <!-- adding a comment to the top of the result -->
      <xsl:text> process run: </xsl:text>
      <xsl:value-of select="$stylesheet"/>
    <xsl:copy-of select="node()"/>


For testing, my one.xsl, two.xsl and three.xsl stylesheets all look
like this (with adjustments):

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"

<xsl:template match="*">
  <xsl:element name="{local-name()}-one">
    <xsl:copy-of select="@*"/>

  <xsl:template match="comment() | processing-instruction()">
    <xsl:copy-of select="."/>


Comments welcome,

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


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.