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.

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

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!
@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: 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.
Thank you so much & yeah I am limited to XSLT 1.0/XPath 1.0!! It will come in handy :D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.