3

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.

halfer
  • 19,824
  • 17
  • 99
  • 186
anpatel
  • 1,952
  • 4
  • 19
  • 36

1 Answers1

4

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.

Zach Young
  • 10,137
  • 4
  • 32
  • 53
  • Thank You!! It does, it worked like a charm! I didn't know there was a concat(,) in xslt, good to know it will help me in the future as well. Thank you so much! – anpatel Jan 20 '12 at 17:16
  • 2
    @MyName: I'm guessing, since you're also tagging these as SharePoint, that you're limited to XSLT 1.0/XPath 1.0. There aren't a lot of string functions for XPath 1.0, but here they are: http://www.w3.org/TR/xpath/#section-String-Functions. There's also the notion of *extension* functions to overcome these limitations, but I haven't really used MSXML, so I don't know them. – Zach Young Jan 20 '12 at 17:22
  • Thank you so much & yeah I am limited to XSLT 1.0/XPath 1.0!! It will come in handy :D – anpatel Jan 20 '12 at 18:30