Unlocking the Mysteries of Data View Web Part XSL Tags – Part 17 – <xsl:comment> and <xsl:text>

This entry is part 17 of 21 in the series Unlocking the Mysteries of Data View Web Part XSL Tags

Cross-posted from EndUserSharePoint.com

There are a few more XSL tags that I should briefly touch upon. They are used much less often than the others that I’ve covered, but more than the bunch that I’m not going to talk about at all. There’s a set of them that are really only going to make sense to hard-code XSL junkies. I’m going to assume that readers of EndUserSharePoint.com don’t typically fall into this category.

<xsl:comment>

This one should be pretty obvious. With <xsl:comment>, you can insert comments into your XSL. (Did you guess right?) You can include any valid text within the <xsl:comment> tags.

There’s a big caveat with this, however, and it’s probably the main reason why you don’t see a lot of comments in Data View Web Part (DVWP) XSL. When you make changes using the Common Data View Tasks (the dialogs), SharePoint Designer can tend to move your comments around. That means that the really great comment you wanted to put into your XSL (like <xsl:comment>The next line does X.</xsl:comment>) may end up in a completely different part of the XSL. (As I’ve mentioned before, SharePoint Designer is really a code-generator.)

<xsl:text>

At least a few of the XSL tags have names that make sense, right? <xsl:text> lets you output text. The nice thing is the by enclosing the text in the <xsl:taxt> tags, you’re basically saying “Don’t mess with this”. You also have the option, like with <xsl:value-of>, to include the disable-output-escaping="yes" attribute. This allows you to include HTML markup.

Here are a few examples:

<xsl:text>blah blah blah</xsl:text>
<xsl:text disable-output-escaping="yes"><a href="http://blah">blah blah blah</a></xsl:text>

Generally, you can achieve the same effect with <xsl:value-of> by enclosing the value in single quotes in the select attribute:

<xsl:value-of select="'blah blah blah'"/>

No, I’m not quite done with this series yet, but I do think that I’ve covered all of the XSL tags that will be of general interest. If there are any which you were waiting breathlessly for, ping me and I’ll add them later. The next installment will cover a few ddwrt: functions which I’ve never been able to figure out. Nothing sensical on the Web, no documentation, just fun stuff all around.

Series Navigation<< Unlocking the Mysteries of Data View Web Part XSL Tags – Part 16 – <xsl:attribute>Unlocking the Mysteries of Data View Web Part XSL Tags – Part 18 – Miscellaneous – Some Math / Number Functions >>

2 Comments

  1. Hi Marc,
    It would be great if you come out with a book on SharePoint Designer’s xsl programming with examples, tips and trick.
    I will be the first one to buy it.
    You are very good at the fundamentals of xsl programming.
    Bharat.

    Reply

Have a thought or opinion?