views:

1115

answers:

15

The use of XSLT (XML Stylesheet Language Transform) has never seen the same popularity of many of the other languages that came out during the internet boom. While it is in use, and in some cases by large successful companies (i.e. Blizzard Entertainment), it has never seemed to reach mainstream. Why do you think this is?

+3  A: 

XSL is mainstream and widely adopted. What other languages are you referring to? XSL isn't a programming language, just a transformation language, so it is pretty limited in scope.

Bryant
What constitutes a programming language... xslt has loops, conditions, variables, sub-routines with parameters... it would be like saying pl/sql isn't a programming language because its scope is limited to Oracle databases. I think it is a language specifically for transformation.
dacracot
XSLT is even turing-complete, see http://www.dpawson.co.uk/xsl/sect4/turing.html
0xA3
+4  A: 

Well... Maybe because it is a pain to write xslts... I had to write a few xslts a few months ago and I was dreaming of pointy brackets...

<Really> 
    <No>
        <fun/>
    </No>
</Really>

(I do know, that this is no xslt)

Mo
+4  A: 

Because most XSLT implementations have a high memory footprint (I suppose that's caused by the design of the language), because people tended to abuse XSLT for all kinds of things that it was not particularly well-suited for and the purely-declarative nature of XSL which makes certain types of transformations quite difficult.

Arno
+3  A: 

Generally, the times when you will be required to transform XML data into a different form of XML data, but not do any other processing to it are going to be very limited. Usually XML is used as an intermediary between two separate systems, one of which is usually custom made to process the output of the other. As such it's simpler to just write one of the systems to process the XML output of the other without the extra step of having to perform some kind of transform.

Orclev
+4  A: 

It's great for xml, but not great for typical coding. It lacks typical basic concepts (ie mutable variables) and makes what should be simple quite complex (or impossible). Most of its problems stem from the fact that xml is a great data representation language but not a great programming language. That being said, I use it daily and would recommend it where it makes sense. In conjunction with external namespaces, it can be made more useful (calls to java, etc). In the end, it's another language to learn, and many coders would prefer to stick with something they're used to or resembles something they're used to.

The absence of mutable variables is not an oversight, as your answer might make it seem, but rather quite deliberate. Functional programming in general revolves, among other things, about immutable values, and has many benefits.
Aristotle Pagaltzis
+7  A: 

XSLTs uses functional programming - something most programmers are not used to (hence why some people consider it non-intuitive I guess).

+1  A: 

I think it tried to cover way too many use cases thus becoming a Turing-complete (or so I heard) language. If you try to do any nontrivial transformation, you end up writing complex loops, conditions... in an ugly and verbose language, which is best done with a GPL.

In my view, this complexity makes writing a correct implementation of XSLT difficult and limited the available choices, thus, widespread use among the vocal hackers who often likes to tinker with small and efficient code, not enterprisey code.

artificialidiot
+1  A: 

XSLT is very powerful, but requires a different way of thinking about the problem. It also made life hard for itself by not providing useful data functionality in the early versions. Take for example a ToUpper() style method, you typically implement it with something like:

<xsl:variable name="lcletters">abcdefghijklmnopqrstuvwxyz</xsl:variable>
<xsl:variable name="ucletters">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>  

<xsl:value-of select="translate($toconvert,$lcletters,$ucletters)"/>

Not the easiest way of coding!

Ray Hayes
+2  A: 

Because it is easier to write and maintain code that uses Java, C#, JavaScript, etc. to deserialize an XML stream, transform it, and export the desired output, and XSLT offers no substantial performance advantage.

XSLT makes somethings easy, but it makes other things very, very hard.

+1  A: 

I think it boils down to XML syntax is arguably good for describing data, but it's not a great syntax for what's essentially a programming language (XSLT).

Michael Burr
+17  A: 

One problem is that XSLT looks complicated. Any developer should be able to pick up the language constructs as there are analogs in most other languages. The problem is that the constructs and data all look exactly the same which makes it difficult to distinguish between the two which makes XSLT more difficult to read than other languges.

A second issue is that the uses for it are more limited than other languages. XSLT is great at what it does; making complicated or radical transformations on XML. But it doesn't apply to as wide a range of problems as other languages, so it is not used as much.

Third, many programming languages have their own libraries for transforming XML. Much of the time when working with XML, only small changes or lookups are needed. The XML is also probably being generated or consumed by a program the developer is already writing in another language. These factors mean that using a language's built in utilities is just more convenient.

Another problem that all of these issues contribute to is inertia. That is, people don't know it, they don't see that they have much need for it, so they avoid it as a solution if there is another option.

What you end up with is a language that is the last choice of many developers when creating solutions. It is likely that XSLT is even avoided when it would be the best tool for the job as a result.

Chuck
I agree with most of what you say, but in a polyglot implementation where you are not doing everything in that perfect all around language, XSLT rocks for transforming XML, which after all is what it is for.
dacracot
A consequence of your first point is that you must escape "i<10" as "i<10". It's minor, but doesn't that just make your skin crawl? It does mine.
13ren
I agree 13ren, XSLT doesn't lend itself to syntactic sugar.
Jweede
+1  A: 

xslt is great for xml to xml, when you have data that is already escaped and a clear definition of inputs and outputs. using it for things like xml2html to me just seems like such a headache, and with nearly any dynamic language and css the output is a lot easier to implement with style.

Adam
+1  A: 

As previously stated XSLT (like “the good parts” of JavaScript) is a functional programming language. Most traditional programmers hate this statelessness. Also too many traditional programmers hate angle brackets.

But, most importantly, correct use of XSLT solves both the declarative-GUI-generation and the data-binding problem for the Web server in a platform agnostic way. Vendors like Microsoft are not motivated to celebrate this “inconvenient” power.

However, I will argue that Microsoft has the finest XSLT support for the IDE (Visual Studio) in the world.

rasx
+3  A: 

In my opinion, one of the most annoying things in standard XSLT (I'm talking about XSLT 1.0 because that's the only version I have used) is that it lacked support of string transformations and some basic date-time functions manipulations.

One thing I could never understand is why a function such as translate() was designed and implemented into xpath wheras other more useful functions such as replace, *to_lower*, *to_upper,* or - let's be crazy - regular expressions were not.

Some of these issues were adressed I guess with eXSLT (extended xslt ?) for parsers other than Microsoft's MSXML. I say I guess because I actually never used it as it was declared incompatible with MSXML.

I don't understand why XSLT 1.0 was designed with this principle that 'text' manipulation was not be in the scope of the language when it's obvious that whenever you are converting files you can't avoid those string conversion issues (e.g. : transform an unregularly padded date given in french format to american format, 31/1/2008 to 2008-01-31) huh...

These text manipulation issues were generally very basic and easily adressed in MSXML by allowing XSL to be extended with JScript functions : you could call a JScript function to perform some processing just as you would call any XSL template, but I always found that solution inelegant and ended up creating my own XSL template libraries. First because the JScript way broke your XSL portability, and then because it forced you to mix your programming logic : some bits in pure XPath/XSLT expression and other bits in DOM/object notation with JScript.

Not having updatable variables is another limitation that is very confusing for newcomers, some people just don't overcome this and keep struggling with that. In some simple cases you can have workarounds with a mix of paremetrized templates and recursive calls (for example to implement an increasing or decrasing counter) but let's face it, recursion is not that natural.

I think I heard all those limitations were adressed in the XSLT 2.0 specification, sadly MS decided not to implement it and promote XQuery instead. That's sad, why not implement both of them? I think that XSLT would still have a good chance of becoming as popular as CSS became for HTML. When you think about it, the most difficult part in learning XSLT is XPath, the rest is not as difficult as understanding the cascading behaviour in CSS, and CSS has become so popular...

So, in my opinon, it's the lack of all those little things mentioned here and the time it took to adress them in XSLT 2.0 (with not even MS supporting it anyway) that has lead to this situation of impopularity. How I wish MS decided to implement it after all...

Lepu
...Nice post. +1
Piotr Dobrogost
A: 

I found it great for 'composite web service architecture'.Sometimes number of webservices work together to have the final output.When those webservices need to communicate among them via XML then XSLT can transform the xml message from one form to another.

Kazi T Ahsan