MOSS Forum

 
Home » Forum » MOSS       Ask a questionRSS Feeds

XSL trying to show results (data view) depending on 2 querystrings.

  Asked By: Matt Stone         Date: Aug 03, 2010      Category: MOSS      Views: 3061
 

Having issues getting this to work. Can some one assist me?


<xsl:template name="dvt_1">
<xsl:variable name="dvt_StyleName">Table</xsl:variable>
<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row" />

<xsl:variable name="RowsWithFilter" >
<xsl:choose>
<xsl:when test="string-length($QSCategory) != 0 and string-length($QSSubCategory) = 0">
<xsl:value-of select="/dsQueryResponse/Rows/Row[contains(normalize-space(@Category),$QSCategory)]"></xsl:value-of>
<xsl:variable name="FilterCount" select="count(/dsQueryResponse/Rows/Row[contains(normalize-space(@Category),$QSCategory)])"></xsl:variable>
</xsl:when>
<xsl:when test="string-length($QSCategory) = 0 and string-length($QSSubCategory) != 0">
<xsl:value-of select="/dsQueryResponse/Rows/Row[contains(normalize-space(@Subcategory),$QSSubCategory)]"></xsl:value-of>
<xsl:variable name="FilterCount" select="count(/dsQueryResponse/Rows/Row[contains(normalize-space(@Subcategory),$QSSubCategory)])"></xsl:variable>
</xsl:when>
<xsl:when test="string-length($QSCategory) != 0 and string-length($QSSubCategory) != 0">
<xsl:value-of select="/dsQueryResponse/Rows/Row[contains(normalize-space(@Category),$QSCategory) and contains(normalize-space(@Subcategory),$QSSubCategory)]"></xsl:value-of>
<xsl:variable name="FilterCount" select="count(/dsQueryResponse/Rows/Row[contains(normalize-space(@Category),$QSCategory) and contains(normalize-space(@Subcategory),$QSSubCategory)])"></xsl:variable>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="/dsQueryResponse/Rows/Row"></xsl:value-of>
<xsl:variable name="FilterCount" select="count(/dsQueryResponse/Rows/Row)"></xsl:variable>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!--Find the number of rows depending on the existence of the parameter-->
<!--<xsl:variable name="dvt_RowCount" select="count($Rows)" />-->
<xsl:variable name="dvt_RowCount">
<xsl:choose>
<xsl:when test="string-length($QSCategory) = 0">
<xsl:value-of select="count($Rows)"></xsl:value-of>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="count($FilterCount)"></xsl:value-of>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>

Tagged:                    

 

2 Answers Found

 
Answer #1       Answered By: Jordon Willis          Answered On: Aug 03, 2010       

Could you please provide more details on what you are trying to do and what is problem you are getting.

 
Answer #2       Answered By: Matt Stone          Answered On: Aug 03, 2010       

I have a SharePoint dataview and i am trying to feed two QueryStrings into the dataview.
If QueryStrings QSCategory blank and QSSubCategory blank
then show  all results  no filter.
If QueryString QSCategory not blank and QSSubCategory blank
then show where @Category = QSSubCategory
If QueryString QSCategory not blank and QSSubCategory not blank
then show where @Category = QSSubCategory and @SubCategory = QSSubCategory


Bassically I have two QueryStrings I want to display all records or check value of
QSCategory and QSSubCategory and filter when a value exists.

Stripping out some of my code I get to this point.


<xsl:template name="dvt_1">
<xsl:variable name="dvt_StyleName">Table</xsl:variable>
<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row" />
<xsl:variable name="RowsWithFilter">
<xsl:choose>
<xsl:when test="$QSCategory = ''">
<xsl:value-of select="/dsQueryResponse/Rows/Row[@Category=$QSCategory]" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="/dsQueryResponse/Rows/Row" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>

<xsl:variable name="dvt_RowCount">
<xsl:choose>
<xsl:when test="$QSCategory = ''">
<xsl:value-of select="count($Rows)" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="count($RowsWithFilter)" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>



Error: Failed setting processor stylesheet: 0x80004005 : Argument 1 must return a node-set. -->count($RowsWithFilter)<--

If you have a better approch or see my problem please help!!

 


Your Answer
  • Answer should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].