0

I´m trying to convert the following XML standard to C# .NET classes:

https://services.mesa.org/ResourceLibrary/ShowResource/0f47758b-60f0-40c6-a71b-fa7b2363fb3a

I´ve downloaded the package (https://services.mesa.org/ResourceLibrary/ShowResource/0f47758b-60f0-40c6-a71b-fa7b2363fb3a), unzipped the filled and moved the Schema files to an empty Schema folder.

I had them opened the Visual Studio 2012 developer prompt and issued:

xsd AllSchemas.xsd /c

After that several schema validation warning reference to undeclared attribute group' (translated) warining happened, as:

Microsoft (R) Xml Schemas/DataTypes support utility
[Microsoft (R) .NET Framework, Version 4.0.30319.17929]
Copyright (C) Microsoft Corporation. All rights reserved.
Schema validation warning: Referˆncia a grupo de modelo nÆo declarado 'http://www.mesa.org/xml/B2MML-V0600-AllExtensions:EquipmentAssetMapping'. Line 404, position 14.
Schema validation warning: Referˆncia a grupo de modelo nÆo declarado 'http://www.mesa.org/xml/B2MML-V0600-AllExtensions:HierarchyScope'. Line 473, position 14.
Schema validation warning: Referˆncia a grupo de modelo nÆo declarado 'http://www.mesa.org/xml/B2MML-V0600-AllExtensions:Location'. Line 525, position 14.
.
.
.

I need help to find out a way to move foward from this. I´ve tried to remove the 'http://www.mesa.org/xml/' reference from all files, but not succeeded.

This is my first experience with this kind of XML files, so I kindly ask for help.

Thanks.

Mendes
  • 17,489
  • 35
  • 150
  • 263

2 Answers2

1

What you're going through is not unheard of with xsd.exe... and it's been like this since version 1.0 of .NET...

My guess is that it's happening due to a bug in xsd.exe, which is most likely related to how schema loading works in .NET.

Your schema set is valid; however, the somewhat complicated way in which the standard you're pointing at is modularized, seems to be too much for the built-in .NET resolver; to make things worse, the chameleon pattern is also used, which further complicates the job of a resolver.

This is what you're dealing with (the highlighted nodes show the CoreComponents - the chameleon - and it's connected nodes; a green edge means xsd:include, the other is xsd:import):

enter image description here

This is what you really have in this set (it means that there are really only two namespaces):

enter image description here

With two files only, xsd.exe works without an error.

You most likely have to refactor the set; I think the easiest (and safest) is to do it without xsd:include. Safest because in my experience, there are a number of mainstream products that are XSD-aware (Microsoft has one example here for SQL Server 2012), that do not support xsd:include.

Petru Gardea
  • 21,373
  • 2
  • 50
  • 62
1

This worked for me:

> xsd.exe B2MML-V0600-AllExtensions.xsd .\AllSchemas.xsd /c

Microsoft (R) Xml Schemas/DataTypes support utility
[Microsoft (R) .NET Framework, Version 4.0.30319.1]
Copyright (C) Microsoft Corporation. All rights reserved.
Writing file 'AllSchemas.cs'.
David
  • 10,458
  • 1
  • 28
  • 40