Microsoft KB Archive/316798

= BUG: The elementFormDefault and attributeFormDefault properties of XSD schema are incorrect when they are read from the designer =

Article ID: 316798

Article Last Modified on 2/22/2007

-

APPLIES TO


 * Microsoft Visual Basic .NET 2002 Standard Edition
 * Microsoft Visual Basic .NET 2003 Standard Edition
 * Microsoft .NET Framework 1.0
 * Microsoft .NET Framework 1.1

-



This article was previously published under Q316798



SYMPTOMS
When you use the XSDSchema designer tool to create an XSD schema, the elementFormDefault and attributeFormDefault properties are read incorrectly by the designer.



CAUSE
The Msdatasetgenerator custom tool generates a DataSet that is used to get the XML schema. The DataSet does not preserve the elementFormDefault and attributeFormDefault properties.



RESOLUTION
Load the created file directly into the XMLSchema object instead of using the designer object to get the schema; the following code accomplishes this: Dim fs As FileStream Dim schema As XmlSchema fs = New FileStream(“book.xsd”, FileMode.Open) schema = XmlSchema.Read(fs, New ValidationEventHandler(AddressOf ShowCompileError))

'Validation Event handler. Public Sub ShowCompileError(ByVal sender As Object, ByVal e As ValidationEventArgs) Console.WriteLine(&quot;Validation Error: {0}&quot;, e.Message) End Sub



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



Steps to Reproduce Behavior
 Create a new Microsoft Visual Basic .NET Windows Application. On the Project menu, click Add New Item, and then select XML Schema. In Solution Explorer, right-click the XMLSchema1 file, and then click Properties. Set the properties of XMLSchema1 as follows:

 Open XMLSchema1.</li> Right-click in the Schema designer window, and then create one element and two attributes:

</li> Set the following properties of

</li> Drag a Button object to Form1.</li>  In the Button click event, paste the following code: Dim objXMLSchema As New SchemaTest.XMLSchema1 objXMLSchema.WriteXmlSchema(Console.Out) </li> In the Output window, note that the attributeFormDefault and elementFormDefault properties are set to &quot;qualified&quot;. This can cause validation problems on the XML data because the property values are not preserved.</li></ol>

Keywords: kbvs2002sp1sweep kbbug kbpending KB316798

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.