title: Make new node using sub-node sub-string
body: <p>I have an xml document that looks like this:</p>
  
  <pre><code>&lt;oldEle userlabel="label1"&gt;
    &lt;ele1&gt;%02d.jpeg&lt;/ele1&gt;
  &lt;/oldEle&gt;
  
  &lt;oldEle userlabel="label2"&gt;
    &lt;ele1&gt;%02d.tiff&lt;/ele1&gt;
  &lt;/oldEle&gt;
  </code></pre>
  
  <p>I want it to be this:</p>
  
  <pre><code>&lt;JPEG userlabel="label1"&gt;
    &lt;ele1&gt;%02d.jpeg&lt;/ele1&gt;
  &lt;/JPEG&gt;
  
  &lt;TIFF userlabel="label2"&gt;
    &lt;ele1&gt;%02d.tiff&lt;/ele1&gt;
  &lt;/TIFF&gt;
  </code></pre>
  
  <p>I've tried this.</p>
  
  <pre><code>&lt;xsl:template match="//xmlns:oldNode[contains(//xmlsns:oldNode/root:ele1, '.')]"&gt;
    &lt;xsl:element name="{translate(substring-after(//xmlns:ele1, '.'),
                 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')}"&gt;
        &lt;xsl:apply-templates select="@*|node()"/&gt;
    &lt;/xsl:element&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>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. </p>
  
  <p>BTW, I also tried this but same thing happened:</p>
  
  <pre><code>&lt;xsl:template match="//xmlns:oldNode[contains(//root:ele1, '.jpeg')]"&gt;
    &lt;xsl:element name="JPEG"&gt;
        &lt;xsl:apply-templates select="@*|node()"/&gt;
    &lt;/xsl:element&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="//xmlns:oldNode[contains(//root:ele1, '.tiff')]"&gt;
    &lt;xsl:element name="TIFF"&gt;
        &lt;xsl:apply-templates select="@*|node()"/&gt;
    &lt;/xsl:element&gt;
  &lt;/xsl:template&gt;
  </code></pre>