xsl-list
[Top] [All Lists]

Re: [xsl] output modified branch - best practice

2010-06-21 11:26:14
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(_at_)mulberrytech(_dot_)com
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
======================================================================


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>