FIX: Default Attribute Value for Nondeclared Elements Does Not Exist in DOM

Symptoms

When you load an XML document into an XML DOMDocument object after you set the validateOnParse property to False, the default attributes are not inserted for elements that are not declared explicitly in the document's document type definition (DTD).

Status

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

This bug was corrected in Microsoft XML 3.0 Service Pack 1.

For additional information on other fixes included in Microsoft XML 3.0 Service Pack 1, click the article number below to view the article in the Microsoft Knowledge Base:

292935 INFO: List of Issues Fixed in Microsoft XML 3.0 Service Pack 1
For the latest information and downloads of MSXML, refer to the following MSDN Web site at:

More Information

Section 3.3 of the World Wide Web Consortium (W3C) specification, located at the following Web site
indicates that the default attribute of an element should be added even if the binding element is not declared in the DTD.

Steps to Reproduce Behavior

  1. Create the HTML document.
    1. Using Windows Notepad or another text editor, create a new text document.
    2. Paste the following code into the new text document:
      <html>
      <script>
      var xmlDoc = new ActiveXObject("MSXML2.DOMDocument");
      xmlDoc.async = false;
      xmlDoc.validateOnParse = false;

      xmlDoc.loadXML("<!DOCTYPE doc [<!ATTLIST doc att CDATA 'default'>]><doc/>");
      alert("Number of attributes = " + xmlDoc.documentElement.attributes.length);
      </script>
      </html>
    3. Save the new text document as C:\InetPub\Wwwroot\Testpage.html.
  2. Browse to the HTML document using Internet Explorer.
The number of attributes is 0 but should be 1, because the default attribute should be added automatically.
Propriedades

ID do Artigo: 290910 - Última Revisão: 23 de mar de 2009 - Revisão: 1

Comentários