xslt - Make new node using sub-node sub-string -


i have xml document looks this:

<oldele userlabel="label1">   <ele1>%02d.jpeg</ele1> </oldele>  <oldele userlabel="label2">   <ele1>%02d.tiff</ele1> </oldele> 

i want 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 first of file ext. e.g. if jpeg first, both of nodes. offer expertise advice on why not working.

btw, tried 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> 

<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> 

Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -