SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

MOSS 2007. I have a joined list with mutliple categories. I have a two column layout where the category is the header for each section with a group of subcategories. The categories are filtered based on a query string value called Audience. If all the categories exist for that Audience the layout works as desired in alphabetical order left to right. If the first category does not exist it will not show in the view and the second category will move over correctly, but the next category will not move up next to the second category. I am assuming this is because the position numbers did not change. So is there a way for me to reset the position number. I cant seem to get the filter I need to work before for-each I think that would solve my problem.

As of right now it looks like below when Category 1 and Category 5 do not exist for this audience.

    Category 2 
    Category 3 | Category 4 
    Category 6  
    Category 7 | Category 8 | Category 9

My code:

<xsl:template name="CategoryList">
    <xsl:variable name="dvt_StyleName">2ColCma</xsl:variable>
    <xsl:variable name="Rows" select="/dsQueryResponse/Categories/Rows/Row" />      
    <table border="0" width="100%">
            <xsl:call-template name="CategoryList.body">
                <xsl:with-param name="Rows" select="$Rows" />
<xsl:template name="CategoryList.body">
    <xsl:param name="Rows" />
    <xsl:for-each select="$Rows">   
        <xsl:sort select="../../../Rows/Row/@Title" order="ascending" />
            <xsl:call-template name="CategoryList.rowview" />
<!--Determines which Categories to display-->
<xsl:template name="CategoryList.rowview">
    <xsl:variable name="ParentCategory" select="@Title" />
    <xsl:variable name="DocumentRows" select="../../../Documents/Rows/Row[contains(@Category, $ParentCategory) and contains(@Audience, $Audience)]" />
    <xsl:variable name="RowCount" select="count($DocumentRows)" />
    <xsl:variable name="dvt_IsEmpty" select="$RowCount != 0" />
    <xsl:if test="$dvt_IsEmpty" >
        <td valign="top" width="50%" >
            <table border="0" cellspacing="0" width="100%">
                <tr class="ms-WPHeader" >
                    <td width="75%" class="ms-standardheader ms-WPTitle" nowrap="nowrap">
                        <xsl:value-of select="@Title" />
                        <xsl:call-template name="SubcategoryList" />
        <xsl:if test="position() mod 2 = 0" ddwrt:cf_ignore="1">
            <xsl:text disable-output-escaping="yes">&lt;/tr&gt;</xsl:text>
                <xsl:if test="position() != last()" ddwrt:cf_ignore="1">
                    <xsl:text disable-output-escaping="yes">&lt;tr&gt;</xsl:text>
share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.