How to “debug” XSLTs

I don’t use any specific tool to test and debug XSLT files. In 90%+ cases the problem is with the XPath and I need to find the exact place where it becomes wrong. So, I use the “count()” function and (sometimes) xsl:comment, like this:

	-<xsl:value-of select="count(aaa)"/>
	-<xsl:value-of select="count(aaa/bbb)"/>
	-<xsl:value-of select="count(aaa/bbb/ccc)"/>
	-<xsl:value-of select="count(aaa/bbb/ccc[@ddd = 'eee'])"/>

If I see something like


in the output, it’s clear that the problem with the XPath condition in the brackets.

Gennady Kim


One thought on “How to “debug” XSLTs

Leave a Reply

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

You are commenting using your 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