Examples of SAXResult


Examples of javax.xml.transform.sax.SAXResult

        renderer.setUserAgent(userAgent);

        userAgent.setRendererOverride(renderer);
       
        Fop fop = fopFactory.newFop(MimeConstants.MIME_FOP_AREA_TREE, userAgent);
        Result res = new SAXResult(fop.getDefaultHandler());
        transformer.transform(src, res);
       
        return (Document)domResult.getNode();
    }
View Full Code Here

Examples of javax.xml.transform.sax.SAXResult

            throws Exception {
        ByteArrayOutputStream baout = new ByteArrayOutputStream();
        Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, ua, baout);
        Transformer transformer = tFactory.newTransformer();
        Source src = new StreamSource(foFile);
        SAXResult res = new SAXResult(fop.getDefaultHandler());
        transformer.transform(src, res);
        final byte[] result = baout.toByteArray();
        if (dumpPdfFile) {
            final File outFile = new File(foFile.getParentFile(), foFile.getName() + ".pdf");
            FileUtils.writeByteArrayToFile(outFile, result);
View Full Code Here

Examples of javax.xml.transform.sax.SAXResult

        //Setup FOP
        Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);

        //Make sure the XSL transformation's result is piped through to FOP
        Result res = new SAXResult(fop.getDefaultHandler());

        //Start the transformation and rendering process
        transformer.transform(src, res);

        //Return the result
View Full Code Here

Examples of javax.xml.transform.sax.SAXResult

  // Return the content handler for this Result object
  try {
      // Result object could be SAXResult, DOMResult, or StreamResult
      if (result instanceof SAXResult) {
                final SAXResult target = (SAXResult)result;
                final ContentHandler handler = target.getHandler();

    _tohFactory.setHandler(handler);

                /**
                 * Fix for bug 24414
                 * If the lexicalHandler is set then we need to get that
                 * for obtaining the lexical information
                 */
                LexicalHandler lexicalHandler = target.getLexicalHandler();

                if (lexicalHandler != null ) {
        _tohFactory.setLexicalHandler(lexicalHandler);
    }

    _tohFactory.setOutputType(TransletOutputHandlerFactory.SAX);
    return _tohFactory.getSerializationHandler();
            }
      else if (result instanceof DOMResult) {
    _tohFactory.setNode(((DOMResult) result).getNode());
    _tohFactory.setNextSibling(((DOMResult) result).getNextSibling());
    _tohFactory.setOutputType(TransletOutputHandlerFactory.DOM);
    return _tohFactory.getSerializationHandler();
            }
      else if (result instanceof StreamResult) {
    // Get StreamResult
    final StreamResult target = (StreamResult) result; 

    // StreamResult may have been created with a java.io.File,
    // java.io.Writer, java.io.OutputStream or just a String
    // systemId.

    _tohFactory.setOutputType(TransletOutputHandlerFactory.STREAM);

    // try to get a Writer from Result object
    final Writer writer = target.getWriter();
    if (writer != null) {
        _tohFactory.setWriter(writer);
        return _tohFactory.getSerializationHandler();
    }

    // or try to get an OutputStream from Result object
    final OutputStream ostream = target.getOutputStream();
    if (ostream != null) {
        _tohFactory.setOutputStream(ostream);
        return _tohFactory.getSerializationHandler();
    }

View Full Code Here

Examples of javax.xml.transform.sax.SAXResult

                              (OutputProperties.getDefaultMethodProperties("xml"));
      serializer.setOutputStream(fos);
  
     
      // Set the result handling to be a serialization to the file output stream.
      Result result = new SAXResult(serializer.asContentHandler());
      handler.setResult(result);
     
      // Parse the XML input document.
      reader.parse("birds.xml");
     
View Full Code Here

Examples of javax.xml.transform.sax.SAXResult

        try {
            TransformerFactory factory = TransformerFactory.newInstance();
            transformer = factory.newTransformer();
            parser = new HTMLParser();
            result = new SAXResult(new DefaultHandler());
        } catch (TransformerConfigurationException e) {
            throw new RepositoryException(e);
        } catch (TransformerFactoryConfigurationError e) {
            throw new RepositoryException(e);
        }
View Full Code Here

Examples of javax.xml.transform.sax.SAXResult

      // Create an XMLReader.
      XMLReader reader = XMLReaderFactory.createXMLReader();
      reader.setContentHandler(tHandler1);
      reader.setProperty("http://xml.org/sax/properties/lexical-handler", tHandler1);

      tHandler1.setResult(new SAXResult(tHandler2));
      tHandler2.setResult(new SAXResult(tHandler3));

      // transformer3 outputs SAX events to the serializer.
      Serializer serializer = SerializerFactory.getSerializer
                                   (OutputProperties.getDefaultMethodProperties("xml"));       
      serializer.setOutputStream(System.out);
      tHandler3.setResult(new SAXResult(serializer.asContentHandler()));

      // Parse the XML input document. The input ContentHandler and output ContentHandler
      // work in separate threads to optimize performance.  
      reader.parse("foo.xml");
    }
View Full Code Here

Examples of javax.xml.transform.sax.SAXResult

  // Return the content handler for this Result object
  try {
      // Result object could be SAXResult, DOMResult, or StreamResult
      if (result instanceof SAXResult) {
                final SAXResult target = (SAXResult)result;
                final ContentHandler handler = target.getHandler();

    _tohFactory.setHandler(handler);
    if (handler instanceof LexicalHandler) {
        _tohFactory.setLexicalHandler((LexicalHandler) handler);
    }
    _tohFactory.setOutputType(TransletOutputHandlerFactory.SAX);
    return _tohFactory.getTransletOutputHandler();
            }
      else if (result instanceof DOMResult) {
    _tohFactory.setNode(((DOMResult) result).getNode());
    _tohFactory.setOutputType(TransletOutputHandlerFactory.DOM);
    return _tohFactory.getTransletOutputHandler();
            }
      else if (result instanceof StreamResult) {
    // Get StreamResult
    final StreamResult target = (StreamResult) result; 

    // StreamResult may have been created with a java.io.File,
    // java.io.Writer, java.io.OutputStream or just a String
    // systemId.

    _tohFactory.setOutputType(TransletOutputHandlerFactory.STREAM);

    // try to get a Writer from Result object
    final Writer writer = target.getWriter();
    if (writer != null) {
        _tohFactory.setWriter(writer);
        return _tohFactory.getTransletOutputHandler();
    }

    // or try to get an OutputStream from Result object
    final OutputStream ostream = target.getOutputStream();
    if (ostream != null) {
        _tohFactory.setOutputStream(ostream);
        return _tohFactory.getTransletOutputHandler();
    }
View Full Code Here

Examples of javax.xml.transform.sax.SAXResult

                  return unmarshal(streamSource.getSystemId());
              }
          } else {
            XMLUnmarshallerHandler handler = this.xmlUnmarshaller.getUnmarshallerHandler();
            XMLTransformer transformer = XMLPlatformFactory.getInstance().getXMLPlatform().newXMLTransformer();
            SAXResult result = new SAXResult(handler);
            transformer.transform(source, result);
            return handler.getResult();         
          }
      }finally {
          xmlUnmarshaller.getStringBuffer().reset();
View Full Code Here

Examples of javax.xml.transform.sax.SAXResult

      Transformer serializer = tf.newTransformer();
      serializer.setOutputProperty(OutputKeys.ENCODING, "UTF8");
      serializer.setOutputProperty(OutputKeys.INDENT, "yes");

      // Transform -> SAX event stream
      SAXResult saxResult = new SAXResult(new NoKernelNamespaceSAXFilter(hd));

      // DOM -> Transform
      serializer.transform(new DOMSource(doc), saxResult);

      // Reuse the parsed document
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.