{

if(datasource != null ){ super.setConnection(datasource.getConnection());

}

if( !(doc.getFirstChild().getNodeName().equalsIgnoreCase("SQLResult"))

){

Element rootElement = doc.createElement("SQLResult"); rootElement.appendChild(doc.getFirstChild()); doc.appendChild(rootElement);

}

super.execute(doc,continueOnSQLError);

}

If this Document’s root element is not SQLResult, add SQLResult, and add the first child (in our case, it is customer), to the SQLResult element. At this time, the customer element was removed from the root and is a child of the SQLResult. Then add the SQLResult to the document, SQLResult will be a root, and customer will be a first child.

11.3.7 Conclusion

SQLToXML and XMLToSQL can be the XML front end of the database. Using these libraries, we can use the XML data as the core data of the application (Figure 11-11).

Browser

Servlet

XSLT Processor

XML Data

SQLToXML XMLToSQL

DB

Figure 11-11 Core data is an XML

You have seen how to use Application Developer to:

￿Update the database with dynamically generated XML within a servlet using XMLToSQL class library.

Chapter 11. Light weight XML-based Enterprise Application 281

Page 297
Image 297
IBM Version 5 manual Conclusion, Core data is an XML