Microsoft KB Archive/815106

From BetaArchive Wiki

Article ID: 815106

Article Last Modified on 9/15/2005



APPLIES TO

  • Microsoft Visual C# .NET 2003 Standard Edition
  • Microsoft Visual C# .NET 2002 Standard Edition
  • Microsoft Visual Basic .NET 2002 Standard Edition
  • Microsoft Visual Basic .NET 2003 Standard Edition
  • Microsoft .NET Framework 1.0
  • Microsoft .NET Framework 1.1



Beta Information

This article discusses a Beta release of a Microsoft product. The information in this article is provided as-is and is subject to change without notice.

No formal product support is available from Microsoft for this Beta product. For information about how to obtain support for a Beta release, see the documentation that is included with the Beta product files, or check the Web location from which you downloaded the release.

SYMPTOMS

You use a group element in a choice element in an XML Schema, and then use the XML Schema Definition Tool (Xsd.exe), to generate a Visual C# .NET class or a Visual Basic .NET class. When you generate the class, the code for the group and choice elements is not present in the generated class.

WORKAROUND

To work around this problem, do not use the group element in the choice element. Instead of using a group element in a choice element, add all the elements of the group element to the choice element. For example, for the schema that is described in step 5 of the "More Information" section, instead of the following:

<s:group ref="s0:PersonalStats" />

use the following in step 5:

<s:element name="Age" type="s:positiveInteger" />
<s:element name="Height" type="s:positiveInteger" />
<s:element name="Weight" type="s:positiveInteger" />

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Start Microsoft Visual Studio .NET.
  2. On the File menu, point to New, and then click File.
  3. In the New File dialog box, click General under Categories, click XML Schema under Templates, and then click Open.
  4. Right-click XMLSchema1, and then click View XML Source.
  5. In the XML pane, replace the existing code with the following code:

    <?xml version="1.0" encoding="utf-8" ?>
    <s:schema xmlns:s="http://www.w3.org/2001/XMLSchema" 
       xmlns:s0="http://www.goffinf.co.uk/webservices" 
       targetNamespace="http://www.goffinf.co.uk/webservices">
        <s:element name="BadChoice">
            <s:complexType>
                <s:sequence>
                    <s:element name="Forename" type="s:string" />
                    <s:element name="Surname" type="s:string" />
                    <s:choice>
                        <s:element name="StaffNo" type="s:string" />
                        <s:group ref="s0:PersonalStats" />
                    </s:choice>
                </s:sequence>
            </s:complexType>
        </s:element>
        <s:group name="PersonalStats">
            <s:sequence>
                <s:element name="Age" type="s:positiveInteger" />
                <s:element name="Height" type="s:positiveInteger" />
                <s:element name="Weight" type="s:positiveInteger" />
            </s:sequence>
        </s:group>
    </s:schema>
  6. On the File menu, click Save XMLSchema1, and then save the schema file as C:\XMLSchema1.xsd.
  7. Open a Visual Studio .NET command prompt.
  8. Type the following command, and then press ENTER to generate code:

    Visual C# .NET Code:

    xsd /c /l:cs /o:c:\ c:\XMLSchema1.xsd


    Visual Basic .NET Code:

    xsd /c /l:vb /o:c:\ c:\XMLSchema1.xsd

In the generated class file, you may not find entries for the group element. For example, there is no entry for Age or Height or Weight.

REFERENCES

For additional information about XML Schemas, click the following article number to view the article in the Microsoft Knowledge Base:

313826 INFO: Roadmap for XML Schemas in the .NET Framework


Keywords: kbbug kbnamespace kbschema kbcodegen kbvs2002sp1sweep KB815106