Package javax.xml.transform

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


    TransformerFactory tFactory = TransformerFactory.newInstance();
    Source stylesheet = tFactory.getAssociatedStylesheet(stream, null, null, null);
   
    if ( stylesheet == null throw (new Exception("SOSXMLTransformer: no stylesheet found in input file." ));
   
    Transformer transformer = tFactory.newTransformer(stylesheet);
    addParameters(transformer, parameters);
    transformer.transform(stream,
        outputStream);
  }
 
View Full Code Here


    Source stylesheet = tFactory.getAssociatedStylesheet(new StreamSource(byteArrayInputStream)
        , null, null, null);
   
    if ( stylesheet == null throw (new Exception("SOSXMLTransformer: no stylesheet found in input file." ));
   
    Transformer transformer = tFactory.newTransformer(stylesheet);
    addParameters(transformer, parameters);
    byteArrayInputStream = new ByteArrayInputStream(bAOS.toByteArray());
    transformer.transform(new StreamSource(byteArrayInputStream),
        outputStream);
  }
View Full Code Here

    if ( data.length() == 0 throw (new Exception("SOSXMLTransformer: no xml document contained in data." ));
    if ( stylesheetStream == null throw (new Exception("SOSXMLTransformer: no stylesheet contained in stream." ));
   
    TransformerFactory tFactory = TransformerFactory.newInstance();
       
    Transformer transformer = tFactory.newTransformer(stylesheetStream);
    addParameters(transformer, parameters);
    transformer.transform(new StreamSource(new StringReader(data)),
        outputStream);
  }
 
View Full Code Here

    if ( stream == null throw (new Exception("SOSXMLTransformer: no xml document contained in stream." ));
    if ( stylesheetStream == null throw (new Exception("SOSXMLTransformer: no stylesheet contained in stream." ));
   
    TransformerFactory tFactory = TransformerFactory.newInstance();   
   
    Transformer transformer = tFactory.newTransformer(stylesheetStream);
    addParameters(transformer, parameters);
    transformer.transform(stream,
        outputStream);
  }
 
View Full Code Here

    StreamSource styleStream = new StreamSource(stylesheetStream);
    StreamSource inputStream = new StreamSource(stream);
   
    TransformerFactory tFactory = TransformerFactory.newInstance();
       
    Transformer transformer = tFactory.newTransformer(styleStream);
    addParameters(transformer, parameters);
    transformer.transform(inputStream,outputStream);
  }
 
  private static void addParameters(Transformer transformer, HashMap parameters){
View Full Code Here

  private String dom2String(Document dom)
      throws TransformerFactoryConfigurationError,
      TransformerConfigurationException, TransformerException {
    //      set up a transformer
          TransformerFactory transfac = TransformerFactory.newInstance();
          Transformer trans = transfac.newTransformer();
          trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
          trans.setOutputProperty(OutputKeys.INDENT, "yes");
   
          //create string from xml tree
          StringWriter sw = new StringWriter();
View Full Code Here

    }
   
    TransformerFactory tranFac = TransformerFactory.newInstance();              // init transfromer to write XML to file
    Transformer t;
    try {
      t = tranFac.newTransformer();
      t.setOutputProperty(OutputKeys.INDENT, "yes");                            // insert newlines
      t.setOutputProperty(OutputKeys.METHOD, "xml");
      t.setOutputProperty(OutputKeys.VERSION, "1.0");
      t.setOutputProperty(OutputKeys.ENCODING, "utf-8");
      t.setOutputProperty(OutputKeys.STANDALONE, "yes");
View Full Code Here

    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

    {
        // Write the DOM back to file
        try
        {
            TransformerFactory tf = TransformerFactory.newInstance();
            Transformer m = tf.newTransformer();
            DOMSource source = new DOMSource(doc);
            FileOutputStream os = new FileOutputStream(fileUrl.getFile());
            StreamResult result = new StreamResult(os);
            m.setOutputProperty(OutputKeys.INDENT, "yes");
            m.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, XMLAutoStarterEntityResolver.PUBLIC_ID_KEY);
View Full Code Here

            {
                //this is a kind of commit, do it somewhere else
                try
                {
                    TransformerFactory tf = TransformerFactory.newInstance();
                    Transformer m = tf.newTransformer();
                    DOMSource source = new DOMSource((Document)conn);
                    FileOutputStream os = new FileOutputStream(file);
                    StreamResult result = new StreamResult(os);
                    m.setOutputProperty(OutputKeys.INDENT, "yes");
                    m.transform(source, result);
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.