Re: [xsl] output modified branch - best practice

Subject: Re: [xsl] output modified branch - best practice
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Mon, 21 Jun 2010 12:25:49 -0400
Hey look,

Martin just did what I suggested in that other thread, to manage a merge ... which turns out to be an interesting kind of value mapping....

At 11:29 AM 6/20/2010, he wrote:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="2.0">
  <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
  <xsl:strip-space elements="*"/>

<xsl:key name="k1" match="/root/update/data/*" use="node-name(.)"/>

  <xsl:template match="/">
    <xsl:apply-templates select="root/base/data"/>
  </xsl:template>

  <xsl:template match="/root/base/data">
    <xsl:copy>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="/root/base/data/*">
    <xsl:variable name="var.update" select="key('k1', node-name(.))"/>
    <xsl:choose>
      <xsl:when test="exists($var.update)">
        <xsl:copy-of select="$var.update"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:copy-of select="."/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

</xsl:stylesheet>

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