Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XSLT: 'xsl:value-of' within an attribute

Tags:

xml

xslt

I have the following XSL transformation:

<xsl:for-each select="refsect1[@id = 'seealso']/para/citerefentry">
  /// <seealso cref=""/>
  <xsl:value-of select="refentrytitle" />
</xsl:for-each>

How can I place the value of refentrytitle in the cref attribute of the seealso tag in the template?

like image 225
Luca Avatar asked Feb 23 '23 02:02

Luca


2 Answers

I don't understand how place the value of refentrytitle in the cref attribute of the seealso tag in the template.

Just put your expression within curly brackets (this is called Attribute Value Templates or simply AVT syntax) like this:

<seealso cref="{refentrytitle}"/>
like image 91
Grzegorz Szpetkowski Avatar answered Feb 25 '23 15:02

Grzegorz Szpetkowski


You could do this:

<xsl:for-each select="refsect1[@id = 'seealso']/para/citerefentry">
  /// <xsl:element name="seealso">
    <xsl:attribute name="cref">
      <xsl:value-of select="refentrytitle" />
    </xsl:attribute>
  </xsl:element>
</xsl:for-each>

Or you could probably just do this:

<xsl:for-each select="refsect1[@id = 'seealso']/para/citerefentry">
  /// <seealso cref="{refentrytitle}" />
</xsl:for-each>
like image 22
James Avatar answered Feb 25 '23 15:02

James