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

Using XSD.exe to create schema from classes - not generating all fields.

P: n/a
Hey, I'm just trying out the XSD.exe tool and have run into a problem -
it doesn't generate classes for all the members. For example, here's
my call:

D:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin>XSD
D:\projects\Repricer
\Repricer\bin\Debug\Repricer.exe
/outputdir:D:\projects\Repricer\Repricer /t:Mut
ator /t:Source

Now, one of the classes listed there is "Source". The class "source"
is included at the bottom of this post. The problem is that source has
three arrays, and only the "Includes" attribute is included in the XSD
- see below:

<xs:complexType name="Source">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="Includes"
type="ArrayOfIncludedDirectory" />
</xs:sequence>
<xs:attribute name="Path" type="xs:string" />
<xs:attribute name="Name" type="xs:string" />
<xs:attribute name="Hidden" type="xs:boolean" use="required" />
</xs:complexType>

Is there some kind of cues I need to give XSD.EXE to actually get _all_
of the members?

[System.Xml.Serialization.XmlTypeAttribute(Namespac e =
"http://pxtl.livejournal.com/")]
public class Source : IEnumerable<Source>
{
[XmlAttribute()]
public string Path;

[XmlAttribute()]
public string Name;

[XmlAttribute()]
public bool Hidden = false;

[XmlArrayAttribute()]
[XmlArrayItem("Include", typeof(IncludedDirectory))]
public IncludedDirectory[] Includes;

[XmlArrayAttribute()]
[XmlArrayItem("Source", typeof(Source))]
public Source[] AdditionalSources;

[XmlArrayAttribute()]
[XmlArrayItem("TagChange", typeof(TagChange))]
[XmlArrayItem("BuildListChange", typeof(BuildListChange))]
public ChangeModule[] ChangeModules;

[XmlArrayAttribute()]
[XmlArrayItem("MergeBuildLists")]
[XmlArrayItem("MergeSides")]
[XmlArrayItem("MergeMoveInfo")]
[XmlArrayItem("MergeFiles")]
public MergeModule[] MergeModules;

public void MergeInto(DirectoryContainer parentSource)
{
DirectoryContainer thisSource =
DirectoryContainer.ConstructDirectoryContainer(thi s);
foreach (Source additionalSource in this.AdditionalSources)
{
additionalSource.MergeInto(thisSource);
}

foreach (ChangeModule module in ChangeModules)
{
module.Execute(thisSource);
}

foreach (MergeModule module in MergeModules)
{
module.Execute(parentSource, thisSource);
}
}

#region IEnumerable<SourceMembers

public IEnumerator<SourceGetEnumerator()
{
yield return this;
foreach(Source s in AdditionalSources)
{
yield return s;
}
}

#endregion

#region IEnumerable Members

System.Collections.IEnumerator
System.Collections.IEnumerable.GetEnumerator()
{
foreach (Source s in this)
{
yield return s;
}
}

#endregion
}

Sep 28 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Check this out:
http://satov.blogspot.com/2006/12/xs...s-causing.html

"ma***********@gmail.com" wrote:
Hey, I'm just trying out the XSD.exe tool and have run into a problem -
it doesn't generate classes for all the members. For example, here's
my call:

D:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin>XSD
D:\projects\Repricer
\Repricer\bin\Debug\Repricer.exe
/outputdir:D:\projects\Repricer\Repricer /t:Mut
ator /t:Source

Now, one of the classes listed there is "Source". The class "source"
is included at the bottom of this post. The problem is that source has
three arrays, and only the "Includes" attribute is included in the XSD
- see below:

<xs:complexType name="Source">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="Includes"
type="ArrayOfIncludedDirectory" />
</xs:sequence>
<xs:attribute name="Path" type="xs:string" />
<xs:attribute name="Name" type="xs:string" />
<xs:attribute name="Hidden" type="xs:boolean" use="required" />
</xs:complexType>

Is there some kind of cues I need to give XSD.EXE to actually get _all_
of the members?

[System.Xml.Serialization.XmlTypeAttribute(Namespac e =
"http://pxtl.livejournal.com/")]
public class Source : IEnumerable<Source>
{
[XmlAttribute()]
public string Path;

[XmlAttribute()]
public string Name;

[XmlAttribute()]
public bool Hidden = false;

[XmlArrayAttribute()]
[XmlArrayItem("Include", typeof(IncludedDirectory))]
public IncludedDirectory[] Includes;

[XmlArrayAttribute()]
[XmlArrayItem("Source", typeof(Source))]
public Source[] AdditionalSources;

[XmlArrayAttribute()]
[XmlArrayItem("TagChange", typeof(TagChange))]
[XmlArrayItem("BuildListChange", typeof(BuildListChange))]
public ChangeModule[] ChangeModules;

[XmlArrayAttribute()]
[XmlArrayItem("MergeBuildLists")]
[XmlArrayItem("MergeSides")]
[XmlArrayItem("MergeMoveInfo")]
[XmlArrayItem("MergeFiles")]
public MergeModule[] MergeModules;

public void MergeInto(DirectoryContainer parentSource)
{
DirectoryContainer thisSource =
DirectoryContainer.ConstructDirectoryContainer(thi s);
foreach (Source additionalSource in this.AdditionalSources)
{
additionalSource.MergeInto(thisSource);
}

foreach (ChangeModule module in ChangeModules)
{
module.Execute(thisSource);
}

foreach (MergeModule module in MergeModules)
{
module.Execute(parentSource, thisSource);
}
}

#region IEnumerable<SourceMembers

public IEnumerator<SourceGetEnumerator()
{
yield return this;
foreach(Source s in AdditionalSources)
{
yield return s;
}
}

#endregion

#region IEnumerable Members

System.Collections.IEnumerator
System.Collections.IEnumerable.GetEnumerator()
{
foreach (Source s in this)
{
yield return s;
}
}

#endregion
}

Jan 4 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.