-2

Going through an ASP.NET project that isn't mine and I noticed it queries the DB, converts the data to xml, then sends that to the view. In the view it calls a class that uses xslt to convert the xml to html and that html is returned to the view.

I've never seen this before. Does anyone have the history of something like this or the pros and cons of this? This seems like a "custom" templating system. Was this something that was done before all these other frameworks like Angular or even MS's Ravor was around?

  • 2
    You have never seen that xslt is used to convert xml to html? Isn't xml transformation the primary use case for xslt? – Doc Brown Aug 9 '16 at 14:06
  • 1
    To add to what Doc Brown has already said, just because you've never seen it before, or it's not popular or sanctioned by one of the powers-that-be like Microsoft or Google, doesn't mean that it's not a perfectly valid technique. – Robert Harvey Aug 9 '16 at 14:08
  • 1
  • 1
    Just some advice for using this site: asking for the history of something without showing any research of your own is like asking someone to do your homework. Pros and Cons questions tend to be open-ended, opinion based and can be difficult to answer without an "it depends" approach. – JeffO Aug 9 '16 at 14:34
  • 1
    @user441521: I did not feel "attacked". I am just asking for clarification - you wonder about xslt for transforming xsl to html, which is core purpose of xslt, so what exactly are you wondering about? The usage of xslt in the specific context of ASP.NET? What do you think exactly is unusual? – Doc Brown Aug 9 '16 at 15:22
0

May be, XSLT was quite popular at times.
Depends how old this codebase is. We still use it in older project but our common scenario was to transform XML files saved on disk, not live data retrieved from DB.
JSON wasn't widely used back then, XML was the only de-facto standard. It's CMS and basically, one XML file was one article or section page.

It has (had) some pros.

  • It was faster than other solutions available in PHP world, as libxslt is written in C.
  • Majority of the view code was written in XSLT and independent of PHP, so it should be easier to migrate to another stack. However that didn't happen in the end.
  • Web designers meant to be able to dissect static html pages into XSLT views with mockup XML data, using 3rd party tools independent of our CMS. This turned out to be not so easy too. :)

Nowadays you have to really like XSLT way of thinking (push vs pull, etc...) to choose it.
I still prefer it to manipulate XML files, but it's usually via xsltproc CLI utility, sometime combined with a lot of grep, sed, etc...

Look at that code once more, maybe you see traces of the same motives there. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.