XSLT axis navigation

Discussion in 'XML' started by A Amitkashaw, Nov 18, 2003.

  1. A Amitkashaw

    A Amitkashaw Guest

    Hi Everyone.

    I'm having a few problems with the following XSL statement -

    <xsl:template match="htm:div[text()='Fred's List of Things:']">
    <xsl:for-each
    select="../following-sibling::*/child::htm:i[text()='Guitars:']">
    <xsl:value-of select="text()"/>
    </xsl:for-each>
    </xsl:template>

    It returns the ELEMENT 'Guitars:' but what I need is the text after it. I'm
    stumped if I can figure out how to get this value to return. The reason why
    I'm using the above XML is because there are lots of other <i> ELEMENTS
    within the document with the text 'Guitars:' and I need Fred's guitar choice
    specifically.

    Here's the XML:

    - <td>
    <div align="right">Fred's List of Things:</div>
    </td>

    <td>
    <i>Hobbys:<i>
    Reading, Writing, painting, riding bikes
    <br />
    <i>Books I have read:</i>
    Animal Farm,
    <br />
    <i>Guitars:</i>
    1 Gibson Les Paul
    <br />
    <i>Cars:</i>
    None, I like riding my bike everywhere
    <br/>
    </td>

    Thanks for your time in this matter.

    - S
     
    A Amitkashaw, Nov 18, 2003
    #1
    1. Advertising

  2. In article <qtqub.2596$>,
    A Amitkashaw <> wrote:

    % select="../following-sibling::*/child::htm:i[text()='Guitars:']">

    % It returns the ELEMENT 'Guitars:' but what I need is the text after it.

    where the element in question is like this

    % <i>Guitars:</i>
    % 1 Gibson Les Paul
    % <br />

    you could try appending

    /../following-sibling::/text()[1]

    to your expression. That should get everything up to the <br/>.
    --

    Patrick TJ McPhee
    East York Canada
     
    Patrick TJ McPhee, Nov 18, 2003
    #2
    1. Advertising

  3. Thanks, Patrick.

    How good are you with the number() function? I'm trying to return mixed
    numbers and string. For example: 45 km. Do I need to strip out the 'km'
    or does the number function take care of this for me?

    Thanks again for your time :)

    - S

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Skaffen Amitkashaw, Nov 18, 2003
    #3
  4. A Amitkashaw

    Marrow Guest

    Hi,

    The following expression will remove any non-numeric characters from, for
    example, the context node...

    translate(.,translate(.,'0123456789',''),'')

    Hope this helps
    Marrow
    http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
    http://www.topxml.com/Xselerator



    "Skaffen Amitkashaw" <> wrote in message
    news:3fba780f$0$200$...
    > Thanks, Patrick.
    >
    > How good are you with the number() function? I'm trying to return mixed
    > numbers and string. For example: 45 km. Do I need to strip out the 'km'
    > or does the number function take care of this for me?
    >
    > Thanks again for your time :)
    >
    > - S
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    Marrow, Nov 19, 2003
    #4
  5. Hello Marrow,

    Thanks ever so much!

    -S

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Skaffen Amitkashaw, Nov 19, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joey Vendetta
    Replies:
    0
    Views:
    3,459
    Joey Vendetta
    Apr 1, 2004
  2. Stefan
    Replies:
    0
    Views:
    742
    Stefan
    May 6, 2004
  3. Replies:
    0
    Views:
    945
  4. hocho888
    Replies:
    1
    Views:
    657
  5. ed
    Replies:
    2
    Views:
    433
    Mike Schilling
    Dec 8, 2006
Loading...

Share This Page