473,320 Members | 1,724 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,320 software developers and data experts.

writing xml files with XSDObjectGen.exe

I have a schema and have used XSDObjectGen.exe to create a set of
classes that represent the schema.

What is the best way to fill xsdobjectgen.exe generated classes with
data? I want to create and serialize an instance of one of the classes
in this schema. the class is declared publicly, but isn't accessible
outside the namespace:

<XmlType(TypeName:="BusinessProperty571LFormsType" ,Namespace:=Declarations.SchemaVersion),XmlRoot,Se rializable,
_
EditorBrowsable(EditorBrowsableState.Advanced)> _
Public Class BusinessProperty571LFormsType
The cause seems to be the XmlType attribute, if I remove it, the class
is accessible. How is this happening? all I want to do is say
something like:
bf = new sdr.BusinessProperty571LFormsType
bf.foo = "some data"
....

but I can't instanciate it.

Secondly, how do you serialize xsdobjectgen.exe class instances?

I'm trying to serialize one of the classes that is visible as a test:
<XmlRoot(ElementName:="SDR",Namespace:=Declaration s.SchemaVersion,IsNullable:=False),Serializable>
_
Public Class SDR
Here is the code:
Dim tmp As sdr.SDR
tmp = New sdr.SDR

Dim bs As System.Xml.Serialization.XmlSerializer
bs = New System.Xml.Serialization.XmlSerializer(GetType(sdr .SDR))
bs.Serialize(System.IO.File.Create("d:/tmp.xml"), tmp)

Here is the exception I get:
Unhandled Exception: System.InvalidOperationException: There was an
error reflecting type 'VisualBasicSax2.sdr.SDR'. --->
System.InvalidOperationException: There was an error reflecting field
'__SDRHeader'. ---> System.InvalidOperationException: There was an
error reflecting type 'VisualBasicSax2.sdr.SDRHeaderType'. --->
System.InvalidOperationException: There was an error reflecting field
'__FilerContacInfo'. ---> System.InvalidOperationException: There was
an error reflecting type 'VisualBasicSax2.sdr.ContactInfoType'. --->
System.InvalidOperationException: There was an error reflecting field
'__FullName'. ---> System.InvalidOperationException: There was an
error reflecting type 'System.String'. --->
System.InvalidOperationException: Value 'SDRStringType' cannot be used
for the XmlElementAttribute.DataType property. The datatype
'http://www.w3.org/2001/XMLSchema:SDRStringType' is missing.

SDRStringType is defined in the schema:
<xs:simpleType name="SDRStringType">
<xs:restriction base="xs:string">
<xs:pattern value="^[a-zA-Z0-9\s.\-/_']+$"/>
</xs:restriction>
</xs:simpleType>

Is this a bug in XSDObjectGen? Or do I need to pass the schema to the
serializer somehow?

Thanks in advance,
Aaron
Nov 12 '05 #1
3 4409
Hi Aaron,

The schema details are missing from your post. Please send me thedetails including the schema in question. I'd have to see moreof the generated code to figure out what is happening.

The serialization errors you are getting can stem from the factthat you're not using an XMLTextWriter as part of theserialization, but are directly opening a file. The stack traceseems to indicate that there are undefined types in your schemaas well, and there may be namespace issues. Again, I'd have tosee the schema.

You might want to first validate the schema to make sure itdoesn't have any obvious errors. You can find a validator onthe gotdotnet web site under the XML tools section.

If you forward the details, I'll take a look.

Dan Rogers
da***@microsoft.com
User submitted from AEWNET (http://www.aewnet.com/)
Nov 12 '05 #2
Please post the schema or email it to me (remove the nospam from my email
address) and I'll take a look at it.

Dan Rogers
Microsoft Corporation

Nov 12 '05 #3
I am having the same problem with .net serialization exposing aWeb Services :P

I havent figured out the way of telling .net serialization thatthe simple type I am using is defined in my xsd and is using mynamespace ... as you, it keeps thinking it is defined inhttp://www.w3.org/2001/XMLSchema
User submitted from AEWNET (http://www.aewnet.com/)
Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Burak | last post by:
Hello, I am working on a VB.NET web service that will be used to send and receive job openings. I would like to use their "industry standard" xsd file ...
2
by: Pavan | last post by:
Hi, I received an error from a schema using the much hyped XSDObjectGen: Unexpected error occured in XSDObjectGen : Specified cast is not valid. Please send the schema to support. However...
5
by: colinco | last post by:
Just out of curiousity, what are the deficiencies you've found with the new xsdobjectgen tool?
3
by: Edward Clements | last post by:
I'm looking for a good tool to generate C# classes (from XSD-schemas) to (de-)serialize XML corresponding to those schemas. XSDObjectGen almost meets these requirements -- only, I need to...
1
by: SteveC | last post by:
I've used XsdObjectGen (1.36) to create some C# classes, all seemed fine Deserialized some test XML into the class, again seemed to work Ok, but then I noticed that any of the DateTime...
0
by: Pascal Brunot | last post by:
Hi, Running XSDObjectGen (1.4.1.0) on the following Infopath-generated XSD gives an "unexpected error": "Event register full" during generation (exact english error message may differ, i am...
0
by: Andrew Burgher | last post by:
Feeding the following .xsd into the XsdObjectGen (v1.4.2.0) tool produces an invalid attribute: with DataType="System.String". Has anybody seen this behaviour before? Is this a bug in...
0
by: TT (Tom Tempelaere) | last post by:
Hi there, I'm using the XSDObjectGen tool to generate a class described as an XSD. <url...
0
by: Jeff Killberg | last post by:
I am working on a .NET 2.0 project where we will be defining a large object model in XML schema and generating the C# code to process XML documents conforming to this XML schema into the object...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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.