Copied to clipboard

Flag this post as spam?

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


  • Kasper Dyrvig 246 posts 379 karma points
    Jul 29, 2010 @ 14:04
    Kasper Dyrvig
    0

    This loop is driving me nuts!

    This...

    <table cellpadding="0" cellspacing="0" style="width: 453px;">
        <xsl:for-each select="umbraco.library:GetXmlNodeById('1126')/Area">
          <xsl:sort select="//omrdenavn" />
          <tr>
            <td class="tableListItem">
              <h2>
                <a>
                  <xsl:attribute name="href">/Search.aspx?name=<xsl:value-of select="//name"/></xsl:attribute>
                  <xsl:value-of select="//name"/></a>
              </h2>
              <a class="imgLink">
                <xsl:attribute name="href">/Search.aspx?name=<xsl:value-of select="//name"/></xsl:attribute>
                <img src="/media/73/blackspace.jpg" alt="" class="img220" /></a>
              <p>
                <xsl:value-of select="Exslt.ExsltStrings:padding('140', //description)"/>...<br />
                <a>
                  <xsl:attribute name="href">/Search.aspx?name=<xsl:value-of select="//name"/></xsl:attribute>
                Læs mere om <xsl:value-of select="//name"/></a>
              </p>
            </td>
          </tr>
      </xsl:for-each>
      </table>

    ...is somehow not working!!! Well, I get something: The same data 2 times! Any comments? Thank you.

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jul 29, 2010 @ 14:10
    Matt Brailsford
    0

    Hey,

    What is the structure of your data?

    At first glance, I would say it is to do with the '//' at the begining of your selectors, as that will fetch any matches.

    Bit dificuilt to pin point it exactly without an idea of data structure though.

    Matt

  • Kasper Dyrvig 246 posts 379 karma points
    Jul 29, 2010 @ 14:18
    Kasper Dyrvig
    0

    The structure is as follows:

     

    • Areas
      • Countries
        • Area 1
        • Area 2

    Area 1 is the one that is being repeated. Area 2 isn't viewed at all.

    I have added your advise (get rid of the first slash), but the result is the same.

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Jul 29, 2010 @ 14:19
    Chriztian Steinmeier
    1

    Hi Webspas,

    I concur with Matt, that you need to tell us about your data, but a surefire way to mess up your output is to use the // (descendant) axis...

    Try this for starters and see where that gets you:

    <table cellpadding="0" cellspacing="0" style="width: 453px;">
        <xsl:for-each select="umbraco.library:GetXmlNodeById('1126')/Area">
            <xsl:sort select="omrdenavn" />
            <tr>
                <td class="tableListItem">
                    <h2>
                        <a href="Search.aspx?name={name}">
                            <xsl:value-of select="name" />
                        </a>
                    </h2>
                    <a class="imgLink" href="/Search.aspx?name={name}">
                        <img src="/media/73/blackspace.jpg" alt="" class="img220" />
                    </a>
                    <p>
                        <xsl:value-of select="Exslt.ExsltStrings:padding('140', description)" />...<br />
                        <a href="/Search.aspx?name={name}">
                            <xsl:text>Læs mere om </xsl:text>
                            <xsl:value-of select="name" />
                        </a>
                    </p>
                </td>
            </tr>
        </xsl:for-each>
    </table>
    

    /Chriztian 

  • Kasper Dyrvig 246 posts 379 karma points
    Jul 29, 2010 @ 14:21
    Kasper Dyrvig
    0

    Hey! Solved! I deleted both slashes and now it works! Thanks!

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jul 29, 2010 @ 14:24
    Matt Brailsford
    0

    Hey Webspas,

    Chriztians example above should do the trick then, assuming 1126 is the id of the "Countries" node.

    If 1126 is the id of the "Areas" node, you should just be able to change the following line

    <xsl:for-each select="umbraco.library:GetXmlNodeById('1126')//Area">

    Matt

Please Sign in or register to post replies

Write your reply to:

Draft