p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   XSLT (http://p2p.wrox.com/forumdisplay.php?f=86)
-   -   element text to element name xslt (http://p2p.wrox.com/showthread.php?t=99906)

smok.hcl@gmail.com June 7th, 2018 11:18 PM

element text to element name xslt
I want to convert element text to element name. I may sound wierd. let me give an example


expected output


Please help.

mhkay June 8th, 2018 03:50 AM

Despite the title of your question, you don't seem to be changing the "element text" at all, you are only changing the name.

Define a mapping from old names to new names like this:


<xsl:key name="renamings" match="root/repeat[1]/*" use="local-name()"/>
And then convert elements like this:


<xsl:template match="root/repeat[position() > 1]/*">
  <xsl:element name="{key('renamings', local-name())}">

And of course you need templates to copy the bits you want to copy and delete the bits you want to delete, but that's all perfectly standard stuff.

All times are GMT -4. The time now is 05:24 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.