mganss / XmlSchemaClassGenerator

Generate C# classes from XML Schema files
Apache License 2.0
614 stars 180 forks source link

enableUpaCheck is defaulting to true, so it cannot be turned off #494

Open AdmiralSnyder opened 8 months ago

AdmiralSnyder commented 8 months ago

Hey, we're having a blast using your tool, but i think enableUpaCheck being initialized with true kindof is a bug?

(context: i hope to get rid of this problem by disabling the Upa check:

Multiple definition of element 'http://www.bipro.net/namespace/prozesse/versicherung/vertrag/kraftfahrt:Fahrzeug' causes the content model to become ambiguous. A content model must be formed such that during validation of an element information item sequence, the particle contained directly, indirectly or implicitly therein with which to attempt to validate each item in the sequence in turn can be uniquely determined without examining the content or attributes of that item, and without any information about the items in the remainder of the sequence.

thanks, Alex

mganss commented 8 months ago

Does disabling the UPA check indeed fix your problem? You can disable the UPA check by specifying -u-.

AdmiralSnyder commented 7 months ago

yes, the xsds are kinda rubbish and have duplicated declarations. i ended up using the nuget package directly, rather than invoking the process over and over, which turned out fine.

Do you know if it's possible to get better error output (i.e. filenames/linenumbers) for the conversion, when the fileset is wildcarded? for now, i ended up building the schemaSet manually and handing it into your generator, but it would be awesome if i could get rid of that code.

third, have you ever encountered the case where types specified in xsd files are omitted by the converter because they are merely extensions of simple types that are just mapped to primitive types like string or decimal in c# - i'd kinda like to see if it's possible to keep the semantics of those types alive by just creating struct wrappers around those primitive types, keeping the name...

thanks, Alex

(and greetings from Berliner Umland)

mganss commented 7 months ago

The error handling code is pretty rudimentary currently: https://github.com/mganss/XmlSchemaClassGenerator/blob/fc43f079bf6a0140bafc4bf003f43538e6f71623/XmlSchemaClassGenerator/Generator.cs#L361-L370 OTOH expansion of wildcards occurs in a separate, earlier step, i.e. only expanded names get passed to XmlSchemaSet and should be included in the error messages. What specifically are you missing?

I don't think XmlSerializer supports wrapping simple types in a struct. But I might be wrong. Do you have an example where this is possible using XmlSerializer?