4 ms·
XML, and surrounding technologies like XPath, XSLT, Schematron, RelaxNG, etc. by extension, are extremely useful as data storage and validation languages. If
by zdw 15y ago
XML, and surrounding technologies like XPath, XSLT, Schematron, RelaxNG, etc. by extension, are extremely useful as data storage and validation languages. If I was planning to keep structured data around for a long time on disk, and want to make sure that I didn't have garbage stored, I'd definitely want it in XML, with a fairly strict schema to validate that data.
If you're writing an API that works with files (not an over the wire format), and you don't want to be locked into any one language or toolset, XML is pretty hard to beat. Being able to write just one XSLT file, and have it processed by any compliant processor is pretty impressive - no other templateing format works that way.
The problem for most people is that they never touch those other technologies that make XML great, because they're looking at basic data serialization, and don't care so much about validation and transform. Most web technologies fall into this category. Any tool can and will be abused - how many of us have seen a monstrous unmaintainable Excel file that performs a task that would be much better done in a scripting language?
TL;DR: XML tech has it's uses, but it's very frequently abused.
- doc4t 15y agoAlthough I find XML to be much too cumbersome and bloated for any practical situation I can still understand the technical arguments in favor of using it. What I don't understand is why anyone would choose XSLT over a full featured scripting language like PHP, ASP, JSP or similar. As you obviously have much more experience than I in this field can you provide an example where XSLT would be the preferred choice?
- showerst 15y agoIf you want store your data in a validateable, language agnostic way, why not apply the same logic to your transformations and templates? ...there are a million oft-argued reasons why not, but that's one line of thinking that will lead you to do it. These discussion always remind me of my favorite old Slashdot quote: "XML is like violence. If it's not solving your problem, you're not using enough of it."
- dlubarov 15y agoWell, it's convenient for simple things. You don't need to run a web server, or run a script to generate HTML.
- doc4t 15y agoYou don't need to run a web server for PHP either...can you give an example of one of these simple things?
- silentOpen 15y agohttp://www.khronos.org/registry/webgl/extensions/OES_texture_float/extension.xml http://www.khronos.org/registry/webgl/extensions/OES_texture... No dynamic server-side templating language, easily transformable to other XML formats (docbook, atom (see front page of registry)). If the user/client has libxml, the processor command is already installed. The specifications are now provided in an application specific format that is language-agnostic instead of manually maintained ad hoc HTML. The extension registry index page is now automatically generated into static HTML instead of manual HTML+JavaScript for sorting the lists. Finally, the restricted power of XSLT is an advantage for this application vs PHP, ASP, or JSP. If browsers actually implemented web technologies like XSLT, sending XML specs and generating HTML on the client side with cached XSLT would save bandwidth.
- aurelianito 15y agoHow is XML + XSLT better than JSON + JavaScript for generating the view in the browser? Note: You can generate HTML using JavaScript but it is not needed. You can manipulate the DOM to change what the user sees.
- silentOpen 15y agoIt is easier for crawlers to ingest.
- chris_wot 15y agoCan you prove this?
- mike-cardwell 15y ago+1 for XSLT being cross-platform. I recently started rewriting a Perl application in NodeJS. It sends out HTML emails. The HTML is constructed using XSLT. This meant I could just continue using the same template. If I'd written it in something like Template Toolkit I would have had to rewrite it in EJS or something.
- sk5t 15y agoWell said -- I think of the same topics every time I hear someone heaping scorn on XML for its wordy serialization output and complex spec (specifically as compared to JSON). All the other tooling around XML is so much richer and more mature... that said, the learning curve for XML and XSLT is certainly much longer and steeper than recent fads like moustache.js.
- JepZ 15y agoFrom my perspective XSLT is a horrible language. Nevertheless I use it for every of my web projects. Besides the fact that I hate the language I love the thing it does: abstraction. In the backend I only have to care about the information I want to provide and for the frontent I can do whatever I want to do with this information. My largest problems are the verbosity of the language and the incomplete implementations (also xpath). Btw. I think the Excel formulas are much closer to a functional language than XSLT should ever be ;-)