Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.scopemvc.view.servlet.xml
Class AbstractXSLPage  view AbstractXSLPage download AbstractXSLPage.java

java.lang.Object
  extended byorg.scopemvc.view.servlet.Page
      extended byorg.scopemvc.view.servlet.xml.AbstractXSLPage
All Implemented Interfaces:
org.scopemvc.core.View
Direct Known Subclasses:
XSLPage

public abstract class AbstractXSLPage
extends org.scopemvc.view.servlet.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.7 $ $Date: 2002/05/26 10:30:55 $

Field Summary
protected  java.lang.String debugXMLDirectory
          Filesystem directory to dump all XML before transforming.
private static org.apache.commons.logging.Log LOG
           
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.
private static java.lang.String systemID
          Base URI to reference XSL URIs from.
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) 55 .
 
Fields inherited from class org.scopemvc.view.servlet.Page
 
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) 55 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

LOG

private static final org.apache.commons.logging.Log LOG

systemID

private static java.lang.String systemID
Base URI to reference XSL URIs from.


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) 55 . 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.

Method Detail

toString

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


setSystemID

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


getSystemID

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


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.)


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.)


streamView

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

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


getXMLOutputProperties

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


getHTMLOutputProperties

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


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.


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.


getContentType

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


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.