JDOMSource and
JDOMResult for advanced uses. This class handles the common case and
presents a simple interface. XSLTransformer is thread safe and may be
used from multiple threads.
XSLTransformer transformer = new XSLTransformer("file.xsl");
Document x2 = transformer.transform(x); // x is a Document
Document y2 = transformer.transform(y); // y is a Document
JDOM relies on TrAX to perform the transformation.
The javax.xml.transform.TransformerFactory Java system property
determines which XSLT engine TrAX uses. Its value should be
the fully qualified name of the implementation of the abstract
javax.xml.transform.TransformerFactory class.
Values of this property for popular XSLT processors include:
com.icl.saxon.TransformerFactoryImplnet.sf.saxon.TransformerFactoryImplorg.apache.xalan.processor.TransformerFactoryImpljd.xml.xslt.trax.TransformerFactoryImploracle.xml.jaxp.JXSAXTransformerFactoryThis property can be set in all the usual ways a Java system property can be set. TrAX picks from them in this order:
System.setProperty( "javax.xml.transform.TransformerFactory",
"classname")classname
option to the java interpreterlib/jaxp.properties properties file
in the JRE directory, in a line like this one:
javax.xml.parsers.DocumentBuilderFactory=classnameMETA-INF/services/javax.xml.transform.TransformerFactory file
in the JAR archives available to the runtime| Modifier and Type | Field and Description |
|---|---|
| private JDOMFactory | factory
The custom JDOM factory to use when building the transformation
result or |
| private Templates |
| Access | Constructor and Description |
|---|---|
| private | |
| public | XSLTransformer(String
source stylesheet as a Source object stylesheetSystemId)Creates a transformer for a given stylesheet system id. |
| public | XSLTransformer(InputStream
InputStream from which the stylesheet is read.
This will create a new |
| public | XSLTransformer(Reader
Reader from which the stylesheet is read.
This will create a new |
| public | XSLTransformer(File
File from which the stylesheet is read.
This will create a new |
| public | XSLTransformer(Document
Document containing the stylesheet.
This will create a new |
| Modifier and Type | Method and Description |
|---|---|
| public JDOMFactory | Returns: the customJDOMFactory used to build the
transformation result or null if the
default JDOM classes are being used.Returns the custom JDOMFactory used to build the transformation result. |
| public void | setFactory(JDOMFactory
the custom factory)JDOMFactory to use or
null to use the default JDOM
classes.Sets a custom JDOMFactory to use when building the transformation result. |
| public List | |
| public Document | |
| public Document | Returns: transformed output documentinput document inputDoc, EntityResolver entity resolver for the input document resolver)Transforms the given document to an output document. |
| factory | back to summary |
|---|---|
| private JDOMFactory factory The custom JDOM factory to use when building the transformation
result or | |
| templates | back to summary |
|---|---|
| private Templates templates | |
| XSLTransformer | back to summary |
|---|---|
| private XSLTransformer(Source stylesheet) throws XSLTransformException | |
| XSLTransformer | back to summary |
|---|---|
| public XSLTransformer(String stylesheetSystemId) throws XSLTransformException Creates a transformer for a given stylesheet system id.
| |
| XSLTransformer | back to summary |
|---|---|
| public XSLTransformer(InputStream stylesheet) throws XSLTransformException
This will create a new
| |
| XSLTransformer | back to summary |
|---|---|
| public XSLTransformer(Reader stylesheet) throws XSLTransformException
This will create a new
| |
| XSLTransformer | back to summary |
|---|---|
| public XSLTransformer(File stylesheet) throws XSLTransformException
This will create a new
| |
| XSLTransformer | back to summary |
|---|---|
| public XSLTransformer(Document stylesheet) throws XSLTransformException
This will create a new
| |
| getFactory | back to summary |
|---|---|
| public JDOMFactory getFactory() Returns the custom JDOMFactory used to build the transformation result.
| |
| setFactory | back to summary |
|---|---|
| public void setFactory(JDOMFactory factory) Sets a custom JDOMFactory to use when building the transformation result. Use a custom factory to build the tree with your own subclasses of the JDOM classes.
| |
| transform | back to summary |
|---|---|
| public List Transforms the given input nodes to a list of output nodes.
| |
| transform | back to summary |
|---|---|
| public Document transform(Document inputDoc) throws XSLTransformException Transforms the given document to an output document.
| |
| transform | back to summary |
|---|---|
| public Document transform(Document inputDoc, EntityResolver resolver) throws XSLTransformException Transforms the given document to an output document.
| |