XSLT: With XSLT Extensions, It's Actually Not Bad

by Jon Davis 3. January 2009 05:55

A couple months ago, while picking up and getting certified in SiteCore CMS, which tries very hard to stay true to ASP.NET such that ASP.NET customizations involve as little proprietary knowledge as possible, the training taught me something new about XSLT. I learned that, in an ASP.NET environment, XSLT with XSLT Extensions is actually quite powerful!

In a previous job, I worked a bit with XSLT, and I immediately hated it. I saw that the looping and if..then blocks and otherwise really lightweight business codification in XSLT makes plain-vanilla XSLT completely brain-dead and a nightmare where business rules need to be applied. Computations and processing, instead of being performed inline (which was possible but awfully ugly) was sometimes done ahead of time and passed in as XSLT variables in the header. In cases like that job, I concluded rather quickly that .ascx ASP.NET Controls are FAR more preferable.

However, with .NET XSLT Extensions, one can isolate blocks of business rule driven functionality with identical ease as referencing an ASP.NET control with a referenced control tag. It's still not as versatile as ASP.NET pages with ASP.NET controls, but it comes really close.

Basically, XSLT Extensions are the utilization of XML namespaces to map to a .NET class. When you specify a particular tag with this namespace (once referenced), the .NET class's members are invoked. And yes, you can pass arguments.

Implementation and configuration is also different from ASP.NET Web Forms, but it's not painful. In SiteCore CMS, you drop some XML bits in the web.config and in a special directory; SiteCore has to provide the extensions functionality, as far as I know, but I could be mistaken. I think that they work with built-in .NET XML/XSLT functionality but what I was trained to use in SiteCore may not be available in core ASP.NET without some plumbing code. Again, not sure, and if I find out otherwise soon I'll likely update this post.

However, when working with an XSLT Extensions enabled framework, whatever it may be, the best part about it is that it is an open standards templating language, complete with business logic tagging. Where ASP.NET templating is proprietary to ASP.NET, XSLT is not proprietary to anything. Theoretically, one can take XSLT template markup from an ASP.NET-based web site, and, after migrating whatever extensions were used, reapply the same template markup on a Java-based web architecture, or some other one that supported XSLT w/ Extensions.

Lacking the need or anticipation of such a migration, ASP.NET w/ controls is preferred over XSLT w/ XSLT Extensions. XSLT Extensions are neat, but not quite as easy to work with as ASP.NET controls. One could also argue that XSLT templates are easier for the non-programmer designer to work with since there is less to learn; personally, while I agree to an extent, I'm still somewhat doubtful that it matters much, because one can simply apply strict rules of simplicity in ASP.NET control implementation and thereby still be far easier to work with. In my opinion, of course.

For more information, here's a Google search: XSLT Extensions

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Web Development

Add comment

(Will show your Gravatar icon)  

  Country flag

  • Comment
  • Preview


Powered by BlogEngine.NET
Theme by Mads Kristensen

About the author

Jon Davis (aka "stimpy77") has been a programmer, developer, and consultant for web and Windows software solutions professionally since 1997, with experience ranging from OS and hardware support to DHTML programming to IIS/ASP web apps to Java network programming to Visual Basic applications to C# desktop apps.
Software in all forms is also his sole hobby, whether playing PC games or tinkering with programming them. "I was playing Defender on the Commodore 64," he reminisces, "when I decided at the age of 12 or so that I want to be a computer programmer when I grow up."

Jon was previously employed as a senior .NET developer at a very well-known Internet services company whom you're more likely than not to have directly done business with. However, this blog and all of jondavis.net have no affiliation with, and are not representative of, his former employer in any way.

Contact Me 

Tag cloud


<<  June 2021  >>

View posts in large calendar