Re: [xsl] XML Elements Tag (lable) Name is assign at run time

Subject: Re: [xsl] XML Elements Tag (lable) Name is assign at run time
From: Mike Brown <mike@xxxxxxxx>
Date: Mon, 3 Mar 2003 02:01:34 -0700 (MST)
amit.parikh wrote:
> <!-- change tag from ZipCode to PostCode -->
>     <PostCode></PostCode>
> is there any solution which can solve problem with out rewriting XSL
> Template again??

option 1:

<xsl:value-of select="ZipCode|PostCode"/>

xsl:value-of creates a text node using the string-value of the node that comes
first in document order, of all the nodes identified in the expression, which
in this case is the union of all ZipCode and PostCode children of the current

option 2 (untested):

<xsl:stylesheet version="1.0"

  <xsl:output method="html"/>

    This could be in an external document, if you wanted:
    Just adjust the $mappings source, below.

  <xsl:variable name="mappings"

  <xsl:key name="equiv" match="../element" use="element"/>

  <xsl:template match="Customer">
        <td>Date Of Birth:</td>
          <xsl:call-template name="get-childElem-stringValue">
            <xsl:with-param name="childElem-name" select="'DOB'"/>
      <!-- (use same approach for all other rows) -->

  <xsl:template name="get-childElem-stringValue">
    <xsl:param name="childElem-name"/>
    <xsl:if test="childElem-name">
      <xsl:for-each select="$mappings">
        <xsl:value-of select="*[local-name()=key('equiv',$childElem-name)]"/>



  Mike J. Brown   |
  Denver, CO, USA |

 XSL-List info and archive:

Current Thread