1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

xslt anyone?

Discussion in 'Programming' started by rosytoes, Jan 27, 2006.

  1. #1
    I need some pointers as to how to make a loop, e.g. I want it to return all authors of a book if there's more than one.

    TIA
     
    rosytoes, Jan 27, 2006 IP
  2. jaymcc

    jaymcc Peon

    Messages:
    139
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Happy to help, you using PHP or ASP (or something else?)

    Jay
     
    jaymcc, Jan 28, 2006 IP
  3. Hon Daddy Dad

    Hon Daddy Dad Peon

    Messages:
    1,041
    Likes Received:
    49
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Need more info.

    What have you got so far?
     
    Hon Daddy Dad, Jan 28, 2006 IP
  4. rosytoes

    rosytoes Peon

    Messages:
    230
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    this is the .xml from an amazon query, here's more info:
    <ItemAttributes>
    <Actor>Kirsten Dunst (Voice)</Actor>
    <Actor>Janeane Garofalo (Voice)</Actor>
    <Director>Hayao Miyazaki</Director>
    .
    .
    .
    </ItemAttributes>

    I have this in the .xsl

    <xsl:if test="aws:ItemAttributes/aws:Actor">
    Actor(s):
    <xsl:for-each select="aws:ItemAttributes/aws:Actor">
    <xsl:value-of select="aws:ItemAttributes/aws:Actor" /><br/>
    </xsl:for-each>
    </xsl:if>

    however, the names are not showing up
    screenshot

    let me know if any more info is needed, thanks.
     
    rosytoes, Jan 28, 2006 IP
  5. jaymcc

    jaymcc Peon

    Messages:
    139
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I would need to test this fully, however I think your context is wrong.

    After you do your for-each, the xml parser now sees the context of the loop as starting from "aws:ItemAttributes/aws:Actor" so when you then try to get the value of the same xpath it doesn't exist.

    Effectively your code is looking for...

    aws:ItemAttributes/aws:Actor/aws:ItemAttributes/aws:Actor

    You may be able to change your xsl:value-of to simply be "/" and it will read the nodes under "aws:ItemAttributes/aws:Actor" for you.

    It's late, try this, i will look in the morning if you have no luck.

    Jay
     
    jaymcc, Jan 28, 2006 IP
  6. rosytoes

    rosytoes Peon

    Messages:
    230
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #6
    this works, although I think it can be done without a for loop.
    <xsl:value-of select="." />
     
    rosytoes, Jan 29, 2006 IP