Re: XPath & CSS, again

Hello!

> I think XPath has different goals, viz., selecting not just elements,
> but also individual attributes, comments, etc. And it is meant to be
> used by a different group of people. That is why it has a different
> syntax. Note that not only does it lack special syntax for CLASS
> attributes, it *can't* select on CLASS attributes at all. (With XSLT,
> my estimate is that you need about 50 lines to select an element with a
> certain CLASS. With the new regular expressions in XPath 2.0 it is
> tricky, but possible within XPath.) Clearly that is not what XPath was
> designed for.

Really? I thought it would be enough to use this expression:

//*[(@class = $c) or contains(@class, concat(' ', $c, ' ')) or 
starts-with(@class, concat($c, ' ') or ends-with(@class, concat(' ', 
$c)]

(okay, it /is/ long, but not 50 lines. )

My intention was not to /replace/ CSS with XPath but to enhance it. 
Especially for generated-content, this would be helpful as there is 
afaik no special CSS-Syntax yet (and you could use XPath 1:1 for 
generated-content, couldn't you?)


--
Pascal Schmitt

Received on Monday, 11 April 2005 20:36:38 UTC