Subject: Assigning node value to a href element!!!!!!!!!
Posted By: rakesh Post Date: 7/25/2008 7:38:40 AM
Hi All,

I have got arequirement to assign value of a node to an href element. Any idea on how to do this?

I tried like this

<a href='<xsl:value-of select="s:CriminalRecord//d8p1:BinaryReferenceID/d8p1:ID"/>'>Photo</a>

which is not working. Then i tried this way also

<xsl:variable name ="test" select="s:CriminalRecord//d8p1:BinaryReferenceID/d8p1:ID"></xsl:variable>
              <a href="$test">Photo</a>

This also doesnt seem to work. Please help me on this.



Reply By: samjudson Reply Date: 7/25/2008 7:44:32 AM
Can I suggest you either read some online tutorials or get a good book as this is a fundamental part of XSLT.

In the mean time look into using either the <xsl:attribute> instruction or the "{xpath}" notation.

/- Sam Judson : Wrox Technical Editor -/
Reply By: rakesh Reply Date: 7/25/2008 8:12:32 AM
Thanks jason and sorry for the silly question

Reply By: samjudson Reply Date: 7/25/2008 8:29:31 AM
Jason? Who is Jason?

/- Sam Judson : Wrox Technical Editor -/
Reply By: mhkay Reply Date: 7/25/2008 3:17:53 PM
Look up "attribute value templates". You can embed an XPath expression within curly braces:

<a href="{s:CriminalRecord//d8p1:BinaryReferenceID/d8p1:ID}">

or of course

<a href="{$test}">

Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference

Go to topic 73009

Return to index page 1