xsd.exe

xsd.exe generates two files, how to join them into one?

折月煮酒 提交于 2019-12-22 12:20:10
问题 I'm not a big XSD expert.. so I'm using xsd.exe to quickly generate some xsd that I need and then tweaking them a bit (minOccur, etc). But now it has created two XSD files, the main one and an extra one where it defines a complex type. How could I mash them together? I've tried for a while but I keep getting compilation errors. Here's what they look like: <?xml version="1.0" encoding="utf-8"?> <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn

XML Serialization of the default values of optional attributes

随声附和 提交于 2019-12-22 04:06:26
问题 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

XML Serialization of the default values of optional attributes

孤街浪徒 提交于 2019-12-22 04:05:32
问题 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

How to create a XSD schema from a class?

雨燕双飞 提交于 2019-12-17 03:56:01
问题 I'm having a hard time with the XSD files. I'm trying to create an XSD file from a class: public enum Levels { Easy, Medium, Hard } public sealed class Configuration { public string Name { get;set; } public Levels Level { get; set; } public ConfigurationSpec { get;set;} } public abstract class ConfigurationSpec { } public class ConfigurationSpec1 { // ... } public class ConfigurationSpec2 { // ... } Please note that I have an abstract class inside of Configuration. With that feature, is it

How to create a XSD schema from a class?

巧了我就是萌 提交于 2019-12-17 03:54:18
问题 I'm having a hard time with the XSD files. I'm trying to create an XSD file from a class: public enum Levels { Easy, Medium, Hard } public sealed class Configuration { public string Name { get;set; } public Levels Level { get; set; } public ConfigurationSpec { get;set;} } public abstract class ConfigurationSpec { } public class ConfigurationSpec1 { // ... } public class ConfigurationSpec2 { // ... } Please note that I have an abstract class inside of Configuration. With that feature, is it

How do I deserialize this simple xml config with the XmlSerializer class?

江枫思渺然 提交于 2019-12-13 02:48:42
问题 I have the following xml I'd like to deserialize into a class <?xml version="1.0" encoding="utf-8" ?> <root> <element1>String1</element1> <element2>String2</element2> </root> I am trying to serialize it into the following class: [XmlRoot("root")] public class root { [XmlElement("element1")] internal string element1 { get; set; } [XmlElement("element2")] internal string element2 { get; set; } } When I try deserializing it using the following code, the config object is instantiated, but the

XSD Class generators: keeping track of element order

喜欢而已 提交于 2019-12-13 00:08:18
问题 I got the following complex type within my XSD schema <xs:complexType name="structure" mixed="true"> <xs:choice maxOccurs="unbounded"> <xs:element type="b" name="b" /> <xs:element type="a" name="a" /> </xs:choice> </xs:complexType> which allows me to state XML definitions like this: <structure> Hello <b>World</b> Hello 2 <b>World 2</b> <a>Hello3</a> <b>World3</b> </structure> Now I tried to generate XSD classes out of my schema, I tried both XSD.exe as well as XSD2Code. They both generate

Are circular groups allowed by XSD schema?

試著忘記壹切 提交于 2019-12-12 15:09:16
问题 For this xml: <elem1 xmlns="http://www.fixprotocol.org/ns/fast/t/1.0"> <elem2> <elem2/> </elem2> </elem1> I have this schema, which seems to validate fine against w3 schema validation service, and the schema validates the above XML just fine. Sadly, xsd.exe and some other tools report it to be an error. Is that correct? Are circular group refs dissallowed by XML schema? Thanks! Update: The schema is not mine, can't change it :( <xs:schema attributeFormDefault="unqualified" elementFormDefault=

how can i use the file that is generated by xsd.exe in windows 10 universal app

馋奶兔 提交于 2019-12-12 11:29:07
问题 I am generating .cs files from .xsd files using xsd.exe. But when I am adding the files to windows 10 universal blank app, I was getting error as "missing an assembly reference" for System.SerializableAttribute() and System.ComponentModel.DesignerCategoryAttribute(‌​"‌​code"). I fixed this by @t.ouvre's trick. Then there were no errors in any of the particular line of the code but when i am building the code i am getting an error saying that " Cannot find type System.ComponentModel

How to use xsd.exe /c output

喜你入骨 提交于 2019-12-12 07:35:06
问题 I tried using xsd.exe to convert an .xsd file into a C# class. It worked, but I'm still not quite sure how to use this class. It has several class-level attributes but the most interesting is System.Xml.Serialization.XmlTypeAttribute. Which class uses that attribute? Is there a simple way to turn an instantiation of this class into a string of XML? 回答1: Super straight-forward. I love the xsd tool. I have taken some liberties below. //From xml to object YourRootType inst = new XmlSerializer