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



The information in this article applies to:

  • Microsoft Visual Basic .NET (2002)
  • Microsoft Visual Basic .NET (2003)
  • Microsoft XML Classes (included with the .NET Framework 1.0)
  • Microsoft XML Classes (included with the .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("Validation Error: {0}", 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.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a new Microsoft Visual Basic .NET Windows Application.
  2. On the Project menu, click Add New Item, and then select XML Schema.
  3. In Solution Explorer, right-click the XMLSchema1 file, and then click Properties.
  4. Set the properties of XMLSchema1 as follows:
    Property NameValue
    Build ActionEmbedded Resource
    Custom ToolMsdatasetgenerator
    Customer Tool NamespaceSchemaTest

  5. Open XMLSchema1.
  6. Right-click in the Schema designer window, and then create one element and two attributes:
    Element NameBook
    Element TypeBook

    Attribute NameAuthor
    Attribute TypeString
    Attribute NamePublisher
    Attribute TypeString

  7. Set the following properties of
    Property NameValue
    attributeFormDefaultunqualified
    elementFormDefaultunqualified

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

Modification Type:MinorLast Reviewed:9/15/2005
Keywords:kbvs2002sp1sweep kbbug kbpending KB316798