Package javax.xml.transform.stream

Examples of javax.xml.transform.stream.StreamSource


                dest.getSOAPPart().setContent(src);
            } else if (SAXSource.class.isAssignableFrom(obj.getClass())) {
                SAXSource src = (SAXSource)obj;
                dest.getSOAPPart().setContent(src);
            } else if (StreamSource.class.isAssignableFrom(obj.getClass())) {
                StreamSource src = (StreamSource)obj;
                dest.getSOAPPart().setContent(src);
            }
        } catch (SOAPException se) {
            //TODO
        }
View Full Code Here


   private static Transformer newTransformer(String systemId, String xslString, URIResolver uriResolver, Map params) throws Exception {
      TransformerFactory transformerFactory = TransformerFactory.newInstance();
      if (uriResolver != null)
         transformerFactory.setURIResolver(uriResolver);
      StreamSource xslStreamSource = null;
      if(systemId != null)
          xslStreamSource = new StreamSource(new StringReader(xslString), systemId);
      else
          xslStreamSource = new StreamSource(new StringReader(xslString));

      Transformer transformer = transformerFactory.newTransformer(xslStreamSource);
      if(params != null) {
          Iterator iter = params.entrySet().iterator();
          while(iter.hasNext()) {
View Full Code Here

      if (transformer == null) {
         log.warning("Transformer for file '" + filename + "' not found (where second choice was '" + secondChoice + "' and third choice was '" + thirdChoice +  "', will return it without modification");
         return in;
      }
      else {
         StreamSource xmlStreamSource = new StreamSource(new ByteArrayInputStream(in));
         ByteArrayOutputStream baos = new ByteArrayOutputStream(in.length);
         StreamResult resultStream = new StreamResult(baos);
         transformer.transform(xmlStreamSource, resultStream);
         return baos.toByteArray();
      }
View Full Code Here

      Transformer transformer = newTransformer(filename, cl);
      if (transformer == null) {
         log.warning("Transformer for file '" + filename + "' not found");
         return in;
      } else {
         StreamSource xmlStreamSource = new StreamSource(in);
         ByteArrayOutputStream baos = new ByteArrayOutputStream(2048);
         StreamResult resultStream = new StreamResult(baos);
         transformer.transform(xmlStreamSource, resultStream);
         ByteArrayInputStream bin = new ByteArrayInputStream(baos.toByteArray());
         return bin;
View Full Code Here

                final Source xmlSource = new DOMSource(this.urlToDocument(xmlDocument));
                final TransformerFactory factory = TransformerFactory.newInstance();
                final URL xslt = new File(transformation).toURL();
                if (xslt != null)
                {
                    final Source xsltSource = new StreamSource(xslt.openStream());
                    final javax.xml.transform.Transformer transformer = factory.newTransformer(xsltSource);
                    final ByteArrayOutputStream output = new ByteArrayOutputStream();
                    final Result result = new StreamResult(output);
                    transformer.transform(
                        xmlSource,
View Full Code Here

            if (StringUtils.isNotBlank(modelUri))
            {
                final URL modelUrl = new URL(modelUri);
                if (xsltTransformations != null && xsltTransformations.length > 0)
                {
                    Source modelSource = new StreamSource(modelUrl.openStream());
                    final List xslts = Arrays.asList(xsltTransformations);
                    final TransformerFactory factory = TransformerFactory.newInstance();
                    final TransformerURIResolver resolver = new TransformerURIResolver();
                    factory.setURIResolver(resolver);
                    for (final Iterator xsltIterator = xslts.iterator(); xsltIterator.hasNext();)
                    {
                        final Transformation transformation = (Transformation)xsltIterator.next();
                        final URL xslt = new URL(transformation.getUri());
                        resolver.setLocation(xslt);
                        if (xslt != null)
                        {
                            AndroMDALogger.info("Applying transformation --> '" + xslt + "'");
                            final Source xsltSource = new StreamSource(xslt.openStream());
                            final javax.xml.transform.Transformer transformer = factory.newTransformer(xsltSource);
                            final ByteArrayOutputStream output = new ByteArrayOutputStream();
                            final Result result = new StreamResult(output);
                            transformer.transform(modelSource, result);
                            final byte[] outputResult = output.toByteArray();
                            stream = new ByteArrayInputStream(outputResult);
   
                            // if we have an output location specified, write the result
                            final String outputLocation = transformation.getOutputLocation();
                            if (StringUtils.isNotBlank(outputLocation))
                            {
                                final File fileOutput = new File(outputLocation);
                                final File parent = fileOutput.getParentFile();
                                if (parent != null)
                                {
                                    parent.mkdirs();
                                }
                                FileOutputStream outputStream = new FileOutputStream(fileOutput);
                                AndroMDALogger.info("Transformation output: '" + outputLocation + "'");
                                outputStream.write(outputResult);
                                outputStream.flush();
                                outputStream.close();
                                outputStream = null;
                            }
                            if (xsltIterator.hasNext())
                            {
                                modelSource = new StreamSource(stream);
                            }
                        }
                    }
                }
                else if (modelUrl != null)
View Full Code Here

            Source source = null;
            if (this.location != null)
            {
                String locationUri = ResourceUtils.normalizePath(this.location.toString());
                locationUri = locationUri.substring(0, locationUri.lastIndexOf('/') + 1);
                source = new StreamSource(locationUri + href);
            }
            return source;
        }
View Full Code Here

        //TODO Set Request/Response Context like Transport Attributes.
        updateRequestContext(dispatch.getRequestContext());

        //TODO Use Async API
        StreamSource resp = dispatch.invoke(request);
       
        updateWebServiceContext(dispatch.getResponseContext());
        return resp;
    }
View Full Code Here

        channel.sendSync(exchange);
        EasyMock.expectLastCall().andReturn(Boolean.TRUE);
        exchange.getOutMessage();                       
        EasyMock.expectLastCall().andReturn(message);
        message.getContent();
        EasyMock.expectLastCall().andReturn(new StreamSource(messageStream));
                               
        EasyMock.replay(channel);
        EasyMock.replay(factory);
        EasyMock.replay(exchange);
        EasyMock.replay(message);
View Full Code Here

        assert context instanceof JBIOutputStreamMessageContext
            : "context must be of type JBIOutputStreamMessageContext";
   
        JBIOutputStreamMessageContext ctx = (JBIOutputStreamMessageContext)context;
        ByteArrayOutputStream bos = (ByteArrayOutputStream)ctx.getOutputStream();
        return new StreamSource(new ByteArrayInputStream(bos.toByteArray()));
    }
View Full Code Here

TOP

Related Classes of javax.xml.transform.stream.StreamSource

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.