xsd.exe

Can't find xsd.exe in the path during MSBuild Community Tasks BeforeBuild step in Visual Studio

為{幸葍}努か 提交于 2019-12-12 06:59:27
问题 I am using MSBuild Community Tasks to run Xsd.exe as part of my build in Visual Studio as thus: <Import Project="$(SolutionDir)Common.targets" /> <PropertyGroup> <MSBuildCommunityTasksPath>$(SolutionDir)TeamBuildTypes</MSBuildCommunityTasksPath> </PropertyGroup> <Import Project="$(MSBuildCommunityTasksPath)\MSBuild.Community.Tasks.Targets" /> <UsingTask TaskName="XSD" AssemblyFile="$(VCTargetsPath)$(CPPTasks)" /> <Target Name="BeforeBuild"> <!--Exec Command="'$(DevEnvDir)..\Tools\vsvars32.bat

Xsd.exe generated class doesn't serialize mandatory elements when null value

随声附和 提交于 2019-12-12 01:51:33
问题 In the following XSD all elements are mandatory: <?xml version="1.0" encoding="utf-16"?> <xs:schema xmlns="http://TestNamespace" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://TestNamespace" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="Test"> <xs:complexType> <xs:sequence> <xs:element minOccurs="1" maxOccurs="1" name="Id" type="xs:int" /> <xs:element minOccurs="1" maxOccurs="1" name="EMail" type="xs:string" /> </xs:sequence> </xs:complexType> <

Deserialise XML response from server

那年仲夏 提交于 2019-12-11 22:04:54
问题 I want to deserialise an object. I saw the following code in msdn.com: private void DeserializeObject(string filename) { Debug.WriteLine("Reading with XmlReader"); // Create an instance of the XmlSerializer specifying type and namespace. XmlSerializer serializer = new XmlSerializer(typeof(User)); // A FileStream is needed to read the XML document. FileStream fs = new FileStream(filename, FileMode.Open); XmlReader reader = XmlReader.Create(filename); // Declare an object variable of the type

Deserialize XML dateTime to UTC

不打扰是莪最后的温柔 提交于 2019-12-11 06:54:56
问题 I am consuming an XML webservice with XSD elements such as: <xs:element nillable="true" type="xs:dateTime" name="ENDDATE"/> XML might look like the following: <ENDDATE>2016-08-01T18:35:49+04:00</ENDDATE> I used XSD.exe to autogenerate C# classes, when I inspect these the DateTime object will contain the time in system-local time, with Kind==Local . Is there a way I can force the DateTime instances to be in UTC time without manually hacking the auto-generated classes for every such field

Generating cXML classes from xsd throws error “The element 'uri:ds:Signature' is missing.”

夙愿已清 提交于 2019-12-11 05:42:27
问题 I'm trying to generate cXML classes for version cXML 1.2.034 as per http://cxml.org/ XSD (converted by visual studio). I converted the cXML.dtd to xsd. Then Tried running: xsd.exe cXML.xsd /c /language:CS /n:MyNamespace But it threw an error: Error: Error generating classes for schema 'cXML'. - The element 'uri:ds:Signature' is missing. Then I found this issue here: Generating C# classes from XSD which seems relevant. So I downloaded xmldsig-core-schema.xsd from http://www.w3.org/TR/xmldsig

how to ask XSD.exe to generate proper class for me, so that i can create a fine XML

[亡魂溺海] 提交于 2019-12-11 03:38:45
问题 I have created an XSD file from Visual Studio 2010, Then I use xsd /c mydemo.xsd to generate class for me, so that I can create a XML file at runtime. However, when I use that class, fill in some values, and serialize the object, the XML file does not look nice to me. Here is my XSD file Click here to see What I expected the XML file to be is Click here to see (Generated from Visual Studio "Sample XML") But when I try to serialize it, the XML file is like this CLick here to see The format is

Deserialization of nullable value with xsd.exe generated class

感情迁移 提交于 2019-12-11 03:26:32
问题 Nullable value with xsd.exe generated class answers why the generated class has a *Specified field and property, and how it's used for serializing an XML file, but how am I able to set this value during deserialization ? I have a generated class as defined below: /// <remarks/> [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.33440")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")]

XML Serialized from xsd.exe generated code using substitution groups is invalid (invalid xsi:type error)

谁说我不能喝 提交于 2019-12-11 02:34:12
问题 I've generated some C# classes from some 3GPP XSDs (multiple XSD files/namespaces) and it works great for serialization apart from one problem with concrete instances of an abstract type used in a substitution group. Firstly, the relevant parts of the schema: (genericNrm.xsd) <element name="ManagedElement"> <complexType> <complexContent> <extension base="xn:NrmClass"> <sequence> ... <choice minOccurs="0" maxOccurs="unbounded"> <element ref="xn:IRPAgent"/> <element ref="xn

XML Schema Definition Tool not generating SchemaLocation

℡╲_俬逩灬. 提交于 2019-12-11 01:52:26
问题 Does the xsd.exe tool provided with Visual Studio generate the SchemaLocation attribute (in the xs:import) when generating XSDs from plain old C# objects? I am finding that my XSDs that were generated are not valid because the xs:import will import a namespace and not provide the relative schemalocation value prompting the below Imported Schema for namespace 'urn:company-event-namespace' was not resolved. 回答1: As you've found, it does not generate that attribute. This may have to do with the

XSD.exe - How to initialize a type created from xs:choice

时间秒杀一切 提交于 2019-12-11 01:43:39
问题 I'm fairly new to working with XSD's and serialization de-serialization, I'm looking for some advice on how to initialise the resulting class object created from a xs:choice element in the XSD, to start here's some info on the XSD and Object class: Examples taken from a larger XSD, object class. XSD: <xs:element name="main-contact"> <xs:complexType> <xs:sequence> <xs:choice> <xs:element name="person"> <xs:complexType> <xs:group ref="person"/> </xs:complexType> </xs:element> <xs:element name=