473,765 Members | 2,047 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 1797


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
2068
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 with potential to be useful, but I would like to hear more opinions first. If this is deemed to be useful, I *may* try to write a PEP for it. This is not a promise or even a proposal, at this point. Broadly generalizing, classes in Python have...
1
9904
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 more operations were skipped. Warnings were encountered. Review generated source comments for more details.
8
3652
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
2185
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 answered... In 1.1 we always did our own myDataAdapter.fills and we liked that control for lots of good reasons. Now the new DataSource (or is it a TableAdapter:Dataset) automatically fills the Gridview. How can we control that fill? In a...
9
6525
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 right. I suspect this is quite simple though. Thanks in advance...
0
1204
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 minOccurs="5" maxOccurs="10" name="Users"> The following code shows the generated Web service code: public NumberOfUsers Users;
0
1410
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 product has its own Data transfer Object that inherits from the base DTO used by the "CheckEligibility" method. I am using the attribute to make the product specific DTO's avaialble to the consumer. Also, the name of the particular objects...
2
2629
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 method to accept a ScheduleEntry object, which is a class I have written. I felt doing this would be cleaner than passing 7 or 8 parameters, but I've run into some problems. First, I learned that declaring classes in Web services isn't such a...
7
2082
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 can't figure out why when I define a function, a variable (specifically a list) that I define and initialize in the argument definitions, will not initialize itself every time its called. So for example, when making a simple list of a counting...
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
10007
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9835
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8832
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, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7379
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 presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3924
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 we have to send another system
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.