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>
contains(), do note that just using contains() isn't sufficient -- the text may be:%02d.jpeg.tiff