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

getting result documents out of a function that calls

Subject: getting result documents out of a function that calls transform()
From: "Graydon graydon@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 31 Mar 2021 18:25:07 -0000
 getting result documents out of a function that calls
In the interest of doing a bunch of small named transformations in a
particular order (for refactoring, or to regularize content before
processing it generally), I have this function:


<xsl:function name="local:processList" as="document-node()">
    <xsl:param as="document-node()" name="initial" />
    <xsl:param as="xs:string*" name="list" />

    <xsl:choose>
      <xsl:when test="not(exists($list))">
        <xsl:sequence select="$initial" />
      </xsl:when>
      <xsl:otherwise>
        <xsl:sequence select="
            local:processList(
              transform(
                map:merge(($transformMap(head($list)),
                map:entry('source-node', $initial))
                )
              )?output, tail($list)
            )" />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:function>

The function works fine; given an initial document, a list of named
transformation events, and a map between transformation even names and
maps of transform() paramters:

<xsl:map>
  <xsl:map-entry key="'first'">
    <xsl:map>
      <xsl:map-entry key="'stylesheet-location'" select="'one.xsl'" />
      <xsl:map-entry key="'stylesheet-params'">
        <xsl:map>
          <xsl:map-entry key="QName('', 'debugPath')" select="concat($diagnosticPath, '/first.xml')" />
        </xsl:map>
      </xsl:map-entry>
      <xsl:map-entry key="'static-params'">
        <xsl:map>
          <xsl:map-entry key="QName('', 'DEBUG')" select="$DEBUG" />
        </xsl:map>
      </xsl:map-entry>
    </xsl:map>
  </xsl:map-entry>
  b&
</xsl:map>

(and the actual individual transform xsl documents), it does the thing
and performs each of the transforms in the expected order.  I can get
$DEBUG into the transform function call, so in principle
xsl:result-document is being called when $DEBUG is true to return
whatever document the individual XSL transform produced.

How do I get those DEBUG result documents back out of the function?

The only approach I can think of is to add an argument to the function
and have that accumulate the full return maps from calls to transform()
and to pass that back when the function completes.  This feels like it
lacks elegance.

Is there a better way?

Thanks!

-- 
Graydon Saunders  | graydonish@xxxxxxxxx
CC&s oferC)ode, C0isses swC! mC&g.
-- Deor  ("That passed, so may this.")

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.