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

XSD

DTD

Web Service

DAD

DADX

Mapping Airline

DB

Figure 9-11 XML Web service

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

Page 208
Image 208
IBM Version 5 manual Creating a Web service, XML Web service