HttpXsltPageletAdaptor

public abstract class HttpXsltPageletAdaptor extends HttpPageletAdaptor

HttpXsltPageletAdaptor is an HTTP pagelet adaptor which employs the XSLT technology for content rendering. It is basically same as the HTTP pagelet adpator except that all the involved pagelets, excluding the template, are XSL documents.

This pagelet adaptor supports an additional generation mode, “xml”, which suppresses the XSL transformation. If the generation mode is “xml”, no rendering will be done and the output will only be a trunk of consecutive XML sources.

Author:Hugo Y. K. Lam

Methods

getErrorSource

protected Source getErrorSource(TemplateElement element, Throwable error, HttpServletRequest request)

Gets the transformation source for the XSL error pagelet.

Parameters:
  • element – the template element which represents the pagelet.
  • error – the error generated by the XSL pagelet process.
  • request – the servlet request.
Throws:
Returns:

the transformation source of the XSL error pagelet or null by default.

See also: .processError(TemplateElement,Throwable,HttpServletRequest,HttpServletResponse)

getPageletSource

protected Source getPageletSource(TemplateElement element, Pagelet pagelet, HttpServletRequest request)

Gets the transformation source for the given XSL pagelet.

Parameters:
  • element – the template element which represents the pagelet.
  • pagelet – the XSL pagelet.
  • request – the servlet request.
Throws:
Returns:

the transformation source of the given XSL pagelet or null by default.

See also: .processPagelet(TemplateElement,Pagelet,HttpServletRequest,HttpServletResponse)

processError

protected void processError(TemplateElement element, Throwable exception, HttpServletRequest request, HttpServletResponse response)

Processes the error generated by the XSL pagelet. The transformation source for the XSL error pagelet will be retrieved by invoking the getErrorSource() method.

Throws:

See also: .transform(Pagelet,Source,HttpServletRequest,HttpServletResponse), .getErrorSource(TemplateElement,Throwable,HttpServletRequest), hk.hku.cecid.piazza.commons.pagelet.HttpPageletAdaptor.processError(hk.hku.cecid.piazza.commons.pagelet.TemplateElement,java.lang.Throwable,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)

processPagelet

protected void processPagelet(TemplateElement element, Pagelet pagelet, HttpServletRequest request, HttpServletResponse response)

Processes the XSL pagelet. The transformation source for the given XSL pagelet will be retrieved by invoking the getPageletSource() method.

Parameters:
  • pagelet – the XSL pagelet.
Throws:

See also: .transform(Pagelet,Source,HttpServletRequest,HttpServletResponse), .getPageletSource(TemplateElement,Pagelet,HttpServletRequest), hk.hku.cecid.piazza.commons.pagelet.HttpPageletAdaptor.processPagelet(hk.hku.cecid.piazza.commons.pagelet.TemplateElement,hk.hku.cecid.piazza.commons.pagelet.Pagelet,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)

processText

protected void processText(TemplateElement element, String text, HttpServletRequest request, HttpServletResponse response)

Processes the text part of the generating page if the generation mode is not “xml”.

See also: hk.hku.cecid.piazza.commons.pagelet.HttpPageletAdaptor.processText(hk.hku.cecid.piazza.commons.pagelet.TemplateElement,java.lang.String,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)

transform

protected void transform(Pagelet xsl, Source source, HttpServletRequest request, HttpServletResponse response)

Transforms a given XML source using the specified XSL and writes the output to the response output stream.

Parameters:
  • xsl – the XSL for the transformation.
  • source – the XML source.
  • request – the servlet request.
  • response – the servlet response.
Throws:
  • IOException – if an I/O exception occurs during openning the XSL stream.
  • TransformerException – if an unrecoverable error occurs during the course of the transformation.