Copied to clipboard

Flag this post as spam?

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


  • ds 191 posts 223 karma points
    Sep 06, 2010 @ 09:41
    ds
    0

    How to prevent displaying nodes twice?

    Hi all,

    I have created such structure for my flash xml file.

    <gallery title="Standalone example" description="Slideshow example demonstrating event listeners.">
    <xsl:for-each select="$currentPage/node [string(data [@alias='umbracoNaviHide']) != '1']">
    <album lgPath="http://localhost" tnPath="http://localhost" title="{data[@alias = 'albumTitle']}" description="{data[@alias = 'albumDescription']}">
    <xsl:for-each select="$currentPage//node [string(data [@alias='umbracoNaviHide']) != '1']">
    <xsl:if test="./data [@alias = 'video']">
    <img src="{data[@alias = 'video']}" title="{data[@alias = 'title']}" caption="{data[@alias = 'caption']}" link="{data[@alias = 'link']}" target="_blank" pause="2" />
    </xsl:if>
    <xsl:if test="node[./data[@alias = 'image']]">
    <img src="{data[@alias = 'image']}" title="{data[@alias = 'title']}" caption="{data[@alias = 'caption']}" link="{data[@alias = 'link']}" target="_blank" pause="2" />
    </xsl:if>
    </xsl:for-each>
    </album>
    </xsl:for-each>
    </gallery>

    and this xml file output the following xml:

    <gallery title="Standalone example" description="Slideshow example demonstrating event listeners.">
    <album lgPath="http://localhost" tnPath="http://localhost" title="news" description="news description">
    <img src="/media/890/1.f4v" title="flash" caption="flash" link="www.asp.net" target="_blank" pause="2"/>
    <img src="" title="flash" caption="flash" link="www.asp.net" target="_blank" pause="2"/>
    <img src="" title="title of the images" caption="caption of the images" link="www.asp.net" target="_blank" pause="2"/>
    <img src="/media/864/dsc_0060.png" title="title" caption="caption of the images" link="www.asp.net" target="_blank" pause="2"/>
    <img src="" title="title of the images" caption="caption of the images" link="" target="_blank" pause="2"/>
    <img src="/media/915/image.png" title="title of the images" caption="caption of the images" link="" target="_blank" pause="2"/>
    </album>
    </gallery>

    As you can see, there are some extra image tags which have no source?

    I also created some nodes for xml file.

    - Flash (xslt file located here)

         - Month name (for example August 2010)

               - Image node

               - Flash node

    Based on my xslt file, which lines should be adjusted?

    thanx,

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Sep 06, 2010 @ 09:47
    Chriztian Steinmeier
    0

    Hi ds,

    Looks like you need to use a choose construct instead of 2 if statements:

    <xsl:choose>
        <xsl:when test="./data [@alias = 'video']">
            <img src="{data[@alias = 'video']}" title="{data[@alias = 'title']}" caption="{data[@alias = 'caption']}" link="{data[@alias = 'link']}" target="_blank" pause="2" />   
        </xsl:when>      
        <xsl:when test="node[./data[@alias = 'image']]">                                                  
            <img src="{data[@alias = 'image']}" title="{data[@alias = 'title']}" caption="{data[@alias = 'caption']}" link="{data[@alias = 'link']}" target="_blank" pause="2" />                          
        </xsl:when>
    </xsl:choose>
    

    /Chriztian

  • Matt Brailsford 2958 posts 15629 karma points MVP 7x c-trib
    Sep 06, 2010 @ 09:52
    Matt Brailsford
    0

    You'll also want to check the attribute for a value aswell. I belive you are currently just checking for the existance of the attribute, so you'll probably want to change the tests in Chriztians example to something like the following:

    test="string-length(./data [@alias = 'video']) &gt; 0"

    Matt

  • ds 191 posts 223 karma points
    Sep 06, 2010 @ 09:59
    ds
    0

    Hi Chriztian,

    I updated code;

           <gallery title="Standalone example" description="Slideshow example demonstrating event listeners.">
    <xsl:for-each select="$currentPage/node [string(data [@alias='umbracoNaviHide']) != '1']">
    <album lgPath="http://localhost" tnPath="http://localhost" title="{data[@alias = 'albumTitle']}" description="{data[@alias = 'albumDescription']}" tn="http://localhost">
    <xsl:for-each select="node">
    <xsl:if test="string-length(./data [@alias = 'image']) &gt; 0">
    <img src="{data[@alias = 'image']}" title="{data[@alias = 'title']}" caption="{data[@alias = 'caption']}" link="{data[@alias = 'link']}" target="_blank" pause="" vidpreview="/flash/gallery/album2/video/1_preview.png"/>
    </xsl:if>
    </xsl:for-each>
    <xsl:for-each select="node">
    <xsl:if test="string-length(./data [@alias = 'video']) &gt; 0">
    <img src="{data[@alias = 'video']}" tn="http://localhost" title="{data[@alias = 'title']}" caption="{data[@alias = 'caption']}" link="{data[@alias = 'link']}" target="_blank" pause="" />
    </xsl:if>
    </xsl:for-each>
    </album>
    </xsl:for-each>
    </gallery>

     

    but video node does not work out.

  • ds 191 posts 223 karma points
    Sep 06, 2010 @ 10:00
    ds
    0

    Hi Matt,

    I will also try your suggestion as well,

    thanx

  • ds 191 posts 223 karma points
    Sep 06, 2010 @ 15:37
    ds
    0

    Chriztian,

    Could you give me some hint for my updated code ?

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies