Re: [xsl] xsl:value-of issue

Subject: Re: [xsl] xsl:value-of issue
From: "Christian Roth" <roth@xxxxxxxxxxxxxx>
Date: Tue, 7 Sep 2010 18:58:35 +0200
Etheridge, Stephen wrote:

>Source:
>
><MilkList>A value</MilkList>
><MilkListLocalVal>Another value</ MilkListLocalVal>
>
>Desired output:
><MilkList>Another value</MilkList>

I think your logic is a complicated approach. Isn't your desired output
the same as saying

"Discard all *List elements and rename any *ListLocalVal elements to
*List elements."

?

That would then be

<xsl:template name="process-list">
  <xsl:choose>
    <xsl:when test="ends-with( local-name(), 'ListLocalVal')">
      <xsl:element name="{substring-before(local-name(), 'LocalVal')}">
        <xsl:apply-templates />
      </xsl:element>
    </xsl:when>
    <xsl:otherwise>
      <!-- discard the element: do nothing here -->
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

Am I thinking too simple?

-chris

Current Thread