Live data from Hacker News

Xee: A Modern XPath and XSLT Engine in Rust

blog.startifact.com

211–220 of 245 posts

Re: Xee: A Modern XPath and XSLT Engine in Rust

#211

Earlier quoted context omitted.

What actually prevents JSON from being used in these spaces? It seems to me that any XML structure can be represented in JSON. Personally, I've yet to come across an XML document I didn't wish was JSON, but perhaps in spaces I haven't worked with, it exists.

How would you represent mixed content in JSON?

`{ type: "p", children: [{type: "text", text: "How would you represent "}, {type: "b", children: [{type: "i", children: [{type: "text", text: "mixed content"}]], {type: "text", text: " in JSON?"]}`

or:

`{paragraphs: [{spans: [{ text: "How you represent "}, {bold: true, italic: true, text: "mixed content"},{text: " in JSON?"}]}`

Re: Xee: A Modern XPath and XSLT Engine in Rust

#212

Earlier quoted context omitted.

My favorite and only use of XSLT that still works pretty well is to allow people to browse my RSS feed as if it were a web page. https://joeldueck.com/feed.atom

>as if it were a web page. Why the "as if"? Isn't it a web page by definition?

Fair point, I was just gesturing at the difference of experience when clicking on an unstyled feed vs a styled one. I could have said “as if it were a normal HTML page”

Re: Xee: A Modern XPath and XSLT Engine in Rust

#213
post #88

Earlier quoted context omitted.

> Elements are for data. Attributes are evil This is like, your opinion, man... ;-) You can devise your schema any way you want. Attributes are great, and they exist in HTML in the form of datasets, which, as usual, are a poorly-specified and ill-designed rethinking of XML attributes > Documents without a schema should not make your tools panic or complain They don't. You absolutely don't need a schema. If you declar…

No, the problem with attributes is that people consistently misuse them. So many things about XML break down when you make everything a self closing tag with 50 attributes. So many programmers just seem to say, "oh, it's shorter text so it must be inherently better" or "oh it's one-to-one so I should strictly avoid anything resembling a heirarchy." Like I think this guy is mostly correct in identifying bad XML: https…

[deleted]

Re: Xee: A Modern XPath and XSLT Engine in Rust

#214

I yearn for the day when people will stop considering the main advertising bullet point feature that their software was written in Rust. Rust 1.0 was released a decade ago, plenty of time for its alleged technical advantages to become apparent. It's like a handbag whose main claim to being a premium product isn't workmanship or materials, but that it has Gucci on its side.

An xpath/xslt engine is something you might want to include in other software, the programming language used might be an important information for this purpose.

Re: Xee: A Modern XPath and XSLT Engine in Rust

#215

There are many humongous XML sources. E.g. the Wikipedia archive is 42GB of uncompressed text. Holding a fully parsed representation of it in memory would take even more, perhaps even >100GB which immediately puts this size of document out of reach. The obvious solution is streaming, but streaming appears to not be supported, though is listed under Challenging Future Ideas: https://github.com/Paligo/xee/blob/main/ide…

I used to work for a NoSQL company that was more or less an XQUERY engine. One of the things we would complain about is we did use wikipedia as a test data set, so the standing joke was for those of us dealing with really big volumes we'd complain about 'only testing Wikipedia' sized things. Good times.

Re: Xee: A Modern XPath and XSLT Engine in Rust

#216
post #192

Earlier quoted context omitted.

What actually prevents JSON from being used in these spaces? It seems to me that any XML structure can be represented in JSON. Personally, I've yet to come across an XML document I didn't wish was JSON, but perhaps in spaces I haven't worked with, it exists.

> It seems to me that any XML structure can be represented in JSON Well it can't: JSON has no processing instructions, no references, no comments, JSON "numbers" are problematic, and JSON arrays can't have attributes, so you're stuck with some kind of additional protocol that maps the two. For something that is basically text (like an HTML document) or a list of dictionaries (like RSS) it may not seem obvious what th…

I think I can see something of where you're coming from. But a question:

You complain about dates in JSON (really a specific case of parsing text in JSON):

> If they implement dates, sometimes it's unix-time, sometimes it's 1000x off from > that, sometimes it's a ISO8601-inspired string, and fuck sometimes I just get an > HTTP date. And so on.

Sure, but does not XML have the exact same problem because everything is just a text?

Re: Xee: A Modern XPath and XSLT Engine in Rust

#217

This, thirty years later, is the best pitch for XML I’ve read. Essentially, it’s a slow moving, standards-based approach to data interoperability. I hated it the minute I learned about it, because it missed something I knew I cared about, but didn’t have a word for in the 90s - developer ergonomics. XML sucks shit for someone who wants to think tersely and code by hand. Seriously, I hate it with a fiery passion. Happ…

>XML has always seemed to be a data standard which is intended to be what computers prefer, not people Interesting take, but I'm always a little hesitant to accept any anthropomorphizing of computer systems. Isn't it always about what we can reason and extrapolate about what the computer is doing? Obviously computers have no preference so it seems like you're really saying "XML is a poor abstraction for what it's try…

I did this for many years at a couple different companies. As you said it worked very well especially at the time (early 2000’s). It was a great way to separate application logic from presentation logic especially for anything web based. Seems like a trivial idea now but at the time I loved it.

In fact the RSS reader I built still uses XSLT to transform the output to HTML as it’s just the easiest way to do so (and can now be done directly in the browser).

Re: Xee: A Modern XPath and XSLT Engine in Rust

#218
post #112

Earlier quoted context omitted.

"How hard is it to implement XML/XSLT/XPATH streaming?" It's actually quite annoying on the general case. It is completely possible to write an XPath expression that says to match a super early tag on an arbitrarily-distant further tag. In another post in this thread I mention how I think it's better to think of it as a multicursor, and this is part of why. XPath doesn't limit itself to just "descending", you can fre…

Would it be possible to transform a large XML document into something on-disk that could be queried like a database by the XPath evaluator?

Given the nature of this processing, I think even an NVMe-based disk storage would be awfully slow. (People often forget, or never realize, that the "gigabytes per second" that NVMe yields is for sequential access. Random access is quite a bit slower; still stomps spinning rust, but by much less. And this is going to be a random access sort of job, so we're in the "several multiples slower than RAM" regime of access.) This sort of thing really wants RAM, and even then, RAM with an eye towards cache coherency and other such performance considerations.

Re: Xee: A Modern XPath and XSLT Engine in Rust

#219

Earlier quoted context omitted.

How would you represent mixed content in JSON?

`{ type: "p", children: [{type: "text", text: "How would you represent "}, {type: "b", children: [{type: "i", children: [{type: "text", text: "mixed content"}]], {type: "text", text: " in JSON?"]}` or: `{paragraphs: [{spans: [{ text: "How you represent "}, {bold: true, italic: true, text: "mixed content"},{text: " in JSON?"}]}`

But that's terrible! How is that better? And can you guarantee correct ordering?

Re: Xee: A Modern XPath and XSLT Engine in Rust

#220

Earlier quoted context omitted.

I don't think people realize just how important XML is in this space (complex documentary editing, textual criticism, scholarly full-text archives in the humanities). JSON cannot be used for the kinds of tasks to which TEI is put. It's not even an option. Nothing could compel me to like XSLT. I admire certain elements of its design, but in practice, it just seems needlessly verbose. But I really love XPath, though.

What actually prevents JSON from being used in these spaces? It seems to me that any XML structure can be represented in JSON. Personally, I've yet to come across an XML document I didn't wish was JSON, but perhaps in spaces I haven't worked with, it exists.

[dead]
Post reply on HN