Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Niels Henriksen 15 posts 35 karma points
    Apr 18, 2011 @ 16:06
    Niels Henriksen
    0

    Problem with custom xml and for-each

    I have a big problem with some xml and xslt. When a user watch a profilepage i generate the xml on-the-fly and in this xml can be several pictures.

    I want to use for-each to list these pictures but now I have been using 4 hours and went 13 pages down on google.

    Function call:

    <xsl:variable name="boat" select="Customer.Xslt:GetBoatOnUrl()"/>

    XML:

    <boat>
    <name>name of test</name>
    <images>
    <url>image1.jpg</url>
    <url>image2.jpg</url>
    <url>image3.jpg</url>
    <url>image4.jpg</url>
    <url>image5.jpg</url>
    <url>image6.jpg</url>
    <url>image7.jpg</url>
    </images>
    </boat>

    XSLT for making the list

    <xsl:variable name="boatimages" select="$boat/images/url"/>
    <xsl:for-each select="$boatimages">
    <div class="slide-pic"><img alt="" src="/gfx/showboat/{url}" /></div>
    </xsl:for-each>

    The result:

    <div class="slide-pic"><img alt="" src="/gfx/showboat/"></div>
    <div class="slide-pic"><img alt="" src="/gfx/showboat/"></div>
    <div class="slide-pic"><img alt="" src="/gfx/showboat/"></div>
    <div class="slide-pic"><img alt="" src="/gfx/showboat/"></div> <div class="slide-pic"><img alt="" src="/gfx/showboat/"></div> <div class="slide-pic"><img alt="" src="/gfx/showboat/"></div>

    I think I have tried everything but right now Im lost :(

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 18, 2011 @ 16:09
    Tom Fulton
    0

    Hi,

    You'll want to change the img src to:  <img alt="" src="concat('/gfx/showboat/', .)"/>

    That is, change {url} to just ".", since you are already selecting the /url node in your for-each.

    -Tom

  • Niels Henriksen 15 posts 35 karma points
    Apr 18, 2011 @ 16:25
    Niels Henriksen
    0

    yes.... it worked :)

    <img alt="" src="{concat('/gfx/showboat/', .)}"/>

    Thanks Tom

Please Sign in or register to post replies

Write your reply to:

Draft