Re: [xsl] Copy results

Subject: Re: [xsl] Copy results
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 08 Jul 2008 17:31:18 -0400
Steven,

At 04:06 PM 7/8/2008, you wrote:
In fact, I was after rather more specific information: unrelated to
any opinion about what I "should" be doing. I essentially asked for
the optimal way to place result-document output in two locations. So
far, I have been offered no quantified reason for not doing what I
propose that actually would impact scaling or robustness.

I don't believe anyone said that doing this much would be such a bad thing. They just warned about going down this road with an expectation of getting very far.


And I added that although I don't rely on it to get very far, I do travel this road frequently, and I don't think there's anything wrong with that.

As for xsl:result-document, since its href takes an AVT, there are as many ways to use it to place output in multiple locations as there are of handling values in XSLT. This usually comes down to iterating over items in a series, with xsl:for-each or (if the items are nodes) with apply-templates. No problem.

<xsl:variable name="locations" as="element()*">
  <loc>file1.xml</loc>
  <loc>file2.xml</loc>
  <loc>file3.xml</loc>
</xsl:variable>
<xsl:apply-templates select="$locations" mode="make-file">
  <xsl:with-param name="contents" select="$contents"/>
</xsl:apply-templates>

...

<xsl:template match="loc" mode="make-file">
  <xsl:param name="contents" as="element()?"/>
  <xsl:if test="exists($contents)">
    <xsl:result-document href="{.}">
      <xsl:copy-of select="$contents"/>
    </xsl:result-document>
  </xsl:if>
</xsl:template>

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