c# - XSD name generation -


i have xsd file:

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

if parse xsd

xsd.exe "my.xsd" /c  /n:"collectionmessage"  

i following output

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 {             {                 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 {             {                 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 {             {                 return this.transactionfield;             }             set {                 this.transactionfield = value;             }         }          /// <remarks/>         [system.xml.serialization.xmlattributeattribute()]         public string prop1 {             {                 return this.prop1field;             }             set {                 this.prop1field = value;             }         }          /// <remarks/>         [system.xml.serialization.xmlattributeattribute()]         public string accno {             {                 return this.accnofield;             }             set {                 this.accnofield = value;             }         }     } } 

however, want have output preserves name, , not append parent name child

eg

public partial class collectionscollectioncollectiondetails { 

should output as

public partial class collectiondetails {  

etc

how accomplish this?

your problem can solved using solution presented in this post. have change editing style local (nested) global. way, tool no longer need make names globally unique.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -