473,324 Members | 2,531 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

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">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
Jul 20 '05 #1
4 3436
In article <qt****************@news-binary.blueyonder.co.uk>,
A Amitkashaw <mu****@blueyonder.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
pt**@interlog.com
Jul 20 '05 #2
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!
Jul 20 '05 #3
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" <sk*****@blueyonder.co.uk> wrote in message
news:3f*********************@news.frii.net...
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!

Jul 20 '05 #4
Hello Marrow,

Thanks ever so much!

-S

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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: ted | last post by:
Was wondering if XSLT alone is appropriate for the following situation. From XML, I'm creating a small website (around 50 pages) with pages that link to each other through a nav menu and a...
3
by: Francis Hwang | last post by:
Hi, Maybe this is a newbie question, but: Is there a way to output an element's contents -- including contained nodes and free-form text -- without the containing tags? I can imagine that...
3
by: Brian Schroeder | last post by:
Hello Group, I'm quite new to xml, xpath and xslt so I hope I've not overlooked a resource where the answer to my question is. I'll try to give a short example, but in XML everything gets...
6
by: Gary Huntress | last post by:
Hi, I'm having trouble with an xslt transform. I'm trying to transform a vector into an array of width N. For example here is my vector: <data> <x id="1">1.2</x> <x id="2">.2</x> <x...
3
by: Philipp Schumann | last post by:
Hi, I have several nested layers of <node> element that are processed by an XSLT template. Is there any possibility to determine the depth of a node in the overall nesting hierarchy? For...
2
by: Pawel | last post by:
I have small problem with XslTransformation. I get from WebService xml document. I have xslt and I want transform xml document to html code. It's look easy but I cant't manage with xPath. Maybe...
6
by: Puzzled | last post by:
http://www.biglist.com/lists/xsl-list/archives/200303/msg01242.html purports to show how xslt can be used to copy all of an xhtml file & selectively transform certain nodes. The copy works fine on...
2
jkmyoung
by: jkmyoung | last post by:
Here's a short list of useful xslt general tricks that aren't taught at w3schools. Attribute Value Template Official W3C explanation and example This is when you want to put dynamic values...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.