InfoQ

InfoQ

News

My Bookmarks

Login or Register to enable bookmarks for unlimited time.

The content has been bookmarked!

There was an error bookmarking this content! Please retry.

The End of XSLT for .NET Programmers?

Posted by Jonathan Allen on Mar 05, 2008

Sections
Development
Topics
.NET ,
XML Databinding
Tags
XSLT ,
Visual Basic.NET

Microsoft's VB team is starting a series of articles on how to use XML Literals. Many of these articles will demonstrate how to replace XSLT code with VB by making direct comparisons between the two languages.

XML Literals is a syntax first pioneered for Haskell and later brought to Microsoft for use in C#. Not finding a home in either language, the Visual Basic team snapped it up and made it a cornerstone of VB 9. This should not be too much of a surprise, as the Haskell syntax was heavily influenced by VBScript's inline HTML notation.

In the first XML Cookbook article, Doug Rothaus demonstrates the VB equivalents to XSLT's <xsl:copy-of>, <xsl:for-each>, <xsl:template>, <xsl:if>, <xsl:value-of>, and <xsl:attribute> elements. He also shows how to use XML Axis Properties in place of XPath.

Though the examples are simple, the VB versions are consistently shorter than the XSLT versions. Most of the gains are from moving away from XSLT's rather verbose syntax. Though not demonstrated here, VB also has an advantage in that you can call out to normal .NET code when needed.

Only VB though by Francois Ward Posted
Re: Only VB though by Hartmut Wilms Posted
Another option is to use JavaScript / EcmaScript 4 XML (E4X) by Paul Fremantle Posted
microsoft's at it "again" by Miguel de Melo Posted
Re: microsoft's at it by Angus McDonald Posted
  1. Back to top

    Only VB though

    by Francois Ward

    XML literals are VB only though...so C# devs still go the old fashionned way (or with LINQ to XML i guess). Plus with XSLT, you have a standard reusable template, which will still be usuable the day we migrate from .NET to the "Next Big Thing(tm)".

    For simple, one shot operations, sure... but if you have a business critical transformation process, why would you do it in normal code?

  2. Back to top

    Re: Only VB though

    by Hartmut Wilms

    I have to agree with Francois, XSLT may be used in a myriad of ways. For instance XSLT can be used to transform artefacts within an MS Build script in order to generate code/XML/... from models.
    XSLT might also be used in conjunction with Web Services that rely on XML (messaging) rather than Code-First Web Services.

    Both use cases (and many more) are a natural way of handling XML and model transformations, independent of the implementation language.

    I would hate to see MS Build files cluttered with calls to VB code, which implements transformations ...

  3. Back to top

    Another option is to use JavaScript / EcmaScript 4 XML (E4X)

    by Paul Fremantle

    I routinely use JavaScript/E4X (Wikipedia Entry) which is a standard extension to JavaScript. It is available in both the Rhino (Java) and SpiderMonkey (C) implementations of JS and means that you can embed simple XML scripting into many applications. It is also available in Adobe Flash, AIR, Acrobat and Flex. The Apache Synapse ESB allows you to use it as an alternative to XSLT when transforming XML messages, whether they are in a filesystem, JMS destination or coming via HTTP POST or GET.

    I have used it on many occasions and I also find it much simpler and more effective than XSLT. I've been using XSLT for 9 years now, and I still have to reach for the manual or samples. But I can write a short, sweet, simple E4X transform in minutes. If you are using the Rhino implementation, you can even replace the default XMLBeans-based parser implementation with one based on Apache Axiom which gives a significant performance boost.

    Finally, there is even an open source Mashup Server based on E4X. [Disclosure - I work for WSO2]

  4. Back to top

    microsoft's at it "again"

    by Miguel de Melo

    Surprise surprise, Microsoft just went out of their way to break yet another standard, and give it some fancy name. The so originally called "XML Literals" looks remarkably identical to the just W3C Standard XQuery, that the rest of the XML community have been working on so had together for years, to make sure it works for everyone, and so that we all agree on a common path.

    So I am not surprised they did it again, after all is part of Microsoft's philosophy, rip off what someone else is doing well, make it worse, and make a bucket out of it . . .

  5. Back to top

    Re: microsoft's at it

    by Angus McDonald

    Miguel,

    It's got nothing to do with XQuery. It simply makes XML literals behave as objects that Visual Basic code can interact with in a more feature-rich way than simple string literals.

    The VB team has combined that with the XML querying features of LINQ (which were designed to allow you to create an object interface to XML data files) to replace some of the operations XSLT allows.

    The point is that a Basic developer now can now use the full power of the language when working with XML. This is in no way an attack on XQuery, it's just that there is no need now for it when using Visual Basic as your language of choice.

    Cheers,
    Angus

Educational Content

New-age Transactional Systems - Not Your Grandpa's OLTP

John Hugg discusses high volume transaction processing applications with high and low frequency profiles, and how VoltDB can be used for that purpose.

Cool Code

Kevlin Henney examines code samples to see what can be learned from them starting from the premise that one won’t write great code unless he knows how to read it.

Collaboration: At the Extremities of Extreme

Jason Ayers share the observations he made watching a team of developers collaborating in real time on the same code base, pushing XP, pair programming and continuous integration to their extremes.

Yesod Web Framework

Michael Snoyman presents Yesod, a web framework written in Haskell and containing a web server, templating, ORM, libraries (templating, gravatar, etc.).

Transactions without Transactions

Richard Kreuter and Kyle Banker on how to avoid classical RDBMS transactional systems by using compensation mechanisms, transactional messaging or transactional procedures.

Attila Szegedi on JVM and GC Performance Tuning at Twitter

Attila Szegedi talks about performance tuning Java and Scala programs at Twitter: how to approach GC problems, the importance of asynchronous I/O, when to use MySQL/Cassandra/Redis, and much more.

10 tips on how to prevent business value risk

One category of risk that project teams need to ensure they address is business value failure – delivering a product that fails to provide value for the business investor.

Interview: Software Systems Architecture: Working With Stakeholders Using Viewpoints and Perspectives

InfoQ spoke to the authors of Software Systems Architecture on a couple of new topics, the System Context viewpoint and Agile, which have been added to the second edition.