Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - XSLT: transforming a document into itself [Thread Next] Re: XSLT: transforming a document into itselfTo: NULL Date: 1/6/2008 5:48:00 PM samppi wrote: > I'm teaching myself XSLT right now, but, just as part of learning, I'm > trying to figure out how one would transform a document an identical > document. > > This doesn't work: > > <?xml version="1.0" encoding="utf-8"?> > <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/ > Transform"> > > <xsl:template match="/"> > > <xsl:value-of select="/"/> Well xsl:value-of outputs the string value of the selected node. If you want to copy the complete document then use <xsl:copy-of select="/"/> instead. That copies everything the XSLT/XPath data model knows about. You should also learn about the identity transformation template <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> as that also copies everything but allows you to add templates to override the behaviour e.g. to change 'foo' elements to 'bar' elements you simply add <xsl:template match="foo"> <bar> <xsl:apply-templates select="@* | node()"/> </bar> </xsl:template> -- Martin Honnen http://JavaScript.FAQTs.com/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
