XSLT axis navigation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • A Amitkashaw

    #1

    XSLT axis navigation

    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">F red'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


  • Patrick TJ McPhee

    #2
    Re: XSLT axis navigation

    In article <qtqub.2596$_L3 .636@news-binary.blueyond er.co.uk>,
    A Amitkashaw <munkei@blueyon der.co.uk> 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
    ptjm@interlog.c om

    Comment

    • Skaffen Amitkashaw

      #3
      Re: XSLT axis navigation

      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!

      Comment

      • Marrow

        #4
        Re: XSLT axis navigation

        Hi,

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

        translate(.,tra nslate(.,'01234 56789',''),'')

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



        "Skaffen Amitkashaw" <skaffen@blueyo nder.co.uk> wrote in message
        news:3fba780f$0 $200$75868355@n ews.frii.net...[color=blue]
        > 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![/color]


        Comment

        • Skaffen Amitkashaw

          #5
          Re: XSLT axis navigation

          Hello Marrow,

          Thanks ever so much!

          -S

          *** Sent via Developersdex http://www.developersdex.com ***
          Don't just participate in USENET...get rewarded for it!

          Comment

          Working...