xsl-list
[Top] [All Lists]

RE: Grouping text nodes

2005-08-04 10:03:32
You could also write this as

*[span/@class='vn']

Some people might find that more intuitive (though I'm not sure why).

Michael Kay
http://www.saxonica.com/

 

-----Original Message-----
From: Jacoby, Peter R. [mailto:PJACOBY(_at_)PARTNERS(_dot_)ORG] 
Sent: 04 August 2005 17:13
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] Grouping text nodes

<xsl:template match="*[span[(_at_)class='vn']]" mode="lg">

What are the extra [ ] doing in this case? 

I've found that understanding XPath statements is easiest if 
you try to turn it
into English (or your favorite spoken language) going left-to-right.

So, match="*" means match on any node
 
*[...] means match on any node where the ... evaluates to true

*[span] means match on any node where it is true that it has 
a child named span

*[span[...]] means match on any node where it is true that is 
has a child named
span and for which the ... evaluates to true for that span child

*[span[(_at_)class='vn']] means match on any node where it is true 
that is has a
child named span and that span child has an attribute named 
class whose text
value is equal to the string "vn"

I know this was probably more verbose than you needed, but 
this is the concept
of breaking down XPath into its various parts that has helped 
me learn it.

Hope this helps.

-Peter

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



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