The method renderView performs the transformation to HTML.
- By Oliver Brüning
- April 24, 2001
COMPONENT JAVA
X4Dialog: Help for Dynamic Web Sites
Oliver Brüning
Listing 1. The method renderView performs the transformation to HTML.
public String renderView()
{
try
{
XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
XMLParserLiaison processorLiason = processor.getXMLProcessorLiaison();
ProcessorLiason.setIndent(2);
StringWriter sw = new StringWriter();
Document xml = getComposite();
Enumeration enStyleSheetParam = styleSheetParamHashtable.keys();
while (enStyleSheetParam.hasMoreElements())
{
String key = (String)enStyleSheetParam.nextElement();
processor.setStylesheetParam(key, "'" +
(String)styleSheetParamHashtable.get(key) + "'");
}
XSLTResultTarget resultTraget = new XSLTResultTarget(sw);
processor.setStylesheet(compiledView);
processor.process(new XSLTInputSource(xml), null, resultTraget);
return sw.toString();
}
catch (SAXException e)
{
e.printStackTrace();
return null;
}
catch (Exception e)
{
e.printStackTrace();
return null;
}
}