Monday, August 3, 2009

More Code Inspection for Bug 245698

As I have mentioned I the previous post, the variable, contentBuilder which is an instance of DOMContentBuilderImpl, is handler the work of creating an XML document in createXMLDocument method of Specifically, the following line in createXMLDocument is trying to create an XML document:

contentBuilder.createDefaultRootContent(cmDocument, cmElementDeclaration, namespaceInfoList);

To get more detail about createDefaultRootContent, I checked out the code for, which is under org.eclipse.wst.xml.core >> src-contentmodel >> org.eclipse.wst.xml.core.internal.contentmodel.util.

When I looked into createDefaultRootContent in, I found out createDefaultRootContent is only creating the root element of an XML document, the method that actually create the other elements in an XML file is createDefaultContent. There are only three lines of code in createDefaultContent. The line dealing with creating XML document elements is:


So then, I looked into the function with the following signature in

public void visitCMElementDeclaration(CMElementDeclaration ed)

Within visitCMElementDeclaration, I found the following lines responsible for creating attributes within an element.

for (int j = 0; j < size; j++) {
} does not have any definition for visitCMNode(), but DOMContentBuilderImpl extends from CMVisitor. So, I checked out the code for, which is in the same package as, and I found the definition for visitCMNode(). When I looked into the code for visitCMNode() in, I found that this method is doing more than creating attributes for an XML element, but when it is used to create attributes for an element, another method, visitCMAttributeDeclaration(), is called from visitCMNode(). In, I found that visitCMAttributeDeclaration() is declared, but not defined. So, I had to go back to to find out the definition for visitCMAttributeDeclaration(). Then I found the following line in visitCMAttributeDeclaration().

String name = computeName(ad, currentParent);

In this line of code, computeName() is the method used to calculated the qualified name of an attribute. So then, I move to the definition for computeName() in There, computeName() in DOMNamespaceHelper is called to calculate the prefix of an attribute. Within computeName(), the following line is used to get the prefix of an attribute.

String qualification = (String)cmNode.getProperty("http://org.eclipse.wst/cm/properties/nsPrefixQualification");

In my old post "Cause of Bug245698", I have explained that the reason why the XML validator detects the error in the newly created XML document is the attribute has an wrong prefix. So to fix this bug, I have to look into the above line calculating the prefix of an attribute and figure out how the prefix is calculated.


  1. Good luck solving the bug!

    If you post code in blogger, you may want to make it prettier. Check this tip out:

  2. Good findings. Looks like your next step involves a dive into the XSD content model from org.eclipse.wst.xsd.core.

  3. Hi, Chris and Nitin.

    Thanks for giving Terry practical advice
    and encouragement when he's trying to fix
    an Eclipse WTP bug as a student.

  4. thanks for sharing this site. there are various kinds of ebooks available from here