LINQ to XSD
An incubation project

on typed XML programming

 

 

Microsoft .NET and LINQ

 

 

 

 

 

 

 

 

 

Welcome to the Microsoft LINQ to XSD Preview Alpha 0.2

February 2008

 

Important: You must accept the enclosed license terms before you can use this pre-release software. If you do not accept the License Terms, you are not authorized to use this pre-release software. The License Terms are included in the distribution of this software.

 

Please consult the LINQ to XSD program menu to find …

  • This ReadMe.
  • Code  samples.
  • Various  documentation.

(Start -> All Programs -> LINQ to XSD Preview)

 

Requirements for the LINQ to XSD Preview

  • Visual Studio 2008.
  • Operating Systems: Windows XP (SP2); Windows Vista; Windows Server 2003.

 

What is LINQ to XSD? 

The LINQ to XSD technology provides .NET developers with support for typed XML programming. LINQ to XSD contributes to the LINQ project (.NET Language Integrated Query); in particular, LINQ to XSD enhances the existing LINQ to XML technology. 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")

      select (double)item.Element("Price")

           * (int)item.Element("Quantity")

     ).Sum();

 

Using LINQ to XSD, .NET developers may instead write `typed’ code as follows:

 

     (from item in purchaseOrder.Item

      select item.Price * item.Quantity

     ).Sum();

 

LINQ to XSD facilitates XML schemas (XSD), which are automatically mapped to object models so that XML data may be processed in typed manner within the OO paradigm. To this end, the generated classes enforce various validation constraints imposed by the input schema. In this respect, LINQ to XSD is similar to existing technologies for so-called X/O mapping or XML data binding. An important aspect of LINQ to XSD though is its foundation on ‘XML objects’ as opposed to ‘plain objects’. That is, the object models, generated from XML schemas, provide XML semantics in terms of XML fidelity and programming idioms, thereby providing a better programming environment for XML-related development tasks. To this end, the generated classes model typed views on untyped XML trees. LINQ to XSD enhances LINQ to XML. Familiar XML programming idioms of LINQ to XML are complemented by typed variations in LINQ to XSD. In particular, typed member access can be used in most cases, and untyped tree access is available as a last resort.

 

What features are offered by this release?

  • Comprehensive and canonical XML-schema-to object-model mapping.
  • The generated classes model typed views on XML trees.
  • Typed descendant and ancestor axes on XML object types.
  • Discoverable object models including tool tips for XML schema constraints.
  • Visual Studio integration through project templates with build tasks.
  • Command-line interface for mapping tool.

 

Documents

  • Overview – Illustrations and design rationale; primary text on LINQ to XSD.
  • Manual – Other technical documentation; recommended reading for typical users.
  • Mapping – Systematic mapping catalogue; optional reading for typical users.

 

Samples

§         Tips:

o        Location: My Documents\Visual Studio 2008\Projects\LINQ to XSD Samples.

o        Quick access: Start -> All Programs -> LINQ to XSD Preview.

o        See the source code for explanations of the samples.

o        The samples are self-checking, i.e., results are checked against a baseline.

o        In some cases, both LINQ to XML code and LINQ to XSD code are shown.

§         C# project LinqToXsdDemo – Scenarios of typed XML programming

o        Total – Query sample that calculates the total over a batch of purchase orders.

o        WageBill – Query sample for salaries in a company using type-driven descendants.

o        Mapping – Consume and produce XML messages with LINQ to XSD and others.

o        Paradise – DML sample that increases the salary of all employees in a company.

o        Reorg – Advanced DML sample dealing with the reorganization of a company.

o        Reports – Count reports of a manager in mixed typed and untyped fashion.

o        Evaluate – Expression evaluation using partial classes and virtual methods.

o        TypeCheck – Expression typechecking using extension methods and annotations.

o        XsdPrimer – Purchase orders from the XSD primer with schema documentation.

o        XsdStyler – XML schemas are analyzed using the XML schema for XML schemas.

o        VsConvert – Visual Studio projects files (XML!) are converted in some ways.

o        QueryExcel – Raw XML data, as it is exported from Excel, is processed.

o        RunAll.cs – The framework for executing the samples.

o        Config.xo – A sample configuration for mapping customization.

§         C# project LinqToXsdAPI  – Samples for using the Typed XLinq API.

§         VB LinqToXsdVB  – Sample for using LINQ to XSD within a VB project.

 §         Directory LinqToXsdCLI  – Sample for building LINQ to XSD apps w/o VS.

 

Known issues and desiderata

§         Better intellisense for LINQ will imply better intellisense for LINQ to XSD.

§         Better discoverability during object construction; cf. XRoot class.

§         Support of LINQ to XSD for the use in WebServices.

§         Tool support (wizard) for adding schemas to project with customization.

§         Automated schema normalization for common XSD organization/coding styles.

§         Performance tuning: stay close to LINQ to XML figures.

§         Improvement of DML for complicated content models; cf. ‘append’ semantics.

§         Open bugs and work items on name/namespace mapping.

§         Open bugs and work items on cast-time validation and handling of restricted types.

§         Support for default elements currently disabled.

§         Support for global and local validation based on forthcoming LINQ to XML support.

§         Name normalization for Camel/Pascal style of capitalization.

§         Streaming support based on forthcoming LINQ to XML support.

§         Improved experience for object browsing and debugging.

§         Multiple typed views on the same XElement instance.

 

Further Information on LINQ to XSD

§         XML Developer Center: http://msdn.microsoft.com/xml/

§         The LINQ Project: http://msdn.microsoft.com/linq/

 

Disclaimer

LINQ to XSD is an incubation project on typed XML programming carried out at Microsoft. LINQ to XSD is not scheduled to ship as a product. It is important to note that this release is being exposed to customers so as to gather their feedback on the typed XML programming experience. Any future products in this space may or may not be similar to LINQ to XSD. See the license terms for details.


Copyright © 2007-2008 Microsoft Corporation.  All rights reserved.