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

XSD.exe and code it generates

I have the following XML snipet:

<PROFILEINSPECTION MODIFIED="TRUE">
<PROFILEINSPECTIONID MODIFIED="TRUE">8622</PROFILEINSPECTIONID>
</PROFILEINSPECTION>

using VS.net I have created a schema, and do the following:
1) remove the Dataset as I don't need it.
2) Set the PROFILEINSPECTIONID maxoccurs to 1

From there I use XSD.exe to create the C# classes for the above XML.
This results in two classes being defined:
1) PROFILEINSPECTION
a) public PROFILEINSPECTIONPROFILEINSPECTIONID
PROFILEINSPECTIONID;
b) public string MODIFIED;
2) PROFILEINSPECTIONPROFILEINSPECTIONID

The issue I have is that there is no code generated to create an
instance for the property PROFILEINSPECTIONID. So when I create an
instance of PROFILEINSPECTION and try to access the
PROFILEINSPECTIONID I receive an exception stating that it is NULL.

So am I missing something with the XSD? or am I trying to do something
with this that it was never ment to do?

Thanks
Wayne
Nov 12 '05 #1
7 1716
I believe it's working as intended. You'll just need to create a
PROFILEINSPECTIONPROFILEINSPECTIONID instance and assign it to the
PROFILEINSPECTIONID field. Of course should you have deserialized the xml
snippet you provided, the serializer would have done that for you.

"Wayne" <me*****@hotmail.com> wrote in message
news:39**************************@posting.google.c om...
I have the following XML snipet:

<PROFILEINSPECTION MODIFIED="TRUE">
<PROFILEINSPECTIONID MODIFIED="TRUE">8622</PROFILEINSPECTIONID>
</PROFILEINSPECTION>

using VS.net I have created a schema, and do the following:
1) remove the Dataset as I don't need it.
2) Set the PROFILEINSPECTIONID maxoccurs to 1

From there I use XSD.exe to create the C# classes for the above XML.
This results in two classes being defined:
1) PROFILEINSPECTION
a) public PROFILEINSPECTIONPROFILEINSPECTIONID
PROFILEINSPECTIONID;
b) public string MODIFIED;
2) PROFILEINSPECTIONPROFILEINSPECTIONID

The issue I have is that there is no code generated to create an
instance for the property PROFILEINSPECTIONID. So when I create an
instance of PROFILEINSPECTION and try to access the
PROFILEINSPECTIONID I receive an exception stating that it is NULL.

So am I missing something with the XSD? or am I trying to do something
with this that it was never ment to do?

Thanks
Wayne

Nov 12 '05 #2
Well I am deserializing the XML when I get it back. Some of my web services
take XML as params. In those cases I am creating an instance of the object
and setting the ID, serializing the obeject then passing the XML to the
webservice at which point I get back a fully filled out profileinspection.

I was affaid that some one would awnser with what you awnsered with. The
object/XML is quite complex to have to create an instance of every property
is going to be a pain. Time to look at what and how I'm doing things to see
if I can change it a bit.

Thanks for your help
Wayne

"Jiho Han" <ji******@infinityinfo.com> wrote in message
news:ut*************@tk2msftngp13.phx.gbl...
I believe it's working as intended. You'll just need to create a
PROFILEINSPECTIONPROFILEINSPECTIONID instance and assign it to the
PROFILEINSPECTIONID field. Of course should you have deserialized the xml
snippet you provided, the serializer would have done that for you.

"Wayne" <me*****@hotmail.com> wrote in message
news:39**************************@posting.google.c om...
I have the following XML snipet:

<PROFILEINSPECTION MODIFIED="TRUE">
<PROFILEINSPECTIONID MODIFIED="TRUE">8622</PROFILEINSPECTIONID>
</PROFILEINSPECTION>

using VS.net I have created a schema, and do the following:
1) remove the Dataset as I don't need it.
2) Set the PROFILEINSPECTIONID maxoccurs to 1

From there I use XSD.exe to create the C# classes for the above XML.
This results in two classes being defined:
1) PROFILEINSPECTION
a) public PROFILEINSPECTIONPROFILEINSPECTIONID
PROFILEINSPECTIONID;
b) public string MODIFIED;
2) PROFILEINSPECTIONPROFILEINSPECTIONID

The issue I have is that there is no code generated to create an
instance for the property PROFILEINSPECTIONID. So when I create an
instance of PROFILEINSPECTION and try to access the
PROFILEINSPECTIONID I receive an exception stating that it is NULL.

So am I missing something with the XSD? or am I trying to do something
with this that it was never ment to do?

Thanks
Wayne


Nov 12 '05 #3
I now have the code deserializing the XML into the Object, however if there
is no node or the node is empty for a given property then no instance of the
property is created.

Is there any way to force the entire object to be set up with the generated
code, other than modifying the generated code to do this?

Thanks
Wayne
"Jiho Han" <ji******@infinityinfo.com> wrote in message
news:ut*************@tk2msftngp13.phx.gbl...
I believe it's working as intended. You'll just need to create a
PROFILEINSPECTIONPROFILEINSPECTIONID instance and assign it to the
PROFILEINSPECTIONID field. Of course should you have deserialized the xml
snippet you provided, the serializer would have done that for you.

"Wayne" <me*****@hotmail.com> wrote in message
news:39**************************@posting.google.c om...
I have the following XML snipet:

<PROFILEINSPECTION MODIFIED="TRUE">
<PROFILEINSPECTIONID MODIFIED="TRUE">8622</PROFILEINSPECTIONID>
</PROFILEINSPECTION>

using VS.net I have created a schema, and do the following:
1) remove the Dataset as I don't need it.
2) Set the PROFILEINSPECTIONID maxoccurs to 1

From there I use XSD.exe to create the C# classes for the above XML.
This results in two classes being defined:
1) PROFILEINSPECTION
a) public PROFILEINSPECTIONPROFILEINSPECTIONID
PROFILEINSPECTIONID;
b) public string MODIFIED;
2) PROFILEINSPECTIONPROFILEINSPECTIONID

The issue I have is that there is no code generated to create an
instance for the property PROFILEINSPECTIONID. So when I create an
instance of PROFILEINSPECTION and try to access the
PROFILEINSPECTIONID I receive an exception stating that it is NULL.

So am I missing something with the XSD? or am I trying to do something
with this that it was never ment to do?

Thanks
Wayne



Nov 12 '05 #4
Not sure if this works because I've never tried it but take a look at
IsNullable property of XmlElementAttribute class.

You'd use it like this:

public class A
{
[XmlElement(IsNullable = false)]
public mypropertyclass B;
}

The only caveat may be that the resulting empty element would contain
xsi:nil = "true" attribute set and maybe that's ok for you, maybe not.

Let me know how it goes.
I'd be interested in the result.

Cheers,
Jiho

"Wayne" <ws*****@NoLandSpamstar.com> wrote in message
news:uT****************@TK2MSFTNGP12.phx.gbl...
I now have the code deserializing the XML into the Object, however if there is no node or the node is empty for a given property then no instance of the property is created.

Is there any way to force the entire object to be set up with the generated code, other than modifying the generated code to do this?

Thanks
Wayne
"Jiho Han" <ji******@infinityinfo.com> wrote in message
news:ut*************@tk2msftngp13.phx.gbl...
I believe it's working as intended. You'll just need to create a
PROFILEINSPECTIONPROFILEINSPECTIONID instance and assign it to the
PROFILEINSPECTIONID field. Of course should you have deserialized the xml snippet you provided, the serializer would have done that for you.

"Wayne" <me*****@hotmail.com> wrote in message
news:39**************************@posting.google.c om...
I have the following XML snipet:

<PROFILEINSPECTION MODIFIED="TRUE">
<PROFILEINSPECTIONID MODIFIED="TRUE">8622</PROFILEINSPECTIONID>
</PROFILEINSPECTION>

using VS.net I have created a schema, and do the following:
1) remove the Dataset as I don't need it.
2) Set the PROFILEINSPECTIONID maxoccurs to 1

From there I use XSD.exe to create the C# classes for the above XML.
This results in two classes being defined:
1) PROFILEINSPECTION
a) public PROFILEINSPECTIONPROFILEINSPECTIONID
PROFILEINSPECTIONID;
b) public string MODIFIED;
2) PROFILEINSPECTIONPROFILEINSPECTIONID

The issue I have is that there is no code generated to create an
instance for the property PROFILEINSPECTIONID. So when I create an
instance of PROFILEINSPECTION and try to access the
PROFILEINSPECTIONID I receive an exception stating that it is NULL.

So am I missing something with the XSD? or am I trying to do something
with this that it was never ment to do?

Thanks
Wayne



Nov 12 '05 #5
Apparently has no effect on the object. According to the help it only
serializes an empty tag for null objects.

Back to looking at other possible options.

Thanks
Wayne

"Jiho Han" <ji******@infinityinfo.com> wrote in message
news:ut**************@TK2MSFTNGP10.phx.gbl...
Not sure if this works because I've never tried it but take a look at
IsNullable property of XmlElementAttribute class.

You'd use it like this:

public class A
{
[XmlElement(IsNullable = false)]
public mypropertyclass B;
}

The only caveat may be that the resulting empty element would contain
xsi:nil = "true" attribute set and maybe that's ok for you, maybe not.

Let me know how it goes.
I'd be interested in the result.

Cheers,
Jiho

"Wayne" <ws*****@NoLandSpamstar.com> wrote in message
news:uT****************@TK2MSFTNGP12.phx.gbl...
I now have the code deserializing the XML into the Object, however if

there
is no node or the node is empty for a given property then no instance of

the
property is created.

Is there any way to force the entire object to be set up with the

generated
code, other than modifying the generated code to do this?

Thanks
Wayne
"Jiho Han" <ji******@infinityinfo.com> wrote in message
news:ut*************@tk2msftngp13.phx.gbl...
I believe it's working as intended. You'll just need to create a
PROFILEINSPECTIONPROFILEINSPECTIONID instance and assign it to the
PROFILEINSPECTIONID field. Of course should you have deserialized the xml snippet you provided, the serializer would have done that for you.

"Wayne" <me*****@hotmail.com> wrote in message
news:39**************************@posting.google.c om...
> I have the following XML snipet:
>
> <PROFILEINSPECTION MODIFIED="TRUE">
> <PROFILEINSPECTIONID MODIFIED="TRUE">8622</PROFILEINSPECTIONID>
> </PROFILEINSPECTION>
>
> using VS.net I have created a schema, and do the following:
> 1) remove the Dataset as I don't need it.
> 2) Set the PROFILEINSPECTIONID maxoccurs to 1
>
> From there I use XSD.exe to create the C# classes for the above XML.
> This results in two classes being defined:
> 1) PROFILEINSPECTION
> a) public PROFILEINSPECTIONPROFILEINSPECTIONID
> PROFILEINSPECTIONID;
> b) public string MODIFIED;
> 2) PROFILEINSPECTIONPROFILEINSPECTIONID
>
> The issue I have is that there is no code generated to create an
> instance for the property PROFILEINSPECTIONID. So when I create an
> instance of PROFILEINSPECTION and try to access the
> PROFILEINSPECTIONID I receive an exception stating that it is NULL.
>
> So am I missing something with the XSD? or am I trying to do something > with this that it was never ment to do?
>
> Thanks
> Wayne



Nov 12 '05 #6
Have you tried it out?

In any case, if all else fails, try this:

http://msdn.microsoft.com/xml/defaul...xsdcodegen.asp

"Wayne" <ws*****@NoLandSpamstar.com> wrote in message
news:em*************@TK2MSFTNGP12.phx.gbl...
Apparently has no effect on the object. According to the help it only
serializes an empty tag for null objects.

Back to looking at other possible options.

Thanks
Wayne

"Jiho Han" <ji******@infinityinfo.com> wrote in message
news:ut**************@TK2MSFTNGP10.phx.gbl...
Not sure if this works because I've never tried it but take a look at
IsNullable property of XmlElementAttribute class.

You'd use it like this:

public class A
{
[XmlElement(IsNullable = false)]
public mypropertyclass B;
}

The only caveat may be that the resulting empty element would contain
xsi:nil = "true" attribute set and maybe that's ok for you, maybe not.

Let me know how it goes.
I'd be interested in the result.

Cheers,
Jiho

"Wayne" <ws*****@NoLandSpamstar.com> wrote in message
news:uT****************@TK2MSFTNGP12.phx.gbl...
I now have the code deserializing the XML into the Object, however if

there
is no node or the node is empty for a given property then no instance of
the
property is created.

Is there any way to force the entire object to be set up with the

generated
code, other than modifying the generated code to do this?

Thanks
Wayne
"Jiho Han" <ji******@infinityinfo.com> wrote in message
news:ut*************@tk2msftngp13.phx.gbl...
> I believe it's working as intended. You'll just need to create a
> PROFILEINSPECTIONPROFILEINSPECTIONID instance and assign it to the
> PROFILEINSPECTIONID field. Of course should you have deserialized
the
xml
> snippet you provided, the serializer would have done that for you.
>
> "Wayne" <me*****@hotmail.com> wrote in message
> news:39**************************@posting.google.c om...
> > I have the following XML snipet:
> >
> > <PROFILEINSPECTION MODIFIED="TRUE">
> > <PROFILEINSPECTIONID

MODIFIED="TRUE">8622</PROFILEINSPECTIONID> > > </PROFILEINSPECTION>
> >
> > using VS.net I have created a schema, and do the following:
> > 1) remove the Dataset as I don't need it.
> > 2) Set the PROFILEINSPECTIONID maxoccurs to 1
> >
> > From there I use XSD.exe to create the C# classes for the above XML. > > This results in two classes being defined:
> > 1) PROFILEINSPECTION
> > a) public PROFILEINSPECTIONPROFILEINSPECTIONID
> > PROFILEINSPECTIONID;
> > b) public string MODIFIED;
> > 2) PROFILEINSPECTIONPROFILEINSPECTIONID
> >
> > The issue I have is that there is no code generated to create an
> > instance for the property PROFILEINSPECTIONID. So when I create an
> > instance of PROFILEINSPECTION and try to access the
> > PROFILEINSPECTIONID I receive an exception stating that it is NULL. > >
> > So am I missing something with the XSD? or am I trying to do

something > > with this that it was never ment to do?
> >
> > Thanks
> > Wayne
>
>



Nov 12 '05 #7
Yes I did try it out, and it apparently had no effect. I'll read teh link
and see what it has to say.

Thanks for your help, it is appreciated.
Wayne


"Jiho Han" <ji******@infinityinfo.com> wrote in message
news:uQ**************@TK2MSFTNGP09.phx.gbl...
Have you tried it out?

In any case, if all else fails, try this:

http://msdn.microsoft.com/xml/defaul...xsdcodegen.asp
"Wayne" <ws*****@NoLandSpamstar.com> wrote in message
news:em*************@TK2MSFTNGP12.phx.gbl...
Apparently has no effect on the object. According to the help it only
serializes an empty tag for null objects.

Back to looking at other possible options.

Thanks
Wayne

"Jiho Han" <ji******@infinityinfo.com> wrote in message
news:ut**************@TK2MSFTNGP10.phx.gbl...
Not sure if this works because I've never tried it but take a look at
IsNullable property of XmlElementAttribute class.

You'd use it like this:

public class A
{
[XmlElement(IsNullable = false)]
public mypropertyclass B;
}

The only caveat may be that the resulting empty element would contain
xsi:nil = "true" attribute set and maybe that's ok for you, maybe not.

Let me know how it goes.
I'd be interested in the result.

Cheers,
Jiho

"Wayne" <ws*****@NoLandSpamstar.com> wrote in message
news:uT****************@TK2MSFTNGP12.phx.gbl...
> I now have the code deserializing the XML into the Object, however if there
> is no node or the node is empty for a given property then no instance
of
the
> property is created.
>
> Is there any way to force the entire object to be set up with the
generated
> code, other than modifying the generated code to do this?
>
> Thanks
> Wayne
>
>
> "Jiho Han" <ji******@infinityinfo.com> wrote in message
> news:ut*************@tk2msftngp13.phx.gbl...
> > I believe it's working as intended. You'll just need to create a
> > PROFILEINSPECTIONPROFILEINSPECTIONID instance and assign it to the
> > PROFILEINSPECTIONID field. Of course should you have deserialized the xml
> > snippet you provided, the serializer would have done that for you.
> >
> > "Wayne" <me*****@hotmail.com> wrote in message
> > news:39**************************@posting.google.c om...
> > > I have the following XML snipet:
> > >
> > > <PROFILEINSPECTION MODIFIED="TRUE">
> > > <PROFILEINSPECTIONID MODIFIED="TRUE">8622</PROFILEINSPECTIONID> > > > </PROFILEINSPECTION>
> > >
> > > using VS.net I have created a schema, and do the following:
> > > 1) remove the Dataset as I don't need it.
> > > 2) Set the PROFILEINSPECTIONID maxoccurs to 1
> > >
> > > From there I use XSD.exe to create the C# classes for the above XML. > > > This results in two classes being defined:
> > > 1) PROFILEINSPECTION
> > > a) public PROFILEINSPECTIONPROFILEINSPECTIONID
> > > PROFILEINSPECTIONID;
> > > b) public string MODIFIED;
> > > 2) PROFILEINSPECTIONPROFILEINSPECTIONID
> > >
> > > The issue I have is that there is no code generated to create an
> > > instance for the property PROFILEINSPECTIONID. So when I create
an > > > instance of PROFILEINSPECTION and try to access the
> > > PROFILEINSPECTIONID I receive an exception stating that it is

NULL. > > >
> > > So am I missing something with the XSD? or am I trying to do

something
> > > with this that it was never ment to do?
> > >
> > > Thanks
> > > Wayne
> >
> >
>
>
>



Nov 12 '05 #8

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

Similar topics

9
by: Maurice LING | last post by:
Hi, Is there any UML tools that is able to take UML and generate Python codes? Cheers Maurice
16
by: Jason | last post by:
Hi, I need a way to use random numbers in c++. In my c++ project, when using the mingw compiler I used a mersenne twister that is publicly available and this did its job well. Now I have...
5
by: DraguVaso | last post by:
Hi, I'm ne to this subject, and has been looking around for some software that does the Object-Relational-Mapping, and generates the Data Access Layer. I found alreaddy a lot of application that...
7
by: Timothy Shih | last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I wrote a simple function which takes in 2 buffers (one a byte buffer, one a char buffer) and copies the contents of the byte...
8
by: edster | last post by:
A *lot* of our teams code is being deleted from the InitializeComponent() section of a winform, such as Grid settings, event handler hooks, layout settings etc. This mainly seems to happen to 3rd...
5
by: Arjen | last post by:
Hi, The login control (<asp:Login) generates a HTML table. I have used my own template without table's. The control generates <table> ... my design(template) ... </table>. I don't like the...
24
by: Klaus Jensen | last post by:
Hi! How do I explore in code, which properties (columns) are in a datatable? I need to run some code for each column. I guess the answer is reflection somehow, but I dont know where to start....
10
by: Mike | last post by:
Is it still true that the managed C++ compiler will produce much better opimizations than the C# compiler, or have some of the more global/aggressive opimizations been rolled into the 2005...
4
by: VMI | last post by:
In the next few weeks, we'll be discussing what standards will be used for our web development, and one of the suggestions was to use a code generator (in our case, the first version of LLBLGen)....
1
by: Ian | last post by:
I've just discovered the msclr::lock class in the C++ Support Library online documentation. This seems like a much cleaner way to implement thread protection than using...
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...
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
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.