Q:

How to make a node result be different depending on the existence of a certain node using XLST? 

My system produces a XML that contain a node that, depending on the type of event, came with different name. 
The name can be <floatRate> or <fixedRate>.  The path is always the same, only the node name that is different. 
I need a transformation that can populate one field based on that name.  The field will be called <type> and the contend must be float or fixed, based on the node name. 
Can this be done? 

A:

This transformation:
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output omit-xml-declaration="yes" indent="yes"/>
    <xsl:strip-space elements="*"/>

 <xsl:template match="node()|@*">
     <xsl:copy>
       <xsl:apply-templates select="node()|@*"/>
     </xsl:copy>
 </xsl:template>

 <xsl:template match="fixedRate|floatRate">
   <type><xsl:value-of select=
           "substring-before(name(),'Rate')"/></type>
 </xsl:template>
</xsl:stylesheet>

when applied on this XML document:
<rates>
    <fixedRate>2.3</fixedRate>
    <floatRate>1.1</floatRate>
</rates>

produces the wanted result:
<rates>
   <type>fixed</type>
   <type>float</type>
</rates>

