Using xs:extension and xs:restriction in a XSD - c#

I wanted to use both xs:extensions and xs:restriction together in my XSD for the below mentioned XML
<?xml version="1.0" encoding="utf-8"?>
<records>
<row id="1">
<record>
<Value class="field">486.89</Value>
</record>
<record>
<Value class="field">811.49</Value>
</record>
</row>
<row id="2">
<record>
<Value class="field">123.45</Value>
</record>
<record>
<Value class="field">678.91</Value>
</record>
</row>
</records>
Below is the XSD im trying :
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="records">
<xs:complexType>
<xs:sequence>
<xs:element name="row">
<xs:complexType>
<xs:sequence>
<xs:element name="record" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="Value">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:totalDigits value="12"/>
<xs:fractionDigits value="2" />
</xs:restriction>
</xs:simpleType>
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:decimal">
<xs:attribute type="xs:string" name="class" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:byte" name="id" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
The above XSD is not working ,which is the solution I found here Using xs:extension & xs:restriction together?. It's throwing an error 'complexType' element already exists in the content model.

You must globally define and name the restricted xs:simpleType that you wish to extend, not define it locally under Value.
Note also that on row you need maxOccurs="unbounded" (or something greater than the default of 1).
Altogether, this XSD will validate your XML successfully:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="Decimal12.2">
<xs:restriction base="xs:decimal">
<xs:totalDigits value="12"/>
<xs:fractionDigits value="2" />
</xs:restriction>
</xs:simpleType>
<xs:element name="records">
<xs:complexType>
<xs:sequence>
<xs:element name="row" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="record" maxOccurs="unbounded"
minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="Value">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="Decimal12.2">
<xs:attribute type="xs:string"
name="class"
use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:byte" name="id" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

Related

Element http://www.w3.org/2001/XMLSchema:complexType is invalid in this context

I'm trying to validate this XML file
<session>
<mic id="1" posname="T1" x="0.0" y="0.0" z="0.0" />
</session>
using this XSD file
<?xml version="1.0" encoding="utf-8"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
attributeFormDefault="unqualified"
elementFormDefault="qualified">
<xs:element name="session">
<xs:complexType>
<xs:sequence>
<xs:element name="mic" type="micType" minOccurs="1" maxOccurs="4">
</xs:element>
<xs:complexType name="micType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:int" name="id"/>
<xs:attribute type="xs:string" name="posname"/>
<xs:attribute type="xs:float" name="x"/>
<xs:attribute type="xs:float" name="y"/>
<xs:attribute type="xs:float" name="z"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
but I get this error message:
XmlSchema error: Element http://www.w3.org/2001/XMLSchema:complexType is invalid in this context.
If I just have the attribute definition for the mic element the program runs fine. I don't know what I'm doing wrong. I'm trying to have the XSD validate the data types for the mic element. Can anybody please tell me what I'm doing wrong?
The complexType named micType should be defined as a global type declaration, i.e. it should be an immediate child of the xs:schema element.
What you have is a non-viable hybrid of a local and global declaration of a complex type. Either define a micType globally (as Michael Kay mentioned) or locally:
Global complexType declaration
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
attributeFormDefault="unqualified"
elementFormDefault="qualified">
<xs:element name="session">
<xs:complexType>
<xs:sequence>
<xs:element name="mic" type="micType" minOccurs="1" maxOccurs="4"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="micType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:int" name="id"/>
<xs:attribute type="xs:string" name="posname"/>
<xs:attribute type="xs:float" name="x"/>
<xs:attribute type="xs:float" name="y"/>
<xs:attribute type="xs:float" name="z"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:schema>
Local complexType declaration
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
attributeFormDefault="unqualified"
elementFormDefault="qualified">
<xs:element name="session">
<xs:complexType>
<xs:sequence>
<xs:element name="mic" minOccurs="1" maxOccurs="4">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:int" name="id"/>
<xs:attribute type="xs:string" name="posname"/>
<xs:attribute type="xs:float" name="x"/>
<xs:attribute type="xs:float" name="y"/>
<xs:attribute type="xs:float" name="z"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Either way is ok and will successfully validate your XML.

Reading XML to DataSet with multiple tables in file

I'm working on building an XML editor for a personal project. Using WinForms DataGridView control and DataSet, I was able to set up Read/Edit/Save with little issue, using a separate XML file for each type.
However, as I started to try adding more "advanced" controls, it became cumbersome to work with several different files - requiring if statements depending on which file I was working with. So, I tried combining these files into one larger file, as below:
<?xml version="1.0" encoding="utf-8" ?>
<Items>
<Armor>
<Item>
<Name>Test Armor</Name>
<Value>1234567</Value>
<Rarity>Common</Rarity>
<Slot>Chest</Slot>
<Damage>1234567</Damage>
<Defense>1234567</Defense>
<Health>1234567</Health>
<Mana>1234567</Mana>
<Strength>1234567</Strength>
<Dexterity>1234567</Dexterity>
<FlavorText>Something about stuff</FlavorText>
<ImageSource>C:\Items\img.gif</ImageSource>
</Item>
</Armor>
<Consumables>
<Item>
<Name>Test Potion</Name>
<Value>1234567</Value>
<Damage>1234567</Damage>
<Defense>1234567</Defense>
<Health>0.1234567</Health>
<Mana>0.1234567</Mana>
<Strength>1234567</Strength>
<Dexterity>1234567</Dexterity>
<FlavorText>Something about stuff</FlavorText>
<ImageSource>C:\Items\img.gif</ImageSource>
</Item>
</Consumables>
<Junk>
<Item>
<Name>Test Junk</Name>
<Value>1234567</Value>
<Stackable>Yes</Stackable>
<FlavorText>Something about stuff</FlavorText>
<ImageSource>C:\Items\img.gif</ImageSource>
</Item>
</Junk>
<QuestItems>
<Item>
<Name>Test Quest Item</Name>
<Stackable>Yes</Stackable>
<FlavorText>Something about stuff</FlavorText>
<ImageSource>C:\Items\img.gif</ImageSource>
</Item>
</QuestItems>
<Weapons>
<Item>
<Name>Test Weapon</Name>
<Value>1234567</Value>
<Rarity>Common</Rarity>
<Slot>Primary</Slot>
<Damage>1234567</Damage>
<Defense>1234567</Defense>
<Health>1234567</Health>
<Mana>1234567</Mana>
<Strength>1234567</Strength>
<Dexterity>1234567</Dexterity>
<FlavorText>Something about stuff</FlavorText>
<ImageSource>C:\Items\img.gif</ImageSource>
</Item>
</Weapons>
</Items>
And the schema, generated from Visual Studio's Create Schema menu, and minimally modified - such as changing unsignedInt to int:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Items">
<xs:complexType>
<xs:sequence>
<xs:element name="Armor">
<xs:complexType>
<xs:sequence>
<xs:element name="Item" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Name" type="xs:string" />
<xs:element name="Value" type="xs:int" />
<xs:element name="Rarity" type="xs:string" />
<xs:element name="Slot" type="xs:string" />
<xs:element name="Damage" type="xs:int" />
<xs:element name="Defense" type="xs:int" />
<xs:element name="Health" type="xs:int" />
<xs:element name="Mana" type="xs:int" />
<xs:element name="Strength" type="xs:int" />
<xs:element name="Dexterity" type="xs:int" />
<xs:element name="FlavorText" type="xs:string" />
<xs:element name="ImageSource" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Consumables">
<xs:complexType>
<xs:sequence>
<xs:element name="Item" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Name" type="xs:string" />
<xs:element name="Value" type="xs:int" />
<xs:element name="Damage" type="xs:int" />
<xs:element name="Defense" type="xs:int" />
<xs:element name="Health" type="xs:decimal" />
<xs:element name="Mana" type="xs:decimal" />
<xs:element name="Strength" type="xs:int" />
<xs:element name="Dexterity" type="xs:int" />
<xs:element name="FlavorText" type="xs:string" />
<xs:element name="ImageSource" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Junk">
<xs:complexType>
<xs:sequence>
<xs:element name="Item" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Name" type="xs:string" />
<xs:element name="Value" type="xs:int" />
<xs:element name="Stackable" type="xs:string" />
<xs:element name="FlavorText" type="xs:string" />
<xs:element name="ImageSource" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="QuestItems">
<xs:complexType>
<xs:sequence>
<xs:element name="Item" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Name" type="xs:string" />
<xs:element name="Stackable" type="xs:string" />
<xs:element name="FlavorText" type="xs:string" />
<xs:element name="ImageSource" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Weapons">
<xs:complexType>
<xs:sequence>
<xs:element name="Item" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Name" type="xs:string" />
<xs:element name="Value" type="xs:int" />
<xs:element name="Rarity" type="xs:string" />
<xs:element name="Slot" type="xs:string" />
<xs:element name="Damage" type="xs:int" />
<xs:element name="Defense" type="xs:int" />
<xs:element name="Health" type="xs:int" />
<xs:element name="Mana" type="xs:int" />
<xs:element name="Strength" type="xs:int" />
<xs:element name="Dexterity" type="xs:int" />
<xs:element name="FlavorText" type="xs:string" />
<xs:element name="ImageSource" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Both of these files are wholly representative of their counterparts - I had separate files for Armor, Consumables, etc.
The expected outcome was to have one file representing the previously separate files, such that:
Items is the root node.
Within Items are the parent nodes - Armor, Consumables, etc.
Within each parent node are the child nodes Item and their properties.
As far as I can tell, the XML structure and schema looks correct, but when I try to read this file into my program, I receive the error: System.FormatException - "Input string was not in a correct format.".
The stack trace shows that System.Number.StringToNumber is throwing this exception. I've dug through the file and the schema a few times and can't seem to find where this is occuring, and the exception detail doesn't provide much further detail.
In my code, I'm reading the data simply using
DataSet data = new DataSet();
data.ReadXmlSchema(itemSchema);
data.ReadXml(itemData);
This exact method worked without issue when the files/schema were separate, which further leads me to believe I've simply overlooked something in the XML/Schema.
At this point, I'm stuck and not sure what it could be. I would greatly appreciate if anyone can help me solve this issue.
The problem is that you repeat the element Item on each item type.
When your code reads the schema, it finds the first appearance of the Item element and tries to apply the same schema to every other appearance; so, when it reads the Test Potion it tries to read it as string, int, string, string, int, int, int, int, int, int, string, string and fails when it finds the 0.1234567 Health value.
My suggestion would be to change your schema it to something like this:
<?xml version="1.0" encoding="utf-8" ?>
<Items>
<Armor>
<ArmorItem>
...Item elements
</ArmorItem>
</Armor>
<Consumables>
<ConsumableItem>
...Item elements
</ConsumableItem>
</Consumables>
<Junk>
<JunkItem>
...Item elements
</JunkItem>
</Junk>
<QuestItems>
<QuestItem>
...Item elements
</QuestItem>
</QuestItems>
<Weapons>
<WeaponItem>
...Item elements
</WeaponItem>
</Weapons>
</Items>

Schema Validation Warnings and Errors

When I run the xsd tool to generate vb classes against:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:element name="Security" type="SecurityType"/>
<xs:complexType name="SecurityType">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="UsernameToken" type="UsernameToken"/>
</xs:sequence>
<xs:attribute name="mustUnderstand" type="xs:string"/>
<xs:anyAttribute/>
</xs:complexType>
<xs:complexType name="UsernameToken">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="Username" type="xs:string"/>
<xs:element minOccurs="0" maxOccurs="1" name="Password" type="Password"/>
</xs:sequence>
<xs:attribute name="Id" type="xs:string"/>
</xs:complexType>
<xs:complexType name="Password">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="Type" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:schema>
I get the following schema validation warnings:
Type Password is not declared
Type UsernameToken is not declared
Type SecurityType is not declared
I get the following Error:
The datatype 'SecurityType' is missing
I added xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" and it worked.

Problem with deserializing a message with substitutionGroup

I have the following XML message that I deserialize with XmlSerializer.
For some reasons, deserialization of this message strips the Database section of the XML message.
I need some help in deserializing this message in its entirety.
This is a sample test XML message.
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Radars xmlns="http://mycompany.com/2008/c2s2">
<Radar>
<Identification>
<Identifier>140:141</Identifier>
<IP>10.216.1.79</IP>
<Label>Radar 1</Label>
<Model>Radar123</Model>
<Category>Civil</Category>
</Identification>
<Database>
<Radar456General>
<Identifier>203</Identifier>
<Version>8</Version>
<RadarStartStop>false</RadarStartStop>
<AntennaRotationSpeed>false</AntennaRotationSpeed>
<RadarAntennaRotation>false</RadarAntennaRotation>
<AntennaStaringPosition>0</AntennaStaringPosition>
</Radar456General>
</Database>
</Radar>
</Radars>
I am using XmlSerializer to deserialize the above message like this:
public static T Deserialize<T>(string message)
{
object obj = null;
try
{
XmlSerializer xs = new XmlSerializer(typeof(T));
StringReader reader = new StringReader(message);
XmlTextReader xmlReader = new XmlTextReader(reader);
obj = xs.Deserialize(xmlReader);
xmlReader.Close();
reader.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex);
throw ex;
}
return (T)obj;
}
Radars radars = Serializer.Deserialize<Radars>(message);
After deserializing it, I get an empty Database section (meaning radars.radar[0].Database.Length == 0).
The schema of the message is specified in a separate XSD file. I use xsd.exe to generate C# classes from it.
This is the partial content of the XSD file.
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://mycompany.com/2008/c2s2"
targetNamespace="http://mycompany.com/2008/c2s2"
elementFormDefault="qualified" version="1.0">
<xs:include schemaLocation="asterix_cat034.xsd"/>
<xs:include schemaLocation="asterix_cat253.xsd"/>
<xs:element name="Radars">
<xs:annotation>
<xs:documentation>List of radar information</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="Radar" type="RadarType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="RadarType">
<xs:sequence>
<xs:element name="Identification" type="RadarIdentificationType"/>
<xs:element name="Database" type="DatabaseType"/>
</xs:sequence>
</xs:complexType>
<xs:element name="Radar" type="RadarType"/>
<xs:complexType name="RadarIdentificationType">
<xs:annotation>
<xs:documentation>
This type represents the radar identification.
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="Identifier" type="xs:string"/>
<xs:element name="IP" type="xs:string"/>
<xs:element name="Label" type="xs:string"/>
<xs:element name="Model" type="RadarModelType"/>
<xs:element name="Category" type="RadarCategoryType"/>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="RadarModelType">
<xs:restriction base="xs:string">
<xs:enumeration value="Radar123"/>
<xs:enumeration value="Radar456"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="RadarCategoryType">
<xs:restriction base="xs:string">
<xs:enumeration value="Civil"/>
<xs:enumeration value="Military"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="DatabaseSectionType">
<xs:sequence>
<xs:element name="Identifier" type="xs:unsignedByte"/>
<xs:element name="Version" type="I253_100_DB_VER"/>
</xs:sequence>
</xs:complexType>
<xs:element name="DatabaseSectionType" type="DatabaseSectionType">
<xs:annotation>
<xs:documentation>root of the substitution group</xs:documentation>
</xs:annotation>
</xs:element>
<xs:complexType name="DatabaseType">
<xs:sequence>
<xs:element ref="DatabaseSectionType" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:element name="Radar456General" substitutionGroup="DatabaseSectionType">
<xs:annotation>
<xs:documentation>Radar456General database section</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="DatabaseSectionType">
<xs:sequence>
<xs:element name="RadarStartStop" type="I253_100_Start_Stop"/>
<xs:element name="AntennaRotationSpeed" type="I253_100_ARS"/>
<xs:element name="RadarAntennaRotation" type="I253_100_ROT"/>
<xs:element name="AntennaStaringPosition" type="I253_100_ASP"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="Radar123General" substitutionGroup="DatabaseSectionType">
<xs:annotation>
<xs:documentation>Radar123General database section</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="DatabaseSectionType">
<xs:sequence>
<xs:element name="Shutdown" type="I253_100_Shutdown"/>
<xs:element name="RotationTransmission" type="I253_100_ROT_TX"/>
<xs:element name="SurfaceInstrumentedRange" type="I253_100_SIR"/>
<xs:element name="TransmitterTuneMode" type="I253_100_TT_mode"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:schema>
So how can I deserialize the message with Database section?
Try create the same object structure in code, serialize it and see he differences between your data and serialized date, than you'll know whats wrong.

Problem deserializing xml file

I auto generated an xsd file from the below xml and used xsd2code to get a c# class. The problem is the entire xml doesn't deserialize.
Here is how I'm attempting to deserialize:
static void Main(string[] args)
{
using (TextReader textReader = new StreamReader("config.xml"))
{
// string temp = textReader.ReadToEnd();
XmlSerializer deserializer = new XmlSerializer(typeof(project));
project p = (project)deserializer.Deserialize(textReader);
}
}
here is the actual XML:
<?xml version='1.0' encoding='UTF-8'?>
<project>
<scm class="hudson.scm.SubversionSCM">
<locations>
<hudson.scm.SubversionSCM_-ModuleLocation>
<remote>https://svn.xxx.com/test/Validation/CPS DRTest DLL/trunk</remote>
</hudson.scm.SubversionSCM_-ModuleLocation>
</locations>
<useUpdate>false</useUpdate>
<browser class="hudson.scm.browsers.FishEyeSVN">
<url>http://fisheye.xxxx.net/browse/Test/</url>
<rootModule>Test</rootModule>
</browser>
<excludedCommitMessages></excludedCommitMessages>
</scm>
<openf>Hello there</openf>
<buildWrappers/>
</project>
When I run the above, the locations node remains null.
Here is the xsd that I'm using:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="project">
<xs:complexType>
<xs:all>
<xs:element name="openf" type="xs:string" minOccurs="0" />
<xs:element name="buildWrappers" type="xs:string" minOccurs="0" />
<xs:element name="scm" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="useUpdate" type="xs:string" minOccurs="0" msdata:Ordinal="1" />
<xs:element name="excludedCommitMessages" type="xs:string" minOccurs="0" msdata:Ordinal="2" />
<xs:element name="locations" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="hudson.scm.SubversionSCM_-ModuleLocation" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="remote" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="browser" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="url" type="xs:string" minOccurs="0" msdata:Ordinal="0" />
<xs:element name="rootModule" type="xs:string" minOccurs="0" msdata:Ordinal="1" />
</xs:sequence>
<xs:attribute name="class" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="class" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="project" />
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
Figured it out. When using xsd2code I had select options to target the 3.5 framework and include the xml attributes. It now deserializes as expected. Not sure which one did it, but works now.
According to this page '.' is not a valid XML tag name character, so you need to rename <hudson.scm.SubversionSCM_-ModuleLocation> to something without the dots.

Categories

Resources