A pedant that hangs out in the dark corner-cases of the web.

Tuesday, April 22, 2008

Dear Microsoft, We Need XSLT 2.0

XSLT2 Is Useful

Listen, I really appreciate the work Microsoft has done on IE8 standards, and I think LINQ to XML really improves on the W3C XML DOM, but I also need to produce XML from templates.

You see, ASP.NET really only produces HTML from templates. If you want to produce RSS, Atom, POX, SVG, P3P, XSLT, or XSL-FO from templates, probably the best way to do this (for flexibility, maintainability, and readability) is with XSLT Simplified Syntax.

Example

<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fn="http://www.w3.org/2006/xpath-functions"
xsl:exclude-result-prefixes="xsl fn"
xsl:version="2.0">
<title>Press Releases</title>
<link href="http://example.org/"/>
<updated>
<xsl:value-of select="fn:max(//story/@releasedate)"/>
</updated>
<id>urn:uuid:7b2845b6-cc0d-4a64-92a4-2c0f33a398a2</id>
<xsl:for-each select="//story">
<entry>
<title>
<xsl:value-of select="@name"/>
</title>
<link href="http://example.org/"/>
<id>
<xsl:text>http://example.org/press/</xsl:text>
<xsl:value-of select="fn:format-dateTime(@releasedate,'YYYYMMDDTHHmmss')"/>
</id>
<updated>
<xsl:value-of select="@releasedate"/>
</updated>
<content type="xhtml" xml:lang="en">
<xsl:copy-of select="div"/>
</content>
</entry>
</xsl:for-each>
</feed>

This is more readable and maintainable than using the DOM to build up the document, or a full XSLT stylesheet. It is much more approachable, since it is a simple template, which allows trivial changes without having to understand the complete XSLT syntax. Plus, a minimal .NET HTTP handler can apply XSLT to source XML (perhaps produced by SQL Server) without much code to maintain.

The Problem

Anyone that's tried to use XSLT 1.0 quickly finds that they can't use most of the modern methods they've become used to in other languages: regular expressions, date/time/number parsing and formatting, grouping, data structures, Unicode support, date/time/timezone/duration data types and functions, set manipulation, aggregate functions, and converting relative URLs to absolute ones, to name some common examples of things that are simply prohibitively difficult and complex in XSLT 1.0 (particularly using the simplified syntax).

Of course these have all been addressed in XSLT 2.0 and XPath 2.0, released as W3C Recommendations over a year ago, moving XSLT from curiosity to practical templating engine.

The .NET XSLT library still only supports XSLT 1.0 and XPath 1.0.

The emphasized functions in the above example give an indication of why this is a problem. How can you provide aggregate functions and date/time formatting without those functions without losing the benefits of the XSLT Simplified Syntax? There are really only two practical answers.

Saxon

Buy Saxon (or use Saxon Basic, which is free).

Benefits
  • You support Michael Kay, XSLT ninja.
  • The market for XSLT grows.
  • You won't have to make changes to all of your templates when Microsoft finally supports XSLT2.
  • You spend no time trying to figure out how to work around the lack of a simple XSLT2 feature.
  • You get used to XSLT2.

Kludgy Workarounds

If your needs are more modest, you could try converting your stylesheet to XSLT1 and work around the limitations of that implementation.

Benefits
  • You don't spend time learning a third party library.
  • You don't have to manage a third party library when deploying your system.
  • You spend no money, provided you do not assign any value to the time required for you to come up with workarounds.

Obviously, you only want to use this approach if you have to, or if there are only a few simple workarounds to get what you want into the template, such as using the SQL Server CONVERT function to format date/time/currency/numeric values before building the XML document, or altering the XML DOM to add or substitute formatted or aggregate values before applying the stylesheet.

Conclusion

Microsoft really needs to focus some resources on getting XSLT 2.0 into the next release of .NET. Clearly, between IE8 and OOXML, standards support is on Microsoft's TODO list, and there's no question about their committment to XML. Microsoft even knows that their customers want XSLT2. The only question that remains is when market pressure will intensify the need to implement this omission. Be sure to contact Microsoft's XML Team to request a timeline for XSLT2.

24 comments:

Mahendra said...

Had MS come with XSLT2.0 API?

Brian said...

As of .NET 3.5, there is no XSLT 2.0 support: Microsoft XML Team's WebLog : XSLT 2.0, and the current consensus is to use a third-party library: When/if XSLT 2.0+ will be supported in .NET : XML and the .NET Framework : Data Platform Development : MSDN Forums.

People were getting impatient a full year ago: It's October, 2007: Do You Know Where Your Microsoft XSLT 2.0 CTP Release Is? - O'Reilly XML Blog.

Searching the Microsoft XML Team's WebLog for "XSLT" returns no results.

Brian said...

There is a tag for XSLT at the Microsoft XML Team's WebLog (XSLT tag), but nothing has been added since 2007. It looks like Microsoft is abandoning native .NET XSLT support.

Jeff said...

Until then, import this library (or parts of it) for some of the basic xslt 2.0 functions.
http://xsltsl.sourceforge.net/

elLoco said...

I definitely agree. See also the article Where is Microsoft's XSLT 2?.

Saxon is still an interpreter which is not suitable for high performance scenarios.

Brian said...

@Anonymous: You can quote me, no need to ask. I'm not sure what the Twitter question is, but I don't currently "tweet".

Anonymous said...

XQSharp now includes full XSLT 2.0 support, in addition to XPath 2.0 and XQuery 1.0.

Nick Jones said...

A native, fully featured XSLT 2.0 processor for .NET is now available from XQSharp.

Currently we are only in beta, but we hope to make a fully supported release next month.

Sanje2v said...

I had to tweak to get VS2010 Professional to show Intellisense for XSTL 2.0. First, download the file [http://www.w3.org/2007/schema-for-xslt20.xsd][1]. You'll then need to edit the file and remove 'schemaLocation' attributes from both 'xsl:import' elements which are located at the beginning of the document after the comments. Then copy this modified file to [Your Visual Studio 10.0 Installation Folder]\Xml\Schemas. If you have VS running restart it. Open your XSLT file so that the XML menu is visible and goto 'XML->Schemas...'. There you will find both version 1.0 and 2.0 schemas for XSLT. You'll need to disable version 1.0 by clicking under its 'Use' field and selecting 'Don't use this scheme'. Now the Intellisense should work.

The requirement to remove 'schemaLocation' attribute may have something to do with .NET security blocking XML documents from retrieving documents from web. I'm not sure. Anyways, the files are available locally so this shouldn't be any problem.

The editor should have selected the version 2.0 of the schema by looking at '<xsl:stylesheet version="2.0" ...' but I'm not a XML guru so there may be a better workaround than disabling schema version 1.0.

Enjoy,
Sanjeev


[1]: http://www.w3.org/2007/schema-for-xslt20.xsd

Anonymous said...

I would like to more know about it. asthma Read a useful article about tramadol tramadol

Anonymous said...

Message26, http://www.arlo.net/massacree/ online viagra, jzpk8, http://www.arlo.net/fccgb/ viagra no prescriptions, ngmg2, http://www.arlo.net/fccgb/notes/ generic viagra, dtid2, http://www.arlo.net/bytes/ buy cheap viagra online, jkzf1, http://www.arlo.net/live/ viagra

Anonymous said...

top [url=http://www.c-online-casino.co.uk/]uk casino[/url] coincide the latest [url=http://www.casinolasvegass.com/]free casino bonus[/url] unshackled no set aside perk at the chief [url=http://www.baywatchcasino.com/]baywatchcasino
[/url].

Anonymous said...

http://site.ru - [url=http://site.ru]site[/url] site
site

Anonymous said...

ebookwise 1150 ebook reader device stores http://audiobookscollection.co.uk/de/William-R-Forstchen/m132837/ ebook os x [url=http://audiobookscollection.co.uk/fr/Chimalpahin-s-Conquest-A-Nahua-Historian-s-Rewriting-of-Francisco-Lopez-de-Gomara-s-La-conquista-de-Mexico/p222113/]ebook convert software[/url] download ebook totem serigala gratis

Anonymous said...

ebook self publisher software program free http://audiobooksplanet.co.uk/Gabriel-Garcia-Moreno-and-Conservative-State-Formation-in-the-Andes/p226665/ ebook philip dick [url=http://audiobooksplanet.co.uk/Video-Tie-ins/c1393/]download power of full enagement ebook[/url] las valquirias ebook

Anonymous said...

sesamee software http://buyoem.co.uk/fr/product-35959/Apple-Final-Cut-Express-4-0-MacOSX accounting cost job software [url=http://buyoem.co.uk/product-34198/Nsasoft-Backup-Key-Recovery-1-3]what is plagiarism detection software[/url] teatime software
[url=http://buyoem.co.uk/es/product-11998/Windows-Vista-Ultimate-x86-SP1]Windows Vista Ultimate x86 SP1 - Cheap Legal OEM Software, Software Sale, Download OEM[/url] geocaching map software
[url=http://buyoem.co.uk/product-37159/Ultralingua-6-0-Italian-English][img]http://buyoem.co.uk/image/2.gif[/img][/url]

Anonymous said...

palm desktop software 3.0.1 http://buyoemsoftware.co.uk/ medical software review australia [url=http://buyoemsoftware.co.uk/it/product-37179/VeryPDF-PDF2Word-3-0-Portable]golbal star software[/url] bizdesign software processes
[url=http://buyoemsoftware.co.uk/category-3/Graphics-and-Publishing?page=76]Graphics & Publishing - Download OEM, Software Sale, OEM Software[/url] wireless network detector software
[url=http://buyoemsoftware.co.uk/it/product-37149/Toxsoft-NextFTP-4-9-x64][img]http://buyoem.co.uk/image/3.gif[/img][/url]

Anonymous said...

world nederlands computers software helpdesk http://buyoemsoftware.co.uk/fr/product-33674/Magic-Music-Editor-8-1 windows 98 clock synchronization software [url=http://buyoemsoftware.co.uk/es/product-36804/Cakewalk-Z3TA-Plus-Waveshaping-Synthesizer-2-1]blue sword bible software[/url] series 1 ge communication software
[url=http://buyoemsoftware.co.uk/product-36791/Adobe-Flash-Media-Interactive-Server-4-5-x32]Adobe Flash Media Interactive Server 4.5 x32 - Software Store[/url] dvd direct printing software
[url=http://buyoemsoftware.co.uk/product-33762/TurboTax-Home-and-Business-Federal-e-File-State-2010][img]http://buyoem.co.uk/image/5.gif[/img][/url]

Anonymous said...

website registration software http://buysoftwareonline.co.uk/de/news-36/Oracle-launches-11g-Business-Intelligence computer software auction online [url=http://buysoftwareonline.co.uk/de/product-10273/Macromedia-Contribute-3-Mac]ds p software ln17ps[/url] best file backup software
[url=http://buysoftwareonline.co.uk/product-35538/Dossier-2-6-MacOSX]Dossier 2.6 MacOSX - Download OEM, Software Sale, OEM Software[/url] masw software
[url=http://buysoftwareonline.co.uk/it/product-35813/FinePrint-PdfFactory-Pro-4-5-Server-Edition][img]http://buyoem.co.uk/image/6.gif[/img][/url]

Anonymous said...

Everything from text books, products, pieces of equipment, in addition , services / whatever, and
they've reached it. Often the My-Kaps will help you reuse the K-Cups eco friendly. Begin new pills to assist you in managing standard calories. A person's Lavazza espresso maker heats up placing a small ,
freshly covered a cup of joe dietary supplement with brewer.
With all this high regard, Krups Nescafe Dolce
Passion fitness machines become the dog's flawlessness since discovering a lot of incentives, i . e . Item of the season winner for 2010 effectively as the The year 2010 Application Forums Product champ.

My blog post; office coffee brewing systems

Anonymous said...

dating free line site http://loveepicentre.com/faq/ jaimacan man dating site
dating jerk warning [url=http://loveepicentre.com/articles/]dating fish[/url] kjaereste aiment ai christian dating websites
apolo ono dating who [url=http://loveepicentre.com]100 0free dating site online[/url] dating horoscope [url=http://loveepicentre.com/user/Charlesdebeavoir/]Charlesdebeavoir[/url] free dating los angeles

Anonymous said...

This amazing translates that your current juice extractor could
only turn into managed that when a single gadgets generally professionally promoted.
Not like disused examples who had a sole sword towards the bottom, some of the numerous utensil can cut the opportunity this
requires to remove one particular thing by 50 percent.
Outdated centrifugal juice extractors must be
emptied amount in case the carrier arrives crammed with pulp.
Before going to Alternative Electricity juice machine was searching, the incidence to do with machine ingestion was never proved to be a key point all through considering the price of every and every juice machine.
Ninja models that watch out for vintage car on their own
focus on a full food processor which comes within just
very handy back primarily just about reliability cooking.

My web-site: blender reviews

Anonymous said...

However, if the device's very free of moisture, so you employ a great bargain, along using the many of the fruit juice sensible really is waiting as part mug, alternatively your own house pulp tub. Normally quantities of this small allows your thoughts result in the birthday gift human race jointly that by having a stainless steel juicer conquered unquestionably the cooking craving for food on your people you're keen on.
Vehicle length and width your house incredibly first.


my webpage - blender reviews

Anonymous said...

Each of our greenstar machine have the ability to your
girl you might by means of extract for any belonging to the treasured vegetable or
fruit. Including canines are undoubtedly catered
meant for and is able to have fun newly terrain treats.
Doing this chute is sort of varied and is used for making juice wide fruits and veggies.


Here is my blog post: best blenders