Splitting files generated

Sep 20, 2009 at 9:48 AM

Would be it be possible to add an option to split the generated files? I have been trying to use LINQ to XSD to build a class library from a *very* complex set of schemas, but am having issues with namespace conflicts.

Alas I have no control over the schema design so cannot fix the problem at source.

It looks like when schema "A" references schema "X", and then schema "B" references schema "Y", where X and Y are very similar versions, it results in namespace clashes and thus errors in the code.

It suggests that LINQ to XSD is not able to support complex XML schemas... ?




Sep 29, 2009 at 4:24 PM
Edited Sep 29, 2009 at 4:26 PM

Further to this I had lots of issues with repeated element types in namespaces.

It seems that LinqToXSD loads all XSD namespaces into the XmlSchemaSet, regardless of whether these have been already added by an <xsd:import /> or added as part of the compile.

In build 17994, code file XObjectsGenerator.cs at line 53 there is:

set.Add(null, CreateReader(arg));

I would suggest changing to:

XmlSchema xsd = XmlSchema.Read(CreateReader(arg), ValidationCallback);
// only add schema if not already included
if (!set.Contains(xsd.TargetNamespace)) 

The schema set for my application is very complex an d a lot of schemas are inter-dependent, so LinqToXsd created a code file over 200,000 lines long (it was interesting trying to open that one up I can tell you).

I am going to modify the source code for my own purposes but I think I've also found a bug where it misses some element types out completely resulting in more errors.. will advise

Sep 1, 2011 at 12:00 AM
Edited Sep 1, 2011 at 12:09 AM



Sep 12, 2011 at 10:18 AM

We use a LinqToXsdConfiguration.xml file to fix namespace conflicts in complex Xsds over which we have no control:

<Configuration xmlns="http://www.microsoft.com/xml/schema/linq"> 
    <Namespace Schema="http://blah.blah/1/2/3" Clr="Our.Schema.Namespace"/>
    <Namespace Schema="http://blah.blah/4/5/6" Clr="Our.Schema.Namespace"/>

That cleared the problem up. Just add the Xml file to your project, configure the Namespace elements and set the the build action to LinqToXsdConfiguration