|
|||||||||
| Home >> All >> org >> javahispano >> canyamo >> services >> presentation >> [ xml overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.javahispano.canyamo.services.presentation.xml
Class HTMLTransformer

java.lang.Objectorg.javahispano.canyamo.services.presentation.xml.HTMLTransformer
- public class HTMLTransformer
- extends java.lang.Object
This class transforms XML files to HTML files using XSL stylesheets. It's a singleton so only one instance will be created in the virtual machine. This transformer can ouput the transformation result as files or Strings. It could be extended to support ouput as XML files as well.
It can take as sources for transformation any Xalan Source, i.e, URLs of xml and XML and XSL files, or representations in memory of files i.e. DOMSources and SAXSources.
This class supports the concept of stylesheet templates. You can use the createTemplate methods for storing stylesheets within the HTMLTransformer cache. These stylesheets will be reused each time so the overall performance increases. Here is a simple example of using HTMLTransformer to output a String:
HTMLTransformer htmlTransformer = HTMLTransformer.newInstance();
String result = htmlTransformer.transformToFile("article.xml",
"article.xsl",out);
If you would like to generate a file instead of using an output stream
PDFTransformer pdfTransformer = PDFTransformer.newInstance();
pdfTransformer.transform("article.xml","article.xsl","article.html");
- Version:
- 1.0
| Field Summary | |
private static HTMLTransformer |
singleton
|
private java.util.Map |
templates
This attribute will store the common used stylesheets to increase transformation process overall performance |
private javax.xml.transform.TransformerFactory |
tFactory
|
| Constructor Summary | |
private |
HTMLTransformer()
|
| Method Summary | |
void |
createTemplates(javax.xml.transform.Source source)
This method creates a template from a source stylesheet so the styleshhet can be reused. |
void |
createTemplates(java.lang.String source)
This method creates a template from a source stylesheet url so the styleshhet can be reused |
(package private) javax.xml.transform.Transformer |
getTransformer(javax.xml.transform.Source xslSource)
Returns a transformer object. |
(package private) javax.xml.transform.Transformer |
getTransformer(java.lang.String xslSource)
Returns a transformer object. |
static HTMLTransformer |
newInstance()
HTMLTransformer will be a singleton object. |
(package private) javax.xml.transform.Result |
transform(javax.xml.transform.Source xmlSource,
javax.xml.transform.Transformer transformer,
javax.xml.transform.Result result)
This is the more general method. |
void |
transformToFile(javax.xml.transform.Source xmlSource,
javax.xml.transform.Source xslSource,
java.io.File file)
Transforms an XML source using an XSL source and stores the result of the transformation process in the specified file. |
void |
transformToFile(java.lang.String xmlSource,
java.lang.String xslSource,
java.io.File file)
Transforms an XML source using an XSL source and stores the result of the transformation process in the specified file. |
java.lang.String |
transformToString(javax.xml.transform.Source xmlSource,
javax.xml.transform.Source xslSource)
Transforms an XML source using an XSL source to an String object. |
java.lang.String |
transformToString(java.lang.String xmlSource,
java.lang.String xslSource)
Transforms an XML source using an XSL source to an String object. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
singleton
private static HTMLTransformer singleton
templates
private java.util.Map templates
- This attribute will store the common used stylesheets to increase
transformation process overall performance
tFactory
private javax.xml.transform.TransformerFactory tFactory
| Constructor Detail |
HTMLTransformer
private HTMLTransformer()
| Method Detail |
newInstance
public static HTMLTransformer newInstance()
- HTMLTransformer will be a singleton object. This methods return
the unique instance of this class and creates it if necessary
createTemplates
public void createTemplates(java.lang.String source) throws TransformerException
- This method creates a template from a source stylesheet url so
the styleshhet can be reused
Typically will be used from within a document management system to store the common stylesheets (articles, news, etc.) used to transform documents.
createTemplates
public void createTemplates(javax.xml.transform.Source source) throws TransformerException
- This method creates a template from a source stylesheet so
the styleshhet can be reused.
Typically will be used from within a document management system to store the common stylesheets (articles, news, etc.) used to transform documents.
transformToString
public java.lang.String transformToString(javax.xml.transform.Source xmlSource, javax.xml.transform.Source xslSource) throws TransformerException
- Transforms an XML source using an XSL source to an String object.
Typical source objects are StreamSource, DOMSource or SAXSource
transformToString
public java.lang.String transformToString(java.lang.String xmlSource, java.lang.String xslSource) throws TransformerException
- Transforms an XML source using an XSL source to an String object.
transformToFile
public void transformToFile(javax.xml.transform.Source xmlSource, javax.xml.transform.Source xslSource, java.io.File file) throws TransformerException
- Transforms an XML source using an XSL source and stores the result
of the transformation process in the specified file.
Typical source objects are StreamSource, DOMSource or SAXSource
transformToFile
public void transformToFile(java.lang.String xmlSource, java.lang.String xslSource, java.io.File file) throws TransformerException
- Transforms an XML source using an XSL source and stores the result
of the transformation process in the specified file.
getTransformer
javax.xml.transform.Transformer getTransformer(java.lang.String xslSource) throws TransformerException
- Returns a transformer object. If xslSource is in the templates
cache then the stored stylesheet template returns a special
transformer object that can be used in multithreading environments
in other case a new transformer is created ( this transformer
object only can be used one time )
getTransformer
javax.xml.transform.Transformer getTransformer(javax.xml.transform.Source xslSource) throws TransformerException
- Returns a transformer object. If xslSource is in the templates
cache then the stored stylesheet template returns a special
transformer object that can be used in multithreading environments
in other case a new transformer is created ( this transformer
object only can be used one time )
transform
javax.xml.transform.Result transform(javax.xml.transform.Source xmlSource, javax.xml.transform.Transformer transformer, javax.xml.transform.Result result) throws TransformerException
- This is the more general method. Takes a source XML file, and a
a source XLS stylesheet and outputs a result
Source is an interface, implementations can be StreamSource,
DOMSource or SAXSource. StreamSource is util for sources like
URLs, files, InputStreams (etc.).
|
|||||||||
| Home >> All >> org >> javahispano >> canyamo >> services >> presentation >> [ xml overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.javahispano.canyamo.services.presentation.xml.HTMLTransformer