getServletContext().getResource(xslName);

String xsltSystemID = stylesheetURL.toExternalForm(); mainStylesheet = transFact.newTemplates(

new StreamSource(xsltSystemID)); stylesheetURL = getServletContext().

getResource(xslResult);

xsltSystemID = stylesheetURL.toExternalForm(); resultStylesheet = transFact.newTemplates(

new StreamSource(xsltSystemID));

}catch (TransformerConfigurationException tce) { log("Unable to compile stylesheet", tce);

throw new UnavailableException( "Unable to compile stylesheet");

}catch (MalformedURLException mue)

{log("Unable to locate XSLT file: " + xslName); throw new UnavailableException(

"Unable to locate XSLT file: " + xslName);

}

}

The showPage method applies a style sheet to a DOM tree. As shown in Figure 10-14 on page 232, and in the source code in Figure 10-3 on page 232, the method first invokes the DOM generation using the produceDOMDocument in the CustomerXML class, mentioned in Example 10-2 on page 230. Following the DOM generation, a new transformer is created. This transformer applies the style sheet on the generated DOM, and writes the transformed HTML result to the Web browser.

Chapter 10. Development of XML-based Enterprise applications 231

Page 247
Image 247
IBM Version 5 manual Development of XML-based Enterprise applications