All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sun.xml.ws.util.xml.StAXResult Maven / Gradle / Ivy

There is a newer version: 4.0.2
Show newest version
/*
 * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Distribution License v. 1.0, which is available at
 * http://www.eclipse.org/org/documents/edl-v10.php.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

package com.sun.xml.ws.util.xml;

import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.sax.SAXResult;

/**
 * A JAXP {@link javax.xml.transform.Result} implementation that produces
 * a result on the specified {@link javax.xml.stream.XMLStreamWriter} or
 * {@link javax.xml.stream.XMLEventWriter}.
 *
 * 

* Please note that you may need to call flush() on the underlying * XMLStreamWriter or XMLEventWriter after the transform is complete. *

* * The fact that JAXBResult derives from SAXResult is an implementation * detail. Thus in general applications are strongly discouraged from * accessing methods defined on SAXResult. * *

* In particular it shall never attempt to call the following methods: * *

    *
  • setHandler
  • *
  • setLexicalHandler
  • *
  • setSystemId
  • *
* *

* Example: * *

    // create a DOMSource
    Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(...);
    Source domSource = new DOMSource(doc);

    // create a StAXResult
    XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(System.out);
    Result staxResult = new StAXResult(writer);

    // run the transform
    TransformerFactory.newInstance().newTransformer().transform(domSource, staxResult);
 * 
* * @author [email protected] * @version 1.0 */ public class StAXResult extends SAXResult { /** * Create a new {@link javax.xml.transform.Result} that produces * a result on the specified {@link javax.xml.stream.XMLStreamWriter} * * @param writer the XMLStreamWriter * @throws IllegalArgumentException iff the writer is null */ public StAXResult(XMLStreamWriter writer) { if( writer == null ) { throw new IllegalArgumentException(); } super.setHandler(new ContentHandlerToXMLStreamWriter( writer )); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy