Mega Code Archive

 
Categories / XML Tutorial / XSLT StyleSheet
 

Add new tags to xml document

File: Data.xml <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <name>   <last>A</last>   <first>B</first> </name> File: Transform.xslt <?xml version="1.0"?> <xsl:stylesheet version="1.0"   xmlns:xsl="http://www.w3.org/1999/XSL/Transform">   <xsl:output method="xml" indent="yes" encoding="UTF-8" />   <xsl:output version="1.1" />   <xsl:template match="name">     <name>       <family>         <xsl:apply-templates select="last" />       </family>       <given>         <xsl:apply-templates select="first" />       </given>     </name>   </xsl:template> </xsl:stylesheet> Output: <?xml version="1.1" encoding="UTF-8"?> <name>    <family>A</family>    <given>B</given> </name>