Simplify your XSLT

Xslt is for data transformation, and it’s very good at that, but a XSLT-code-file can easily get very complex and hard to read and debug. It’s good to

  • simplify the code
  • combine it with calls to regular .net-code in assemblies
  • separate code in templates
  • handle variables in a separate section
  • use a good naming convention.

And specifically

Put  variable selects inside the variable tag,

<xsl:variable name="booleanVariable" select="$expression"/>

instead of

<xsl:variable name="booleanVariable"><xsl:value-of select="$expression/></xsl:variable>

most important for boolean variables, because they will evaluate to string ‘true’ / ‘false’ if used as in the latter.

Leave a Reply

Please log in using one of these methods to post your comment: 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