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 CustomerXSL.

2.Extract customer data from HTTPRequest.

3.Set data to CustomerXSL.

4.Get the XML Document invoking CustomerXSL’s produceDOMDocument.

Servlet

HTTP

Request

-FirstName -LastName -email -Membership

instantiate

set data

CustomerXSL

produceDOMDocument

XML Document

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>

Chapter 11. Light weight XML-based Enterprise Application 265

Page 281
Image 281
IBM Version 5 Creating an XML Document, Modifying the produceDOMDocument method, Example 11-1 initSQLProperties method