Chr*_*ian 3 c# xml xsd xsd.exe
我有点理解我应该如何处理xml文件,所以我希望你们可以指导我正确的dirrection :)希望我能够解释我的问题清楚:)
我有很多.xsd文件都是从上到下连接的.所以我有10个带有命名空间A的.xsd和带有命名空间B的10个.xsd.让我们说两个命名空间代表每个自己的汽车.这意味着它们共享许多相同的元素,如引擎,滚轮等.我认为我可以使用xsd.exe,然后只需在我的C#代码中序列化xml文件.但是,当我将.xsd文件转换为两个.cs文件(每个命名空间/汽车一个)时,它们共享许多相同的类.当我想将两个.cs文件添加到我的项目时,这会产生问题.不能有两个同名的班级......我该如何解决这个问题?我使用错误的工具还是完全误解了我应该做什么?:)
.cs文件的开头:
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.261
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System.Xml.Serialization;
//
// This source code was auto-generated by xsd, Version=4.0.30319.1.
//
/// <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://rep.oio.dk/sundcom.dk/medcom.dk/xml/schemas/2006/07/01/")]
[System.Xml.Serialization.XmlRootAttribute("FixedFont", Namespace="http://rep.oio.dk/sundcom.dk/medcom.dk/xml/schemas/2006/07/01/", IsNullable=false)]
public partial class SimpleFormattedText {
private object[] itemsField;
private ItemsChoiceType[] itemsElementNameField;
private string[] textField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("Bold", typeof(BreakableText))]
[System.Xml.Serialization.XmlElementAttribute("Break", typeof(Break))]
[System.Xml.Serialization.XmlElementAttribute("Center", typeof(BreakableText))]
[System.Xml.Serialization.XmlElementAttribute("Italic", typeof(BreakableText))]
[System.Xml.Serialization.XmlElementAttribute("Right", typeof(BreakableText))]
[System.Xml.Serialization.XmlElementAttribute("Space", typeof(Space))]
[System.Xml.Serialization.XmlElementAttribute("Underline", typeof(BreakableText))]
[System.Xml.Serialization.XmlChoiceIdentifierAttribute("ItemsElementName")]
public object[] Items {
get {
return this.itemsField;
}
set {
this.itemsField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("ItemsElementName")]
[System.Xml.Serialization.XmlIgnoreAttribute()]
public ItemsChoiceType[] ItemsElementName {
get {
return this.itemsElementNameField;
}
set {
this.itemsElementNameField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlTextAttribute()]
public string[] Text {
get {
return this.textField;
}
set {
this.textField = value;
}
}
Run Code Online (Sandbox Code Playgroud)
}
最好的方法可能是同时将所有XSD文件提供给xsd.exe.只是为了说明,假设你有三个XSD文件,你只需要调用它:
xsd.exe a.xsd b.xsd c.xsd /c
Run Code Online (Sandbox Code Playgroud)
如果需要覆盖命名空间,只需为xsd.exe提供一个额外参数:
/namespace:MyCompany.Xsd.Something
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4753 次 |
| 最近记录: |