192 The XML Files: Develo pment of XML/XSL Applications Using WebS phere Studio
method. The instance of the Templates can be instantiate using newTemplates
method of TransformerFactory class:
TransformerFactory transFact = TransformerFactory.newInstance();
String xslName = "/WEB-INF/xsl/Passenger.xsl";
URL stylesheetURL = getServletContext().getResource(xslName);
String xsltSystemID = stylesheetURL.toExternalForm();
template = transFact.newTemplates(new StreamSource(xsltSystemID));
Using the templates, we can load and compile the XSL into the memor y while we
are initializing the servlet. Doing this in the init method, the servlet can hold the
Templates as a global variable. To get the instance of Transformer, use
newTransformer method of the template:
Transformer transformer = template.newTransformer();
9.2 Creating a Web service
In the previous application we were extracting the information from an static XML
file. Now, we are going to extract the information from the database using an
XML Web service. We are going to generate a Web service using the previous
generated XML files, so the flow would be as shown in Figure 9-11.
Figure 9-11 XML Web service
Airline
Airline
DB
DB
DTD
DADX
DAD
Mapping

Web Service

XSD