com.caucho.xsl
Class AbstractStylesheetFactory

java.lang.Object
  |
  +--javax.xml.transform.TransformerFactory
        |
        +--javax.xml.transform.sax.SAXTransformerFactory
              |
              +--com.caucho.xsl.AbstractStylesheetFactory
All Implemented Interfaces:
Source, StylesheetFactory
Direct Known Subclasses:
StyleScript, Xsl

public abstract class AbstractStylesheetFactory
extends SAXTransformerFactory
implements StylesheetFactory

Abstract factory for creating stylesheets.


Fields inherited from class javax.xml.transform.sax.SAXTransformerFactory
FEATURE, FEATURE_XMLFILTER
 
Constructor Summary
protected AbstractStylesheetFactory()
           
 
Method Summary
 Source getAssociatedStylesheet(Source source, java.lang.String media, java.lang.String title, java.lang.String charset)
          Returns the stylesheet source object associated with the given XML document.
 java.lang.Object getAttribute(java.lang.String name)
          Returns an implementation-specific attribute.
 java.lang.ClassLoader getClassLoader()
          Gets the classloader for the stylesheet.
 java.lang.String getClassName()
           
 ErrorListener getErrorListener()
          Returns the error listener.
 boolean getFeature(java.lang.String name)
          Returns an implementation-specific feature.
 boolean getLoadPrecompiledStylesheet()
          Returns true if precompiled stylesheets should be loaded.
 Path getScriptPath()
           
 Path getSearchPath()
          Returns the stylesheet search path.
 Path getStylePath()
          Returns the stylesheet search path.
 java.lang.String getSystemId()
          Returns the system-id (file path) of the Source
 URIResolver getURIResolver()
          Returns the URI to filename resolver.
 Path getWorkPath()
          Gets the working directory.
protected  StylesheetImpl loadStylesheet(java.lang.String systemId, java.lang.String className)
          Loads the compiled stylesheet .class file
 Stylesheet newStylesheet(Document xsl)
          Creates a new stylesheet from an XML document.
 Stylesheet newStylesheet(java.io.InputStream is)
          Create a new stylesheet from a reader.
 Stylesheet newStylesheet(Path path)
           
 Stylesheet newStylesheet(java.io.Reader reader)
          Create a new stylesheet from a reader.
 Stylesheet newStylesheet(java.lang.String systemId)
          Loads a stylesheet from a named file
 Templates newTemplates(Node node)
          Convenience class to create a compiled stylesheet.
 Templates newTemplates(Source source)
          Create a compiled stylesheet from an input stream.
 Templates newTemplates(java.lang.String systemId)
          Convenience class to create a compiled stylesheet.
 TemplatesHandler newTemplatesHandler()
          Returns a templates handler.
 Transformer newTransformer()
          Create an identity transformer.
 Transformer newTransformer(Document xsl)
          Convenience class to create a transformer instance.
 Transformer newTransformer(Source source)
          Create a transformer from an input stream.
 TransformerHandler newTransformerHandler()
          Create a new transformer handler.
 TransformerHandler newTransformerHandler(Source source)
          Create a new transformer handler based on a source.
 TransformerHandler newTransformerHandler(Templates templates)
          Create a new transformer handler based on a stylesheet.
 org.xml.sax.XMLFilter newXMLFilter(Source source)
          Returns an XML filter from the transformer.
 org.xml.sax.XMLFilter newXMLFilter(Templates templates)
          Returns an XML filter from the transformer.
protected  Node parseStylesheet(Source source)
          Parses a stylesheet from the source.
protected abstract  Document parseXSL(ReadStream rs)
          Parses the XSL into a DOM document.
 void setAttribute(java.lang.String name, java.lang.Object value)
          Sets an implementation-specific attribute.
 void setClassLoader(java.lang.ClassLoader loader)
          Sets the classloader for the stylesheet.
 void setClassName(java.lang.String className)
           
 void setErrorListener(ErrorListener errorListener)
          Sets the error listener.
 void setLoadPrecompiledStylesheet(boolean preload)
          Returns true if precompiled stylesheets should be loaded.
 void setScriptPath(Path path)
           
 void setSearchPath(Path path)
          Sets the search path for stylesheets.
 void setStylePath(Path path)
          Sets the search path for stylesheets.
 void setSystemId(java.lang.String systemId)
          Sets the system-id (file path) of the Source.
 void setURIResolver(URIResolver uriResolver)
          Sets the URI to filename resolver.
 void setWorkPath(Path path)
          Sets the working directory.
 void transform(Document xsl, Node xml, java.io.OutputStream out)
          Convenience class to transform a node.
 void transform(java.lang.String xsl, Node xml, java.io.OutputStream out)
          Convenience class to transform a node.
 
Methods inherited from class javax.xml.transform.TransformerFactory
newInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractStylesheetFactory

protected AbstractStylesheetFactory()
Method Detail

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Returns an implementation-specific attribute.
Overrides:
getAttribute in class TransformerFactory
Parameters:
name - the attribute name

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Sets an implementation-specific attribute.
Overrides:
setAttribute in class TransformerFactory
Parameters:
name - the attribute name
value - the attribute value

getFeature

public boolean getFeature(java.lang.String name)
Returns an implementation-specific feature.
Overrides:
getFeature in class TransformerFactory
Parameters:
name - the feature name

getURIResolver

public URIResolver getURIResolver()
Returns the URI to filename resolver.
Overrides:
getURIResolver in class TransformerFactory

setURIResolver

public void setURIResolver(URIResolver uriResolver)
Sets the URI to filename resolver.
Overrides:
setURIResolver in class TransformerFactory

getErrorListener

public ErrorListener getErrorListener()
Returns the error listener.
Overrides:
getErrorListener in class TransformerFactory

setErrorListener

public void setErrorListener(ErrorListener errorListener)
Sets the error listener.
Overrides:
setErrorListener in class TransformerFactory

getSystemId

public java.lang.String getSystemId()
Description copied from interface: Source
Returns the system-id (file path) of the Source
Following copied from interface: javax.xml.transform.Source
Returns:
the system id as a URL

setSystemId

public void setSystemId(java.lang.String systemId)
Description copied from interface: Source
Sets the system-id (file path) of the Source.
Following copied from interface: javax.xml.transform.Source
Parameters:
systemId - set the system id as a URL

setStylePath

public void setStylePath(Path path)
Sets the search path for stylesheets. Generally applications will use MergePath to create their search path.
Specified by:
setStylePath in interface StylesheetFactory
Parameters:
path - path containing stylesheets.

getStylePath

public Path getStylePath()
Returns the stylesheet search path.
Specified by:
getStylePath in interface StylesheetFactory

setSearchPath

public void setSearchPath(Path path)
Sets the search path for stylesheets. Generally applications will use MergePath to create their search path.
Parameters:
path - path containing stylesheets.

getSearchPath

public Path getSearchPath()
Returns the stylesheet search path.

setScriptPath

public void setScriptPath(Path path)

getScriptPath

public Path getScriptPath()

setWorkPath

public void setWorkPath(Path path)
Sets the working directory.

getWorkPath

public Path getWorkPath()
Gets the working directory.

setClassName

public void setClassName(java.lang.String className)

getClassName

public java.lang.String getClassName()

setClassLoader

public void setClassLoader(java.lang.ClassLoader loader)
Sets the classloader for the stylesheet.
Specified by:
setClassLoader in interface StylesheetFactory
Parameters:
loader - the new loader.

getClassLoader

public java.lang.ClassLoader getClassLoader()
Gets the classloader for the stylesheet.
Specified by:
getClassLoader in interface StylesheetFactory

getLoadPrecompiledStylesheet

public boolean getLoadPrecompiledStylesheet()
Returns true if precompiled stylesheets should be loaded.

setLoadPrecompiledStylesheet

public void setLoadPrecompiledStylesheet(boolean preload)
Returns true if precompiled stylesheets should be loaded.

getAssociatedStylesheet

public Source getAssociatedStylesheet(Source source,
                                      java.lang.String media,
                                      java.lang.String title,
                                      java.lang.String charset)
                               throws TransformerConfigurationException
Returns the stylesheet source object associated with the given XML document.
Overrides:
getAssociatedStylesheet in class TransformerFactory
Parameters:
source - the XML document which needs a stylesheet.
media - the media attribute for the stylesheet
title - the title attribute for the stylesheet
charset - the character encoding for the stylesheet result.

newTransformer

public Transformer newTransformer(Source source)
                           throws TransformerConfigurationException
Create a transformer from an input stream.
Overrides:
newTransformer in class TransformerFactory
Parameters:
source - the source stream
Returns:
the compiled stylesheet

newTransformer

public Transformer newTransformer()
                           throws TransformerConfigurationException
Create an identity transformer.
Overrides:
newTransformer in class TransformerFactory
Returns:
the compiled stylesheet

newStylesheet

public Stylesheet newStylesheet(Document xsl)
                         throws java.lang.Exception
Creates a new stylesheet from an XML document.
Specified by:
newStylesheet in interface StylesheetFactory

newStylesheet

public Stylesheet newStylesheet(java.io.Reader reader)
                         throws java.lang.Exception
Create a new stylesheet from a reader.
Specified by:
newStylesheet in interface StylesheetFactory

newStylesheet

public Stylesheet newStylesheet(java.io.InputStream is)
                         throws java.lang.Exception
Create a new stylesheet from a reader.
Specified by:
newStylesheet in interface StylesheetFactory
Following copied from interface: com.caucho.transform.StylesheetFactory
Parameters:
is - input stream to an XSL/StyleScript file.
Returns:
the compiled stylesheet.

newStylesheet

public Stylesheet newStylesheet(java.lang.String systemId)
                         throws java.lang.Exception
Loads a stylesheet from a named file
Specified by:
newStylesheet in interface StylesheetFactory
Parameters:
systemId - the URL of the file

newStylesheet

public Stylesheet newStylesheet(Path path)
                         throws java.lang.Exception

newTemplates

public Templates newTemplates(Source source)
                       throws TransformerConfigurationException
Create a compiled stylesheet from an input stream.
Overrides:
newTemplates in class TransformerFactory
Parameters:
source - the source stream
Returns:
the compiled stylesheet

newTransformerHandler

public TransformerHandler newTransformerHandler()
                                         throws TransformerConfigurationException
Create a new transformer handler.
Overrides:
newTransformerHandler in class SAXTransformerFactory

newTransformerHandler

public TransformerHandler newTransformerHandler(Source source)
                                         throws TransformerConfigurationException
Create a new transformer handler based on a source.
Overrides:
newTransformerHandler in class SAXTransformerFactory

newTransformerHandler

public TransformerHandler newTransformerHandler(Templates templates)
                                         throws TransformerConfigurationException
Create a new transformer handler based on a stylesheet.
Overrides:
newTransformerHandler in class SAXTransformerFactory
Following copied from class: javax.xml.transform.sax.SAXTransformerFactory
Parameters:
templates - compiled stylesheet

newTemplatesHandler

public TemplatesHandler newTemplatesHandler()
                                     throws TransformerConfigurationException
Returns a templates handler.
Overrides:
newTemplatesHandler in class SAXTransformerFactory
Parameters:
source - the source file

newXMLFilter

public org.xml.sax.XMLFilter newXMLFilter(Source source)
                                   throws TransformerConfigurationException
Returns an XML filter from the transformer.
Overrides:
newXMLFilter in class SAXTransformerFactory
Parameters:
source - the source file

newXMLFilter

public org.xml.sax.XMLFilter newXMLFilter(Templates templates)
                                   throws TransformerConfigurationException
Returns an XML filter from the transformer.
Overrides:
newXMLFilter in class SAXTransformerFactory
Parameters:
source - the source file

parseStylesheet

protected Node parseStylesheet(Source source)
                        throws TransformerConfigurationException
Parses a stylesheet from the source.

newTemplates

public Templates newTemplates(Node node)
                       throws TransformerConfigurationException
Convenience class to create a compiled stylesheet.
Parameters:
node - DOM source for the stylesheet.
Returns:
a compiled stylesheet

newTemplates

public Templates newTemplates(java.lang.String systemId)
                       throws TransformerConfigurationException
Convenience class to create a compiled stylesheet.
Parameters:
systemId - source path for the stylesheet.
Returns:
a compiled stylesheet

newTransformer

public Transformer newTransformer(Document xsl)
                           throws TransformerConfigurationException
Convenience class to create a transformer instance.
Parameters:
xsl - DOM source for the stylesheet.
Returns:
a transformer instance.

transform

public void transform(Document xsl,
                      Node xml,
                      java.io.OutputStream out)
               throws java.lang.Exception
Convenience class to transform a node.
Parameters:
xsl - DOM containing the parsed xsl.
xml - DOM document node.
out - output stream destination.

transform

public void transform(java.lang.String xsl,
                      Node xml,
                      java.io.OutputStream out)
               throws java.lang.Exception
Convenience class to transform a node.
Parameters:
xsl - path name to the xsl file.
xml - dom source document.
out - output stream destination.

parseXSL

protected abstract Document parseXSL(ReadStream rs)
                              throws TransformerConfigurationException
Parses the XSL into a DOM document.
Parameters:
rs - the input stream.

loadStylesheet

protected StylesheetImpl loadStylesheet(java.lang.String systemId,
                                        java.lang.String className)
                                 throws java.lang.Exception
Loads the compiled stylesheet .class file
Parameters:
className - the mangled classname for the stylesheet