Search code examples
xsltsharepoint-2010sharepoint-designerxslt-1.0

Changing URL query string parameter value in for-each loop, xslt


I am using a key to get distinct values from a column's substring as follows:

<xsl:for-each select="//dsQueryResponse/Rows/Row[generate-id() = generate-id(key('Years',substring(@Date, string-length(@Date) - 3, 4))[1])]">

    <a href="../RestOfTheURL?QSP=2010">
        <xsl:value-of select="substring(@Date, string-length(@Date) - 3, 4)" />
    </a>
    <xsl:text> | </xsl:text>
 </xsl:for-each>

I want to pass the URL (in place of the set 2010) different values at each iteration (In particular I want to pass 'substring(@Date, string-length(@Date) - 3, 4)'. Is this possible in xslt?

I am new to xslt.


Solution

  • I think this is what you're asking for:

    <a>
      <xsl:attribute name="href">
        <xsl:value-of select="concat('../RestOfTheURL?', substring(@Date, string-length(@Date) - 3, 4))"/>
      </xsl:attribute>
      <xsl:value-of select="substring(@Date, string-length(@Date) - 3, 4)"/>
    </a>
    

    I hope this helps.