Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert value using XSLT

Tags:

xslt

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>
like image 337
Alex Avatar asked Aug 20 '09 13:08

Alex


2 Answers

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

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

like image 116
Adam Batkin Avatar answered Oct 06 '22 00:10

Adam Batkin


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.

like image 43
Jukka Matilainen Avatar answered Oct 05 '22 22:10

Jukka Matilainen