Copied to clipboard

Flag this post as spam?

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


  • Claushingebjerg 886 posts 2415 karma points
    Sep 01, 2010 @ 22:28
    Claushingebjerg
    0

    selecting nodes based on parents attribute

    As in my previous post im using an extenal xml file as a data source.

    Im trying to get nodes below an "arrs" node with a specific "genre" attribute. Eg. "Music"

    Im trying to do it like this (not full source, just the essentials):

    <xsl:template match="/">
    <xsl:apply-templates select="$kalender//arrs[@genre=Music]"/>
    </xsl:template>

    <xsl:template match="arr">
    <xsl:value-of select="kunstner"/>
    </xsl:template>


    My xml is as follows:

     <arrlist>
          <arrs genre="Music">
             <arr ArrNr="4640717">
                <kunstner>something something </kunstner>
             </arr>
             <arr ArrNr="4743104">        
              <kunstner>something2 something2</kunstner>         
            </arr>
    </arrs>
          <arrs genre="Theatre">
             <arr ArrNr="2342342">
                <kunstner>something something </kunstner>
             </arr>
             <arr ArrNr="234234234">        
              <kunstner>something2 something2</kunstner>         
            </arr>
    </arrs>

    </arrlist>

     

    But this doesnt really return anything... What am i missing?  

    <xsl:apply-templates select="$kalender//arrs"/>

    returns all "arr" nodes correctly, so that works so far...

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Sep 01, 2010 @ 22:38
    Chriztian Steinmeier
    1

    Hi Claus,

    Could it be as simple as forgetting the apostrophes around Music? You should do this:

    <xsl:apply-templates select="$kalender//arrs[@genre = 'Music']" />

    Assuming it's not a typo, the one you wrote will try to find an element named Music and take the string value of that as the genre...

    /Chriztian

  • Claushingebjerg 886 posts 2415 karma points
    Sep 01, 2010 @ 22:48
    Claushingebjerg
    0

    Yep, that was exactly what was missing. Thanks a lot

  • 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