4 ms·
I'm sure there are countless incredibly legitimate use-cases for a technology like this, but there's part of my brain that seriously wants to explode at the not
by rosser 11y ago
I'm sure there are countless incredibly legitimate use-cases for a technology like this, but there's part of my brain that seriously wants to explode at the notion of coupling Node and XSLT.
- xaduha 11y agoYes, one is an example of a very advanced technology and the other is NodeJS.
- flogic 11y agoI've learned the hard way that the only legitimate use for XML is to maintain compatibility with things that already use XML. It doesn't have a direct translation to any sensible data structure other than DOM. It sucks as a markup language since document writers find syntax errors anathema. I've seen the idea of XSD schemas used as a defense since then you at least have a schema unlike JSON. However, experience has taught me that in practice everyone does XML wrong so that's of limited value at best. I guess there is a limited situation in which you have pre-existing XSLT to translate between two pre-existing XML interfaces but eww.
- xaduha 11y agoThere are other APIs and/or data models other than DOM, you know. Tree is the data structure there and it's not synonymous with DOM. But what always sucked is trying to work with trees using a procedural/imperative/OO language. There's also a cadre of people, colloquially known as 'XML guys', that do use XML the right way.
- Mikhail_Edoshin 11y agoSo, if XML sucks as a markup language, does HTML suck as well?
- PeCaN 11y agoXSLT is actually insanely cool, it's just poorly executed. For example, XSLT lets you decouple the content structure of your document from the presentation structure. XSLT makes nested <div> obsolete. It lets you have responsive HTML—you can serve different stylesheets to differently sized browsers (or switch them on-the-fly with JS). In general, what it can do is cool, but using it is not. If XSLT weren't something of a trainwreck the web would be in a better place.
- voltagex_ 11y agoIt's also seriously useful in an email tempting system - look up this content, apply this XSLT, send the resulting HTML email.
- vbezhenar 11y agoXSLT is cool "theoretically". It was made to solve real problems with correct approach. But practical implementation is not cool at all. XML is not good as a programming language representation. As an alternative to XSLT consider CDuce language. It was made to solve a similar problem: XML manipulation. But language itself uses traditional syntax and much easier to use and understand.
- spdustin 11y agoXML is not meant to be a programming language representation. It's meant to be a predictable, simple set of grammatical rules for representing data that may be hierarchical/shaped/tree-like. XSLT is meant to provide a library of templates used to transform XML to something else (usually XML again, but can be nearly any output format) in a declarative way. XSL is a little bit like CSS in one way: CSS has selectors, and XSL does too. CSS also has rules (one or more selectors and the properties listed for them) that apply to an output device's representation of the nodes matching those selectors (e.g. a browser's visual styling), and XSL has templates that change the structure of the nodes that match the XSL template's selector. Each template has a context, can transform the input "tree" to any intermediate representation necessary, can apply itself recursively, and can completely transform the XML-structured input into practically any output required. It's also a religion along the same lines as vim/emacs/atom or Mac/PC/Linux/UNIX/BSD/etc., and thus, discussions decrying the blasphemy of declarative transformations will result in fervent cries of, "XSL sucks, nuke it from orbit," as well as equally impassioned speeches that, "XSL kicks ass, get enlightened!"
- Mikhail_Edoshin 11y agoIt's not that bad; besides, this allows to embed XSLT inside XML documents or transform XSLT using another XSLT. E.g. I remember having a large project I initially split into multiple XSLT files; in the end I wrote a XSLT to take them all and combine into a single file.