raklos
raklos

Reputation: 28545

xslt concat with select inside for-each

Can i use a Select within a concat in xslt? eg

<xsl:for-each select="root/OrderItems/lineitem">
  <xsl:element name="img">
    <xsl:attribute name="src">
    <xsl:value-of select="concat('http://www.site.com/r&amp;h=11', '&amp;q=',<xsl:value-of select="Quantity" />, )" />
    </xsl:attribute>
    </xsl:element>
</xsl:for-each>

Upvotes: 1

Views: 4168

Answers (2)

Nick Allen
Nick Allen

Reputation: 12220

No, because it is not well formed XML, you cannot put a self closing XML element within a self closing XML element, or I suppose in this case you cannot use an XML element in the value of an XML attribute

Upvotes: 0

Andrew Hare
Andrew Hare

Reputation: 351566

Try this:

<xsl:for-each select="root/OrderItems/lineitem">
  <xsl:element name="img">
    <xsl:attribute name="src">
      <xsl:value-of 
        select="concat('http://www.site.com/r&amp;h=11', '&amp;q=', Quantity)" />
    </xsl:attribute>
  </xsl:element>
</xsl:for-each>

Upvotes: 4

Related Questions