Technology Toolbox

Your technology Sherpa for the Microsoft platform

Jeremy Jameson - Founder and Principal



XSLT "Identity Transform"

This post originally appeared on my MSDN blog:

Since I no longer work for Microsoft, I have copied it here in case that blog ever goes away.

Last week, I was explaining to a teammate that it is often helpful to use the XSLT "Identity Transform" in order to view the raw XML -- in other words, without any "real" transformation by the XSL stylesheet.

For example, suppose you need to customize how search results are displayed in Microsoft Office SharePoint Server (MOSS) 2007. With the Search Core Results Web Part -- or really any Data View Web Part or the newer Data Form Web Part -- you can temporarily replace the XSL stylesheet with the "Identity Transform" in order to view the raw XML to be transformed.

This certainly isn't a new concept -- MSDN has shown how to do this since before MOSS 2007 was even released. Perhaps it was just the fact that I referred to this as the "Identity Transform" that was unknown to my colleague. Having an engineering background -- with more coursework in matrices, determinants, and systems of linear equations than I can remember -- it seems only natural to refer to this as the "Identity Transform."

Regardless of what you call it, here is what I periodically use to view the raw XML:

<xsl:stylesheet version="1.0"
  <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
  <xsl:template match="/">
      <xsl:copy-of select="*"/>

The deprecated <xmp> element is simply used to render the raw XML as text, not as HTML-formatted elements (I don't recommend using this element in any "permanent" fashion).

Save the stylesheet above in your Toolbox as IdentityTransform-Formatted.xslt and you'll never have to recall it from memory or search the Web for it again.


  1. # infoblog » XSLT “Identity Transform”

    March 25, 2009 3:25 AM

Add Comment

Optional, but recommended (especially if you have a Gravatar). Note that your email address will not appear with your comment.
If URL is specified, it will be included as a link with your name.

To prevent spam from being submitted, please select the following fruit: Pear

Please add 6 and 1 and type the answer here: