W3C home > Mailing lists > Public > www-style@w3.org > March 2000

Re: xpath and selectors

From: Robin Berjon <robin@knowscape.com>
Date: Sun, 12 Mar 2000 01:37:39 -0500
Message-Id: <4.1.20000312013315.00990180@mail.knowscape.net>
To: "Joe Hewitt" <joe@joehewitt.com>
Cc: <www-style@w3c.org>
At 01:03 12/03/2000 -0500, Joe Hewitt wrote:
>It occurred to me today as I was perusing the CSS3 selectors draft that much
>of what one can do with CSS selectors is the same thing that one would do
>with an XPath expression.  Would it not make sense for both CSS and XSL to
>use the same language for selecting nodes?

I agree in part with you, at least on the feeling that there shouldn't be
duplication. However, I find CSS selectors to be easier to write than XPath
selectors which is imho a good reason to use them. I think what would be
truly useful would be css2xpath/xpath2css tools that would do the
conversion. It shouldn't be hard at all.

>The only thing I can think of that XPath can't do that CSS selectors do is
>pseudo-elements/classes.   Some things like :first-line, :hover, :active,
>:focus, etc... can't be accomplished with XPath because they refer to a sort
>of "meta" state. However, things like :before, :first-child, :nth-child()
>would be easily accomplished.  Perhaps some syntax for "meta-states" could
>be added to the XPath spec using the single colon as the operator.

Or maybe we could use functions ? Having a mapping from one to the other
would be nice, and XPath states that extra functions can be added. This is
totally off the top of my head late at night so I don't know whether it
would be accurate, however some such device could prove useful.



.Robin
"What I like about deadlines is the lovely whooshing sound they make as
they rush past." --Douglas Adams
Received on Sunday, 12 March 2000 01:37:01 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:04 GMT