Search in sources :

Example 1 with TXWSerializer

use of com.sun.xml.txw2.output.TXWSerializer in project jaxb-ri by eclipse-ee4j.

the class TXW method create.

/**
 * Creates a new {@link TypedXmlWriter} to write a new instance of a document.
 *
 * @param <T> an instance of {@link TypedXmlWriter}
 * @param rootElement
 *      The {@link TypedXmlWriter} interface that declares the content model of the root element.
 *      This interface must have {@link XmlElement} annotation on it to designate the tag name
 *      of the root element.
 * @param out
 *      The target of the writing.
 * @return
 *      always return non-null {@link TypedXmlWriter} that can be used
 *      to write the contents of the root element.
 */
public static <T extends TypedXmlWriter> T create(Class<T> rootElement, XmlSerializer out) {
    if (out instanceof TXWSerializer) {
        TXWSerializer txws = (TXWSerializer) out;
        return txws.txw._element(rootElement);
    }
    Document doc = new Document(out);
    QName n = getTagName(rootElement);
    return new ContainerElement(doc, null, n.getNamespaceURI(), n.getLocalPart())._cast(rootElement);
}
Also used : TXWSerializer(com.sun.xml.txw2.output.TXWSerializer) QName(javax.xml.namespace.QName)

Aggregations

TXWSerializer (com.sun.xml.txw2.output.TXWSerializer)1 QName (javax.xml.namespace.QName)1