php - Convert all node's attributes into child nodes -


is there way convert nodes' attributes child nodes using xslt 1.0 ? must run flawlessly php's xsltprocessor. attributes must removed (if possible).

example input :

<root aaa="111" bbb="222" ccc="333">     <bob ddd="444" />      <data eee="555">         <steve>bar1</steve>         <john>bar2</john>         <peter fff="666">bar3</peter>     </data>      <greg ggg="777" /> </root> 

the desired result :

<root>     <aaa>111</aaa>     <bbb>222</bbb>     <ccc>333</ccc>     <bob>         <ddd>444</ddd>     </bob>     <data>         <eee>555</eee>         <steve>bar1</steve>         <john>bar2</john>         <peter>             <fff>666</fff>             bar3         </peter>     </data>     <greg>         <ggg>777</ggg>     </greg> </root> 

thank you!

tested on oxygen/xml using saxon6.5:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform" version="1.0">   <xsl:output method="xml" indent="yes"/>    <xsl:template match="node()">     <xsl:copy>       <xsl:apply-templates select="@*|node()"/>     </xsl:copy>   </xsl:template>    <xsl:template match="@*">     <xsl:element name="{name()}"><xsl:value-of select="."/></xsl:element>   </xsl:template>  </xsl:stylesheet> 

this based on using identity template element nodes , template converts attributes elements.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -