Quantcast
Channel: C1 CMS Foundation - Open Source on .NET
Viewing all articles
Browse latest Browse all 2540

New Post: Using an Image Path with a "background-image" attribute in an XSLT Function

$
0
0
I tried your sample simplified a bit and it works OK.

Please try to write the entire variable declaration in one line:
<xsl:variable>...</xsl:variable>
and not in 2+ lines:
<xsl:variable>
...
</xsl:variable>
The latter inserts spaces before and after ~/media(...) and thus doesn't resolve

In my example below, I omitted the "actionimage" set and changed the GetIActionImageFileXml to the system's GetIImageFileXml
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:in="http://www.composite.net/ns/transformation/input/1.0"
    xmlns:lang="http://www.composite.net/ns/localization/1.0"
    xmlns:f="http://www.composite.net/ns/function/1.0"
    xmlns="http://www.w3.org/1999/xhtml"
    exclude-result-prefixes="xsl in lang f">

    <xsl:variable name="TileActionImage">~/media(<xsl:value-of select="in:inputs/in:result[@name='GetIImageFileXml']/IImageFile/@Id" />)</xsl:variable>
    <xsl:attribute-set name="actionimage">
        <xsl:attribute name="style">background-image:url('<xsl:value-of select="$TileActionImage" />'); background-repeat:no-repeat; background-position:right bottom;</xsl:attribute>
    </xsl:attribute-set>

    <xsl:template match="/">
        <html>
            <head/>
            <body>
                <div xsl:use-attribute-sets="actionimage">
                    hghghghg
                    <br/>
                    gfgfgf
                    <br/>
                    ddhdjd
                    
                </div>  
            </body>
        </html>
    </xsl:template>
</xsl:stylesheet>
This works.

/Vitaly

Viewing all articles
Browse latest Browse all 2540

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>