xsd.exe

Manually Create classes to map to XML Request Response

╄→尐↘猪︶ㄣ 提交于 2019-12-10 15:48:15
问题 I have been assigned to implement an interface to an API that uses XML request/response. The API providers don't provide any xsd(s) for the XML calls. I generated the C# classes using xsd.exe: .xml -> .xsd -> .cs However, I did not find the generated classes satisfactory, as the calls include a lot of lists, which xsd.exe doesn't handle properly. Should I take the pain and create classes manually that maps to all the request/responses? That might help in maintaining the code easily later on.

Generating an XSD file with xsd.exe tool from an XML file with multiple namespaces

匆匆过客 提交于 2019-12-09 13:23:09
问题 What I want to do: I am trying to generate an XSD file for an existing XML file. I'm using the xsd.exe tool (shipped with Visual Studio). Some of the elements in the XML file are namespace-qualified. In some cases local names are the same, just as below: <images> <icons> <icon url="http://www.icons.com/logo.png"/> </icons> <foo:icons> <foo:foo_icon url="http://www.foo.org/pic.ico"/> </foo:icons> </images> What I am getting: Calling xsd.exe myfile.xml gives me an error: Cannot add a column

How to generate .xsd from a .cs using xsd.exe tool?

China☆狼群 提交于 2019-12-08 18:38:10
问题 I have a .cs file that contains a subclass of XTypedElement and IXMetaData. Microsoft has a tool that generates XSD files automatically from managed code, but it doesn't accept .cs files. It only accepts .exe, .dll, .xdr, .xml, and .xsd. How do I convert my .cs file into a .xsd file with this tool? 回答1: You first need to compile it into dll or exe file, i.e. .NET assembly, and then use this as an input for xsd.exe If you want to convert only a specific class, use the following command: xsd

XSD.exe doesn't enforce minOccurs

北城余情 提交于 2019-12-08 17:51:43
问题 I have a simple schema where I'm declaring both minOccurs and maxOccurs to 1. When I run the XSD.exe to generate a C# class and consume the class in code; the field is not enforced as mandatory. Is there some additional step missing? or does the classes generated using XSD.exe don't mandatory fields? any suggestions or insight will be helpful. 回答1: Like the Xml / infer schema tool in visual studio, whenever I've used XSD.exe I've ended up fixing some of the generated code. XSD.exe does a good

Generate Nested Types instead of Global Types with xsd.exe

核能气质少年 提交于 2019-12-07 16:45:40
问题 Using xsd.exe in a C# class, is there a way to produce a xsd file with Nested Type, instead of Global Types? I want to use this xsd file, with SSIS - Sql Server Integration Services, and look SSIS is not reading my xsd very well. I want to generate the xsd like this, with Nested Types : <?xml version="1.0" encoding="utf-8"?> <xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/XMLSchema.xsd" xmlns:mstns="http://tempuri.org

Prevent DebuggerStepThroughAttribute from applying to my non-xsd-generated partial class?

∥☆過路亽.° 提交于 2019-12-06 17:11:13
问题 I used the xsd.exe tool to generate a class based on my xml schema. It created a public partial class with DebuggerStepThroughAttribute. Well, I created another partial class file for this class to write my custom code and want to be able to step-into this code I've written but it appears the debugger is applying the step-through attribute to my partial class as well. Is there an easy way for me to step-into my code without manually removing the attribute each time I re-generate the partial

Nullable value with xsd.exe generated class

☆樱花仙子☆ 提交于 2019-12-05 12:24:16
问题 I have been using xsd.exe to generate a class for deserializing XML into. I have decimal value in the source xsd that is not required: <xs:attribute name="Balance" type="xs:decimal" use="optional" /> The resulting class from xsd generates the following code: private decimal balanceField; [System.Xml.Serialization.XmlAttributeAttribute()] public decimal Balance { get { return this.balanceField; } set { this.balanceField = value; } } Which I note is not nullable. How do I instead generate the

XML Serialization of the default values of optional attributes

蓝咒 提交于 2019-12-05 02:34:18
I have a set of classes build using xsd.exe, and I am trying to serialise them. However, an attribute is not being included in the resulting XML. Here is part of the schema where the problem lies. <xsd:element name="Widget"> <xsd:complexType> /* sequence removed for brevity */ <xsd:attribute name="Version" type="Version" use="optional" default="1.1"/> </xsd:complexType> </xsd:element> <xsd:simpleType name="Version"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="1.0"/> <xsd:enumeration value="1.1"/> </xsd:restriction> </xsd:simpleType> xsd.exe generated a property called "Version"

Prevent DebuggerStepThroughAttribute from applying to my non-xsd-generated partial class?

孤街醉人 提交于 2019-12-04 22:51:04
I used the xsd.exe tool to generate a class based on my xml schema. It created a public partial class with DebuggerStepThroughAttribute. Well, I created another partial class file for this class to write my custom code and want to be able to step-into this code I've written but it appears the debugger is applying the step-through attribute to my partial class as well. Is there an easy way for me to step-into my code without manually removing the attribute each time I re-generate the partial class? You can make the debugger ignore this attribute under Tools->Options->Debugger->General. Uncheck

XSD Gen Classes That Reference a Common Type

僤鯓⒐⒋嵵緔 提交于 2019-12-04 09:23:31
问题 I am using XSD's to define my DTO types in C#. I am using XSD.exe to gen the classes from the XSD's. I have a Common.xsd that defines an Address type and I want to use this in more than one class: <xs:complexType name="Address"> <xs:sequence> <xs:element name="Street1" type="xs:string"/> <xs:element name="Street2" type="xs:string"/> <xs:element name="City" type="xs:string"/> <xs:element name="State" type="xs:string"/> <xs:element name="Zip" type="xs:string"/> </xs:sequence> </xs:complexType>