com.caucho.xsl
Class AbstractStylesheetFactory

java.lang.Object
  extended by javax.xml.transform.TransformerFactory
      extended by javax.xml.transform.sax.SAXTransformerFactory
          extended by com.caucho.xsl.AbstractStylesheetFactory
Direct Known Subclasses:
StyleScript, Xsl

public abstract class AbstractStylesheetFactory
extends javax.xml.transform.sax.SAXTransformerFactory

Abstract factory for creating stylesheets.


Field Summary
 
Fields inherited from class javax.xml.transform.sax.SAXTransformerFactory
FEATURE, FEATURE_XMLFILTER
 
Constructor Summary
protected AbstractStylesheetFactory()
           
 
Method Summary
 javax.xml.transform.Source getAssociatedStylesheet(javax.xml.transform.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()
           
 javax.xml.transform.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 getSearchPath()
          Returns the stylesheet search path.
 Path getStylePath()
          Returns the stylesheet search path.
 java.lang.String getSystemId()
           
 javax.xml.transform.URIResolver getURIResolver()
          Returns the URI to filename resolver.
 Path getWorkPath()
          Gets the working directory.
 boolean isAutoCompile()
          Returns true if the stylesheet should be automatically compiled.
protected  StylesheetImpl loadStylesheet(java.lang.String systemId, java.lang.String className)
          Loads the compiled stylesheet .class file
 StylesheetImpl newStylesheet(org.w3c.dom.Document xsl)
          Creates a new stylesheet from an XML document.
 StylesheetImpl newStylesheet(java.io.InputStream is)
          Create a new stylesheet from an input stream.
 StylesheetImpl newStylesheet(Path path)
           
 StylesheetImpl newStylesheet(java.io.Reader reader)
          Create a new stylesheet from a reader.
 StylesheetImpl newStylesheet(java.lang.String systemId)
          Loads a stylesheet from a named file
 javax.xml.transform.Templates newTemplates(org.w3c.dom.Node node)
          Convenience class to create a compiled stylesheet.
 javax.xml.transform.Templates newTemplates(javax.xml.transform.Source source)
          Create a compiled stylesheet from an input stream.
 javax.xml.transform.Templates newTemplates(java.lang.String systemId)
          Convenience class to create a compiled stylesheet.
 javax.xml.transform.sax.TemplatesHandler newTemplatesHandler()
          Returns a templates handler.
 javax.xml.transform.Transformer newTransformer()
          Create an identity transformer.
 javax.xml.transform.Transformer newTransformer(org.w3c.dom.Document xsl)
          Convenience class to create a transformer instance.
 javax.xml.transform.Transformer newTransformer(javax.xml.transform.Source source)
          Create a transformer from an input stream.
 javax.xml.transform.sax.TransformerHandler newTransformerHandler()
          Create a new transformer handler.
 javax.xml.transform.sax.TransformerHandler newTransformerHandler(javax.xml.transform.Source source)
          Create a new transformer handler based on a source.
 javax.xml.transform.sax.TransformerHandler newTransformerHandler(javax.xml.transform.Templates templates)
          Create a new transformer handler based on a stylesheet.
 org.xml.sax.XMLFilter newXMLFilter(javax.xml.transform.Source source)
          Returns an XML filter from the transformer.
 org.xml.sax.XMLFilter newXMLFilter(javax.xml.transform.Templates templates)
          Returns an XML filter from the transformer.
protected  org.w3c.dom.Node parseStylesheet(javax.xml.transform.Source source)
          Parses a stylesheet from the source.
protected abstract  org.w3c.dom.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 setAutoCompile(boolean autoCompile)
          Returns true if precompiled stylesheets should be loaded.
 void setClassLoader(java.lang.ClassLoader loader)
          Sets the classloader for the stylesheet.
 void setClassName(java.lang.String className)
           
 void setErrorListener(javax.xml.transform.ErrorListener errorListener)
          Sets the error listener.
 void setFeature(java.lang.String name, boolean value)
          Sets an implementation-specific feature
 void setLoadPrecompiledStylesheet(boolean preload)
          Returns true if precompiled stylesheets should be loaded.
 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)
           
 void setURIResolver(javax.xml.transform.URIResolver uriResolver)
          Sets the URI to filename resolver.
 void setWorkPath(Path path)
          Sets the working directory.
 void transform(org.w3c.dom.Document xsl, org.w3c.dom.Node xml, java.io.OutputStream out)
          Convenience class to transform a node.
 void transform(java.lang.String xsl, org.w3c.dom.Node xml, java.io.OutputStream out)
          Convenience class to transform a node.
 
Methods inherited from class javax.xml.transform.TransformerFactory
newInstance, 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.

Specified by:
getAttribute in class javax.xml.transform.TransformerFactory
Parameters:
name - the attribute name

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Sets an implementation-specific attribute.

Specified by:
setAttribute in class javax.xml.transform.TransformerFactory
Parameters:
name - the attribute name
value - the attribute value

getFeature

public boolean getFeature(java.lang.String name)
Returns an implementation-specific feature.

Specified by:
getFeature in class javax.xml.transform.TransformerFactory
Parameters:
name - the feature name

setFeature

public void setFeature(java.lang.String name,
                       boolean value)
Sets an implementation-specific feature

Specified by:
setFeature in class javax.xml.transform.TransformerFactory
Parameters:
name - the feature name
value - the feature value

getURIResolver

public javax.xml.transform.URIResolver getURIResolver()
Returns the URI to filename resolver.

Specified by:
getURIResolver in class javax.xml.transform.TransformerFactory

setURIResolver

public void setURIResolver(javax.xml.transform.URIResolver uriResolver)
Sets the URI to filename resolver.

Specified by:
setURIResolver in class javax.xml.transform.TransformerFactory

getErrorListener

public javax.xml.transform.ErrorListener getErrorListener()
Returns the error listener.

Specified by:
getErrorListener in class javax.xml.transform.TransformerFactory

setErrorListener

public void setErrorListener(javax.xml.transform.ErrorListener errorListener)
Sets the error listener.

Specified by:
setErrorListener in class javax.xml.transform.TransformerFactory

getSystemId

public java.lang.String getSystemId()

setSystemId

public void setSystemId(java.lang.String systemId)

setStylePath

public void setStylePath(Path path)
Sets the search path for stylesheets. Generally applications will use MergePath to create their search path.

Parameters:
path - path containing stylesheets.

getStylePath

public Path getStylePath()
Returns the stylesheet search path.


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.


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.

Parameters:
loader - the new loader.

getClassLoader

public java.lang.ClassLoader getClassLoader()
Gets the classloader for the stylesheet.


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.


isAutoCompile

public boolean isAutoCompile()
Returns true if the stylesheet should be automatically compiled.


setAutoCompile

public void setAutoCompile(boolean autoCompile)
Returns true if precompiled stylesheets should be loaded.


getAssociatedStylesheet

public javax.xml.transform.Source getAssociatedStylesheet(javax.xml.transform.Source source,
                                                          java.lang.String media,
                                                          java.lang.String title,
                                                          java.lang.String charset)
                                                   throws javax.xml.transform.TransformerConfigurationException
Returns the stylesheet source object associated with the given XML document.

Specified by:
getAssociatedStylesheet in class javax.xml.transform.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.
Throws:
javax.xml.transform.TransformerConfigurationException

newTransformer

public javax.xml.transform.Transformer newTransformer(javax.xml.transform.Source source)
                                               throws javax.xml.transform.TransformerConfigurationException
Create a transformer from an input stream.

Specified by:
newTransformer in class javax.xml.transform.TransformerFactory
Parameters:
source - the source stream
Returns:
the compiled stylesheet
Throws:
javax.xml.transform.TransformerConfigurationException

newTransformer

public javax.xml.transform.Transformer newTransformer()
                                               throws javax.xml.transform.TransformerConfigurationException
Create an identity transformer.

Specified by:
newTransformer in class javax.xml.transform.TransformerFactory
Returns:
the compiled stylesheet
Throws:
javax.xml.transform.TransformerConfigurationException

newStylesheet

public StylesheetImpl newStylesheet(org.w3c.dom.Document xsl)
                             throws java.lang.Exception
Creates a new stylesheet from an XML document.

Throws:
java.lang.Exception

newStylesheet

public StylesheetImpl newStylesheet(java.io.Reader reader)
                             throws java.lang.Exception
Create a new stylesheet from a reader.

Throws:
java.lang.Exception

newStylesheet

public StylesheetImpl newStylesheet(java.io.InputStream is)
                             throws java.lang.Exception
Create a new stylesheet from an input stream.

Throws:
java.lang.Exception

newStylesheet

public StylesheetImpl newStylesheet(java.lang.String systemId)
                             throws java.lang.Exception
Loads a stylesheet from a named file

Parameters:
systemId - the URL of the file
Throws:
java.lang.Exception

newStylesheet

public StylesheetImpl newStylesheet(Path path)
                             throws java.lang.Exception
Throws:
java.lang.Exception

newTemplates

public javax.xml.transform.Templates newTemplates(javax.xml.transform.Source source)
                                           throws javax.xml.transform.TransformerConfigurationException
Create a compiled stylesheet from an input stream.

Specified by:
newTemplates in class javax.xml.transform.TransformerFactory
Parameters:
source - the source stream
Returns:
the compiled stylesheet
Throws:
javax.xml.transform.TransformerConfigurationException

newTransformerHandler

public javax.xml.transform.sax.TransformerHandler newTransformerHandler()
                                                                 throws javax.xml.transform.TransformerConfigurationException
Create a new transformer handler.

Specified by:
newTransformerHandler in class javax.xml.transform.sax.SAXTransformerFactory
Throws:
javax.xml.transform.TransformerConfigurationException

newTransformerHandler

public javax.xml.transform.sax.TransformerHandler newTransformerHandler(javax.xml.transform.Source source)
                                                                 throws javax.xml.transform.TransformerConfigurationException
Create a new transformer handler based on a source.

Specified by:
newTransformerHandler in class javax.xml.transform.sax.SAXTransformerFactory
Throws:
javax.xml.transform.TransformerConfigurationException

newTransformerHandler

public javax.xml.transform.sax.TransformerHandler newTransformerHandler(javax.xml.transform.Templates templates)
                                                                 throws javax.xml.transform.TransformerConfigurationException
Create a new transformer handler based on a stylesheet.

Specified by:
newTransformerHandler in class javax.xml.transform.sax.SAXTransformerFactory
Throws:
javax.xml.transform.TransformerConfigurationException

newTemplatesHandler

public javax.xml.transform.sax.TemplatesHandler newTemplatesHandler()
                                                             throws javax.xml.transform.TransformerConfigurationException
Returns a templates handler.

Specified by:
newTemplatesHandler in class javax.xml.transform.sax.SAXTransformerFactory
Parameters:
source - the source file
Throws:
javax.xml.transform.TransformerConfigurationException

newXMLFilter

public org.xml.sax.XMLFilter newXMLFilter(javax.xml.transform.Source source)
                                   throws javax.xml.transform.TransformerConfigurationException
Returns an XML filter from the transformer.

Specified by:
newXMLFilter in class javax.xml.transform.sax.SAXTransformerFactory
Parameters:
source - the source file
Throws:
javax.xml.transform.TransformerConfigurationException

newXMLFilter

public org.xml.sax.XMLFilter newXMLFilter(javax.xml.transform.Templates templates)
                                   throws javax.xml.transform.TransformerConfigurationException
Returns an XML filter from the transformer.

Specified by:
newXMLFilter in class javax.xml.transform.sax.SAXTransformerFactory
Parameters:
source - the source file
Throws:
javax.xml.transform.TransformerConfigurationException

parseStylesheet

protected org.w3c.dom.Node parseStylesheet(javax.xml.transform.Source source)
                                    throws javax.xml.transform.TransformerConfigurationException
Parses a stylesheet from the source.

Throws:
javax.xml.transform.TransformerConfigurationException

newTemplates

public javax.xml.transform.Templates newTemplates(org.w3c.dom.Node node)
                                           throws javax.xml.transform.TransformerConfigurationException
Convenience class to create a compiled stylesheet.

Parameters:
node - DOM source for the stylesheet.
Returns:
a compiled stylesheet
Throws:
javax.xml.transform.TransformerConfigurationException

newTemplates

public javax.xml.transform.Templates newTemplates(java.lang.String systemId)
                                           throws javax.xml.transform.TransformerConfigurationException
Convenience class to create a compiled stylesheet.

Parameters:
systemId - source path for the stylesheet.
Returns:
a compiled stylesheet
Throws:
javax.xml.transform.TransformerConfigurationException

newTransformer

public javax.xml.transform.Transformer newTransformer(org.w3c.dom.Document xsl)
                                               throws javax.xml.transform.TransformerConfigurationException
Convenience class to create a transformer instance.

Parameters:
xsl - DOM source for the stylesheet.
Returns:
a transformer instance.
Throws:
javax.xml.transform.TransformerConfigurationException

transform

public void transform(org.w3c.dom.Document xsl,
                      org.w3c.dom.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.
Throws:
java.lang.Exception

transform

public void transform(java.lang.String xsl,
                      org.w3c.dom.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.
Throws:
java.lang.Exception

parseXSL

protected abstract org.w3c.dom.Document parseXSL(ReadStream rs)
                                          throws javax.xml.transform.TransformerConfigurationException
Parses the XSL into a DOM document.

Parameters:
rs - the input stream.
Throws:
javax.xml.transform.TransformerConfigurationException

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
Throws:
java.lang.Exception