xml to xml conversion using xslt

As I am new to XSLT wanted to perform some xsl transformation on my xml file and generate the xml. But when I were looking for some example how to do it I was getting all example who teach you how to transform an xml to html. So here is the way I found after some web search. Look at the tag <xsl:output> and its method just set it to xml as below. The code snippet to just copy all the elements and attributes from one xml file to another. If you want to perform some operations or checks you are free to add new templates.

<xsl:stylesheet version='1.0' 
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> 

<xsl:output method='xml' indent='yes' /> 

<!-- copy all elements which don't match any template --> 
  <xsl:template match="* | @*"> 
    <xsl:copy> 
       <xsl:copy-of select="@*" /> 
       <xsl:apply-templates /> 
    </xsl:copy> 
  </xsl:template> 
</xsl:stylesheet>

Posted at at 6:19 AM on Thursday, September 30, 2010 by Posted by Ravindra Nikam | 0 comments   | Filed under: , , ,