subhorachana
asked on
Complex XSLt query for Data Viewer web part in Sharepoint
Hello,
I am using Data Viewer Web part to show data from a sharepoint list after applying certain conditions to it.
As per my initial requirement, I was supposed to show data from the list that satisfied the below criteria:
<xsl:variable name="Rows" select="/dsQueryResponse/R ows/Row[co ntains(nor malize-spa ce(@Progra m), 'BCare') and contains(normalize-space(@ Functional _x0020_Uni t), 'ClientServices')]" />
I created this as an xslt in the 'Filter' ->Add xslt filtering feature of Dataview Webpart using SPD.The above line got rendered on the Code view of the page.
Now as per the new requirement, I have to add some additional logic. There is a check box field in my list 'Private Flag'.I believe Check Box fields are boolean values.
If <Private Flag> is checked, then do not use the above xslt when retreiving data, else use the above xslt for retreiving data.
I created the following below and replaced the portion of code view with "<xsl:variable name="Rows" select="/dsQueryResponse/R ows/Row[co ntains(nor malize-spa ce(@Progra m), 'BCare') and contains(normalize-space(@ Functional _x0020_Uni t), 'ClientServices')]" />",
with my new code:
<xsl:choose>
<xsl:when test="@Private_x0020_Flag = 1">
<xsl:variable name="Rows" select="/dsQueryResponse/R ows/Row[co ntains(nor malize-spa ce(@Progra m), 'Care') and contains(normalize-space(@ Functional _x0020_Uni t), 'ClientServices')]" />
</xsl:when>
<xsl:otherwise></xsl:other wise></xsl :choose>
This does not work and gives an error on rendering the data view web part.I am very new to xslt.Please suggest what is going wrong here.
I am using Data Viewer Web part to show data from a sharepoint list after applying certain conditions to it.
As per my initial requirement, I was supposed to show data from the list that satisfied the below criteria:
<xsl:variable name="Rows" select="/dsQueryResponse/R
I created this as an xslt in the 'Filter' ->Add xslt filtering feature of Dataview Webpart using SPD.The above line got rendered on the Code view of the page.
Now as per the new requirement, I have to add some additional logic. There is a check box field in my list 'Private Flag'.I believe Check Box fields are boolean values.
If <Private Flag> is checked, then do not use the above xslt when retreiving data, else use the above xslt for retreiving data.
I created the following below and replaced the portion of code view with "<xsl:variable name="Rows" select="/dsQueryResponse/R
with my new code:
<xsl:choose>
<xsl:when test="@Private_x0020_Flag = 1">
<xsl:variable name="Rows" select="/dsQueryResponse/R
</xsl:when>
<xsl:otherwise></xsl:other
This does not work and gives an error on rendering the data view web part.I am very new to xslt.Please suggest what is going wrong here.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Based on this thread:
http://vspug.com/mkruger/2007/06/26/free-sharepoint-dataview-tips/
I get the impression that checkboxes are not boolean, but carry a text value (presumably the content of the checkbox element's value attribute). So if your checkbox is something like
<input type="checkbox" name="Private Flag" value="hitMe" />
maybe your XSLT needs to read something like <xsl:when test="@Private_x0020_Flag = 'hitMe'">
Just a stab in the dark, though.