By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,573 Members | 903 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,573 IT Pros & Developers. It's quick & easy.

xsd.exe duplicate class declaration

P: n/a
I generated a .cs class from a .xsd schema using the xsd.exe tool from Visual
Studio 2005 and noticed that is generating duplicate class declarations. This
happens because of my schema structure. I have an element, <QuestionList>,
that is a set of <Questionelements that is defined at the root of the
schema and but it can also be defined as child of an element <QuestionGroup>.
The tool, instead of generation a class for the QuestionList element,
generates it twice, one for the root element (class FormQuestion) and a class
FormQuestionQuestionGroupQuestion for <Questionelement defined under
<QuestionGroup>.

Here is a portion of a xml instance based on the xsd schema:

<QuestionList>
<Question>
<QuestionGroup>
<QuestionList>
<Question>
....

xsd tool seems to generate classes as a string concatenation of the elements
throughout the schema hierarchy. Any way to avoid this class declaration
duplication?

Thanks
Miguel

Jul 24 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Problem solved. Problem was with the schema. I inferred the schema from a xml
file and Visual Studio 2005 generated it without complex types, duplicating
the elements definition. I edited the schema and generated complex types from
the elements (option Make Complex Type) and regenerated the class.

Thanks
Miguel

"Miguel Isidoro" wrote:
I generated a .cs class from a .xsd schema using the xsd.exe tool from Visual
Studio 2005 and noticed that is generating duplicate class declarations. This
happens because of my schema structure. I have an element, <QuestionList>,
that is a set of <Questionelements that is defined at the root of the
schema and but it can also be defined as child of an element <QuestionGroup>.
The tool, instead of generation a class for the QuestionList element,
generates it twice, one for the root element (class FormQuestion) and a class
FormQuestionQuestionGroupQuestion for <Questionelement defined under
<QuestionGroup>.

Here is a portion of a xml instance based on the xsd schema:

<QuestionList>
<Question>
<QuestionGroup>
<QuestionList>
<Question>
....

xsd tool seems to generate classes as a string concatenation of the elements
throughout the schema hierarchy. Any way to avoid this class declaration
duplication?

Thanks
Miguel
Jul 24 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.