org.sandev.tools.HTTP
Class XSLTransformer

java.lang.Object
  extended by org.sandev.tools.HTTP.XSLTransformer
All Implemented Interfaces:
javax.xml.transform.URIResolver, org.sandev.ui.util.SandTransformer

public class XSLTransformer
extends java.lang.Object
implements org.sandev.ui.util.SandTransformer, javax.xml.transform.URIResolver

Applies XSLT to XML to customize output display rendering. See the SandTransformer interface for more information. Note that the templateReader must be set before any transformations are requested.


Field Summary
protected  javax.xml.transform.URIResolver oldResolver
          The URIResolver that the TransformerFactory was originally using.
protected  org.sandev.ui.util.TemplateReader templateReader
          Our TemplateReader for retrieving the contents of the templates.
 
Constructor Summary
XSLTransformer()
           
 
Method Summary
protected  void debug(java.lang.String text)
          Dump out the text to stdout with a prefix showing the source.
 javax.xml.transform.URIResolver getOldResolver()
          accessor for oldResolver
 org.sandev.ui.util.TemplateReader getTemplateReader()
          accessor for templateReader
 javax.xml.transform.Source resolve(java.lang.String href, java.lang.String base)
          Given an href which is probably another template, and a base which is probably somewhere useless, return a source.
 void setOldResolver(javax.xml.transform.URIResolver res)
          mutator for oldResolver
 void setTemplateReader(org.sandev.ui.util.TemplateReader tr)
          mutator for templateReader
static java.lang.String stripDoctype(java.lang.String text)
          Filter out the DOCTYPE declaration.
 java.lang.String transform(java.lang.String template, java.lang.String text, java.util.Locale locale)
          Retrieve the contents of the named template, and apply that XSLT to the XML in the text.
 void transform(java.lang.String template, java.lang.String text, java.io.OutputStream out, java.util.Locale locale)
          Retrieve the contents of the named template, and apply that XSLT to the XML in the text, writing results to the given stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

templateReader

protected org.sandev.ui.util.TemplateReader templateReader
Our TemplateReader for retrieving the contents of the templates. This is set by the caller before any transformation work is requested.


oldResolver

protected javax.xml.transform.URIResolver oldResolver
The URIResolver that the TransformerFactory was originally using.

Constructor Detail

XSLTransformer

public XSLTransformer()
Method Detail

getTemplateReader

public org.sandev.ui.util.TemplateReader getTemplateReader()
accessor for templateReader


setTemplateReader

public void setTemplateReader(org.sandev.ui.util.TemplateReader tr)
mutator for templateReader


getOldResolver

public javax.xml.transform.URIResolver getOldResolver()
accessor for oldResolver


setOldResolver

public void setOldResolver(javax.xml.transform.URIResolver res)
mutator for oldResolver


resolve

public javax.xml.transform.Source resolve(java.lang.String href,
                                          java.lang.String base)
                                   throws javax.xml.transform.TransformerException
Given an href which is probably another template, and a base which is probably somewhere useless, return a source.

Specified by:
resolve in interface javax.xml.transform.URIResolver
Throws:
javax.xml.transform.TransformerException

transform

public java.lang.String transform(java.lang.String template,
                                  java.lang.String text,
                                  java.util.Locale locale)
                           throws org.sandev.ui.util.SandTransformerException
Retrieve the contents of the named template, and apply that XSLT to the XML in the text. Return the transformed result.

Specified by:
transform in interface org.sandev.ui.util.SandTransformer
Throws:
org.sandev.ui.util.SandTransformerException

transform

public void transform(java.lang.String template,
                      java.lang.String text,
                      java.io.OutputStream out,
                      java.util.Locale locale)
               throws org.sandev.ui.util.SandTransformerException
Retrieve the contents of the named template, and apply that XSLT to the XML in the text, writing results to the given stream.

Specified by:
transform in interface org.sandev.ui.util.SandTransformer
Throws:
org.sandev.ui.util.SandTransformerException

stripDoctype

public static java.lang.String stripDoctype(java.lang.String text)
Filter out the DOCTYPE declaration. So if the given text contains "

debug

protected void debug(java.lang.String text)
Dump out the text to stdout with a prefix showing the source.