Examples of SAXResult


Examples of javax.xml.transform.sax.SAXResult

            throws SAXException, RepositoryException {
        try {
            byte[] xml = remote.exportDocumentView(path, binaryAsLink, noRecurse);

            Source source = new StreamSource(new ByteArrayInputStream(xml));
            Result result = new SAXResult(handler);

            TransformerFactory factory = TransformerFactory.newInstance();
            Transformer transformer = factory.newTransformer();
            transformer.transform(source, result);
        } catch (RemoteException ex) {
View Full Code Here

Examples of javax.xml.transform.sax.SAXResult

                ContentHandler handler =
                    SerializingContentHandler.getSerializer(writer);
                TransformerFactory factory = TransformerFactory.newInstance();
                Transformer transformer = factory.newTransformer();
                transformer.transform(
                        new DOMSource(doc), new SAXResult(handler));
                writer.flush();

                // TODO: Should this be application/xml? See JCR-1621
                httpResponse.setContentType(
                        "text/xml; charset=" + SerializingContentHandler.ENCODING);
View Full Code Here

Examples of javax.xml.transform.sax.SAXResult

              serializer.setOutputProperties(serializationProps);

              if (contentHandler != null)
              {
                SAXResult result = new SAXResult(contentHandler);

                serializer.transform(new DOMSource(outNode), result);
              }
              else
                serializer.transform(new DOMSource(outNode), strResult);
            }
            else if (flavor.equals("th"))
            {
              for (int i = 0; i < 1; i++) // Loop for diagnosing bugs with inconsistent behavior
              {
              // System.out.println("Testing the TransformerHandler...");

              // ===============
              XMLReader reader = null;

              // Use JAXP1.1 ( if possible )     
              try
              {
                javax.xml.parsers.SAXParserFactory factory =
                  javax.xml.parsers.SAXParserFactory.newInstance();

                factory.setNamespaceAware(true);

                javax.xml.parsers.SAXParser jaxpParser =
                  factory.newSAXParser();

                reader = jaxpParser.getXMLReader();
              }
              catch (javax.xml.parsers.ParserConfigurationException ex)
              {
                throw new org.xml.sax.SAXException(ex);
              }
              catch (javax.xml.parsers.FactoryConfigurationError ex1)
              {
                throw new org.xml.sax.SAXException(ex1.toString());
              }
              catch (NoSuchMethodError ex2){}
              catch (AbstractMethodError ame){}

              if (null == reader)
              {
                reader = XMLReaderFactory.createXMLReader();
              }
             
              if (!useXSLTC)
                stf.setAttribute(org.apache.xalan.processor.TransformerFactoryImpl.FEATURE_INCREMENTAL,
                   Boolean.TRUE);
                
              TransformerHandler th = stf.newTransformerHandler(stylesheet);
             
              reader.setContentHandler(th);
              reader.setDTDHandler(th);
             
              if(th instanceof org.xml.sax.ErrorHandler)
                reader.setErrorHandler((org.xml.sax.ErrorHandler)th);
             
              try
              {
                reader.setProperty(
                  "http://xml.org/sax/properties/lexical-handler", th);
              }
              catch (org.xml.sax.SAXNotRecognizedException e){}
              catch (org.xml.sax.SAXNotSupportedException e){}
              try
              {
                reader.setFeature("http://xml.org/sax/features/namespace-prefixes",
                                  true);
              } catch (org.xml.sax.SAXException se) {}
       
              th.setResult(strResult);
             
              reader.parse(new InputSource(inFileName));
              }                           
            }
            else
            {
              if (entityResolver != null)
              {
                XMLReader reader = null;

                // Use JAXP1.1 ( if possible )     
                try
                {
                  javax.xml.parsers.SAXParserFactory factory =
                    javax.xml.parsers.SAXParserFactory.newInstance();

                  factory.setNamespaceAware(true);

                  javax.xml.parsers.SAXParser jaxpParser =
                    factory.newSAXParser();

                  reader = jaxpParser.getXMLReader();
                }
                catch (javax.xml.parsers.ParserConfigurationException ex)
                {
                  throw new org.xml.sax.SAXException(ex);
                }
                catch (javax.xml.parsers.FactoryConfigurationError ex1)
                {
                  throw new org.xml.sax.SAXException(ex1.toString());
                }
                catch (NoSuchMethodError ex2){}
                catch (AbstractMethodError ame){}

                if (null == reader)
                {
                  reader = XMLReaderFactory.createXMLReader();
                }

                reader.setEntityResolver(entityResolver);

                if (contentHandler != null)
                {
                  SAXResult result = new SAXResult(contentHandler);

                  transformer.transform(
                    new SAXSource(reader, new InputSource(inFileName)),
                    result);
                }
                else
                {
                  transformer.transform(
                    new SAXSource(reader, new InputSource(inFileName)),
                    strResult);
                }
              }
              else if (contentHandler != null)
              {
                SAXResult result = new SAXResult(contentHandler);

                transformer.transform(new StreamSource(inFileName), result);
              }
              else
              {
View Full Code Here

Examples of javax.xml.transform.sax.SAXResult

        parse(new InputSource(systemId));
    }

    public void setContentHandler (ContentHandler handler)
    {
  _transformer.setResult(new SAXResult(handler));
  if (getParent() == null) {
                try {
                    createParent();
                }
                catch (SAXException  e) {
View Full Code Here

Examples of javax.xml.transform.sax.SAXResult

            for (Entry<String, Object> entry : map.entrySet()) {
                transformer.setParameter(entry.getKey(), entry.getValue());
            }
        }

        final SAXResult result = new SAXResult();
        result.setHandler(consumer);
        // According to TrAX specs, all TransformerHandlers are LexicalHandlers
        result.setLexicalHandler(consumer);
        transformerHandler.setResult(result);

        super.setXMLConsumer(new XMLConsumerAdapter(transformerHandler, transformerHandler));
    }
View Full Code Here

Examples of javax.xml.transform.sax.SAXResult

    public void testHandler() throws Exception {
        String content = "<Root xmlns='http://springframework.org/spring-ws/1' " +
                "xmlns:child='http://springframework.org/spring-ws/2'>" +
                "<child:Child attribute='value'>Content</child:Child></Root>";
        Source source = new StringSource(content);
        Result result = new SAXResult(handler);
        transformer.transform(source, result);
        Name rootName = envelope.createName("Root", "", "http://springframework.org/spring-ws/1");
        Iterator<?> iterator = envelope.getBody().getChildElements(rootName);
        Assert.assertTrue("No child found", iterator.hasNext());
        SOAPBodyElement rootElement = (SOAPBodyElement) iterator.next();
View Full Code Here

Examples of javax.xml.transform.sax.SAXResult

    @Override
    public final Source invoke(Source request) throws Exception {
        ContentHandler contentHandler = null;
        if (request != null) {
            contentHandler = createContentHandler();
            SAXResult result = new SAXResult(contentHandler);
            transform(request, result);
        }
        return getResponse(contentHandler);
    }
View Full Code Here

Examples of javax.xml.transform.sax.SAXResult

      // Setup input stream
      Source src = new StreamSource(in);

      // Resulting SAX events (the generated FO) must be piped through to FOP
      Result res = new SAXResult(fop.getDefaultHandler());

      // Start XSLT transformation and FOP processing
      transformer.transform(src, res);
     
     
View Full Code Here

Examples of javax.xml.transform.sax.SAXResult

                // Setup input stream
                Source src = new StreamSource(in);

                // Resulting SAX events (the generated FO) must be piped through to FOP
                Result res = new SAXResult(fop.getDefaultHandler());

                // Start XSLT transformation and FOP processing
                transformer.transform(src, res);
            }
        catch (FOPException e)
View Full Code Here

Examples of javax.xml.transform.sax.SAXResult

     * @throws TransformerException
     */
    public static final void parse(final InputStream file, final ContentHandler handler)
    throws TransformerException {
        final Transformer transformer = FACTORY.newTransformer();
        transformer.transform( new StreamSource( file ), new SAXResult( handler ) );
    }
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.