|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnu.xom.xslt.XSLTransform
This class serves as an interface to a TrAX aware XSLT processor such as Xalan or Saxon.
The following example shows how to apply an XSL Transformation
to a XOM document and get the transformation result in the form
of a XOM Nodes
:
public static Nodes transform(Document in) throws XSLException { XSLTransform stylesheet = new XSLTransform("mystylesheet.xsl"); return stylesheet.transform(doc); }
XOM 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.TransformerFactoryImpl
net.sf.saxon.TransformerFactoryImpl
org.apache.xalan.processor.TransformerFactoryImpl
jd.xml.xslt.trax.TransformerFactoryImpl
oracle.xml.jaxp.JXSAXTransformerFactory
This 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
")
lib/jaxp.properties
properties file in the JRE directory, in a line like this one:
javax.xml.parsers.DocumentBuilderFactory=classname
META-INF/services/javax.xml.transform.TransformerFactory
file in the JAR archives available to the runtime
Constructor Summary | |
XSLTransform(Document stylesheet)
This will create a new XSLTransform by
reading the stylesheet from the specified Document . |
|
XSLTransform(java.io.File stylesheet)
This will create a new XSLTransform
by reading the stylesheet from the specified File . |
|
XSLTransform(java.io.InputStream stylesheet)
This will create a new XSLTransform by
reading the stylesheet from the specified
InputStream . |
|
XSLTransform(java.io.Reader stylesheet)
This will create a new XSLTransform by
reading the stylesheet from the specified
Reader . |
|
XSLTransform(java.lang.String systemID)
This will create a new XSLTransform by
reading the stylesheet from the specified URL. |
Method Summary | |
void |
setNodeFactory(NodeFactory factory)
Sets the factory used to construct nodes in the output tree. |
java.lang.String |
toString()
This returns a String form of this
XSLTransform , suitable for debugging. |
Nodes |
transform(Document in)
This will create a new Nodes from the
input Document by applying this object's
stylesheet. |
Nodes |
transform(Nodes in)
This will create a new Nodes from the
input Nodes by applying this object's
stylesheet. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public XSLTransform(java.io.InputStream stylesheet) throws XSLException
This will create a new XSLTransform
by
reading the stylesheet from the specified
InputStream
.
stylesheet
- InputStream
from
which the stylesheet is read
XSLException
- when an IOException, format error, or
something else prevents the stylesheet from being compiledpublic XSLTransform(java.io.Reader stylesheet) throws XSLException
This will create a new XSLTransform
by
reading the stylesheet from the specified
Reader
.
stylesheet
- Reader
from which the stylesheet
is read
XSLException
- when an IOException, format error, or
something else prevents the stylesheet from being compiledpublic XSLTransform(java.io.File stylesheet) throws XSLException
This will create a new XSLTransform
by reading the stylesheet from the specified File
.
stylesheet
- File
from which the
stylesheet is read
XSLException
- when an IOException, format error, or
something else prevents the stylesheet from being compiledpublic XSLTransform(Document stylesheet) throws XSLException
This will create a new XSLTransform
by
reading the stylesheet from the specified Document
.
stylesheet
- Document
containing
the stylesheet
XSLException
- when the supplied Document
is not syntactically correct XSLTpublic XSLTransform(java.lang.String systemID) throws XSLException
This will create a new XSLTransform
by
reading the stylesheet from the specified URL.
systemID
- URL from which the stylesheet is read
XSLException
- when an IOException, format error, or
something else prevents the stylesheet from being compiledMethod Detail |
public Nodes transform(Document in) throws XSLException
This will create a new Nodes
from the
input Document
by applying this object's
stylesheet. The original Document
is not
changed.
in
- Document
to transform
Nodes
containing the result of the
transformation
XSLException
- if the transformation fails, normally
due to an XSLT errorpublic Nodes transform(Nodes in) throws XSLException
This will create a new Nodes
from the
input Nodes
by applying this object's
stylesheet. The original Nodes
is not
changed.
in
- Document
to transform
Nodes
containing the result of
the transformation
XSLException
- if the transformation fails, normally
due to an XSLT errorpublic void setNodeFactory(NodeFactory factory)
Sets the factory used to construct nodes in the output tree. Passing null uses the default factory.
factory
- the NodeFactory
used to construct
nodes in the output treepublic java.lang.String toString()
This returns a String
form of this
XSLTransform
, suitable for debugging.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |