View Single Post
  #2 (permalink)  
Old June 8th, 2018, 03:50 AM
mhkay's Avatar
mhkay mhkay is offline
Wrox Author
Points: 18,438, Level: 59
Points: 18,438, Level: 59 Points: 18,438, Level: 59 Points: 18,438, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,954
Thanks: 0
Thanked 290 Times in 285 Posts
Default

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:

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

Code:
<xsl:template match="root/repeat[position() > 1]/*">
  <xsl:element name="{key('renamings', local-name())}">
     <xsl:apply-templates/>
  </xsl:element>
</xsl:template>
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.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference

Last edited by mhkay; June 8th, 2018 at 03:56 AM..
Reply With Quote