Search

Why doesn’t this work?

<xsl:attribute name="style">background-image:url({$root}/workspace/images/article-list-images/<xsl:apply-templates select="article-list-image/item/filename" />);</xsl:attribute>

{$root} is not evaluated into the current root.

Because $root is part of the text content in your expression.

Try this:

<xsl:attribute name="style">background-image:url(<xsl:value-of select="$root"/>/workspace/images/article-list-images/<xsl:apply-templates select="article-list-image/item/filename" />);</xsl:attribute>

Of course. Thanks!

Why doesn’t this work?

Adding to what Michael said, curly braces are used to evaluate an expression within an attribute (i.e. between the quotes). Remember that <xsl:attribute> is an element.

Thanks, Lewis. I was really missing the right words…

FWIW, the curly braces contain ‘attribute value templates’, for your XSL jargon library.

Andrew FTW :-)

‘attribute value templates’

Cool.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details