Search in sources :

Example 1 with FilteredXmlInput

use of org.apache.axiom.core.stream.FilteredXmlInput in project webservices-axiom by apache.

the class BuilderSpec method from.

static BuilderSpec from(StAXParserConfiguration configuration, Source source) {
    if (source instanceof SAXSource) {
        return from((SAXSource) source, true);
    } else if (source instanceof DOMSource) {
        return from(((DOMSource) source).getNode(), true);
    } else if (source instanceof StreamSource) {
        StreamSource streamSource = (StreamSource) source;
        InputSource is = new InputSource();
        is.setByteStream(streamSource.getInputStream());
        is.setCharacterStream(streamSource.getReader());
        is.setPublicId(streamSource.getPublicId());
        is.setSystemId(streamSource.getSystemId());
        return from(configuration, is);
    } else if (source instanceof StAXSource) {
        return from(((StAXSource) source).getXMLStreamReader());
    } else {
        try {
            return new BuilderSpec(new FilteredXmlInput(new StAXPullInput(StAXUtils.getXMLInputFactory().createXMLStreamReader(source), true, null), NamespaceRepairingFilter.DEFAULT), null);
        } catch (XMLStreamException ex) {
            throw new OMException(ex);
        }
    }
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) InputSource(org.xml.sax.InputSource) SAXSource(javax.xml.transform.sax.SAXSource) XMLStreamException(javax.xml.stream.XMLStreamException) StAXPullInput(org.apache.axiom.om.impl.stream.stax.pull.StAXPullInput) StreamSource(javax.xml.transform.stream.StreamSource) StAXSource(javax.xml.transform.stax.StAXSource) FilteredXmlInput(org.apache.axiom.core.stream.FilteredXmlInput) OMException(org.apache.axiom.om.OMException)

Example 2 with FilteredXmlInput

use of org.apache.axiom.core.stream.FilteredXmlInput in project webservices-axiom by apache.

the class BuilderSpec method from.

static BuilderSpec from(StAXParserConfiguration configuration, final MultipartBody message) {
    Part rootPart = message.getRootPart();
    InputSource is = new InputSource(rootPart.getInputStream(false));
    is.setEncoding(rootPart.getContentType().getParameter("charset"));
    BuilderSpec spec = create(configuration, is, false);
    return new BuilderSpec(new FilteredXmlInput(spec.getInput(), new XOPDecodingFilter(new OMAttachmentAccessor() {

        @Override
        public DataHandler getDataHandler(String contentID) {
            Part part = message.getPart(contentID);
            return part == null ? null : part.getDataHandler();
        }
    })), new Detachable() {

        @Override
        public void detach() {
            message.detach();
        }
    });
}
Also used : OMAttachmentAccessor(org.apache.axiom.om.OMAttachmentAccessor) Detachable(org.apache.axiom.om.impl.common.builder.Detachable) InputSource(org.xml.sax.InputSource) Part(org.apache.axiom.mime.Part) DataHandler(javax.activation.DataHandler) FilteredXmlInput(org.apache.axiom.core.stream.FilteredXmlInput) XOPDecodingFilter(org.apache.axiom.om.impl.stream.xop.XOPDecodingFilter)

Aggregations

FilteredXmlInput (org.apache.axiom.core.stream.FilteredXmlInput)2 InputSource (org.xml.sax.InputSource)2 DataHandler (javax.activation.DataHandler)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 DOMSource (javax.xml.transform.dom.DOMSource)1 SAXSource (javax.xml.transform.sax.SAXSource)1 StAXSource (javax.xml.transform.stax.StAXSource)1 StreamSource (javax.xml.transform.stream.StreamSource)1 Part (org.apache.axiom.mime.Part)1 OMAttachmentAccessor (org.apache.axiom.om.OMAttachmentAccessor)1 OMException (org.apache.axiom.om.OMException)1 Detachable (org.apache.axiom.om.impl.common.builder.Detachable)1 StAXPullInput (org.apache.axiom.om.impl.stream.stax.pull.StAXPullInput)1 XOPDecodingFilter (org.apache.axiom.om.impl.stream.xop.XOPDecodingFilter)1