Copied to clipboard

Flag this post as spam?

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


  • niccolo rossi 33 posts 53 karma points
    Sep 12, 2011 @ 12:02
    niccolo rossi
    0

    for each return always the firts value

    Hi all,

    i've a macro with a variabile that contain 3 data row called "test" and a for each.

     <xsl:variable name="test" 
      select="umbraco.library:GetXmlNodeById(1091)//umbNewsArticle 
      [string(visibileInHomePage) = '1' and string(numeroPubblicazione) =$currentPage/numeroPubblicazione]" />  
     
      <xsl:for-each select="$test  ">

    if i ask the node name of the data row all works fine but when i call a info contained in it 

    <xsl:value-of select="$test/settore" />

    the macro display 3 time the first row value. 

    how can i resolve this? 

    there is a book where i can study this things? 

    thank you

    nico


  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Sep 12, 2011 @ 12:57
    Lee Kelleher
    0

    Hi Nico,

    Try removing the $test from the 'select':

    <xsl:value-of select="settore" />

    Reason is that once you are inside the for-each loop, you already have the context of the $test variable, so don't need to reference it again.

    If you want to learn more about XSLT, you could try the W3Schools tutorials? http://www.w3schools.com/xsl/

    ... or if you are from more of a C# background, then take a look at Razor?

    Cheers, Lee.

Please Sign in or register to post replies

Write your reply to:

Draft