Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# XSD.exe缺少嵌套属性_C#_Xslt_Xsd - Fatal编程技术网

C# XSD.exe缺少嵌套属性

C# XSD.exe缺少嵌套属性,c#,xslt,xsd,C#,Xslt,Xsd,我这里有一个扁平的XSD: 我有一个针对它运行的“替换”XSLT脚本来修复XSD.exe(它忽略引用的元素),但是结果XSD缺少一些属性。(UniqueID\u Type中不存在ID) 有人能提供一个XSLT脚本来正确地执行这些替换,或者甚至提供另一个解决方案吗?有趣的是,有人建议编写自己的xsd.exe,并依赖XmlSchemaImporter。。。首先,我不认为这是一项微不足道的任务;第二,属性缺失的问题来源于;ImportAttributeGroupMembers中有一个bug:它不是在

我这里有一个扁平的XSD:

我有一个针对它运行的“替换”XSLT脚本来修复XSD.exe(它忽略引用的元素),但是结果XSD缺少一些属性。(
UniqueID\u Type
中不存在
ID


有人能提供一个XSLT脚本来正确地执行这些替换,或者甚至提供另一个解决方案吗?

有趣的是,有人建议编写自己的xsd.exe,并依赖XmlSchemaImporter。。。首先,我不认为这是一项微不足道的任务;第二,属性缺失的问题来源于;ImportAttributeGroupMembers中有一个bug:它不是在寻找XmlSchemaAttributeGroupRef,而是在检查XmlSchemaAttributeGroup(以下摘录由Reflector提供):

private void importAttributeGroup成员(XmlSchemaAttributeGroup组,字符串标识符,CodeIdentifiers成员,CodeIdentifiers成员作用域,字符串ns)
{
对于(int i=0;i
还有一个类似的实用程序,在进入XMLSchema重构(XSR)之前,我会尝试使用原始的XSD

如果你想走这条路,我推荐XSR(我与之相关)。我已经用最新版本(4.0.21)试用过你的XSD,它很有效。我已经公布了结果

使用XSD.exe为您指出有缺陷的片段生成的代码(我只是显示字段)现在显示ID属性的idField:

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.opentravel.org/OTA/2003/05")]
public partial class UniqueID_Type {

    private CompanyNameType companyNameField;

    private string uRLField;

    private string typeField;

    private string instanceField;

    private string idField;

    private string iD_ContextField;

    ...
}
//
[System.CodeDom.Compiler.GeneratedCodeAttribute(“xsd”,“4.0.30319.1”)]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute(“代码”)]
[System.Xml.Serialization.XmlTypeAttribute(命名空间=”http://www.opentravel.org/OTA/2003/05")]
公共部分类唯一ID_类型{
私有公司名称类型公司名称字段;
私有字符串字段;
私有字符串类型字段;
私有字符串instanceField;
专用字符串字段;
私有字符串iD_上下文字段;
...
}
特定于您的设置的是必须设置为true的InlineAttributeGroup:


如果您对使用QTAssistant进行重构的更多细节感兴趣,请参阅。无论如何,我已经发布了整个重构模式,请随意使用它……

您是否知道
xsd.exe
只是框架类(
XmlSchema
XmlSchemaImporter
XmlCodeExporter
CodeDomProvider
)的一个薄薄的包装,并且您可以非常轻松地编写自己的
xsd.exe
,要在输出中显示您希望看到的任何代码样式和任何奇特的功能,请执行以下操作:非常感谢!生成的.xsd文件在xsd.exe中运行良好。我下载了QTAssistant并打开了我原来的XSD试图复制您的修复程序,但似乎无法做到这一点。你能概述一下你在QTAssistant中采取的步骤吗?@maxp,是的,我将发布一份文档,其中包含你特定设置的所有步骤;如果这篇文章(关于SO的另一篇文章)对你不起作用,请先告诉我:嗨,佩特罗,我试着理解它,但中途有点困惑。我应该先创建一个XSR吗?我试图使用“.NET xsd.exe”工具链接,“选择文件集”总是显示为空?我迷路了,所以一个“howto”文档会很棒。@maxp,我会专门制作一个;我只能在今天晚些时候做,我希望你能同意。@maxp,我需要多一点时间,我遇到了一些关于OTA标准的问题,我决定也记录这些问题,以供你将来参考;我想不迟于今天中午。
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.opentravel.org/OTA/2003/05")]
public partial class UniqueID_Type {

    private CompanyNameType companyNameField;

    private string uRLField;

    private string typeField;

    private string instanceField;

    private string idField;

    private string iD_ContextField;

    ...
}