[updated with the public download location and resolution of the “XNamespace.Blank” issue]
As S. Somasegar announced, Orcas Beta 1 is ready to ship and is available for download. There are some new (and renewed) features in LINQ to XML that you can check out in this release, and some minor changes introduced in response to reviews and comments:
The “renewed” feature is XStreamingElement. As we noted previously, it was removed after the May 2006 CTP to keep the slate clean for possibly incompatible changes to support streaming. At the end of the discussion we concluded that XStreamingElement is necessary and that the original design made sense.
We added LoadOptions and SaveOptions flags on the Load() and Save() methods instead of the booleans used in previous releases. There are not very many options supported at the moment, mainly PreserveWhitespace on load and DisableFormatting on save. This allows us to add more options as demand warrants without adding new overloads.
We did reverse one previously discussed decision and added the capability to keep track of the line number in the XML data source from which each node was parsed. This is a fairly expensive option, since it creates an annotation on every XObject subclass in the tree. There is also a LoadOption to preserve the base URI of a subtree that is loaded. Both options are specified in the LoadFlags.
The somewhat cosmetic changes are:
- XName.NamespaceUri was renamed to XName.NamespaceName, because namespace names don’t have the exact same semantics as URIs and we pass them as strings rather than Uri objects.
- The “No Namespace Namespace” now lives in XNamespace.Blank rather than XNamespace.Xmlns. We determined that this improves usability. [Update: Apparently not; after hearing your feedback we decided to change it to “XNamespace.None”. “NoNamespace” is probably a bit more accurate, but redundant. “Empty” isn’t quite right because it implies that there are no names in an “empty” namespace, but there usually are. This change will be available in Beta2 in a few months.]
- XName now implements ISerializable (but this is the only LINQ to XML class that does!). This is because XName has proven to be convenient in various applications that must deal with XML global name – local name pairs conveniently yet efficiently even if they do not require the rest of the LINQ to XML functionality, and supporting ISerializable allows calls with XName arguments to be remotable.
- XElement and XDocument support IXmlSerializable, to make LINQ to XML a convenient API for working with the XML sent to or received from seb services calls.
There is one somewhat hidden change: Save() is no longer implemented with a recursive algorithm, which means that you will not get an unrecoverable stack overflow exception when serializing a very deeply nested XML document.
The planned LINQ to XML work is very close to being done, and there won’t be much in the way of new LINQ to XML features new in Orcas Beta 2 in a few months. The work underway focuses on a) performance optimization (but LINQ to XML is already measurably faster than DOM for almost all of the scenarios in our test suite), b) server-side security hardening (to both allow DTDs to be processed by default yet mitigate well known DTD-based denial of service attacks) and c) a better story for binding LINQ to XML objects to WPF GUI controls.
Please try out this API with real data and real application requirements, and let us know of any issues. There is time and talent available to respond to customer needs, so make them known! The final Orcas RTM schedule is not public, but we’re definitely approaching the endgame, so the sooner the LINQ to XML team gets feedback, the more likely it is to be reflected in the final product.