Examples of StreamResult


Examples of javax.xml.transform.stream.StreamResult

    PipedOutputStream out = new PipedOutputStream(pipe);

    try {
      parse(pipe, baseURI, latch);

      transformer.transform(source, new StreamResult(out));
    }
    catch (TransformerException e) {
      handleException();
      throw new RDFParseException(e);
    }
View Full Code Here

Examples of javax.xml.transform.stream.StreamResult

      }
      else {
         try {
            StreamSource xmlStreamSource = new StreamSource(new StringReader(xmlLiteral));
            StringWriter stringWriter = new StringWriter();
            StreamResult resultStream = new StreamResult(stringWriter);
            this.transformer.transform(xmlStreamSource, resultStream);
            return stringWriter.toString();
         }
         catch (TransformerException ex) {
            throw new XmlBlasterException(this.glob, ErrorCode.RESOURCE_CONFIGURATION, "XslTransformer", "An exception occured when transforming '" + xmlLiteral + "'", ex);
View Full Code Here

Examples of mf.javax.xml.transform.stream.StreamResult

    public void validate(Source source, Result result)
        throws SAXException, IOException {
        if (result instanceof StreamResult || result == null) {
            final StreamSource streamSource = (StreamSource) source;
            final StreamResult streamResult = (StreamResult) result;
            XMLInputSource input = new XMLInputSource(streamSource.getPublicId(), streamSource.getSystemId(), null);
            input.setByteStream(streamSource.getInputStream());
            input.setCharacterStream(streamSource.getReader());
           
            // Gets the parser configuration. We'll create and initialize a new one, if we
            // haven't created one before or if the previous one was garbage collected.
            boolean newConfig = false;
            XMLParserConfiguration config = (XMLParserConfiguration) fConfiguration.get();
            if (config == null) {
                config = initialize();
                newConfig = true;
            }
            // If settings have changed on the component manager, refresh the error handler and entity resolver.
            else if (fComponentManager.getFeature(PARSER_SETTINGS)) {
                config.setProperty(ENTITY_RESOLVER, fComponentManager.getProperty(ENTITY_RESOLVER));
                config.setProperty(ERROR_HANDLER, fComponentManager.getProperty(ERROR_HANDLER));
                config.setProperty(SECURITY_MANAGER, fComponentManager.getProperty(SECURITY_MANAGER));
            }
           
            // prepare for parse
            fComponentManager.reset();
           
            if (streamResult != null) {
                if (fSerializerFactory == null) {
                    fSerializerFactory = SerializerFactory.getSerializerFactory(Method.XML);
                }

                // there doesn't seem to be a way to reset a serializer, so we need to make
                // a new one each time.
                Serializer ser;
                if (streamResult.getWriter() != null) {
                    ser = fSerializerFactory.makeSerializer(streamResult.getWriter(), new OutputFormat());
                }
                else if (streamResult.getOutputStream() != null) {
                    ser = fSerializerFactory.makeSerializer(streamResult.getOutputStream(), new OutputFormat());
                }
                else if (streamResult.getSystemId() != null) {
                    String uri = streamResult.getSystemId();
                    OutputStream out = XMLEntityManager.createOutputStream(uri);
                    ser = fSerializerFactory.makeSerializer(out, new OutputFormat());
                }
                else {
                    throw new IllegalArgumentException(JAXPValidationMessageFormatter.formatMessage(fComponentManager.getLocale(),
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.