Package org.zkoss.idom.transform
Class Transformer
- java.lang.Object
-
- org.zkoss.idom.transform.Transformer
-
public class Transformer extends java.lang.ObjectTransforms an iDOM Document.- Author:
- andrewho@potix.com, tomyeh
-
-
Constructor Summary
Constructors Constructor Description Transformer()Transformer constructor without stylesheet.Transformer(javax.xml.transform.Source source)Constructs a transformer with a stylesheet in form of Source.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidenableOutputDocType(boolean enable)Sets whether to output the doc type.javax.xml.transform.ErrorListenergetErrorListener()Get the error event handler in effect for the transformation.java.util.PropertiesgetOutputProperties()Get a copy of the output properties for the transformation.java.lang.StringgetOutputProperty(java.lang.String name)Get an output property that is in effect for the transformation.javax.xml.transform.TransformergetTransformer()Returns the JAXP transformer encapsulated by this object.voidsetErrorListener(javax.xml.transform.ErrorListener listener)Set the error event listener in effect for the transformation.voidsetOutputProperties(java.util.Properties props)Set the output properties for the transformation.voidsetOutputProperty(java.lang.String name, java.lang.String value)Set an output property that will be in effect for the transformation.Documenttransform(javax.xml.transform.Source source)Transforms a source and returns the transformed result as an iDOM Document.voidtransform(javax.xml.transform.Source source, javax.xml.transform.Result result)Transforms from a source to a result.Documenttransform(Document doc)Transforms an iDOM document and returns the transformed result as another iDOM Document.voidtransform(Document doc, javax.xml.transform.Result result)Transforms from an iDOM document to a result.Documenttransform(Element elm)Transforms an iDOM element and returns the transformed result as another iDOM Document.voidtransform(Element elm, javax.xml.transform.Result result)Transforms from an iDOM element to a result.
-
-
-
Constructor Detail
-
Transformer
public Transformer() throws javax.xml.transform.TransformerConfigurationExceptionTransformer constructor without stylesheet.- Throws:
javax.xml.transform.TransformerConfigurationException
-
Transformer
public Transformer(javax.xml.transform.Source source) throws javax.xml.transform.TransformerConfigurationExceptionConstructs a transformer with a stylesheet in form of Source.Examples:
- File file
- new Transformer(new javax.xml.transform.stream.StreamSource(file));
- Reader reader
- new Transformer(new javax.xml.transform.stream.StreamSource(reader));
- URL url
- new Transformer(new javax.xml.transform.stream.StreamSource(url.openStream()));
- iDOM or DOM dom
- new Transformer(new javax.xml.transform.dom.DOMSource(dom));
See javax.xml.transform.stream.StreamSource and javax.xml.transform.dom.DOMSource
- Throws:
javax.xml.transform.TransformerConfigurationException
-
-
Method Detail
-
enableOutputDocType
public final void enableOutputDocType(boolean enable)
Sets whether to output the doc type. Default: true.Useful only if
Documentis used in transform(), e.g.,transform(Document, Result). If not, you have to set OutputKeys.DOCTYPE_SYSTEM and OutputKeys.DOCTYPE_PUBLIC explicitly (thrugetTransformer()).
-
getTransformer
public final javax.xml.transform.Transformer getTransformer()
Returns the JAXP transformer encapsulated by this object. Then, you can use it to set properties, listener and so on.Notice: OutputKeys.DOCTYPE_SYSTEM and OutputKeys.DOCTYPE_PUBLIC are set automatically if outDocType is true when constructing this object and
Documentis used to transform.
-
transform
public final void transform(javax.xml.transform.Source source, javax.xml.transform.Result result) throws javax.xml.transform.TransformerExceptionTransforms from a source to a result. and javax.xml.transform.dom.DOMSource- Parameters:
source- the sourceresult- the result- Throws:
javax.xml.transform.TransformerException- See Also:
transform(Document, Result)
-
transform
public final void transform(Document doc, javax.xml.transform.Result result) throws javax.xml.transform.TransformerException
Transforms from an iDOM document to a result.Examples:
- File file
- transformer.transform(doc, new javax.xml.transform.stream.StreamResult(file));
- Writer writer
- transformer.transform(doc, new javax.xml.transform.stream.StreamResult(writer));
- URL url
- No simple way yet.
- iDOM or DOM dom
transform(Source)andtransform(Document).- String systemId
- transformer.transform(doc, new javax.xml.transform.stream.StreamResult(systemId));
See javax.xml.transform.stream.StreamResult and javax.xml.transform.dom.DOMResult
- Parameters:
doc- the source documentresult- the result- Throws:
javax.xml.transform.TransformerException- See Also:
transform(Source, Result),transform(Document)
-
transform
public final void transform(Element elm, javax.xml.transform.Result result) throws javax.xml.transform.TransformerException
Transforms from an iDOM element to a result.- Parameters:
elm- the source elementresult- the result- Throws:
javax.xml.transform.TransformerException
-
transform
public final Document transform(javax.xml.transform.Source source) throws javax.xml.transform.TransformerException
Transforms a source and returns the transformed result as an iDOM Document.- Parameters:
source- the source- Returns:
- the transformed result in an iDOM document
- Throws:
javax.xml.transform.TransformerException
-
transform
public final Document transform(Document doc) throws javax.xml.transform.TransformerException
Transforms an iDOM document and returns the transformed result as another iDOM Document.- Parameters:
doc- the source document- Returns:
- the transformed result in an iDOM document
- Throws:
javax.xml.transform.TransformerException
-
transform
public final Document transform(Element elm) throws javax.xml.transform.TransformerException
Transforms an iDOM element and returns the transformed result as another iDOM Document.- Parameters:
elm- the source element- Returns:
- the transformed result in an iDOM document
- Throws:
javax.xml.transform.TransformerException
-
getOutputProperties
public final java.util.Properties getOutputProperties()
Get a copy of the output properties for the transformation.
-
getOutputProperty
public final java.lang.String getOutputProperty(java.lang.String name)
Get an output property that is in effect for the transformation.
-
setOutputProperty
public final void setOutputProperty(java.lang.String name, java.lang.String value)Set an output property that will be in effect for the transformation.
-
setOutputProperties
public final void setOutputProperties(java.util.Properties props)
Set the output properties for the transformation.
-
getErrorListener
public final javax.xml.transform.ErrorListener getErrorListener()
Get the error event handler in effect for the transformation.
-
setErrorListener
public final void setErrorListener(javax.xml.transform.ErrorListener listener)
Set the error event listener in effect for the transformation.
-
-