473,405 Members | 2,344 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,405 software developers and data experts.

XSLT: path expression

Hi,

I would like to initialize a variable
but need help selecting the appropriate node.

How can I select

the only anchor element of a
section element,(anywhere in the document), whose only
section_header element's text is equal to "Menus"?

<chapter>
<section/>
<section/>
<section>
<anchor>3_Menus</anchor>
<section_header>Menus</section_header>
</section>
<section/>
</chapter>

Variable value would equal "3_Menus".

I've tried several expressions including,
//section/anchor[parent::section_header/text() =" Menus"],
but no luck so far.

Thanks
Jeff Higgins
May 13 '06 #1
2 1172
> //section/anchor[parent::section_header/text() =" Menus"],

1) parent:: specifies an axis, not a step. Not what you're looking for.

2) If you want to test the entire text content of an element, you can do
so directly. Explicitly using text() means you're looking for a single
text node whose value matches the one you've specified. Doesn't make a
difference in this case either way, but worth pointing out for future.

3) If you want to match "Menus", don't write " Menus" ... (I presume
that was just a typo.

Summary: Try either
section/anchor[../section_header="Menus"]
or
section/anchor[../section_header/text()="Menus"]

(I'd use the former.)

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
May 13 '06 #2

Joe Kesselman wrote:
//section/anchor[parent::section_header/text() =" Menus"],
1) parent:: specifies an axis, not a step. Not what you're looking for.


axis - step - got it + more studies
2) If you want to test the entire text content of an element, you can do
so directly. Explicitly using text() means you're looking for a single
text node whose value matches the one you've specified. Doesn't make a
difference in this case either way, but worth pointing out for future.
<A>This is some <b>BOLD</b>text.</A> - A/text()[2] = "text." ? I'll check it
out.
3) If you want to match "Menus", don't write " Menus" ... (I presume that
was just a typo.
Yes, in my stylesheet8-P
Summary: Try either
section/anchor[../section_header="Menus"]
or
section/anchor[../section_header/text()="Menus"]

(I'd use the former.)


Thanks Joe. Appreciate it.
Jeff Higgins
May 13 '06 #3

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

Similar topics

3
by: Rupa | last post by:
Hi, I'm trying to write an xslt to convert an email in xml format to a new xml format. <descr> <xsl:choose> <xsl:value-of select="body"> </xsl:value-of select> <xsl:when test=" <xsl:value-of...
6
by: Ramon M. Felciano | last post by:
Helo all -- I'm trying to gain a deeper understand for what type of semi-declarative programming can be done through XML and XPath/XSLT. I'm looking at graph processing problems as a testbed for...
2
by: Bart | last post by:
I'm trying to transform an xml file to another xml file by using xslt. for every child node, i need to do some transformations, except for the first one, so I can't use a for-each construction....
0
by: Antonio Collins | last post by:
I must be an idiot because I STILL cannot coax .NET to successfully execute a transform which uses the XSLT id() function. Here's the bare-bones code: XmlValidatingReader xvr = new...
7
by: Harolds | last post by:
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005 the pmID is evaluated to "" instead of what the value is set to: .... xmlItems.Document = pmXML // Add the pmID...
4
by: | last post by:
Hi Guys, I am using XSLT to render my XML dataset at the client side to HTML code. When I am trying to load the XslTransform with an Xslt file, it gives me the following error. >>>> The...
6
by: markoniinimaki | last post by:
Hi, suppose I get a document name a.xml and a path //foo/bar (which nodes eventually to read from it) from another doc. Problem: how to combine them so that the whole expression gets...
1
by: Sergey Dubinets | last post by:
In effort to prioritize our goals we composed the list of random features each of them may add value to set of XSLT tools offered from Microsoft. 1. XSLTc (Compiler for XSLT...
2
by: milecimm | last post by:
Hello, I need some help to solve the following problem (if it is possible, that's it): I'm using a xpath expression to programatically get data from my xml file. I want to transform ONLY the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.