Why xslt is bad




















I describe this as:. You have no idea what a single line of code will do without analyzing every other line of code in your program. There are plenty of ways to do this properly in real programming languages.

In my Haskell-based DITA processing code, for example, there is a setting allowing you to specify specific handling for individual elements. Then in the calling code, you are explicitly calling into a function for which you don't know what the output will necessarily be.

Everything is properly namespaced and segregated, and you can know by looking at the code in front of you just how it's going to be dispatched.

I'm out of time for now, but if anyone wants to see examples of XML processing done right, let me know. The "Begin Rust" book Share this. Get new blog posts via email Subscribe! Before getting into the claims of my post itself, let me address some of the counter-claims I saw in some of the discussions: XSLT isn't functional , it's declarative.

I can agree with this distinction, and think the XSLT world needs to accept it. XSLT is actually very concise. No, it's not. In fact, when designing xml-conduit , Aristid and I designed the combinators after XPath. XSLT 2. It changes none of the underlying problems.

It seems to me this question can be answered. Two people said that XSLT is disliked because the concepts it uses from functional programming are alien to many programmers. That pretty much answered it for me, and taught me something that has to do with programming I'll know what to expect when I try XSLT.

Show 16 more comments. Active Oldest Votes. Common use-cases: converting an xml document purely containing data into a document exposing a user-interface such as an xhtml document converting an xml document into a different structure to suit someone elses schema e. Biz2Biz communications A great implementation of the xslt technology is the apache-cocoon project which transforms xml documents into multiple output formats including html, excel, chart images, pdf's with an extensible plugin architecture.

Improve this answer. The irony here is that XSLT isn't really functional : it doesn't have functions as first-class values!

The real catch is that XSLT is pure : no assignments or mutations whatsoever. That's what confuses so many people. Add a comment. Notes: best used at the server; client-side support is hit'n'miss a few key things missed in 1. Marc Gravell Marc Gravell k gold badges silver badges bronze badges. I do find that you need the exslt extensions for complex tasks though.

Regarding the data transformation, it is exactly what I used it for, I was parsing websites and XSLT proved to be quite handy at this task.

If whitespace is important don't use xslt, you'll save your day overbloated and unreadable template — frenchone. I personally dislike XSLT because it seems to combine several things that are generrally disliked in the developer community: it uses magic strings XPATH that look like noise aka perl reg exs.

XSLT uses regexes not Perl ones by the way, they're far more limited only in the same way as e. Python does - i. You're definitely not forced to use them. Or do you actually mean XPath?

My note regarding reg exs was unclear. Because when they become longer than few chars they are not instantly understood. They are so contrived that you can't tell for sure what they do until you mentally debug. Just out of curiosity, what did your lines of XSLT do?

Bill the Lizard Bill the Lizard k gold badges silver badges bronze badges. I'm pretty sure those are the two most popular use cases for XSLT. Bill: I don't think more verbose is less readable, not always at least. Anyways, XSLT 2. As a language it sure has its quirks, but as a tool is invaluable. Remus Rusanu Remus Rusanu k 39 39 gold badges silver badges bronze badges.

Tim Stewart Tim Stewart 4, 1 1 gold badge 26 26 silver badges 43 43 bronze badges. The functional aspect of XSLT was one of the thing that bugged me the most at the beggining!

Cody C Cody C 4, 3 3 gold badges 27 27 silver badges 36 36 bronze badges. Steven Sudit Steven Sudit PetervanBoheemen PetervanBoheemen 41 4 4 bronze badges. Sasha Chedygov Sasha Chedygov k 26 26 gold badges 98 98 silver badges bronze badges. XSLT is both functional and imperative at the same time. This trips up a lot of people. It is easy to write bad code in it. But if you follow good patterns you can do some really neat things very easily. Paul Tarjan Paul Tarjan In what sense is it iterative?

See point 1 in my answer to another question. Will XSLT be a significant choice in future? Can you recommend new programmers to study XSLT? Not only XSLT can be used in some circumstances when other approaches would be more difficult, but also XSLT has a very specific approach that other languages don't have. Let's take a good example: unit test reports in continuous integration.

Most unit testing and code coverage programs simply output tons of unreadable XML. But with a few simple XSLTs, you can create a dozen useful reports from the same data. And other people can reuse those reports.

Now you could write these in whatever language the CI tool uses for plugins, but if you don't know that language say, you're a. NET developer, using Jenkins then there is no need to learn it. XSLT is pretty much dead because only a few enthusiasts still use it. However, there is no real alternative for it. If you focus only on a single use case, such as for example rendering of HTML pages from semantic documents, you find better tools. If you look for code generation template engines, again there is better tools.

The same for document transformation. But if you look for a tool that supports all these use cases pretty well on all platforms, then choices get very limited. If you already have an XML document and would have to transform it to something to be able to use your tool, you're probably better of just processing your data with XSLT or XQuery. Either way, you can learn XSLT in a matter of days, maybe weeks.

It won't hurt you to make a first hand experience. Just give it a shot. It's at least worth the effort to store this kind of pattern rule based transformations in your head for later use. This alone justifies learning XSLT. There will always be choice and variety in programming languages, and the reasons why one gets chosen in preference to another are as much to do with familiarity and fashion as with objective criteria like functionality, productivity, and performance.

No one can predict fashion, so no one can predict future trends in programming languages. But there are plenty of people who have got past the initial learning barriers for XSLT and find that it is an extremely productive tool for a very wide variety of tasks possibly a wider variety than it was ever designed to tackle.

XSLT is not human-readable. The meta-information the tags take too much place over the real information text, xpath requests.

A good code should look like a documentation and this is fairly not the case of XSLT. It is rather a good persistence format for mapping tools. GenerateXY is even a bit better since it separates the preview and the flow while with Velocity you would have to unfortunately break the preview indentation to provide a readable flow. The only good point in XSLT is that it cares about modularity by using and even abusing of the "xsl:template" elements.

The problem with this is that it is good for a data processing language Java, C, Something will probably supersede XSLT one day since it's a bit cumbersome to learn and use. Basically all these are the same thing however, the transformation of one XML data file to another. Now let's look at some different tools we could use instead of XSLT.



0コメント

  • 1000 / 1000