Hi I have passed a paramter which is a field data value of a list of items in an xslt file i need to sort the data based on a field <xsl:value-of select="employeeDepartment"/> where i need to check if the employeeDepartment=$DeptName (as parmeter form request query string)
<xsl:for-each select="$currentPage/*">
<xsl:choose>
<xsl:when test="$deptparam != ''">
<xsl:if test="department=$deptparam">
... do something with filtered department ...
</xsl:if>
</xsl:when>
<xsl:otherwise>
... do something with all departments
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
xslt sorting based on a Value Parameter
Hi I have passed a paramter which is a field data value of a list of items in an xslt file i need to sort the data based on a field <xsl:value-of select="employeeDepartment"/>
where i need to check if the employeeDepartment=$DeptName (as parmeter form request query string)
any code example of the sorting wil be useful
you can sort within a for-each block (http://www.w3schools.com/xsl/el_sort.asp)
This will sort but you won't see much since the department would be the same for all
Are you actually wanting to only filter and not sort?
i thinks its filter cos there are many employees form different departments i wann filter according to paramter the department name
Then use what I suggested but remove the sort line:
Thanks it works how to put a condition there if there is no paramter provided then the for-each statement wont be initiated that way
<xsl:for-each select="$currentPage/*"> <xsl:choose> <xsl:when test="$deptparam != ''"> <xsl:if test="department=$deptparam"> ... do something with filtered department ... </xsl:if> </xsl:when> <xsl:otherwise> ... do something with all departments </xsl:otherwise> </xsl:choose> </xsl:for-each>
Thanks for the anwwers it was very useful
is working on a reply...