Peter
Peter

Reputation: 59

XSLT with value of select in URL string

I want to combine some XSL with XML and put out the resulting HTML.

My XSl contains this line which doesnt work:

<a href="www.domain.com/account/business/get/?t=2&amp;id=<xsl:value-of select="row/objectid"/>">Click here</a>

The desired output would be:

<a href="www.domain.com/account/business/get/?t=2&id=6">Click here</a>

The code works when I leave out the <xsl:value-of select="row/objectid"/> part in the URL. It also works when I place the <xsl:value-of select="row/objectid"/> outside the hyperlink tag, so i KNOW the value-of-select to be correct by itself.

So I suspect that the quotes are messing things up...how can I fix this?

PS. I tried replacing " with ' as well

Upvotes: 0

Views: 1899

Answers (1)

Wayne
Wayne

Reputation: 60414

Your stylesheet should contain well-formed XML, so you can't include the output from value-of in an attribute. Use an attribute value template instead:

<a href="www.domain.com/account/business/get/?t=2&amp;id={row/objectid}"
  >Click here</a>

The expression in curly braces will be evaluated and replaced with its output.

Upvotes: 2

Related Questions