xsd 警告和错误转换为 c# 类 [英] xsd warning and error converting to c# class

查看:36
本文介绍了xsd 警告和错误转换为 c# 类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将以下 XML 标准转换为 C# .NET 类:

适用于 SQL Server 2012),不支持 xsd:include.

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.

解决方案

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):

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

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.

这篇关于xsd 警告和错误转换为 c# 类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆