org.jdom.transform
Class JDOMSource
SAXSource
org.jdom.transform.JDOMSource
public class JDOMSource
extends SAXSource
A holder for an XML Transformation source: a Document, Element, or list of
nodes.
The is provides input to a
JAXP TrAX Transformer
.
The following example shows how to apply an XSL Transformation
to a JDOM document and get the transformation result in the form
of a list of JDOM nodes:
public static List transform(Document doc, String stylesheet)
throws JDOMException {
try {
Transformer transformer = TransformerFactory.newInstance()
.newTransformer(new StreamSource(stylesheet));
JDOMSource in = new JDOMSource(doc);
JDOMResult out = new JDOMResult();
transformer.transform(in, out);
return out.getResult();
}
catch (TransformerException e) {
throw new JDOMException("XSLT Transformation failed", e);
}
}
$Revision: 1.20 $, $Date: 2007/11/10 05:29:02 $- Laurent Bihanic
- Jason Hunter
static String | JDOM_FEATURE - If
javax.xml.transform.TransformerFactory.getFeature
returns true when passed this value as an
argument, the Transformer natively supports JDOM.
|
JDOMSource(List source) - Creates a JDOM TrAX source wrapping a list of JDOM nodes.
|
JDOMSource(Document source) - Creates a JDOM TrAX source wrapping a JDOM document.
|
JDOMSource(Document source, EntityResolver resolver) - Creates a JDOM TrAX source wrapping a JDOM element with an
associated EntityResolver to resolve external entities.
|
JDOMSource(Element source) - Creates a JDOM TrAX source wrapping a JDOM element.
|
Document | getDocument() - Returns the source document used by this TrAX source.
|
List | getNodes() - Returns the source node list used by this TrAX source.
|
XMLReader | getXMLReader() - Returns the XMLReader to be used for the Source.
|
void | setDocument(Document source) - Sets the source document used by this TrAX source.
|
void | setInputSource(InputSource inputSource) - Sets the SAX InputSource to be used for the Source.
|
void | setNodes(List source) - Sets the source node list used by this TrAX source.
|
void | setXMLReader(XMLReader reader) - Set the XMLReader to be used for the Source.
|
JDOM_FEATURE
public static final String JDOM_FEATURE
If
javax.xml.transform.TransformerFactory.getFeature
returns
true
when passed this value as an
argument, the Transformer natively supports JDOM.
Note: This implementation does not override
the
SAXSource.FEATURE
value defined by its superclass
to be considered as a SAXSource by Transformer implementations
not natively supporting JDOM.
JDOMSource
public JDOMSource(List source)
Creates a JDOM TrAX source wrapping a list of JDOM nodes.
source
- the JDOM nodes to use as source for the
transformations
JDOMSource
public JDOMSource(Document source)
Creates a JDOM TrAX source wrapping a JDOM document.
source
- the JDOM document to use as source for the
transformations
JDOMSource
public JDOMSource(Document source,
EntityResolver resolver)
Creates a JDOM TrAX source wrapping a JDOM element with an
associated EntityResolver to resolve external entities.
source
- The JDOM Element to use as source for the
transformationsresolver
- Entity resolver to use for the source
transformation
JDOMSource
public JDOMSource(Element source)
Creates a JDOM TrAX source wrapping a JDOM element.
source
- the JDOM element to use as source for the
transformations
getDocument
public Document getDocument()
Returns the source document used by this TrAX source.
- the source document used by this TrAX source or
null
if the source is a node list.
getNodes
public List getNodes()
Returns the source node list used by this TrAX source.
- the source node list used by this TrAX source or
null
if the source is a JDOM document.
getXMLReader
public XMLReader getXMLReader()
Returns the XMLReader to be used for the Source.
This implementation returns a specific XMLReader reading
the XML data from the source JDOM document.
- an XMLReader reading the XML data from the source
JDOM document.
setDocument
public void setDocument(Document source)
Sets the source document used by this TrAX source.
source
- the JDOM document to use as source for the
transformations
setInputSource
public void setInputSource(InputSource inputSource)
throws UnsupportedOperationException
Sets the SAX InputSource to be used for the Source.
As this implementation only supports JDOM document as data
source, this method always throws an
UnsupportedOperationException
.
inputSource
- a valid InputSource reference.
setNodes
public void setNodes(List source)
Sets the source node list used by this TrAX source.
source
- the JDOM nodes to use as source for the
transformations
setXMLReader
public void setXMLReader(XMLReader reader)
throws UnsupportedOperationException
Set the XMLReader to be used for the Source.
As this implementation only supports JDOM document as data
source, this method throws an
UnsupportedOperationException
if the provided reader
object does not implement the SAX
XMLFilter
interface. Otherwise, the JDOM document reader will be
attached as parent of the filter chain.
reader
- a valid XMLReader or XMLFilter reference.
Copyright B) 2007 Jason Hunter, Brett McLaughlin. All Rights Reserved.