xslt tag in html property
I am using xslt in Umbraco. I want to get an image from the media folder as a background for a div I'm creating. My problem is I don`t know how to use both HTML and xslt in the same line (if I even need to开发者_运维问答) For example:
<div style="background-image: url([get image path via xslt]);"></div>
Any ideas on how this can be done? Thank you! -Elad
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<div style="background-image: url({/root/image});"/>
</xsl:template>
</xsl:stylesheet>
Applied against this XML:
<root>
<image>http://example.com/lolcat.gif</image>
</root>
Result is:
<div style="background-image: url(http://example.com/lolcat.gif);"></div>
I know nothing about Umbraco but you can try to read if this is what you wanted.
<xsl:element name="div">
<xsl:attribute name="style">
<xsl:text disable-output-escaping="yes">background-image: url(</xsl:text>
<xsl:value-of select="[get image path via xslt]"/>
<xsl:text disable-output-escaping="yes">);</xsl:text>
</xsl:attribute>
</xsl:element>
精彩评论