This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Brackets in XPATHS
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: Edward dot Middleton at nikonoa dot net
- Cc: xsl-list at lists dot mulberrytech dot com
- Date: Thu, 14 Feb 2002 08:52:30 +0000
- Subject: Re: [xsl] Brackets in XPATHS
- Organization: Jeni Tennison Consulting Ltd
- References: <95B3DC792A040C45807C9CFA11B7B1AF030FD999@OHISV4.nikonoa.net>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Edward,
>>/xpath1/*[name()='xpath2' or name()='xpath3']/xpath4
>
> the xpath's are xpaths not names, I just wrote them this way to
> emphasise what I was talking about.
>
> xpath1 = tag1/tag2[@attrib1='fads']/tag3[@attrib2='ahf']
> xpath2 = tag4
> xpath3 = tag5[1][attrib3='gf' and tag6/@attrib4 ='flk']
> xpath4 = @attrib5
You could use the self:: axis instead, with:
tag1/tag2[@attrib1 = 'fads']/tag3[@attrib2 = 'ahf']
/node()[self::tag4 |
self::tag5[1][attrib3 = 'gf' and tag6/@attrib4 = 'flk']]
/@attrib5
This pattern doesn't work for *all* paths. Specifically, you couldn't
use it if path2 or path3 were selecting attribute or namespace nodes.
However, even if you weren't using such complex paths, using the
self:: axis is better than testing against the name() function because
it's namespace-aware, whereas the name() function uses the prefixes
from the source document.
Note that the path:
tag1/tag2[@attrib1 = 'fads']/tag3[@attrib2 = 'ahf']
/(tag4 |
tag5[1][attrib3 = 'gf' and tag6/@attrib4 = 'flk'])
/@attrib5
will be just fine in XPath 2.0.
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list