Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XSLT: path expression

Reply
Thread Tools

XSLT: path expression

 
 
Jeff Higgins
Guest
Posts: n/a
 
      05-13-2006
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


 
Reply With Quote
 
 
 
 
Joe Kesselman
Guest
Posts: n/a
 
      05-13-2006
> //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
 
Reply With Quote
 
 
 
 
Jeff Higgins
Guest
Posts: n/a
 
      05-13-2006

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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Seek xpath expression where an attribute name is a regular expression GIMME XML 3 12-29-2008 03:11 PM
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" Adem C++ 42 11-04-2008 12:39 PM
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" Adem C Programming 45 11-04-2008 12:39 PM
Matching abitrary expression in a regular expression =?iso-8859-1?B?bW9vcJk=?= Java 8 12-02-2005 12:51 AM
Dynamically changing the regular expression of Regular Expression validator VSK ASP .Net 2 08-24-2003 02:47 PM



Advertisments