<see langword="null"/> workaround.

Topics: User Forum
Oct 8, 2007 at 9:32 PM
Hi All...

I think most of us use the <see langword="null"/> in our XML docs, hoping that it would be translated into something like "null (Nothing in Visual Basic)".

And when I compiled my docs I found it was being replaced with <span class="cs">null</span><span class="vb">Nothing</span>.

Which was not exactly what I was expecting...

So, poking here and there I added the following to the Sandcastle\Presentation\Shared\transforms\utilities_reference.xsl that finally translated it right, although not quite using <see langword...>, instead a costruct like <langword name="..."/>.

<!-- Support for the tag <langword name="" /> -->
<xsl:template match="langword@name">
<xsl:choose>
<xsl:when test="@name='null' or @name='Nothing'">
<span class="keyword">null</span> (<span class="keyword">Nothing</span> in Visual Basic)
</xsl:when>
<xsl:when test="@name='static' or @name='Shared'">
<span class="keyword">static</span> (<span class="keyword">Shared</span> in Visual Basic)
</xsl:when>
<xsl:when test="@name='virtual' or @name='Overridable'">
<span class="keyword">virtual</span> (<span class="keyword">Overridable</span> in Visual Basic)
</xsl:when>
<xsl:otherwise>
<span class="keyword">
<xsl:value-of select="@name" />
</span>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

Adding the above just before the end of the stylesheet.
Coordinator
Oct 9, 2007 at 12:50 AM
Actually, the default behavior is connected to the language filter. If you select VB.NET, you see the VB.NET keyword, if you select C#, you see the C# keyword, etc.

Eric
Oct 9, 2007 at 1:23 AM
OK, then how do I make to display the language selector?
Coordinator
Oct 9, 2007 at 2:28 AM
For the Prototype style, there's a combo box in the upper right corner of the page. For the Hana and VS2005 styles, there's Language Filter link at the top of the page. Hovering over it shows a popup in which you can check or uncheck the languages. Since Hana and VS2005 are multi-select with regard to the language filter, it defaults to the VB.NET style for the filtered elements such as langword. The only way to change that behavior is to edit the stylesheet to set the default state of the display attribute for the various span elements such as span.vb, span.cs, etc.

Eric
Oct 10, 2007 at 7:57 AM
I think this should be considered a bug. I have just noticed the effect and it does not make any sense. In the VS2005, if you
select All, nothing appears for the null keyword just empty space!

Best regards,
Paul.