R – Extending Sharepoint XSL template

sharepointxslt

Thanks to this post I've come up with the following template:-

<xsl:variable name="Doc">
  <xsl:call-template name="OuterTemplate.GetTitle">
    <xsl:with-param name="Title" select="@DocumentLink1"/>
  </xsl:call-template>
</xsl:variable>

<a href="{substring-before($Doc,',')}">
  <xsl:value-of select="substring-after($Doc,',')" />
</a>

This template is nested in an unorderd list and li tag (see below). Since this code has a physical and visual presence in the html page when no content exists I would like to add the li tags and possibly the ul tags to the template. Can anyone tell me how to accomplish this?

<ul>
<li>
    <xsl:variable name="Doc">
        <xsl:call-template name="OuterTemplate.GetTitle">
            <xsl:with-param name="Title" select="@DocumentLink1"/>
        </xsl:call-template>
    </xsl:variable>
<a href="{substring-before($Doc,',')}">
    <xsl:value-of select="substring-after($Doc,',')"/>
</a>
</li>
<li>
<xsl:variable name="Doc">
        <xsl:call-template name="OuterTemplate.GetTitle">
            <xsl:with-param name="Title" select="@DocumentLink2"/>
        </xsl:call-template>
    </xsl:variable>
<a href="{substring-before($Doc,',')}">
    <xsl:value-of select="substring-after($Doc,',')"/>
</a>
</li>
<li>
<xsl:variable name="Doc">
        <xsl:call-template name="OuterTemplate.GetTitle">
            <xsl:with-param name="Title" select="@DocumentLink3"/>
        </xsl:call-template>
    </xsl:variable>
<a href="{substring-before($Doc,',')}">
    <xsl:value-of select="substring-after($Doc,',')"/>
</a>
</li>

Best Solution

I'm assuming from your link to the other post that you are using the Content Query Web Part here.

You need to wrap your call to this variable using XSLT header/footer techniques. Here is one of a few posts I've seen that show how this can be done with the CQWP in particular.

Related Question