Saturday, July 11, 2009

Code Inspection for Bug 245698

In the past two weeks, to locate the code which causes the bug, I have checked out org.eclipse.wst.sse.core, org.eclipse.wst.xml.core, org.eclipse.wst.sse.ui, and org.eclipse.wst.xml.ui. I started with searching for the radio button label "Create XML file from an XML schema file" in new XML wizard. Then I found out the source code for creating a New XML schema Wizard window in org.eclipse.wst.xml.ui - NewXMLWizard.java.
In NewXMLWizard.java, there is a fuction called perfromFinish(), and here is its signature public boolean performFinish(). Within the function is the code doing the background processes when the "Finish" button on the New XML Wizard is clicked. In performFinish(), I found the following code handling the creation of a new xml document.

if (getContainer().getCurrentPage() == selectRootElementPage) {
generator.createXMLDocument(newFile, xmlFileName);
}
else {
// put template contents into file
String templateString = fNewXMLTemplatesWizardPage.getTemplateString();
generator.createTemplateXMLDocument(newFile, templateString);
}

So, I inserted a break point in the first line of the above code, debugged eclipse-wtp, and reproduced the bug. When the break point was hit, it met the codition in the if statement, and called createXMLDocument(). Then I looked up the type of generator, and found the type of it is NewXMLGenerator. NewXMLGenerator.java is in also in org.eclipse.wst.xml.ui. Then, I checked out createXMLDocument() in org.eclipse.wst.xml.ui. createXMLDocument is overloaded with three different signatures. The one called from NewXMLWizard.java is public ByteArrayOutputStream createXMLDocument(String xmlFileName, String charset) throws Exception. Basically, the createXMLDocument() is responsible for creating the XML document from the XML schema and then put the content of the newly created XML document into a file named by the user with an output stream, The following line in createXMLDocument is doing the job of creating a new XML document based on a XML schema.

DOMContentBuilderImpl contentBuilder = new DOMContentBuilderImpl(xmlDocument);

So, in the following week, I will look more into DOMContentBuilderImpl...

2 comments:

  1. Hi, Terry.

    I enjoyed reading your progress in inspecting
    the source code.

    Peter.

    ReplyDelete
  2. Terry,

    This is a good start. I hope you will have success in fixing this bug.

    I wish success,
    Jordan

    ReplyDelete