Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XPATH Basic question

Reply
Thread Tools

XPATH Basic question

 
 
bjam
Guest
Posts: n/a
 
      04-28-2005
Hi, a quick basic question here on XPATH

if I have the following data

<X>
<X1>TEST</X1>
<Z>
<Z1>Item 1</Z1>
<Z2>Item 2</Z2>
<Z3>Item 3</Z3>
</Z>
</X>
<X>
<X1>TEST2</X1>
<Z>
<Z1> ... </Z1>
<Z2> ... etc.
</Z>
</X>

will the following XPATH statement be valid in a template match
statement? My experience has been no, and I have had to get the root
node X and then do an if on X1 before processing. See below for the
statement. Any ideas on how to get this to work in a single XPATH
statement?


<xsl:template match="/X/X1[starts-with(text(),'TEST2']/Z">
<!-- assumption here is that I get the <Z> node to process -->
<!-- however I am thinking that the predicate has to be the last
statement in an XPATH statement, is this true?-->

 
Reply With Quote
 
 
 
 
Dimitre Novatchev
Guest
Posts: n/a
 
      04-28-2005

"bjam" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Hi, a quick basic question here on XPATH
>
> if I have the following data
>
> <X>
> <X1>TEST</X1>
> <Z>
> <Z1>Item 1</Z1>
> <Z2>Item 2</Z2>
> <Z3>Item 3</Z3>
> </Z>
> </X>
> <X>
> <X1>TEST2</X1>
> <Z>
> <Z1> ... </Z1>
> <Z2> ... etc.
> </Z>
> </X>
>
> will the following XPATH statement be valid in a template match
> statement? My experience has been no, and I have had to get the root
> node X and then do an if on X1 before processing. See below for the
> statement. Any ideas on how to get this to work in a single XPATH
> statement?
>
>
> <xsl:template match="/X/X1[starts-with(text(),'TEST2']/Z">


Yes.

> <!-- assumption here is that I get the <Z> node to process -->
> <!-- however I am thinking that the predicate has to be the last
> statement in an XPATH statement, is this true?-->


No.


Cheers,
Dimitre Novatchev


 
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
"Memory leak" in javax.xml.xpath.XPath Marvin_123456 Java 4 07-29-2005 03:49 PM
XPath: efficiency in xpath expressions Tjerk Wolterink XML 1 11-13-2004 06:03 PM
Are there any XPath parsers that generate XPath trees? goog XML 0 01-14-2004 01:47 PM
XPath that does not include other XPath Anna XML 0 07-31-2003 07:55 AM
Problem selecting a node with XPATH if attribute value contains backslashes - how to force XPATH string to be treated as literal? Alastair Cameron XML 1 07-08-2003 07:24 PM



Advertisments