|
Devsphere.com |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--javax.xml.transform.Transformer
|
+--com.devsphere.xml.saxdomix.SDXTransformer
|
+--com.devsphere.examples.xml.saxdomix.SmartTransformer
|
+--com.devsphere.examples.xml.saxdomix.WrapperTransformer
This example is based on SmartTransformer, but it creates
an HTML file as output. The SAX events are ignored during the mixed parsing.
The markup that results from the transformation of the DOM sub-trees
is outputted between a header and a footer, which are taken from an HTML
wrapper.
SDXTransformer,
SmartTransformer,
TransformerRunner| Field Summary | |
protected int |
footerLength
The length of the HTML footer |
protected int |
footerOffset
The offset of the HTML footer |
protected int |
headerLength
The length of the HTML header |
protected int |
headerOffset
The offset of the HTML header |
protected java.io.OutputStream |
stream
The stream used for output |
protected byte[] |
variable
The name of the wariable from the HTML wrapper |
protected byte[] |
wrapper
The content of the HTML wrapper |
protected java.io.Writer |
writer
The writer used for output |
| Fields inherited from class com.devsphere.examples.xml.saxdomix.SmartTransformer |
elements, jaxpFactory |
| Fields inherited from class com.devsphere.xml.saxdomix.SDXTransformer |
builder, fragmentTransformer, resultFilter, serializer, traxFactory |
| Constructor Summary | |
WrapperTransformer(java.lang.String xslSystemID,
java.lang.String wrapperSystemID,
java.lang.String variableName)
Does the initialization. |
|
| Method Summary | |
protected org.xml.sax.ContentHandler |
createBuilder(javax.xml.transform.sax.TransformerHandler serializer)
Creates the SDXBuilderT object. |
protected void |
initHeaderAndFooter(java.lang.String wrapperSystemID,
java.lang.String variableName)
Initializes the fields that maintain the offsets and the lengths of the HTML header and footer. |
protected byte[] |
loadWrapper(java.lang.String wrapperSystemID)
Loads the wrapper and returns its content as a byte array. |
static void |
main(java.lang.String[] args)
Uses TransformerRunner in order to create an instance of
this class, configure it and call its transform() method. |
void |
transform(javax.xml.transform.Source xmlSource,
javax.xml.transform.Result outputTarget)
Does the transformation. |
| Methods inherited from class com.devsphere.examples.xml.saxdomix.SmartTransformer |
buildElementsVector, processPath, processPattern, wantDOM |
| Methods inherited from class com.devsphere.xml.saxdomix.SDXTransformer |
clearParameters, createResultFilter, createSerializer, getErrorListener, getOutputProperties, getOutputProperty, getParameter, getURIResolver, handleDOM, setErrorListener, setOutputProperties, setOutputProperty, setParameter, setURIResolver |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected byte[] wrapper
protected byte[] variable
protected int headerOffset
protected int headerLength
protected int footerOffset
protected int footerLength
protected java.io.OutputStream stream
protected java.io.Writer writer
| Constructor Detail |
public WrapperTransformer(java.lang.String xslSystemID,
java.lang.String wrapperSystemID,
java.lang.String variableName)
throws javax.xml.transform.TransformerException,
javax.xml.parsers.ParserConfigurationException,
org.xml.sax.SAXException,
java.io.IOException
| Method Detail |
public void transform(javax.xml.transform.Source xmlSource,
javax.xml.transform.Result outputTarget)
throws javax.xml.transform.TransformerException
This method can work only with a StreamResult.
It saves its stream or writer within an instance variable for later
usage. Then it calls the method with the same name inherited from
SDXTransformer.
transform in class SDXTransformerxmlSource - The input source for the transformationoutputTarget - The output target for the transformation
javax.xml.transform.TransformerException - If an error must be signaled
protected org.xml.sax.ContentHandler createBuilder(javax.xml.transform.sax.TransformerHandler serializer)
throws javax.xml.transform.TransformerException
SDXBuilderT object. This customization of
SDXTransformer in necessary in order to save the header
and the footer of the HTML output.
Instead of using the serializer object, the application
provides its own handler for the SAX events that don't participate to
the construction of the DOM sub-trees. The startDocument()
and endDocument() events are still forwarded to the
serializer object.
createBuilder in class SDXTransformerserializer - The current serializer object
builder
javax.xml.transform.TransformerException - If an error must be signaled
protected void initHeaderAndFooter(java.lang.String wrapperSystemID,
java.lang.String variableName)
throws java.io.IOException
java.io.IOException
protected byte[] loadWrapper(java.lang.String wrapperSystemID)
throws java.io.IOException
java.io.IOExceptionpublic static void main(java.lang.String[] args)
TransformerRunner in order to create an instance of
this class, configure it and call its transform() method.
|
Devsphere.com |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||