I've been doing some really cool stuff with the Content Query Web Part (CQWP) lately, so I'm gonna put together a few posts on some of the nice challenges that I had to tackle.
After playing around with XSLT for a while now, I have grown to love it and I think it is awesome and really flexible. When styling the CQWP, you sometimes have to get to the RAW xml data that comes out of it – it really helps you understand how XSL style sheets work when you have the raw view. In my case, I had to understand how the grouping functionality of the web part works, so I can incorporate it into my XSLT styling (more posts to follow).
The following XSL template dumps the xml for you:
1: <xsl:template match="/">
2: <xmp><xsl:copy-of select="*"/></xmp>
3: </xsl:template>
I place the above in my own “main” XSL file of the CQWP – I never edit the original one created by the Publishing Infrastructure feature called ContentQueryMain.xsl.
I replace the following template call with the 3 lines above:
1: <xsl:template match="/">
2: <xsl:call-template name="OuterTemplate" />
3: </xsl:template>
I also do a small change to the output tag (the first line after the opening <xsl:stylesheet tag)
1: //the original:
2: <xsl:output method="html" indent="no" />
3:
4: //modified
5: <xsl:output method="xml" indent="yes" />
This shows me the raw xml in a nice, structured way: