Chapter 11. Light weight XML-based Enterprise Application 265
initSQLProperties();
򐂰Also, we instantiate XMLToSQL in the init method:
xml2sql = new XMLToSQL(sqlProperties);
Example 11-1 initSQLProperties method
private void initSQLProperties()
{ sqlProperties = new SQLProperties();
sqlProperties.setJdbcDriver("COM.ibm.db2.jdbc.app.DB2Driver");
sqlProperties.setLoginId("db2admin");
sqlProperties.setPassword("db2admin");
sqlProperties.setSchema("registration");
sqlProperties.setJdbcServer("jdbc:db2:AIRLINE");
sqlProperties.setAction(SQLProperties.INSERT);
}
Creating an XML Document
We reused CustomerXSL to generate an XML Document which contains new
customer data (Figure 11-6). To do this:
1. Instantiate CustomerX SL.
2. Extract customer data from HTTPRequest .
3. Set data to CustomerXSL.
4. Get the XML Document invoking CustomerXSLs produceDOMDocument.
Figure 11-6 Getting an XML Document using CustomerXSL
Modifying the produceDOMDocument method
As we mentioned, the XMLToSQL does not accept the document. XMLToSQL is
expecting the following document. Currently, CustomerXSL produces following
XML Document:
<Customer>
<firstname>firstname</firstname>
<lastname>lastname</lastname>
XML Document
HTTP
Request
-FirstName
-LastName
-email
-Membership
set data
Servlet instantiate
CustomerXSL
produceDOMDocument