Working with different versions of a Schema in Liquid XML Objects

Please also see the Schema Versioning Knowledge Base Article.

If the Schema version 1 and 2 have different namespaces:
You can simply generate code from them both. These are the approaches you could take:
  • Add the XSD files to your C#/VB.Net project and generate code from them
  • Add a .xsds (XML schema set) file to your C#/VB.Net project, this allows you to list all the source xsd files you want to generate code for.
  • Generate an assembly for each XSD version, and reference them in your main project.

If the Schema version 1 and 2 have the same namespace:
This is slightly more complex as you will have multiple objects defined within your project that describe the same XML element. The simplest approach is to Generate an assembly for each XSD version, (ensuring the .Net namespace is different for each assembly), and reference them in your main project. When it comes to using the objects you need to tell the LxSerializer where it should look for its definitions. The easiest way is to tell it which assembly to search, so the code would look something like this:
var mySchemaVer1RootElmSerializer = new LxSerializer<MySchemaVer1.RootElm >(typeof(MySchemaVer1.RootElm).Assembly); 
var mySchemaVer2RootElmSerializer = new LxSerializer<MySchemaVer2.RootElm >(typeof(MySchemaVer2.RootElm).Assembly);
If you have to bundle everything into a single assembly, then you can add a classRegistrationFilter, which controls which definitions are added to the LxSerializer (for example this could use the namespace of the types to filter on), see the LxSerializer constructor.