Live data from Hacker News

What Happened to XPath?

webreflection.medium.com

61–70 of 97 posts

Re: What Happened to XPath?

#61

XPath and XML in general is a great example of "Death by Committee". They tried too hard to be too smart and try to solve everything, and overcomplicated it to death. This is why people largely abandoned it. This is what is happening to C++ and they are steering themselves by committee into a dead end.

I'm starting to pay more attention to technologies that are resistant to this. Maybe I'm just getting old that I'm beginning to value mature, proven technologies over fads. More importantly, is the difficult skill of being able to spot them.

The troule is they are as rare as hens teeth. The temptation to add a little more is overwhelming. I know I suffer from it myself.

Re: What Happened to XPath?

#62
post #28

XPath and XSLT was the first time (despite doing Haskell at university) that I started to really understand functional programming. The first time was working on a tech stack that was basically Microsoft SHAPE queries transformed into HTML. The second was multiple projects customising Google custom search engine results. It was weird realising that these very limited primitive were actually infinitely powerful if you…

There may be need for a replacement with simpler syntax; i wonder if GraphQL might be used in that role. Out of curiosity, what tools do you use for scraping? Is there a similar simple tool for defining queries over trees?

fyi: XSLT was designed by James Clark, based on concepts and experience of XSLT's Scheme-based predecessor DSSSL. So there's your alternate syntax :) In a way, DSSSL has yielded to a XML-ish surface syntax much like JavaScript, also conceived as a LISPy language, yielded to a Java-ish (awk-ish, actually) syntax.

Re: What Happened to XPath?

#63
post #2

XPath post 1.0 got ridiculous, like many things do. What started with a simple, elegant language morphed into one with a http client, filesystem methods, json support, functions, loops, extensions and the ability to read environment variables. I wrote a post about it a while back[1] (I regret some of the wording used there) and maintain a tool[2] that can exploit XPath injection issues. I'd recommend sticking with 1…

But does it send email?

Re: What Happened to XPath?

#64
post #2

XPath post 1.0 got ridiculous, like many things do. What started with a simple, elegant language morphed into one with a http client, filesystem methods, json support, functions, loops, extensions and the ability to read environment variables. I wrote a post about it a while back[1] (I regret some of the wording used there) and maintain a tool[2] that can exploit XPath injection issues. I'd recommend sticking with 1…

With the rise of numerous hierarchical document formats (JSON, YAML, TOML, properties files), what XPath REALLY should have evolved into was a more format-flexible path language with format-specific extensions as needed.

> what XPath REALLY should have evolved into was a more format-flexible path language with format-specific extensions as needed.

You can probably already do that just fine: ignore attribute nodes, and e.g.

    {"menu": {
      "id": "file",
      "value": "File",
      "popup": {
        "menuitem": [
          {"value": "New", "onclick": "CreateNewDoc()"},
          {"value": "Open", "onclick": "OpenDoc()"},
          {"value": "Close", "onclick": "CloseDoc()"}
        ]
      }
    }}

    /menu/popup/menuitem/*[last()]/preceding-sibling::*[1]/value
selects "Open". Something along those lines.

Maybe relax nodetypes so they can be pluggable per-language, but I'm not sure that's even useful or necessary.

Re: What Happened to XPath?

#65
I do a bunch of of XML/XSLT work still. I use XPATH 1.0 basically everyday. It's also awesome for web scraping. Overall, it's a great tool that doesn't get a ton of exposure.

Re: What Happened to XPath?

#66
post #2

XPath post 1.0 got ridiculous, like many things do. What started with a simple, elegant language morphed into one with a http client, filesystem methods, json support, functions, loops, extensions and the ability to read environment variables. I wrote a post about it a while back[1] (I regret some of the wording used there) and maintain a tool[2] that can exploit XPath injection issues. I'd recommend sticking with 1…

XPath/XSLT 2+ also have only a single implementation (by the spec author) so don't meet W3C's requirement of two interoperating implementations. Basically, XSLT ceased to be a "standard" whereas XSLT 1.0 had excellent portability across libxslt, Saxon, Xalan, and MS' xslt.exe. Edit: there is/was a token implementation for XSLT 2.0 called Gestalt

It also worth noting that the specification’s author also built his company on this single implementation.

Re: What Happened to XPath?

#67
I love the XPath model of declaratively querying and transforming data, which has been highly influential (see JQ, JSONPath, GROQ, etc.). Ultimately, it was too closely tied with XML, which was overdesigned complex, and sucked into the committee hell that brought us more overdesigned technologies like SOAP and XML Schema.

Re: What Happened to XPath?

#68
post #29

Xpath is so powerful for web scraping I just realized recently. I'd been using css selectors for my occasional scraping needs and never bothered to learn xpath until on day on a whim decided to learn at least the basics. Man I can now write scrapers in 2 minutes that used to take me quite some time thanks to the power of xpath. Thing like ancestors, contains, the ability to chain, etc is so so powerful. I used to wri…

Can you point out the resources you used for learning ? I wrote a lot of scrappers and am knee-deep in css hacks.

If you know CSS well, I find this useful:

https://devhints.io/xpath

The problem with xpath is that you rarely use it, so you forget how to do certain things. Then you have to go and re-learn when you need it. Rinse and repeat.

Re: What Happened to XPath?

#69
post #47

Earlier quoted context omitted.

I was going to suggest Vim as a counterexample, but sure enough https://github.com/soywod/iris.vim

That's a community based plugin, Vim is still focused on text editing and not much else.

Most of the functionality on the editors like vim and emacs comes from community based plugins. People would mostly not use them if there were no such expansions.

Re: What Happened to XPath?

#70
post #28

XPath and XSLT was the first time (despite doing Haskell at university) that I started to really understand functional programming. The first time was working on a tech stack that was basically Microsoft SHAPE queries transformed into HTML. The second was multiple projects customising Google custom search engine results. It was weird realising that these very limited primitive were actually infinitely powerful if you…

There may be need for a replacement with simpler syntax; i wonder if GraphQL might be used in that role. Out of curiosity, what tools do you use for scraping? Is there a similar simple tool for defining queries over trees?

I've often compared GraphQL to SOAP-XML with WSDL. It's nearly the same thing, and just about as boilerplate-y.

XSLT is about templating/transforming one XML doc into some other format. And there are simple replacements that largely fill the same role. Mustache, Handlebars, Template Toolkit (which was also the simpler solution back when XSLT was popular).

Post reply on HN