473,324 Members | 2,567 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

MS XML Scheme defn tool doesn't generate root name

OK here's my (minimal) schema:
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <xs:schema targetNamespace="fred" elementFormDefault="qualified" xmlns="fred" xmlns:mstns="http://tempuri.org/XMLSchema.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  3.   <xs:element name="Devices">
  4.     <xs:complexType>
  5.       <xs:sequence>
  6.           <xs:element maxOccurs="unbounded" name="device"  />
  7.       </xs:sequence>
  8.     </xs:complexType>
  9.   </xs:element>
  10. </xs:schema>
  11.  
Here's the code from xds.exe $(ItemPath) /c /outputdir:..:
Expand|Select|Wrap|Line Numbers
  1. [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.42")]
  2. [System.SerializableAttribute()]
  3. [System.Diagnostics.DebuggerStepThroughAttribute()]
  4. [System.ComponentModel.DesignerCategoryAttribute("code")]
  5. [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="fred")]
  6. [System.Xml.Serialization.XmlRootAttribute(Namespace="fred", IsNullable=false)]
  7. public partial class Devices {
  8.  
  9.     private object[] deviceField;
  10.  
  11.     /// <remarks/>
  12.     [System.Xml.Serialization.XmlElementAttribute("device")]
  13.     public object[] device {
  14.         get {
  15.             return this.deviceField;
  16.         }
  17.         set {
  18.             this.deviceField = value;
  19.         }
  20.     }
  21. }
  22.  
No name generated for the root , I was expecting "Devices" in there somewhere.

My deserializer code:
Expand|Select|Wrap|Line Numbers
  1.             XmlReaderSettings deviceSettings = new XmlReaderSettings();
  2.             deviceSettings.Schemas.Add("fred", "DeviceConfigration.xsd");
  3.             deviceSettings.ValidationType = ValidationType.Schema;
  4.             deviceSettings.IgnoreWhitespace = true;
  5.             deviceSettings.ValidationEventHandler += new ValidationEventHandler(booksSettingsValidationEventHandler);
  6.  
  7.             XmlReader reader = XmlReader.Create("DeviceConfiguration.xml", deviceSettings);
  8.             XmlSerializer serializer = new XmlSerializer(typeof(Devices));
  9.             Devices devices;
  10.             try
  11.             {
  12.                 devices = (Devices)serializer.Deserialize(reader);
  13.             }
  14.             catch (Exception ex)
  15.             {
  16.                 return;
  17.             }
  18.  
This code always hits the exception , which gives some variation of '<Devices xmlns=... was not expected'

This is whether I add the missing name or not.
Sep 17 '07 #1
1 1433
Dököll
2,364 Expert 2GB
Greetings and salutations!

It's likely you've seen this, if not, perhaps you might want to have a look:

http://msdn.microsoft.com/msdnmag/is...erviceStation/

Will keep searching for other options...

In a bit!
Sep 20 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
50
by: Edward K. Ream | last post by:
I would like to say a few (actually more than a few) words here about some recent discoveries I have made concerning the interaction of Leo and Python. If you don't want to hear an inventor enthuse...
3
by: Mikael Petterson | last post by:
Hi, I have the following in my xml file: <attribute name="bbBusState"> I need to generate to the following: public static final String BB_BUS_STATE_ATTR_TYPE.
1
by: Ron Vecchi | last post by:
I have created a simple xml doc. then I created a simple xslt doc to transform so data. Im using a <asp:Xml> control to render the data on the page. Everything is working great....except... ...
0
by: swtrse | last post by:
Hi, There is a big problem using an XSD-Schema in C# to generate an XML-File (with WriteXML). The Scheme is defined as ------------------------------------------------------------ <?xml...
17
by: clintonG | last post by:
I'm using an .aspx tool I found at but as nice as the interface is I think I need to consider using others. Some can generate C# I understand. Your preferences please... <%= Clinton Gallagher ...
2
by: hil12345 | last post by:
Hello I Wonder if any one could give me a hand, I am trying to implement a numeric type restriction on an xml scheme. Somehow in doesn't work, while string restriction on length do work to...
4
by: Anastasios Hatzis | last post by:
I'm looking for a pattern where different client implementations can use the same commands of some fictive tool ("foo") by accessing some kind of API. Actually I have the need for such pattern for...
2
by: SimonHeffer | last post by:
To quote the MS on-line help: "The XmlChoiceIdentifierAttribute allows you to assign a special enumeration value to each instance of the member. You must either create the enumeration yourself or it...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shćllîpôpď 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.