com.sun.xml.internal.bind.unmarshaller.DOMScanner Java Examples

The following examples show how to use com.sun.xml.internal.bind.unmarshaller.DOMScanner. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UnmarshallerImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public final Object unmarshal0( Node node, JaxBeanInfo expectedType ) throws JAXBException {
    try {
        final DOMScanner scanner = new DOMScanner();

        InterningXmlVisitor handler = new InterningXmlVisitor(createUnmarshallerHandler(null,false,expectedType));
        scanner.setContentHandler(new SAXConnector(handler,scanner));

        if(node.getNodeType() == Node.ELEMENT_NODE) {
            scanner.scan((Element)node);
        } else if(node.getNodeType() == Node.DOCUMENT_NODE) {
            scanner.scan((Document)node);
        } else {
            throw new IllegalArgumentException("Unexpected node type: "+node);
        }

        Object retVal = handler.getContext().getResult();
        handler.getContext().clearResult();
        return retVal;
    } catch( SAXException e ) {
        throw createUnmarshalException(e);
    }
}
 
Example #2
Source File: UnmarshallerImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public final Object unmarshal0( Node node, JaxBeanInfo expectedType ) throws JAXBException {
    try {
        final DOMScanner scanner = new DOMScanner();

        InterningXmlVisitor handler = new InterningXmlVisitor(createUnmarshallerHandler(null,false,expectedType));
        scanner.setContentHandler(new SAXConnector(handler,scanner));

        if(node.getNodeType() == Node.ELEMENT_NODE) {
            scanner.scan((Element)node);
        } else if(node.getNodeType() == Node.DOCUMENT_NODE) {
            scanner.scan((Document)node);
        } else {
            throw new IllegalArgumentException("Unexpected node type: "+node);
        }

        Object retVal = handler.getContext().getResult();
        handler.getContext().clearResult();
        return retVal;
    } catch( SAXException e ) {
        throw createUnmarshalException(e);
    }
}
 
Example #3
Source File: UnmarshallerImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public final Object unmarshal0( Node node, JaxBeanInfo expectedType ) throws JAXBException {
    try {
        final DOMScanner scanner = new DOMScanner();

        InterningXmlVisitor handler = new InterningXmlVisitor(createUnmarshallerHandler(null,false,expectedType));
        scanner.setContentHandler(new SAXConnector(handler,scanner));

        if(node.getNodeType() == Node.ELEMENT_NODE) {
            scanner.scan((Element)node);
        } else if(node.getNodeType() == Node.DOCUMENT_NODE) {
            scanner.scan((Document)node);
        } else {
            throw new IllegalArgumentException("Unexpected node type: "+node);
        }

        Object retVal = handler.getContext().getResult();
        handler.getContext().clearResult();
        return retVal;
    } catch( SAXException e ) {
        throw createUnmarshalException(e);
    }
}
 
Example #4
Source File: SchemaCompilerImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public void parseSchema( String systemId, Element element ) {
    checkAbsoluteness(systemId);
    try {
        DOMScanner scanner = new DOMScanner();

        // use a locator that sets the system ID correctly
        // so that we can resolve relative URLs in most of the case.
        // it still doesn't handle xml:base and XInclude and all those things
        // correctly. There's just no way to make all those things work with DOM!
        LocatorImpl loc = new LocatorImpl();
        loc.setSystemId(systemId);
        scanner.setLocator(loc);

        scanner.setContentHandler(getParserHandler(systemId));
        scanner.scan(element);
    } catch (SAXException e) {
        // since parsing DOM shouldn't cause a SAX exception
        // and our handler will never throw it, it's not clear
        // if this will ever happen.
        fatalError(new SAXParseException2(
            e.getMessage(), null, systemId,-1,-1, e));
    }
}
 
Example #5
Source File: SchemaCompilerImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void parseSchema( String systemId, Element element ) {
    checkAbsoluteness(systemId);
    try {
        DOMScanner scanner = new DOMScanner();

        // use a locator that sets the system ID correctly
        // so that we can resolve relative URLs in most of the case.
        // it still doesn't handle xml:base and XInclude and all those things
        // correctly. There's just no way to make all those things work with DOM!
        LocatorImpl loc = new LocatorImpl();
        loc.setSystemId(systemId);
        scanner.setLocator(loc);

        scanner.setContentHandler(getParserHandler(systemId));
        scanner.scan(element);
    } catch (SAXException e) {
        // since parsing DOM shouldn't cause a SAX exception
        // and our handler will never throw it, it's not clear
        // if this will ever happen.
        fatalError(new SAXParseException2(
            e.getMessage(), null, systemId,-1,-1, e));
    }
}
 
Example #6
Source File: UnmarshallerImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public final Object unmarshal0( Node node, JaxBeanInfo expectedType ) throws JAXBException {
    try {
        final DOMScanner scanner = new DOMScanner();

        InterningXmlVisitor handler = new InterningXmlVisitor(createUnmarshallerHandler(null,false,expectedType));
        scanner.setContentHandler(new SAXConnector(handler,scanner));

        if(node.getNodeType() == Node.ELEMENT_NODE) {
            scanner.scan((Element)node);
        } else if(node.getNodeType() == Node.DOCUMENT_NODE) {
            scanner.scan((Document)node);
        } else {
            throw new IllegalArgumentException("Unexpected node type: "+node);
        }

        Object retVal = handler.getContext().getResult();
        handler.getContext().clearResult();
        return retVal;
    } catch( SAXException e ) {
        throw createUnmarshalException(e);
    }
}
 
Example #7
Source File: SchemaCompilerImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void parseSchema( String systemId, Element element ) {
    checkAbsoluteness(systemId);
    try {
        DOMScanner scanner = new DOMScanner();

        // use a locator that sets the system ID correctly
        // so that we can resolve relative URLs in most of the case.
        // it still doesn't handle xml:base and XInclude and all those things
        // correctly. There's just no way to make all those things work with DOM!
        LocatorImpl loc = new LocatorImpl();
        loc.setSystemId(systemId);
        scanner.setLocator(loc);

        scanner.setContentHandler(getParserHandler(systemId));
        scanner.scan(element);
    } catch (SAXException e) {
        // since parsing DOM shouldn't cause a SAX exception
        // and our handler will never throw it, it's not clear
        // if this will ever happen.
        fatalError(new SAXParseException2(
            e.getMessage(), null, systemId,-1,-1, e));
    }
}
 
Example #8
Source File: SchemaCompilerImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void parseSchema( String systemId, Element element ) {
    checkAbsoluteness(systemId);
    try {
        DOMScanner scanner = new DOMScanner();

        // use a locator that sets the system ID correctly
        // so that we can resolve relative URLs in most of the case.
        // it still doesn't handle xml:base and XInclude and all those things
        // correctly. There's just no way to make all those things work with DOM!
        LocatorImpl loc = new LocatorImpl();
        loc.setSystemId(systemId);
        scanner.setLocator(loc);

        scanner.setContentHandler(getParserHandler(systemId));
        scanner.scan(element);
    } catch (SAXException e) {
        // since parsing DOM shouldn't cause a SAX exception
        // and our handler will never throw it, it's not clear
        // if this will ever happen.
        fatalError(new SAXParseException2(
            e.getMessage(), null, systemId,-1,-1, e));
    }
}
 
Example #9
Source File: UnmarshallerImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public final Object unmarshal0( Node node, JaxBeanInfo expectedType ) throws JAXBException {
    try {
        final DOMScanner scanner = new DOMScanner();

        InterningXmlVisitor handler = new InterningXmlVisitor(createUnmarshallerHandler(null,false,expectedType));
        scanner.setContentHandler(new SAXConnector(handler,scanner));

        if(node.getNodeType() == Node.ELEMENT_NODE) {
            scanner.scan((Element)node);
        } else if(node.getNodeType() == Node.DOCUMENT_NODE) {
            scanner.scan((Document)node);
        } else {
            throw new IllegalArgumentException("Unexpected node type: "+node);
        }

        Object retVal = handler.getContext().getResult();
        handler.getContext().clearResult();
        return retVal;
    } catch( SAXException e ) {
        throw createUnmarshalException(e);
    }
}
 
Example #10
Source File: SchemaCompilerImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public void parseSchema( String systemId, Element element ) {
    checkAbsoluteness(systemId);
    try {
        DOMScanner scanner = new DOMScanner();

        // use a locator that sets the system ID correctly
        // so that we can resolve relative URLs in most of the case.
        // it still doesn't handle xml:base and XInclude and all those things
        // correctly. There's just no way to make all those things work with DOM!
        LocatorImpl loc = new LocatorImpl();
        loc.setSystemId(systemId);
        scanner.setLocator(loc);

        scanner.setContentHandler(getParserHandler(systemId));
        scanner.scan(element);
    } catch (SAXException e) {
        // since parsing DOM shouldn't cause a SAX exception
        // and our handler will never throw it, it's not clear
        // if this will ever happen.
        fatalError(new SAXParseException2(
            e.getMessage(), null, systemId,-1,-1, e));
    }
}
 
Example #11
Source File: UnmarshallerImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public final Object unmarshal0( Node node, JaxBeanInfo expectedType ) throws JAXBException {
    try {
        final DOMScanner scanner = new DOMScanner();

        InterningXmlVisitor handler = new InterningXmlVisitor(createUnmarshallerHandler(null,false,expectedType));
        scanner.setContentHandler(new SAXConnector(handler,scanner));

        if(node.getNodeType() == Node.ELEMENT_NODE) {
            scanner.scan((Element)node);
        } else if(node.getNodeType() == Node.DOCUMENT_NODE) {
            scanner.scan((Document)node);
        } else {
            throw new IllegalArgumentException("Unexpected node type: "+node);
        }

        Object retVal = handler.getContext().getResult();
        handler.getContext().clearResult();
        return retVal;
    } catch( SAXException e ) {
        throw createUnmarshalException(e);
    }
}
 
Example #12
Source File: SchemaCompilerImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void parseSchema( String systemId, Element element ) {
    checkAbsoluteness(systemId);
    try {
        DOMScanner scanner = new DOMScanner();

        // use a locator that sets the system ID correctly
        // so that we can resolve relative URLs in most of the case.
        // it still doesn't handle xml:base and XInclude and all those things
        // correctly. There's just no way to make all those things work with DOM!
        LocatorImpl loc = new LocatorImpl();
        loc.setSystemId(systemId);
        scanner.setLocator(loc);

        scanner.setContentHandler(getParserHandler(systemId));
        scanner.scan(element);
    } catch (SAXException e) {
        // since parsing DOM shouldn't cause a SAX exception
        // and our handler will never throw it, it's not clear
        // if this will ever happen.
        fatalError(new SAXParseException2(
            e.getMessage(), null, systemId,-1,-1, e));
    }
}
 
Example #13
Source File: SchemaCompilerImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public void parseSchema( String systemId, Element element ) {
    checkAbsoluteness(systemId);
    try {
        DOMScanner scanner = new DOMScanner();

        // use a locator that sets the system ID correctly
        // so that we can resolve relative URLs in most of the case.
        // it still doesn't handle xml:base and XInclude and all those things
        // correctly. There's just no way to make all those things work with DOM!
        LocatorImpl loc = new LocatorImpl();
        loc.setSystemId(systemId);
        scanner.setLocator(loc);

        scanner.setContentHandler(getParserHandler(systemId));
        scanner.scan(element);
    } catch (SAXException e) {
        // since parsing DOM shouldn't cause a SAX exception
        // and our handler will never throw it, it's not clear
        // if this will ever happen.
        fatalError(new SAXParseException2(
            e.getMessage(), null, systemId,-1,-1, e));
    }
}
 
Example #14
Source File: SchemaCompilerImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public void parseSchema( String systemId, Element element ) {
    checkAbsoluteness(systemId);
    try {
        DOMScanner scanner = new DOMScanner();

        // use a locator that sets the system ID correctly
        // so that we can resolve relative URLs in most of the case.
        // it still doesn't handle xml:base and XInclude and all those things
        // correctly. There's just no way to make all those things work with DOM!
        LocatorImpl loc = new LocatorImpl();
        loc.setSystemId(systemId);
        scanner.setLocator(loc);

        scanner.setContentHandler(getParserHandler(systemId));
        scanner.scan(element);
    } catch (SAXException e) {
        // since parsing DOM shouldn't cause a SAX exception
        // and our handler will never throw it, it's not clear
        // if this will ever happen.
        fatalError(new SAXParseException2(
            e.getMessage(), null, systemId,-1,-1, e));
    }
}
 
Example #15
Source File: UnmarshallerImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public final Object unmarshal0( Node node, JaxBeanInfo expectedType ) throws JAXBException {
    try {
        final DOMScanner scanner = new DOMScanner();

        InterningXmlVisitor handler = new InterningXmlVisitor(createUnmarshallerHandler(null,false,expectedType));
        scanner.setContentHandler(new SAXConnector(handler,scanner));

        if(node.getNodeType() == Node.ELEMENT_NODE) {
            scanner.scan((Element)node);
        } else if(node.getNodeType() == Node.DOCUMENT_NODE) {
            scanner.scan((Document)node);
        } else {
            throw new IllegalArgumentException("Unexpected node type: "+node);
        }

        Object retVal = handler.getContext().getResult();
        handler.getContext().clearResult();
        return retVal;
    } catch( SAXException e ) {
        throw createUnmarshalException(e);
    }
}
 
Example #16
Source File: UnmarshallerImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public final Object unmarshal0( Node node, JaxBeanInfo expectedType ) throws JAXBException {
    try {
        final DOMScanner scanner = new DOMScanner();

        InterningXmlVisitor handler = new InterningXmlVisitor(createUnmarshallerHandler(null,false,expectedType));
        scanner.setContentHandler(new SAXConnector(handler,scanner));

        if(node.getNodeType() == Node.ELEMENT_NODE) {
            scanner.scan((Element)node);
        } else if(node.getNodeType() == Node.DOCUMENT_NODE) {
            scanner.scan((Document)node);
        } else {
            throw new IllegalArgumentException("Unexpected node type: "+node);
        }

        Object retVal = handler.getContext().getResult();
        handler.getContext().clearResult();
        return retVal;
    } catch( SAXException e ) {
        throw createUnmarshalException(e);
    }
}
 
Example #17
Source File: DOMForestScanner.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates the whole set of SAX events by treating
 * element e as if it's a root element.
 */
public void scan( Element e, ContentHandler contentHandler ) throws SAXException {
    DOMScanner scanner = new DOMScanner();

    // insert the location resolver into the pipe line
    LocationResolver resolver = new LocationResolver(scanner);
    resolver.setContentHandler(contentHandler);

    // parse this DOM.
    scanner.setContentHandler(resolver);
    scanner.scan(e);
}
 
Example #18
Source File: DOMForestScanner.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates the whole set of SAX events by treating
 * element e as if it's a root element.
 */
public void scan( Element e, ContentHandler contentHandler ) throws SAXException {
    DOMScanner scanner = new DOMScanner();

    // insert the location resolver into the pipe line
    LocationResolver resolver = new LocationResolver(scanner);
    resolver.setContentHandler(contentHandler);

    // parse this DOM.
    scanner.setContentHandler(resolver);
    scanner.scan(e);
}
 
Example #19
Source File: DOMForestScanner.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates the whole set of SAX events by treating
 * element e as if it's a root element.
 */
public void scan( Element e, ContentHandler contentHandler ) throws SAXException {
    DOMScanner scanner = new DOMScanner();

    // insert the location resolver into the pipe line
    LocationResolver resolver = new LocationResolver(scanner);
    resolver.setContentHandler(contentHandler);

    // parse this DOM.
    scanner.setContentHandler(resolver);
    scanner.scan(e);
}
 
Example #20
Source File: SAAJMessage.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void writeTo(ContentHandler contentHandler, ErrorHandler errorHandler) throws SAXException {
    String soapNsUri = soapVersion.nsUri;
    if (!parsedMessage) {
        DOMScanner ds = new DOMScanner();
        ds.setContentHandler(contentHandler);
        ds.scan(sm.getSOAPPart());
    } else {
        contentHandler.setDocumentLocator(NULL_LOCATOR);
        contentHandler.startDocument();
        contentHandler.startPrefixMapping("S", soapNsUri);
        startPrefixMapping(contentHandler, envelopeAttrs,"S");
        contentHandler.startElement(soapNsUri, "Envelope", "S:Envelope", getAttributes(envelopeAttrs));
        if (hasHeaders()) {
            startPrefixMapping(contentHandler, headerAttrs,"S");
            contentHandler.startElement(soapNsUri, "Header", "S:Header", getAttributes(headerAttrs));
            MessageHeaders headers = getHeaders();
            for (Header h : headers.asList()) {
                h.writeTo(contentHandler, errorHandler);
            }
            endPrefixMapping(contentHandler, headerAttrs,"S");
            contentHandler.endElement(soapNsUri, "Header", "S:Header");

        }
        startPrefixMapping(contentHandler, bodyAttrs,"S");
        // write the body
        contentHandler.startElement(soapNsUri, "Body", "S:Body", getAttributes(bodyAttrs));
        writePayloadTo(contentHandler, errorHandler, true);
        endPrefixMapping(contentHandler, bodyAttrs,"S");
        contentHandler.endElement(soapNsUri, "Body", "S:Body");
        endPrefixMapping(contentHandler, envelopeAttrs,"S");
        contentHandler.endElement(soapNsUri, "Envelope", "S:Envelope");
    }
}
 
Example #21
Source File: DOMForestScanner.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates the whole set of SAX events by treating
 * element e as if it's a root element.
 */
public void scan( Element e, ContentHandler contentHandler ) throws SAXException {
    DOMScanner scanner = new DOMScanner();

    // insert the location resolver into the pipe line
    LocationResolver resolver = new LocationResolver(scanner);
    resolver.setContentHandler(contentHandler);

    // parse this DOM.
    scanner.setContentHandler(resolver);
    scanner.scan(e);
}
 
Example #22
Source File: DOMForestScanner.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates the whole set of SAX events by treating
 * element e as if it's a root element.
 */
public void scan( Element e, ContentHandler contentHandler ) throws SAXException {
    DOMScanner scanner = new DOMScanner();

    // insert the location resolver into the pipe line
    LocationResolver resolver = new LocationResolver(scanner);
    resolver.setContentHandler(contentHandler);

    // parse this DOM.
    scanner.setContentHandler(resolver);
    scanner.scan(e);
}
 
Example #23
Source File: DOMForestScanner.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates the whole set of SAX events by treating
 * element e as if it's a root element.
 */
public void scan( Element e, ContentHandler contentHandler ) throws SAXException {
    DOMScanner scanner = new DOMScanner();

    // insert the location resolver into the pipe line
    LocationResolver resolver = new LocationResolver(scanner);
    resolver.setContentHandler(contentHandler);

    // parse this DOM.
    scanner.setContentHandler(resolver);
    scanner.scan(e);
}
 
Example #24
Source File: DOMForestScanner.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates the whole set of SAX events by treating
 * element e as if it's a root element.
 */
public void scan( Element e, ContentHandler contentHandler ) throws SAXException {
    DOMScanner scanner = new DOMScanner();

    // insert the location resolver into the pipe line
    LocationResolver resolver = new LocationResolver(scanner);
    resolver.setContentHandler(contentHandler);

    // parse this DOM.
    scanner.setContentHandler(resolver);
    scanner.scan(e);
}
 
Example #25
Source File: SAAJMessage.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void writeTo(ContentHandler contentHandler, ErrorHandler errorHandler) throws SAXException {
    String soapNsUri = soapVersion.nsUri;
    if (!parsedMessage) {
        DOMScanner ds = new DOMScanner();
        ds.setContentHandler(contentHandler);
        ds.scan(sm.getSOAPPart());
    } else {
        contentHandler.setDocumentLocator(NULL_LOCATOR);
        contentHandler.startDocument();
        contentHandler.startPrefixMapping("S", soapNsUri);
        startPrefixMapping(contentHandler, envelopeAttrs,"S");
        contentHandler.startElement(soapNsUri, "Envelope", "S:Envelope", getAttributes(envelopeAttrs));
        if (hasHeaders()) {
            startPrefixMapping(contentHandler, headerAttrs,"S");
            contentHandler.startElement(soapNsUri, "Header", "S:Header", getAttributes(headerAttrs));
            MessageHeaders headers = getHeaders();
            for (Header h : headers.asList()) {
                h.writeTo(contentHandler, errorHandler);
            }
            endPrefixMapping(contentHandler, headerAttrs,"S");
            contentHandler.endElement(soapNsUri, "Header", "S:Header");

        }
        startPrefixMapping(contentHandler, bodyAttrs,"S");
        // write the body
        contentHandler.startElement(soapNsUri, "Body", "S:Body", getAttributes(bodyAttrs));
        writePayloadTo(contentHandler, errorHandler, true);
        endPrefixMapping(contentHandler, bodyAttrs,"S");
        contentHandler.endElement(soapNsUri, "Body", "S:Body");
        endPrefixMapping(contentHandler, envelopeAttrs,"S");
        contentHandler.endElement(soapNsUri, "Envelope", "S:Envelope");
    }
}
 
Example #26
Source File: SAAJMessage.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void writeTo(ContentHandler contentHandler, ErrorHandler errorHandler) throws SAXException {
    String soapNsUri = soapVersion.nsUri;
    if (!parsedMessage) {
        DOMScanner ds = new DOMScanner();
        ds.setContentHandler(contentHandler);
        ds.scan(sm.getSOAPPart());
    } else {
        contentHandler.setDocumentLocator(NULL_LOCATOR);
        contentHandler.startDocument();
        contentHandler.startPrefixMapping("S", soapNsUri);
        startPrefixMapping(contentHandler, envelopeAttrs,"S");
        contentHandler.startElement(soapNsUri, "Envelope", "S:Envelope", getAttributes(envelopeAttrs));
        if (hasHeaders()) {
            startPrefixMapping(contentHandler, headerAttrs,"S");
            contentHandler.startElement(soapNsUri, "Header", "S:Header", getAttributes(headerAttrs));
            MessageHeaders headers = getHeaders();
            for (Header h : headers.asList()) {
                h.writeTo(contentHandler, errorHandler);
            }
            endPrefixMapping(contentHandler, headerAttrs,"S");
            contentHandler.endElement(soapNsUri, "Header", "S:Header");

        }
        startPrefixMapping(contentHandler, bodyAttrs,"S");
        // write the body
        contentHandler.startElement(soapNsUri, "Body", "S:Body", getAttributes(bodyAttrs));
        writePayloadTo(contentHandler, errorHandler, true);
        endPrefixMapping(contentHandler, bodyAttrs,"S");
        contentHandler.endElement(soapNsUri, "Body", "S:Body");
        endPrefixMapping(contentHandler, envelopeAttrs,"S");
        contentHandler.endElement(soapNsUri, "Envelope", "S:Envelope");
    }
}
 
Example #27
Source File: DOMForestScanner.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates the whole set of SAX events by treating
 * element e as if it's a root element.
 */
public void scan( Element e, ContentHandler contentHandler ) throws SAXException {
    DOMScanner scanner = new DOMScanner();

    // insert the location resolver into the pipe line
    LocationResolver resolver = new LocationResolver(scanner);
    resolver.setContentHandler(contentHandler);

    // parse this DOM.
    scanner.setContentHandler(resolver);
    scanner.scan(e);
}
 
Example #28
Source File: DOMForestScanner.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates the whole set of SAX events by treating
 * element e as if it's a root element.
 */
public void scan( Element e, ContentHandler contentHandler ) throws SAXException {
    DOMScanner scanner = new DOMScanner();

    // insert the location resolver into the pipe line
    LocationResolver resolver = new LocationResolver(scanner);
    resolver.setContentHandler(contentHandler);

    // parse this DOM.
    scanner.setContentHandler(resolver);
    scanner.scan(e);
}
 
Example #29
Source File: SAAJMessage.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void writeTo(ContentHandler contentHandler, ErrorHandler errorHandler) throws SAXException {
    String soapNsUri = soapVersion.nsUri;
    if (!parsedMessage) {
        DOMScanner ds = new DOMScanner();
        ds.setContentHandler(contentHandler);
        ds.scan(sm.getSOAPPart());
    } else {
        contentHandler.setDocumentLocator(NULL_LOCATOR);
        contentHandler.startDocument();
        contentHandler.startPrefixMapping("S", soapNsUri);
        startPrefixMapping(contentHandler, envelopeAttrs,"S");
        contentHandler.startElement(soapNsUri, "Envelope", "S:Envelope", getAttributes(envelopeAttrs));
        if (hasHeaders()) {
            startPrefixMapping(contentHandler, headerAttrs,"S");
            contentHandler.startElement(soapNsUri, "Header", "S:Header", getAttributes(headerAttrs));
            MessageHeaders headers = getHeaders();
            for (Header h : headers.asList()) {
                h.writeTo(contentHandler, errorHandler);
            }
            endPrefixMapping(contentHandler, headerAttrs,"S");
            contentHandler.endElement(soapNsUri, "Header", "S:Header");

        }
        startPrefixMapping(contentHandler, bodyAttrs,"S");
        // write the body
        contentHandler.startElement(soapNsUri, "Body", "S:Body", getAttributes(bodyAttrs));
        writePayloadTo(contentHandler, errorHandler, true);
        endPrefixMapping(contentHandler, bodyAttrs,"S");
        contentHandler.endElement(soapNsUri, "Body", "S:Body");
        endPrefixMapping(contentHandler, envelopeAttrs,"S");
        contentHandler.endElement(soapNsUri, "Envelope", "S:Envelope");
    }
}
 
Example #30
Source File: DOMForestScanner.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates the whole set of SAX events by treating
 * element e as if it's a root element.
 */
public void scan( Element e, ContentHandler contentHandler ) throws SAXException {
    DOMScanner scanner = new DOMScanner();

    // insert the location resolver into the pipe line
    LocationResolver resolver = new LocationResolver(scanner);
    resolver.setContentHandler(contentHandler);

    // parse this DOM.
    scanner.setContentHandler(resolver);
    scanner.scan(e);
}