Pass-through XSL for debugging

When debugging certain webparts (e.g. CQWP), you often want to see the raw XML before the XSL is applied. The XSLs below (developed by a colleague) will spit out the original XML.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
	<xsl:template match="/">
		<xmp>
			<xsl:copy-of select="*"/>
		</xmp>
	</xsl:template>
</xsl:stylesheet>

 

This one below renders the XML as a table, with each entity as a row, and each attribute as a column. This would only work if the XML is a single list of entities, and the entities have no child entities.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:variable name="UTCTime" select="/Rows/queryData/CurrentTimeUTC" />
	<xsl:template match="/">
		<Table>
			<xsl:for-each select="//row">
				<TR>
					<xsl:for-each select="@*">
						<TD>
							<br />
							<B>
								<xsl:value-of select="name()" />
							</B>
						</TD>
						<TD>
							<xsl:value-of select="." />
						</TD>
					</xsl:for-each>
				</TR>
			</xsl:for-each>
			<tr>
				<td></td>
			</tr>
		</Table>
	</xsl:template>
</xsl:stylesheet>
Advertisements

About Bernado

Based in Australia, I am a freelance SharePoint and Dynamics CRM developer. I love developing innovative solutions that address business and everyday problems. Feel free to contact me if you think I can help you with your SharePoint or CRM implementation.
This entry was posted in WebPart, XSL. Bookmark the permalink.

One Response to Pass-through XSL for debugging

  1. Tony says:

    Just used this little code snip in a hot situation to save my butt! Thanks!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s