I have an xml document that looks like this:

```
<oldEle userlabel="label1">
  <ele1>%02d.jpeg</ele1>
</oldEle>

<oldEle userlabel="label2">
  <ele1>%02d.tiff</ele1>
</oldEle>

```

I want it to be this:

```
<JPEG userlabel="label1">
  <ele1>%02d.jpeg</ele1>
</JPEG>

<TIFF userlabel="label2">
  <ele1>%02d.tiff</ele1>
</TIFF>

```

I've tried this.

```
<xsl:template match="//xmlns:oldNode[contains(//xmlsns:oldNode/root:ele1, '.')]">
  <xsl:element name="{translate(substring-after(//xmlns:ele1, '.'),
               'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')}">
      <xsl:apply-templates select="@*|node()"/>
  </xsl:element>
</xsl:template>

```

but only get the first of the file ext. e.g. if jpeg is first, I would get for both of the nodes. Could someone offer expertise advice on why this is not working. 

BTW, I also tried this but same thing happened:

```
<xsl:template match="//xmlns:oldNode[contains(//root:ele1, '.jpeg')]">
  <xsl:element name="JPEG">
      <xsl:apply-templates select="@*|node()"/>
  </xsl:element>
</xsl:template>

<xsl:template match="//xmlns:oldNode[contains(//root:ele1, '.tiff')]">
  <xsl:element name="TIFF">
      <xsl:apply-templates select="@*|node()"/>
  </xsl:element>
</xsl:template>

```
['https://Stackoverflow.com/questions/10903013', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1140072/']
```
<xsl:template match="oldNode">
    <xsl:choose>
        <xsl:when test="contains(ele1,'.jpeg')">
            <xsl:element name="JPEG">
                <xsl:apply-templates select="@*|node()"/>
            </xsl:element>
        </xsl:when>
        <xsl:when test="contains(ele1,'.tiff')">
            <xsl:element name="TIFF">
                <xsl:apply-templates select="@*|node()"/>
            </xsl:element>
        </xsl:when>
    </xsl:choose>
</xsl:template>

```
**Here is the same answer as to your previous question -- this solves completely the old and the current problem and no recursion is used**:

```
<xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:my="my:my">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>

     <my:suffixes>
      <s>jpeg</s><s>JPEG</s>
      <s>tiff</s><s>TIFF</s>
      <s>giv</s><s>GIV</s>
      <s>png</s><s>PNG</s>
     </my:suffixes>

     <xsl:variable name="vSufs" select="document('')/*/my:suffixes/s"/>

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

     <xsl:template match="*">
       <xsl:variable name="vSufFound" select=
        "$vSufs[position() mod 2 = 1]
             [substring(translate(current()/ele1, ., ''),
                        string-length(translate(current()/ele1, ., ''))
                        )
             =
              '.'
             ]"/>
       <xsl:choose>
         <xsl:when test="not($vSufFound)">
          <xsl:call-template name="identity"/>
         </xsl:when>
         <xsl:otherwise>
           <xsl:element name="{$vSufFound/following-sibling::s[1]}">
             <xsl:apply-templates select="node()|@*"/>
           </xsl:element>
         </xsl:otherwise>
       </xsl:choose>
     </xsl:template>
</xsl:stylesheet>

```

**When this transformation is applied on the provided XML document, the wanted, correct result is produced:**

```
<t>
    <JPEG userlabel="label1">
        <ele1>%02d.jpeg</ele1>
    </JPEG>
    <TIFF userlabel="label2">
        <ele1>%02d.tiff</ele1>
    </TIFF>
</t>

```

**Explanation**:

In this transformation we are using the following XPath 1.0 expression to implement the standard XPath 2.0 `ends-with($t, $suf)` function:

```
$suf = substring($t, string-length($t) - string-length($suf) +1)

```