October 10, 2005

ValidationType.Auto is obsolete, what do I do?

In .NET 2.0 ValidationType.Auto value is made obsolete. What's worse - it doesn't work for XmlReaders created via XmlReader.Create() factory method. But how do you validate against either DTD and/or schema, i.e. against DTD if document has a DOCTYPE and/or schema if any is applicable? The answer is: you can ...

August 28, 2005

On XPathNavigator.SelectSingleNode again

I've seen some people talking and some leaving comments that newly introduced XPathNavigator.SelectSingleNode() method is actually a wrapper around XPathNavigator.Select and so it provides no performance benefits. This is both true and false. It's true that you won't get any performance boost from moving to XPathNavigator.SelectSingleNode() method, because it's really ...

August 1, 2005

New in .NET 2.0: Push-Based XML Validation with XmlSchemaValidator Class

This is a real hidden gem in .NET 2.0 everybody (including me) have pretty much overlooked. XmlSchemaValidator class from the System.Xml.Schema namespace is a push-based W3C XML Schema validatation engine. Push-based means different processing model - an opposite for pull-based one. Think about how you work with XmlWriter (push) and ...

July 28, 2005

Erik Saltwell: "What the heck is OutputSettings"

Erik Saltwell explains what this XslCompiledTransform.OutputSettings property is and why it exists. That's really fresh, clean and powerful design once you get it. I didn't first. ...

July 19, 2005

New in .NET 2.0: XPathNavigator finally has SelectSingleNode() method

In .NET 2.0 XPathNavigator finally has SelectSingleNode() method! MSXML and XmlDocument (XmlNode actually) have it forever and it's so widely used because it's soooo handy. Obviously despite its name, XPathNavigator.SelectSingleNode() returns not a node, but node equivalent in XPathNavigator's data model - XPathNavigator. And this method is even better than ...

July 18, 2005

nxslt 1.6 and nxslt2 Beta1 released

nxslt 1.6 and nxslt2 Beta1 are available for download. For those not familiar with nxslt: nxslt is free feature-rich .NET XSLT Command Line Utility. nxslt 1.6 is the next version for the .NET 1.X Frameworks. New features include optionality for source XML or stylesheet, pretty printing, ASCII only escaped output ...

July 12, 2005

Outputting HTML with XslCompiledTransform and XmlResolver

I was wrong in my last post. Here is how one can output HTML with XslCompiledTransform when XmlResolver needs to be passed to Transform() method. using (XmlReader src = XmlReader.Create("../../source.xml")) { XslCompiledTransform xslt = new XslCompiledTransform(); xslt.Load("../../style.xslt"); XmlWriter result = XmlWriter.Create(Console.Out, xslt.OutputSettings); xslt.Transform(src, null, result, new XmlUrlResolver()); } The key ...

July 11, 2005

XslCompiledTransform API bug (update - not a bug, my fault)

I'm porting nxslt utility to .NET 2.0 with XslCompiledTransform as XSLT processor and I just found out XslCompiledTransform API is really severe broken. I was writing before that the only Transform() method overload that accepts XmlResolver outputs to XmlWriter. So if you want to create HTML and to have some ...

July 10, 2005

Loading XPathDocument with XmlWriter

What I dislike in System.Xml v2.0 (and v1.X for that matter) is a poor support for push-based XML processing. Somehow it's all about pull - XmlReader, while push - XmlWriter seems to be a second class citizen. For instance one can't populate XML into XPathDocument or XSLT stylesheet into XslCompiledTransform ...

June 22, 2005

Alex Homer explains how to read and write XML in .NET 2.0

15seconds.com published a series of articles by Alex Homer on reading and writing XML in .NET Version 2.0: Reading and Writing XML in .NET Version 2.0 - Part 1 Reading and Writing XML in .NET Version 2.0 - Part 2 Excellent articles. Part 3 is expected too according to Alex's ...

June 8, 2005

Microsoft XML Team strikes back on XML performance comparison in .NET and Java

Microsoft XML Team has posted a response "Comparing XML Performance" to the Sun XML Mark 1.0 benchmark and accompanying whitepaper from Sun XML Performance Team asserted that Java significantly outperforms .NET in XML processing performance. ...

June 7, 2005

Helping to make System.Xml v2.0 better

kzu says he has broken the mark of 100 bugs filed to the MSDN Feedback Center. That's impressive. My numbers are humble - only 15 bugs and suggestions. Gotta be more active here. I spent a day working on an adapter to my homegrown XSLT test suite for the XslCompiledTransform ...

June 1, 2005

What's new in System.Xml 2.0: XPathNavigator is now IXPathNavigable

Another improvement System.Xml 2.0 brings, from the how-come-I-didn't-make-it--before department is that XPathNavigator class now implements IXPathNavigable. Sounds obvious, huh? In both common and OOP sense of course XPathNavigator should be IXPathNavigable, but somehow in .NET 1.0 and 1.1 it is not. (And by the way I still wonder how come ...

May 16, 2005

System.Xml 2.0: XmlReader is now IDisposabe

Another handy feature implemented in .NET 2.0 Beta2 is that XmlReader class now implements IDisposable interface and so can be closed automatically when using with "using" statement in C#: using (XmlReader r = XmlReader.Create("../../source.xml")) { while (r.Read()) Console.WriteLine(r.NodeType); } Really handy. And implemented in literally couple of lines. It's a ...

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 ...

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 ...

May 5, 2005

Declarative way to expose methods as XSLT extension functions?

I had a conversation with somebody about how EXSLT.NET worked around the hyphenated EXSLT function names problem and if there are better ways to solve it. Here is a suggestion for Microsoft: give us more control over exposing .NET methods as extension functions and make it declarative. ...

May 4, 2005

.NET 2.0 prohibits DTD in XML by default

Yep, no DTD is allowed by default in the .NET 2.0 Beta2: XmlReaderSettings.ProhibitDtd Property (System.Xml) Gets or sets a value indicating whether to prohibit document type definition (DTD) processing. Return Value true to prohibit DTD processing; otherwise false. The default is true. Remarks This setting can be useful in preventing ...

April 17, 2005

XslCompiledTransform (new XSLT 1.0 processor in .NET 2.0) - no more pull-mode XSLT

I'm studying new XSLT 1.0 implementation provided by Microsoft in the .NET 2.0 Beta2 - XslCompiledTransform class. The guys who wrote it are my good friends and excellent developers, but let me to complain a little bit, not because I'm a complainer, but trying to make this cool piece of ...