[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XML Elements Tag (lable) Name is assign at run tim

Subject: Re: 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)
xsl select entire element tag
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
node.


option 2 (untested):

<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:data="urn:dummy-non-null-ns">

  <xsl:output method="html"/>

  <!--
    This could be in an external document, if you wanted:
    Just adjust the $mappings source, below.
  --> 
  <data:sourceMappings>
    <equivalentElementNames>
      <element>DOB</element>
      <element>DateOfBirth</element>
    </equivalentElementNames>
    <equivalentElementNames>
      <element>ZipCode</element>
      <element>PostCode</element>
    </equivalentElementNames>
  </data:sourceMappings>

  <xsl:variable name="mappings"
    select="document('')/xsl:stylesheet/data:sourceMappings"/>

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

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

  <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)]"/>
      </xsl:for-each>
    </xsl:if>
  </xsl:template>

</xsl:stylesheet>

Mike

-- 
  Mike J. Brown   |  http://skew.org/~mike/resume/
  Denver, CO, USA |  http://skew.org/xml/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.