Package javax.xml.transform

Examples of javax.xml.transform.TransformerFactory.newTransformer()


            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) {
            throw new RemoteRepositoryException(ex);
        } catch (IOException ex) {
            throw new SAXException(ex);
View Full Code Here


            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) {
            throw new RemoteRepositoryException(ex);
        } catch (IOException ex) {
            throw new SAXException(ex);
View Full Code Here

                Writer writer = new OutputStreamWriter(
                        out, SerializingContentHandler.ENCODING);
                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
View Full Code Here

        for (int i = 0; i < artifacts.length; i++) {
            Artifact artifact = artifacts[i];
            createText(doc, versions, "version", artifact.getVersion().toString());
        }
        TransformerFactory xfactory = XmlUtil.newTransformerFactory();
        Transformer xform = xfactory.newTransformer();
        xform.setOutputProperty(OutputKeys.INDENT, "yes");
        xform.transform(new DOMSource(doc), new StreamResult(writer));
    }

View Full Code Here

    try {
      // Apply an XSLT transform to the entire Feed
      TransformerFactory factory = TransformerFactory.newInstance();
      Document xslt = getParser().parse(FOMTest.class.getResourceAsStream("/test.xslt"));
      AbderaSource xsltSource = new AbderaSource(xslt);
      Transformer transformer = factory.newTransformer(xsltSource);
      Document<Feed> feed = getParser().parse(FOMTest.class.getResourceAsStream("/simple.xml"));
      AbderaSource feedSource = new AbderaSource(feed);
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      Result result = new StreamResult(out);
      transformer.transform(feedSource, result);
View Full Code Here

      assertEquals(out.toString(), "This is a test urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6");
     
      // Apply an XSLT transform to XML in the content element
      xslt = getParser().parse(FOMTest.class.getResourceAsStream("/content.xslt"));
      xsltSource = new AbderaSource(xslt);
      transformer = factory.newTransformer(xsltSource);
      feed = getParser().parse(FOMTest.class.getResourceAsStream("/xmlcontent.xml"));
      Entry entry = feed.getRoot().getEntries().get(0);
      Content content = entry.getContentElement();
      AbderaSource contentSource = new AbderaSource(content.getValueElement());
      out = new ByteArrayOutputStream();
View Full Code Here

        }


        // Use a Transformer for output
        TransformerFactory tFactory = TransformerFactory.newInstance();
        Transformer transformer = tFactory.newTransformer();

        // write the document back into a temporary file.
        File tempFile = new File(targetDirectory, "ResultsSummary-2.html");
        FileOutputStream os = new FileOutputStream( tempFile );
        DOMSource source = new DOMSource(document);
View Full Code Here

        try {
            TransformerFactory tFactory = TransformerFactory.newInstance();
            Source xmlSource = new StreamSource(new StringReader(sb.toString()));
            Source xslSource = new StreamSource(xsltInputStream);
            Transformer transformer = tFactory.newTransformer(xslSource);

            ByteArrayOutputStream stream = new ByteArrayOutputStream();
            OutputStreamWriter osWriter = new OutputStreamWriter(stream, "UTF8");
            StreamResult out = new StreamResult(osWriter);
            transformer.transform(xmlSource, out);
View Full Code Here

        ByteArrayOutputStream out = new ByteArrayOutputStream();

        try
        {
            TransformerFactory factory = TransformerFactory.newInstance();
            Transformer transformer = factory.newTransformer();
            transformer.setOutputProperty( OutputKeys.METHOD, "xml" );
            transformer.setOutputProperty( OutputKeys.ENCODING, "UTF-8" );
            transformer.setOutputProperty( OutputKeys.INDENT, "no" );
            transformer.transform( new DOMSource( xmlDocument ), new StreamResult( out ) );
        }
View Full Code Here

   * @return a String representation
   */
  public static String getStringFromElement(Element element) {
    try {
      TransformerFactory tf = TransformerFactory.newInstance();
      Transformer trans = tf.newTransformer();
      StringWriter sw = new StringWriter();
      trans.transform(new DOMSource(element), new StreamResult(sw));
      String elementString = sw.toString();
      return elementString;
    } catch (TransformerConfigurationException e) {
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.