    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class org.jdom.transform.JDOMSource

    java.lang.Object
       |
       +----javax.xml.transform.sax.SAXSource
               |
               +----org.jdom.transform.JDOMSource

public class JDOMSource
extends SAXSource

Acts as an holder for JDOM document sources.

This class shall be used to wrap a JDOM Document to provide it as input to a JAXP Transformer

The following example shows how to apply an XSL Transformation to a JDOM document and get the transformation result in the form of another JDOM Document:

>        public static Document transform(Document in, String stylesheet)
>                                             throws JDOMException {
>          try {
>            Transformer transformer = TransformerFactory.newInstance()
>               .newTransformer(new StreamSource(stylesheet));
>            JDOMResult out = new JDOMResult();
>            transformer.transform(new JDOMSource(in), out);
>            return out.getDocument();
>          }
>          catch (TransformerException e) {
>            throw new JDOMException("XSLT Trandformation failed", e);
>          }
>        }

Version:
  $Revision: 1.6 $, $Date: 2002/01/08 09:17:10 $
Author:
  Laurent Bihanic, Jason Hunter
See Also:
  JDOMResult

##

JDOM_FEATURE
  If {

##

JDOMSource(Document)
  Creates a JDOM TRaX source wrapping a JDOM document.

##

getDocument()
  Returns the source document used by this TRaX source.
getXMLReader()
  Returns the XMLReader to be used for the Source.
setDocument(Document)
  Sets the source document used by this TRaX source.
setInputSource(InputSource)
  Sets the SAX InputSource to be used for the Source.
setXMLReader(XMLReader)
  Set the XMLReader to be used for the Source.

##

JDOM_FEATURE

     public static final String JDOM_FEATURE

  If {@link 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 {@link SAXSource#FEATURE} value defined by its superclass to be considered as a SAXSource by Transformer implementations not natively supporting JDOM.

##

JDOMSource

     public JDOMSource(Document source)

  Creates a JDOM TRaX source wrapping a JDOM document.

  Parameters:
    source - the JDOM document to use as source for the transformations
  Throws: NullPointerException
    if `source` is `null`.
  See Also:
    setDocument

##

setDocument

     public void setDocument(Document source)

  Sets the source document used by this TRaX source.

  Parameters:
    source - the JDOM document to use as source for the transformations
  Throws: NullPointerException
    if `source` is `null`.
  See Also:
    getDocument

getDocument

     public Document getDocument()

  Returns the source document used by this TRaX source.

  Returns:
    the source document used by this TRaX source or `null` if none has been set.
  See Also:
    setDocument

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 {@link UnsupportedOperationException}.

  Parameters:
    inputSource - a valid InputSource reference.
  Throws: UnsupportedOperationException
    always!
  Overrides:
    setInputSource in class SAXSource

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 {@link UnsupportedOperationException} if the provided reader object does not implement the SAX {@link XMLFilter} interface. Otherwise, the JDOM document reader will be attached as parent of the filter chain.

  Parameters:
    reader - a valid XMLReader or XMLFilter reference.
  Throws: UnsupportedOperationException
    always!
  Overrides:
    setXMLReader in class SAXSource
  See Also:
    getXMLReader

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.

  Returns:
    an XMLReader reading the XML data from the source JDOM document.
  Overrides:
    getXMLReader in class SAXSource

    All Packages  Class Hierarchy  This Package  Previous  Next  Index