473,498 Members | 1,725 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Controlling class definitions generated from xsd.exe

Hi,

I am using the xsd.exe tool (in .NET 2.0) to generate C# classes from a set
of schemas. Some of the XML types that I have defined are used by more than
one schema. For maintenance purposes, I have placed these “common” types
into their own schema and have imported them into the other schemas as
needed. As a simple example, I have something like the following:

Type1.xsd - defines a type called Type1
Type2.xsd - defines a type called Type2 that has sub-elements of type
Type1. Imports Type1.xsd.
Type3.xsd - defines a type called Type3 that has sub-elements of type
Type1. Imports Type1.xsd.

When I generate the classes from these schemas, I would like to place the
class generated from Type1 into its own .cs file and into a namespace that is
different from the namespaces of Type2 and Type3. I would like the
generated .cs file for Type2 to define only the class that corresponds to
Type2. I do not want the .cs file to also define Type1. Instead, I would
like it to generate the correct using statement for the Type1 namespace (or
fully qualify the references to Type1 within the code of Type2). Similarly,
I would like the generated .cs file for Type3 to define only the class for
Type3 and the correct using statement or fully qualified names for Type1.

The output I describe above would more closely match the class organization
I would create by hand if I was not generating the classes from a schema. By
doing so, I could then include Type1 in its own assembly, for example.

My problem is, as far I can tell, I cannot get xsd.exe to do this. It
insists on defining all classes required by a type in a single .cs file. So
the .cs file that is generated for Type2 defines both Type2 and Type1. The
output generated for Type3 defines both Type3 and Type1. As a result, I now
have Type1 defined multiple times, and each one of these instances is
considered a different type.

Is there any way to control the output of xsd.exe as I describe above? I
tried using the /element option, but this does not seem to help. I can hand
modify the generated .cs files after running xsd, but I’d like to avoid this
if possible.

Thanks in advance.

Aug 28 '06 #1
1 1772


robc wrote:

My problem is, as far I can tell, I cannot get xsd.exe to do this.
There is an improved tool "XSD Object Code Generator" available here
<http://msdn.microsoft.com/XML/XMLDownloads/default.aspx>
I don't know whether it provides the features you are looking for but
you could try yourself.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Aug 28 '06 #2

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

Similar topics

0
2051
by: Carlos Ribeiro | last post by:
I thought about this problem over the weekend, after long hours of hacking some metaclasses to allow me to express some real case data structures as Python classes. I think that this is something...
1
9880
by: ffhansix | last post by:
Hi, I am having problems with generating a c# proxy class from a IBM websphere WSDL file, when running the wsdl.exe to create the c# proxy file command i recieve an error: Warning: one or...
8
3639
by: Joe | last post by:
I have a web service which returns many types (classes) to match the return type. I want to cast the return type to the actual class type. For example: namespace Test { class MyClass { ...
8
2163
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got...
9
6501
by: S Wheeler | last post by:
Hi all - I am trying to create an instance of a vb .net class containing a form from unmanaged vc++. The vb.net is a dll. How to do this ? I am trying #import by can't seem to get it quite...
0
1175
by: Kevin Burton | last post by:
I searched some of the documentation and this description of my problem came closest: The following original schema element definitions contain minOccurs or maxOccurs attributes: <xs:element...
0
1383
by: Nogusta123 | last post by:
My web service has a single method called "CheckEligibility". This method can be used to check a person's eligibility for multiple products. Each product has different data requiements so each...
2
2596
by: Jeff Johnson | last post by:
Disclaimer: I am extremely new to Web services and may very well be doing the wrong thing! Background: I have a Web service and a Windows Forms client app (VS 2005). The Web service exposes a...
7
2065
by: Brentt | last post by:
Hi, I know this is a terribly simple question, but the docs seem to be designed for people who probably find a the answer to this question terribly obvious. But its not at all obvious to me. I...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7205
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5462
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
1
4910
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
291
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.