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>
Just used this little code snip in a hot situation to save my butt! Thanks!