tags:

views:

115

answers:

2

Hi all, I have an tag, and need to assign value to it's attribute within my XSLT

<?xml version="1.0" encoding="UTF-8" ?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">     
  <xsl:template match="/">

I need to assign value to the trId attribute, but the way I have it now don't work, what is the right way to do it?

<ABX trId="<xsl:value-of select="CODE_VALUE"/>">


  </xsl:template>    
</xsl:stylesheet>
+6  A: 
<ABX>
    <xsl:attribute name="trId"><xsl:value-of select="CODE_VALUE"/></xsl:attribute>
</ABX>

The XSLT <attribute> tag will do exactly what you want.

Adam Batkin
+2  A: 

Or you could simply do this:

<ABX trId="{CODE_VALUE}"/>

The expression inside curly braces is evaluated and the result is put into the attribute value. See Section 7.6.2, Attribute Value Templates in the spec.

Jukka Matilainen