0
我有一個XSD文件:XSD名代
<xs:schema id="collections" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" targetNamespace="myNamespace" >
<xs:element name="collections" msdata:IsDataSet="true" msdata:Locale="en-US">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="collection">
<xs:complexType>
<xs:sequence>
<xs:element name="collectionDetails" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="transaction" minOccurs="0" maxOccurs="unbounded">
</xs:element>
</xs:sequence>
<xs:attribute name="Prop1" type="xs:string" />
<xs:attribute name="AccNo" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
如果我解析此XSD與
xsd.exe "my.xsd" /c /n:"CollectionMessage"
我得到以下輸出
namespace CollectionMessage {
using System.Xml.Serialization;
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="myNamespace")]
[System.Xml.Serialization.XmlRootAttribute(Namespace="myNamespace", IsNullable=false)]
public partial class collections {
private collectionsCollection[] itemsField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("collection", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public collectionsCollection[] Items {
get {
return this.itemsField;
}
set {
this.itemsField = value;
}
}
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
public partial class collectionsCollection {
private collectionsCollectionCollectionDetails[] collectionDetailsField;
[System.Xml.Serialization.XmlElementAttribute("collectionDetails", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public collectionsCollectionCollectionDetails[] collectionDetails {
get {
return this.collectionDetailsField;
}
set {
this.collectionDetailsField = value;
}
}
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
public partial class collectionsCollectionCollectionDetails {
private object[] transactionField;
private string prop1Field;
private string accNoField;
[System.Xml.Serialization.XmlElementAttribute("transaction", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public object[] transaction {
get {
return this.transactionField;
}
set {
this.transactionField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string Prop1 {
get {
return this.prop1Field;
}
set {
this.prop1Field = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string AccNo {
get {
return this.accNoField;
}
set {
this.accNoField = value;
}
}
}
}
不過,我想有保留名稱的輸出,並且不會將父名稱附加到子女
如
public partial class collectionsCollectionCollectionDetails {
應該輸出
public partial class collectionDetails {
等
我如何做到這一點?
使用複雜類型或?...如果它對xsd本身很小,我不反對它。 – Alex