org.scopemvc.view.servlet.xml
Class AbstractXSLPage

java.lang.Object
  |
  +--org.scopemvc.view.servlet.Page
        |
        +--org.scopemvc.view.servlet.xml.AbstractXSLPage
All Implemented Interfaces:
View
Direct Known Subclasses:
XSLPage

public abstract class AbstractXSLPage
extends Page

A ServletView that references an XSLT URI used to transform an XML representation of the View's bound model objects.

The XSLT is assumed to describe the entire view, not just a part of the overall page, even when this view is a subview or a parent of subviews.

Model objects are turned to a SAX source in a concrete subclass, which is transformed with the XSLT to a SAX stream that gets fed to a SAX ContentHandler (eg an HTML serializer) that writes to an OutputStream (eg the HTTPResponse's output stream).

This abstract base class does some generic XSLT handling, including caching compiled stylesheets. The concrete Scope impl is in XSLPage.

Version:
$Revision: 1.9 $ $Date: 2002/09/05 15:41:45 $
Author:
Steve Meyfroidt

Field Summary
protected  java.lang.String debugXMLDirectory
          Filesystem directory to dump all XML before transforming.
protected  boolean shouldCacheTemplates
          Do we want to cache the stylesheets? Yes for production, no for development because you want to see changes to the XSLTs as soon as you make them rather than after restarting the web application.
protected static java.util.HashMap templateCache
          A cache for compiled stylesheets.
protected  java.lang.String xslURI
          URI of the XSLT for this View relative to the setSystemID(java.lang.String).
 
Constructor Summary
AbstractXSLPage(java.lang.String inViewID, java.lang.String inXslURI)
          Specify the XSLT to use when showing this View.
 
Method Summary
protected abstract  void generateXMLDocument(org.xml.sax.ContentHandler inContentHandler)
          Override to implement model to SAX conversion into the passed ContentHandler.
 java.lang.String getContentType()
          Allow subclasses to deliver different content types.
protected  java.util.Properties getHTMLOutputProperties()
          Make Properties for Transformer.setOutputProperties suitable for final HTML output.
static java.lang.String getSystemID()
          Where XSLT URIs are referenced relative to.
protected  javax.xml.transform.sax.TransformerHandler getTransformerHandler(java.io.OutputStream inOutputStream)
          Thread-safe Templates are cached for reuse to avoid parsing and compiling stylesheets repeatedly.
protected  java.util.Properties getXMLOutputProperties()
          Make Properties for Transformer.setOutputProperties suitable for debug XML output.
 java.lang.String getXslURI()
          The XSLT that will be shown for this view.
protected  org.xml.sax.ContentHandler makeSerializer(java.io.OutputStream inStream, java.util.Properties inOutputProperties)
          Make a null transformer to take SAX input and stream it to an OutputStream using the passed OutputProperties.
static void setSystemID(java.lang.String inSystemID)
          Where XSLT URIs are referenced relative to.
 void setXslURI(java.lang.String inURI)
          The XSLT that will be shown for this view.
 void streamView(java.io.OutputStream inOutputStream)
           Stream the view by calling generateXMLDocument(org.xml.sax.ContentHandler) and processing the result with the XSLT.
 java.lang.String toString()
          For debug.
 
Methods inherited from class org.scopemvc.view.servlet.Page
equalsID, getBoundModel, getController, getID, getParent, issueControl, populateModel, setBoundModel, setController, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

templateCache

protected static java.util.HashMap templateCache
A cache for compiled stylesheets.


shouldCacheTemplates

protected boolean shouldCacheTemplates
Do we want to cache the stylesheets? Yes for production, no for development because you want to see changes to the XSLTs as soon as you make them rather than after restarting the web application.


xslURI

protected java.lang.String xslURI
URI of the XSLT for this View relative to the setSystemID(java.lang.String). The XSLT is assumed to be for the whole page, even if this view is a subview of a parent.


debugXMLDirectory

protected java.lang.String debugXMLDirectory
Filesystem directory to dump all XML before transforming. Useful for debug and development but disable in production!

Constructor Detail

AbstractXSLPage

public AbstractXSLPage(java.lang.String inViewID,
                       java.lang.String inXslURI)
Specify the XSLT to use when showing this View. The XSLT is assumed to be for the whole page, even if this view is a subview or a parent of some subviews.

Parameters:
inXslURI - a URI to the XSLT relative to what has been set in setSystemID(java.lang.String)
inViewID - TODO: Describe the Parameter
Method Detail

getSystemID

public static java.lang.String getSystemID()
Where XSLT URIs are referenced relative to. See javax.xml.transform.sax.TransformerHandler

Returns:
The systemID value

setSystemID

public static void setSystemID(java.lang.String inSystemID)
Where XSLT URIs are referenced relative to. See javax.xml.transform.sax.TransformerHandler

Parameters:
inSystemID - The new systemID value

getXslURI

public java.lang.String getXslURI()
The XSLT that will be shown for this view. (If null then the default "pass-through" XSL is used.)

Returns:
The xslURI value

getContentType

public java.lang.String getContentType()
Allow subclasses to deliver different content types. Here "text/html" unless no stylesheet in which case "text/xml".

Returns:
The contentType value

setXslURI

public void setXslURI(java.lang.String inURI)
The XSLT that will be shown for this view. (If null then the default "pass-through" XSL is used.)

Parameters:
inURI - The new xslURI value

toString

public java.lang.String toString()
For debug.

Overrides:
toString in class java.lang.Object
Returns:
TODO: Describe the Return Value

streamView

public void streamView(java.io.OutputStream inOutputStream)
                throws java.lang.Exception

Stream the view by calling generateXMLDocument(org.xml.sax.ContentHandler) and processing the result with the XSLT.

Parameters:
inOutputStream - Stream the result of the XSLT processing into here.
Throws:
java.lang.Exception - TODO: Describe the Exception

getXMLOutputProperties

protected java.util.Properties getXMLOutputProperties()
Make Properties for Transformer.setOutputProperties suitable for debug XML output.

Returns:
The xMLOutputProperties value
See Also:
OutputKeys

getHTMLOutputProperties

protected java.util.Properties getHTMLOutputProperties()
Make Properties for Transformer.setOutputProperties suitable for final HTML output.

Returns:
The hTMLOutputProperties value
See Also:
OutputKeys

getTransformerHandler

protected javax.xml.transform.sax.TransformerHandler getTransformerHandler(java.io.OutputStream inOutputStream)
                                                                    throws java.lang.Exception
Thread-safe Templates are cached for reuse to avoid parsing and compiling stylesheets repeatedly.

Parameters:
inOutputStream - TODO: Describe the Parameter
Returns:
The transformerHandler value
Throws:
java.lang.Exception - TODO: Describe the Exception

makeSerializer

protected org.xml.sax.ContentHandler makeSerializer(java.io.OutputStream inStream,
                                                    java.util.Properties inOutputProperties)
Make a null transformer to take SAX input and stream it to an OutputStream using the passed OutputProperties.

Parameters:
inStream - TODO: Describe the Parameter
inOutputProperties - TODO: Describe the Parameter
Returns:
ContentHandler around a null Transformer
See Also:
getXMLOutputProperties(), getHTMLOutputProperties()

generateXMLDocument

protected abstract void generateXMLDocument(org.xml.sax.ContentHandler inContentHandler)
                                     throws java.lang.Exception
Override to implement model to SAX conversion into the passed ContentHandler.

Parameters:
inContentHandler - TODO: Describe the Parameter
Throws:
java.lang.Exception - TODO: Describe the Exception


Copyright © 2000-2002 The Scope Team. All Rights Reserved.