Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Max 144 posts 166 karma points
    Mar 28, 2011 @ 09:24
    Max
    0

    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

     

     

  • Daniel Bardi 924 posts 2556 karma points
    Mar 28, 2011 @ 09:29
    Daniel Bardi
    0

    you can sort within a for-each block  (http://www.w3schools.com/xsl/el_sort.asp)

    <xsl:for-each select="$currentPage/*[department=$deptparam]">

    <xsl:sort select="department" />
    ... do something...

    </xsl:for-each>

    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?

  • Max 144 posts 166 karma points
    Mar 28, 2011 @ 10:05
    Max
    0

    i thinks its filter cos there are many employees form different departments i wann filter according to paramter the department name

     

  • Daniel Bardi 924 posts 2556 karma points
    Mar 28, 2011 @ 10:12
    Daniel Bardi
    0

    Then use what I suggested but remove the sort line:

    <xsl:for-each select="$currentPage/*[department=$deptparam]">

    ... do something...

    </xsl:for-each>

  • Max 144 posts 166 karma points
    Mar 28, 2011 @ 10:52
    Max
    0

    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

     

  • Daniel Bardi 924 posts 2556 karma points
    Mar 28, 2011 @ 11:04
    Daniel Bardi
    0

     

    <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>

     

  • Max 144 posts 166 karma points
    Mar 28, 2011 @ 12:05
    Max
    0

    Thanks for the anwwers it was very useful

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies