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

## javax.xml.bind.util
Class JAXBSource

    java.lang.Object
      |
      +--javax.xml.transform.sax.SAXSource
            |
            +--javax.xml.bind.util.JAXBSource

All Implemented Interfaces:
  javax.xml.transform.Source

public class JAXBSource
extends javax.xml.transform.sax.SAXSource

JAXP `Source` implementation that marshals a JAXB-generated object.

This utility class is useful to combine JAXB with other Java/XML technologies.

The following example shows how to use JAXB to marshal a document for transformation by XSLT.

>            MyObject o = // get JAXB content tree

>            // jaxbContext is a JAXBContext object from which 'o' is created.
>            JAXBSource source = new JAXBSource( jaxbContext, o );

>            // set up XSLT transformation
>            TransformerFactory tf = TransformerFactory.newInstance();
>            Transformer t = tf.newTransformer(new StreamSource("test.xsl"));

>            // run transformation
>            t.transform(source,new StreamResult(System.out));

Author:
  Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)

Field Summary

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

Constructor Summary
`JAXBSource(JAXBContext context, java.lang.Object contentObject)` Creates a new `Source` for the given content object.
`JAXBSource(Marshaller marshaller, java.lang.Object contentObject)` Creates a new `Source` for the given content object.

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

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

Constructor Detail

### JAXBSource

    public JAXBSource(JAXBContext context,
                      java.lang.Object contentObject)
               throws JAXBException

  Creates a new `Source` for the given content object.

Parameters:
  `context` - JAXBContext that was used to create `contentObject`. This context is used to create a new instance of marshaller and must not be null.
  `contentObject` - An instance of a JAXB-generated class, which will be used as a `Source` (by marshalling it into XML). It must not be null.
Throws:
  `JAXBException` - if an error is encountered while creating the JAXBSource or if either of the parameters are null.

### JAXBSource

    public JAXBSource(Marshaller marshaller,
                      java.lang.Object contentObject)
               throws JAXBException

  Creates a new `Source` for the given content object.

Parameters:
  `marshaller` - A marshaller instance that will be used to marshal `contentObject` into XML. This must be created from a JAXBContext that was used to build `contentObject` and must not be null.
  `contentObject` - An instance of a JAXB-generated class, which will be used as a `Source` (by marshalling it into XML). It must not be null.
Throws:
  `JAXBException` - if an error is encountered while creating the JAXBSource or if either of the parameters are null.

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

Comments to: jaxb-spec-comments@sun.com
More information at: http://java.sun.com/xml/jaxb

Copyright © 2001 by Sun Microsystems, Inc., 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.