Announcing the LINQ to XSD Preview
Ever since PDC 2005, when XLinq was unleashed (now called LINQ to XML), we have been receiving questions about the possibility of a typed XML programming approach in the LINQ world. Not surprisingly, we have been pondering about this problem indeed. This was also mentioned in the XLinq overview. (Please, also see the “Typed XML programmer” series of blog posts.) For some time now we have been focusing incubation efforts on typed XML programming for LINQ. One overall approach is to engage in a mapping of XML types to ‘plain’ object types, that is, classes with ‘fields that maintain state’ and with support for XML serialization and de-serialization. While this approach would effectively reduce typed XML programming to ‘LINQ to objects’ + de-/serialization, it potentially leads to a lossy and complicated XML programming model. Consequently, our efforts have focused on a more natural and faithful approach which builds on top of LINQ to XML.
Today we are happy to announce the LINQ to XSD Preview Alpha 0.1:
- Here is the link to the LINQ to XSD download.
- The LINQ to XSD overview document is available separately.
- You also need the LINQ download (May 2006 CTP).
We'd like to encourage everyone with a stake in XML programming and ‘schema-first’ applications to take a look at LINQ to XSD and send your observations, questions and suggestions this way; we'll be eagerly waiting for feedback! The whole point of this incubation project is to investigate options for the future of typed XML programming. We are still very early in the design process. So your feedback is critical and can help shape the design of the project as we are going forward.
This is pre-release software; it is provided “as-is” – we’re crucially interested in getting feedback from customers but we can’t make any guarantee with regard to supporting or maintaining this software or releasing future versions on any specific timeline. In particular, while the underlying LINQ to XML technology is expected for Orcas, no such commitment exists for LINQ to XSD.
What is LINQ to XSD?
LINQ to XSD provides .NET developers with support for typed XML programming on top of LINQ to XML. While the LINQ to XML programmer operates on generic XML trees, the LINQ to XSD programmer operates on typed XML trees -- instances of .NET types that model the XML types of a specific XML schema (XSD). To get an idea, consider the following C#3.0 fragment for a LINQ to XML query that computes the total over the items in a XML tree for a purchase order:
(from item in purchaseOrder.Elements("Item")
Using LINQ to XSD, the query is written in a much clearer and type-safe way:
(from item in purchaseOrder.Item
select item.Price * item.Quantity
LINQ to XSD can be used whenever you have an XML schema available, or you are willing to infer a schema from the XML data at hand. LINQ to XSD is integrated into Visual Studio; so you just tag an XML schema as an ‘LINQ to XSD schema’, build your project, and the automatically derived object model is then part of your solution -- just as if XML schemas were .NET types.
The derived object model enforces various validation constraints imposed by the underlying XML schema -- quite similar to other technologies for so-called X/O mapping or XML data binding. Two important aspects of LINQ to XSD are its integration into the LINQ family of technologies and its foundation on ‘XML objects’ as opposed to ‘plain objects’. That is, the derived object models provide XML semantics in terms of XML fidelity and programming idioms. To this end, the derived object models define .NET types (classes) that are essentially views on generic LINQ to XML trees. Typed member access and other typed axes can be used in most cases, while untyped tree access is still available, when necessary.
What’s in the release?
- An overview document -- also available separately.
- A mapping tool deriving object models from XML schemas.
- Visual Studio templates for C# LINQ to XSD projects.
- A command-line interface for the abovementioned tool.
- Samples (scenario-based and API-based).
- A technical user manual.
- A mapping documentation.
LINQ to XSD-related pointers
- The LINQ project.
- The LINQ to XSD download.
- The LINQ download (May 2006 CTP).
- The LINQ to XSD overview document.
- The “Typed XML programmer …” series of blog posts.
- An upcoming presentation at XML 2006 (paper forthcoming).
- The forum XML and the .NET Framework for related discussions.
We really look forward receiving your feedback.
Data Programmability / XML team