Re: xpath and selectors

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.

"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 UTC