<email>email</email>

<membership>membership</membership>

</Customer>

We need to add SQLResult as a root element for this document and change all tags related to the table name or column names to CAPITAL. The easiest way is to modify the produceDOMDocument method in the CustomerXSL class. The following code fragment is the original code.

Element rootElement = doc.createElement("Customer"); doc.appendChild(rootElement);

We need to change to:

Element superRootElement = doc.createElement("SQLResult"); doc.appendChild(superRootElement);

Element rootElement = doc.createElement("Customer");

superRootElement.appendChild(rootElement);

We created a new produceDOMDocumentforTools method as follows.

Example 11-2 ProduceDOMDocumentforTools

public Document produceDOMDocumentforTools() throws ParserConfigurationException

{

//use Sun's JAXP to create the DOM Document DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = dbf.newDocumentBuilder();

Document doc = docBuilder.newDocument();

Element parent = null;

//Now we need SQLResult as a root.

Element superRootElement = doc.createElement("SQLResult"); doc.appendChild(superRootElement);

Element rootElement = doc.createElement("CUSTOMER");

superRootElement.appendChild(rootElement); addElement(doc, rootElement, "FIRSTNAME",

convertToString(getFirstName())); addElement(doc, rootElement, "LASTNAME",

convertToString(getLastName())); addElement(doc, rootElement, "MEMBERSHIP",

convertToString(getMembership())); addElement(doc, rootElement, "EMAIL",

convertToString(getEmail()));

return doc;

}

266 The XML Files: Development of XML/XSL Applications Using WebSphere Studio

Page 282
Image 282
IBM Version 5 manual We need to change to, Example 11-2 ProduceDOMDocumentforTools