Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jdom.transform
Class JDOMSource

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

All Implemented Interfaces:
  javax.xml.transform.Source

    public class JDOMSource

extends javax.xml.transform.sax.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);
         }
       }

See Also:
  `JDOMResult`

Nested Class Summary
`private static class` | `JDOMSource.DocumentReader` An implementation of the SAX2 XMLReader interface that presents a SAX view of a JDOM Document.
`private static class` | `JDOMSource.JDOMInputSource` A subclass of the SAX InputSource interface that wraps a JDOM Document.

Field Summary
`private static java.lang.String` | `CVS_ID`
`static java.lang.String` | `JDOM_FEATURE` If `TransformerFactory.getFeature(java.lang.String)` returns `true` when passed this value as an argument, the Transformer natively supports JDOM.
`private org.xml.sax.EntityResolver` | `resolver` Optional entity resolver associated to the source of this document or `null` if no EntityResolver was supplied with this JDOMSource.
`private org.xml.sax.XMLReader` | `xmlReader` The XMLReader object associated to this source or `null` if no XMLReader has yet been requested.

Fields inherited from class javax.xml.transform.sax.SAXSource
`FEATURE`

Constructor Summary
`JDOMSource(Document source)` Creates a JDOM TrAX source wrapping a JDOM document.
`JDOMSource(Document source, org.xml.sax.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.
`JDOMSource(java.util.List source)` Creates a JDOM TrAX source wrapping a list of JDOM nodes.

Method Summary
`private org.xml.sax.XMLReader` | `buildDocumentReader()` Build an XMLReader to be used for the source.
`Document` | `getDocument()` Returns the source document used by this TrAX source.
`java.util.List` | `getNodes()` Returns the source node list used by this TrAX source.
`org.xml.sax.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(org.xml.sax.InputSource inputSource)` Sets the SAX InputSource to be used for the Source.
`void` | `setNodes(java.util.List source)` Sets the source node list used by this TrAX source.
`void` | `setXMLReader(org.xml.sax.XMLReader reader)` Set the XMLReader to be used for the Source.

Methods inherited from class javax.xml.transform.sax.SAXSource
`getInputSource, getSystemId, setSystemId, sourceToInputSource`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### CVS_ID

    private static final java.lang.String CVS_ID

See Also:
  Constant Field Values

### JDOM_FEATURE

    public static final java.lang.String JDOM_FEATURE

  If `TransformerFactory.getFeature(java.lang.String)` 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.

  See Also:
    Constant Field Values

### xmlReader

    private org.xml.sax.XMLReader xmlReader

  The XMLReader object associated to this source or `null` if no XMLReader has yet been requested.

  See Also:
    `getXMLReader()`

### resolver

    private org.xml.sax.EntityResolver resolver

  Optional entity resolver associated to the source of this document or `null` if no EntityResolver was supplied with this JDOMSource.

  See Also:
    `buildDocumentReader()`

Constructor Detail

### 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:
    `java.lang.IllegalArgumentException` - if `source` is `null`.

### JDOMSource

    public JDOMSource(java.util.List source)

  Creates a JDOM TrAX source wrapping a list of JDOM nodes.

  Parameters:
    `source` - the JDOM nodes to use as source for the transformations
  Throws:
    `java.lang.IllegalArgumentException` - if `source` is `null`.

### JDOMSource

    public JDOMSource(Element source)

  Creates a JDOM TrAX source wrapping a JDOM element.

  Parameters:
    `source` - the JDOM element to use as source for the transformations
  Throws:
    `java.lang.IllegalArgumentException` - if `source` is `null`.

### JDOMSource

    public JDOMSource(Document source,
                      org.xml.sax.EntityResolver resolver)

  Creates a JDOM TrAX source wrapping a JDOM element with an associated EntityResolver to resolve external entities.

  Parameters:
    `source` - The JDOM Element to use as source for the transformations
    `resolver` - Entity resolver to use for the source transformation
  Throws:
    `java.lang.IllegalArgumentException` - if`source` is `null`

Method Detail

### 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:
    `java.lang.IllegalArgumentException` - 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 the source is a node list.
  See Also:
    `setDocument(org.jdom.Document)`

### setNodes

    public void setNodes(java.util.List source)

  Sets the source node list used by this TrAX source.

  Parameters:
    `source` - the JDOM nodes to use as source for the transformations
  Throws:
    `java.lang.IllegalArgumentException` - if `source` is `null`.
  See Also:
    `getNodes()`

### getNodes

    public java.util.List getNodes()

  Returns the source node list used by this TrAX source.

  Returns:
    the source node list used by this TrAX source or `null` if the source is a JDOM document.
  See Also:
    `setDocument(org.jdom.Document)`

### setInputSource

    public void setInputSource(org.xml.sax.InputSource inputSource)
                        throws java.lang.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`.

  Overrides:
    `setInputSource` in class `javax.xml.transform.sax.SAXSource`
  Parameters:
    `inputSource` - a valid InputSource reference.
  Throws:
    `java.lang.UnsupportedOperationException` - always!

### setXMLReader

    public void setXMLReader(org.xml.sax.XMLReader reader)
                      throws java.lang.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.

  Overrides:
    `setXMLReader` in class `javax.xml.transform.sax.SAXSource`
  Parameters:
    `reader` - a valid XMLReader or XMLFilter reference.
  Throws:
    `java.lang.UnsupportedOperationException` - if `reader` is not a SAX `XMLFilter`.
  See Also:
    `getXMLReader()`

### getXMLReader

    public org.xml.sax.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.

  Overrides:
    `getXMLReader` in class `javax.xml.transform.sax.SAXSource`
  Returns:
    an XMLReader reading the XML data from the source JDOM document.

### buildDocumentReader

    private org.xml.sax.XMLReader buildDocumentReader()

  Build an XMLReader to be used for the source. This will create a new instance of DocumentReader with an EntityResolver instance if available.

  Returns:
    XMLReader reading the XML data from the source JDOM document with an optional EntityResolver

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD