log.trace("entering renderXML()");
}
try {
// Perform the transformation
XSLT xslt = XSLT.getTransformer(this, this.runtimeData.getLocales());
Document xml = getXml();
if (xml == null) {
throw new IllegalStateException("The Document we would transform, as returned by getXml(), was illegally null.");
}
if (log.isTraceEnabled()) {
log.trace("getXml() returned Document: [" + xml + "]");
String xmlAsString = XML.serializeNode(xml);
log.trace("XML DOM was: [" + xmlAsString + "]");
}
xslt.setXML(xml);
String xsltUri = getXsltUri();
if (log.isTraceEnabled()) {
log.trace("getXsltUri() returned: [" + xsltUri + "]");
}
if (xsltUri == null) {
throw new IllegalStateException("The URI of our XSLT we would use to transform our Document, as returned by getXsltUri(), was illegally null.");
/*
* It would probably be a neat feature to detect the case where
* getXsltUri() returns null and in that case dump the XML directly to
* the ContentHandler, but this is not yet implemented.
*/
}
xslt.setXSL(xsltUri);
xslt.setTarget(out);
Map paramsMap = getStylesheetParams();
if (log.isTraceEnabled()) {
log.trace("getStylesheetParams() returned [" + paramsMap + "]");
}
if (paramsMap == null) {
xslt.setStylesheetParameters(new HashMap());
} else {
// XSLT requires HashMap or HashTable rather than
// accepting any Map.
// We accomodate this by dumping our paramsMap into a
// HashMap to ensure it is of an acceptable type.
// Skipping this putAll() where it is unnecessary probably wouldn't
// result in any worthwhile performance difference.
HashMap tempHashMap = new HashMap();
tempHashMap.putAll(paramsMap);
xslt.setStylesheetParameters(tempHashMap);
}
if (log.isTraceEnabled()) {
log.trace("Configured XSLT as [" + xslt + "]");
}
xslt.transform();
} catch (PortalException pe) {
// we just re-throw PortalExceptions, confident that the
// channel rendering framework will log and handle them, as
// defined by the IChannel API we are implementing.
throw pe;