May 11, 2005

Blogging engine running XSLT?

Dave Pawson investigates if there is enough interest in a community developed web logging system based on XSLT processing and Atom8. He welcomes any feedback. I've been using XSLT-powered online publishing systems such as Docbook Website and definitely see enough potential behind Dave's idea. ...

May 10, 2005

.NET XSLT API - broken again?

.NET XSLT API is traditionally ugly. XslTransform class (obsoleted in .NET 2.0) had 8 Load() methods and 9 Transform() ones in .NET 1.0. In .NET 1.1 - 11 Load() methods (5 of them obsoleted) and 18 Transform() (9 obsoleted). Huge mess. Brand new XslCompiledTransform in .NET 2.0 Beta2 has just ...

For instance there is no Transform() method that accepts IXPathNavigable and XmlResolver. That means one can't transform already loaded XmlDocument or XPathDocument and provide XmlReader instance (say with user credentials set) at the same time. The only workaround is to pass XmlReader over XmlDocument or XPathDocument, which means ridiculous thing - I've got loaded XPathDocument, but have to pass an XmlReader over it so XslCompiledTransform will build another temporary copy of this XPathDocument. What a waste of memory!

Another uncovered case - the only Transform() method accepting XmlResolver outputs to an XmlWriter. But what if I transfrom to HTML or text? There is no workaround here.

Why this stuff is so complicated? The core problem is that input and output of an XSLT processor can be of a variety of forms. Generally speaking XSLT input can be string (document URI), Stream, TextReader, XmlReader or IXPathNavigable. And output can be string (URI), Stream, TextWriter or XmlWriter. 5 times 4 = 20. Plus optional XsltArgumentList and optional XmlResolver - 20 times 2 times 2 = 80 Transform() methods for the maximum usability. That's of course crazy. Encapsulation usully helps. Stream can be encapsulated into TextReader and TextReader into XmlReader and XmlReader into IXPathNavigable. Output isn't so easy. Stream, TextWriter or XmlWriter arte really needed. And recall usability... So it's still to many methods.

I wonder if the XML Team considered javax.xml.transform.Result approach?

May 9, 2005

foreach and XPathNodeIterator - finally together

This one little improvement in System.Xml 2.0 Beta2 is sooo cool anyway: XPathNodeIterator class at last implements IEnumerable! Such unification with .NET iteration model means we can finally iterate over nodes in an XPath selection using standard foreach statement: XmlDocument doc = new XmlDocument(); doc.Load("orders.xml"); XPathNavigator nav = doc.CreateNavigator(); foreach ...

May 8, 2005

Security changes in .NET 2.0's XSLT

More security changes made in XSLT in .NET 2.0 Beta2. When working with XslCompiledTransform class: document() function is disabled by default. To enable it, one has to provide XsltSettings enum value with EnableDocumentFunction field set to the XslCompiledTransform.Load() method: XslCompiledTransform xslt = new XslCompiledTransform(); XsltSettings settings = new XsltSettings(); settings.EnableDocumentFunction ...