Live data from Hacker News

XSLT – Native, zero-config build system for the Web

github.com

221–230 of 337 posts

Re: XSLT – Native, zero-config build system for the Web

#221
post #138

Earlier quoted context omitted.

> It's generally speaking part of the problem with the entire "XML as a savior" mindset of that earlier era and a big reason of why we left them Generally speaking I feel like this is true for a lot of stuff in programming circles, XML included. New technology appears, some people play around with it. Others come up with using it for something else. Give it some time, and eventually people start putting it everywhere…

A controversial opinion, but JSON is that too. Not as bad as XML was (̶t̶h̶e̶r̶e̶'̶s̶ ̶n̶o̶ ̶"̶J̶S̶L̶T̶"̶)̶, but wasting cycles to manifest structured data in an unstructured textual format has massive overhead on the source and destination sides. It only took off because "JavaScript everywhere" was taking off — performance be damned. Protobufs and other binary formats already existed, but JSON was appealing because…

There is JSLT: https://github.com/schibsted/jslt and it can be useful if you need to transform a json document into another json structure.

Re: XSLT – Native, zero-config build system for the Web

#222
post #217

I built an actual shipping product that used this approach over 25 years ago. The server would have the state of every session, that would be serialized to xml, and then xslt templates would be used to render html. Idea was that this would allow customers to customize the visual appearance of the webpages, but xslt was too difficult. Not a success.

I did something like this at an employer a while ago as well. Taking it a step further, we wanted to be able to dynamically build the templates that the browser would then use for building the HTML. Senior dev felt the best way would be to have a "master" xslt that would then generate the xslt for the browser. I ended up building the initial implementation and it was a bit of a mind bender. Fun, but not developer friendly for sure .

Re: XSLT – Native, zero-config build system for the Web

#224
Throw in php in the mix and you have a wonderful solution for templating with bullet proof standards:

// XML $xml_doc = new DOMDocument(); $xml_doc->load("file1.xml");

// XSL $xsl_doc = new DOMDocument(); $xsl_doc->load("file.xsl");

// Proc $proc = new XSLTProcessor(); $proc->importStylesheet($xsl_doc); $newdom = $proc->transformToDoc($xml_doc);

print $newdom->saveXML();

XSLT lacks functionality? No problem, use php functions in xslt: https://www.php.net/manual/en/xsltprocessor.registerphpfunct...

RTFM

Re: XSLT – Native, zero-config build system for the Web

#225
post #207

Earlier quoted context omitted.

Hmm my memory is fuzzy but I remember seeing backend processing of xml files a lot around 2005.

Yeah, I was using Novell DirXML to do XSLT processing of inbound/outbound data in 2000 ( https://support.novell.com/techcenter/articles/ana20000701.h... ) for directory services stuff. It was full XML body (albeit small document sizes, as they were usually user or identity style manifests from HR systems), no streaming as we know it today.

Ok, I never heard of the pre and post xml streaming era.. I got taught.

Re: XSLT – Native, zero-config build system for the Web

#226
post #210

> can use HTML import? nope not exist Well, Apache says hi: https://httpd.apache.org/docs/2.4/howto/ssi.html (Look for "include")

Doesn't work on Github Pages, but this will.

True - just thought people would be interested in some options

Re: XSLT – Native, zero-config build system for the Web

#229

Earlier quoted context omitted.

XSLT/XPath have evolved since XSLT 1.0. Features are now available like key (index) to greatly speedup the processing. Good XSLT implementation like Saxon definitively helps as well on the perf aspect. When it comes to transform XML to something else, XSLT is quite handy by structuring the logic.

XSLT just needs a different, non-XML serialization. XML (the data structure) needs a non-XML serialization. Similar to how Semantic Web's Owl has four different serializations, only one of them being the XML serialization. (eg. Owl can be represented in Functional, Turtle, Manchester, Json, and N-triples syntaxes.)

> XML (the data structure) needs a non-XML serialization.

That's YAML, and it is arguibly worse. Here's a sample YAML 1.2 document straight from their spec:

    %TAG !e! tag:example.com,2000:app/
    ---
    - !local foo
    - !!str bar
    - !e!tag%21 baz
Nightmare fuel. Just by looking at it, can you tell what it does?

--

Some notes:

- SemWeb also has JSON-LD serialization. It's a good compromise that fits modern tooling nicely.

- XML is still a damn good compromise between human readable and machine readable. Not perfect, but what is perfect anyway?

- HTML5 is now more complex than XHTML ever was (all sorts of historical caveats in this claim, I know, don't worry).

- Markup beauty is relative, we should accept that.

Re: XSLT – Native, zero-config build system for the Web

#230
post #32

What is this "XSLT works natively in the browser" sourcery? The last time I used XSLT was like 20 years ago- but I used it A LOT, FOR YEARS. In those days you needed a massive wobbly tower of enterprise Java to make it work which sort of detracted from the elegance of XSLT itself. But if XSLT actually works in the browser- has the holy grail of host-anywhere static templating actually been sitting under our noses thi…

Chrome has libxslt; FireFox has something called "Transformiix". Both 1.0. Chrome has no extensions, only 'exsl:node-set'; FireFox has quite a few, although not all of EXSLT.

Plug: here is a small project to get the basic information about the XSLT processor and available extensions. To use with a browser find the 'out/detect.xslt' file there and drag it into the browser. Works with Chrome and Firefox; didn't work with Safari, but I only have an old Windows version of it.

https://github.com/MikhailEdoshin/xslt-detect-ext/

Post reply on HN