xsl-list
[Top] [All Lists]

RE: xpath confusion (compound xpath)

2003-01-21 22:23:59
Mabe this will help explain.  Here is an example of what is happending in your 
xpath.

Your xpath
/grammar/start/element/zeroOrMore/choice/element[1]//zeroOrMore//*[self=current()]

Based on the specification
http://www.w3.org/TR/xpath#predicates

[8]    Predicate    ::=    '[' PredicateExpr ']'

"A predicate filters a node-set"

In this example your node set will be the nodes matched by
node-set = /grammar/start/element/zeroOrMore/choice/element[1]//zeroOrMore//*

From the specification

"For each node in the node-set to be filtered, the PredicateExpr is evaluated 
with 
that node as the context node"

Your PredicateExpr will be

PredicateExpr = "self=current()"

in psydo code think

for each node in the node-set
    current = node     // context node = current
    "self" = current.nodeName
next

Edward Middleton

-----Original Message-----
From: S Woodside [mailto:sbwoodside(_at_)yahoo(_dot_)com]
Sent: Wednesday, January 22, 2003 1:52 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] xpath confusion (compound xpath)



On Sunday, January 19, 2003, at 02:41  AM, Dimitre Novatchev wrote:

What am I doing wrong?

The problem is here:

       <xsl:when  
test="/grammar/start/element/zeroOrMore/choice/element[1]// 
zeroOrMore//*[self=current()]">

You are testing if the current node has child named "self" and its
string value is equal to the string value of the current node.

gah! I can't believe it. I must have though I was using the self::  
axis. Would self::* have worked? How do I know if it's going to treat  
the stuff inside the predicate as a string or as a node-set?

I find the XPath spec to be unusually confusing ... would you mind  
pointing out the part of the spec that defines this, because it's  
totally unclear to me. In fact, I find there's a distinctive lack of  
clear documentation on the net. I'd rather not have to waste the money  
and dead trees on the O'Reilly book and usually the online docu is  
enough for me.

Obviously, you wanted:

/grammar/start/element/zeroOrMore/choice/element[1]//zeroOrMore//
*[generate-id() = generate-id( current())]

Thanks,

simon
---
www.simonwoodside.com


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>