Package javax.xml.transform.sax

Examples of javax.xml.transform.sax.SAXSource


     */
    @SuppressWarnings("unchecked")
    protected <T extends Source>T createSAXSource(
            Class<T> sourceClass) throws SQLException {

        SAXSource source = null;

        try {
            source = (sourceClass == null) ? new SAXSource()
                    : (SAXSource) sourceClass.newInstance();
        } catch (SecurityException ex) {
            throw Exceptions.sourceInstantiation(ex);
        } catch (InstantiationException ex) {
            throw Exceptions.sourceInstantiation(ex);
        } catch (IllegalAccessException ex) {
            throw Exceptions.sourceInstantiation(ex);
        } catch (ClassCastException ex) {
            throw Exceptions.sourceInstantiation(ex);
        }

        Reader      reader      = getCharacterStreamImpl();
        InputSource inputSource = new InputSource(reader);

        source.setInputSource(inputSource);

        return (T) source;
    }
View Full Code Here


            response.setCharacterEncoding(preferredEncoding);
        }

        // Create the trasformation source using our custom ObjectInputSource
        InputSource inputSource = new ObjectInputSource(object);
        Source source = new SAXSource(saxReader, inputSource);

        // Create the trasformation result
        // Result result = new StreamResult(response.getWriter());
        Result result = new StreamResult(response.getOutputStream());
View Full Code Here

        t.setOutputProperty(OutputKeys.ENCODING, response
                .getCharacterEncoding());

        // Create the trasformation source using our custom ObjectInputSource
        InputSource inputSource = new ObjectInputSource(object);
        Source source = new SAXSource(saxReader, inputSource);

        // Create the trasformation result
        // Result result = new StreamResult(response.getWriter());
        Result result = new StreamResult(response.getOutputStream());
View Full Code Here

        InputSource inputSource = new ObjectInputSource(throwable);

        // Create the sax "parser".
        ObjectXMLReader saxReader = new ErrorRequestXMLReader();

        Source source = new SAXSource(saxReader, inputSource);

        // Create the trasformation result
        Result result = new StreamResult(response.getWriter());
        // Result result = new StreamResult(response.getOutputStream());
View Full Code Here

    TransformerFactory tfactory = TransformerFactory.newInstance();
    XMLReader reader;
    try {
      reader = XMLReaderFactory.createXMLReader();
      reader.setEntityResolver(er);
      Source xsltsource = new SAXSource(reader, new InputSource(new StringReader(replacedOutput)));
      this.transformer = tfactory.newTransformer(xsltsource);
    } catch (SAXException e) {
      throw new OLATRuntimeException("Could not initialize transformer!", e);
    } catch (TransformerConfigurationException e) {
      throw new OLATRuntimeException("Could not initialize transformer (wrong config)!", e);
View Full Code Here

            /* Caller still has access to stream/reader; no need to
             * force auto-close-input
             */
            autoCloseInput = cfg.willAutoCloseInput();
        } else if (src instanceof SAXSource) {
            SAXSource ss = (SAXSource) src;
            /* 28-Jan-2006, TSa: Not a complete implementation, but maybe
             *   even this might help...
             */
            sysId = ss.getSystemId();
            InputSource isrc = ss.getInputSource();
            if (isrc != null) {
                encoding = isrc.getEncoding();
                in = isrc.getByteStream();
                if (in == null) {
                    r = isrc.getCharacterStream();
View Full Code Here

    return null;
  }
 
  private static Schema getSchemaFromStream(final InputStream is, final String location) {
    try {
      Schema s = SF.newSchema(new SAXSource(new InputSource(is)));
      if (s != null) {
        LOGGER.info("Successfully loaded schema at: " + location); //$NON-NLS-1$
      } else {
        LOGGER.severe("Schema failed to load: " + location); //$NON-NLS-1$
      }
View Full Code Here

        return parseStringDocument(string, source.getSystemId());
      else
        return new QDocument();
    }
    else if (source instanceof SAXSource) {
      SAXSource saxSource = (SAXSource) source;
     
      XMLReader reader = saxSource.getXMLReader();

      if (reader == null)
        return new QDocument();
     
      InputSource inputSource = saxSource.getInputSource();

      Document doc = new QDocument();
      DOMBuilder builder = new DOMBuilder();
      builder.init(doc);
      reader.setContentHandler(builder);
View Full Code Here

                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)
              {
View Full Code Here

        SOAPService service = new SOAPService(wsdl, SERVICE_NAME);
        assertNotNull(service);

        InputStream is = getClass().getResourceAsStream("resources/GreetMeDocLiteralReq.xml");
        InputSource inputSource = new InputSource(is);
        SAXSource saxSourceReq = new SAXSource(inputSource);
        assertNotNull(saxSourceReq);

        Dispatch<SAXSource> disp = service.createDispatch(PORT_NAME, SAXSource.class, Service.Mode.MESSAGE);
        disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
                                     "http://localhost:"
                                     + greeterPort
                                     + "/SOAPDispatchService/SoapDispatchPort");
        SAXSource saxSourceResp = disp.invoke(saxSourceReq);
        assertNotNull(saxSourceResp);
        String expected = "Hello TestSOAPInputMessage";
        assertTrue("Expected: " + expected, XMLUtils.toString(saxSourceResp).contains(expected));

        // Test oneway
        InputStream is1 = getClass().getResourceAsStream("resources/GreetMeDocLiteralReq1.xml");
        InputSource inputSource1 = new InputSource(is1);
        SAXSource saxSourceReq1 = new SAXSource(inputSource1);
        assertNotNull(saxSourceReq1);
        disp.invokeOneWay(saxSourceReq1);

        // Test async polling
        InputStream is2 = getClass().getResourceAsStream("resources/GreetMeDocLiteralReq2.xml");
        InputSource inputSource2 = new InputSource(is2);
        SAXSource saxSourceReq2 = new SAXSource(inputSource2);
        assertNotNull(saxSourceReq2);

        Response<SAXSource> response = disp.invokeAsync(saxSourceReq2);
        SAXSource saxSourceResp2 = response.get();
        assertNotNull(saxSourceResp2);
        String expected2 = "Hello TestSOAPInputMessage2";
        assertTrue("Expected: " + expected, XMLUtils.toString(saxSourceResp2).contains(expected2));

        // Test async callback
        InputStream is3 = getClass().getResourceAsStream("resources/GreetMeDocLiteralReq3.xml");
        InputSource inputSource3 = new InputSource(is3);
        SAXSource saxSourceReq3 = new SAXSource(inputSource3);
        assertNotNull(saxSourceReq3);
        TestSAXSourceHandler tssh = new TestSAXSourceHandler();
        Future<?> fd = disp.invokeAsync(saxSourceReq3, tssh);
        assertNotNull(fd);
        waitForFuture(fd);

        String expected3 = "Hello TestSOAPInputMessage3";
        SAXSource saxSourceResp3 = tssh.getSAXSource();
        assertNotNull(saxSourceResp3);
        assertTrue("Expected: " + expected, XMLUtils.toString(saxSourceResp3).contains(expected3));
    }
View Full Code Here

TOP

Related Classes of javax.xml.transform.sax.SAXSource

Copyright © 2018 www.massapicom. 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.