Package javax.xml.transform

Examples of javax.xml.transform.TransformerFactory


  FileNotFoundException, IOException, Exception {
   
    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


  FileNotFoundException, IOException, Exception {
   
    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

    if ( stylesheetStream == null throw (new Exception("SOSXMLTransformer: no stylesheet contained in stream" ));
   
    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);
  }
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

            if (is == null) {
                throw new ServletException("Cannot find stylesheet: "
                        + xsltStyleSheet);
            }
            try {
                TransformerFactory tfactory = TransformerFactory.newInstance();
                Source xslSource = new StreamSource(is);
                // Note that if we don't do this, relative URLs can not be
                // resolved correctly!
                xslSource.setSystemId(getServletContext().getRealPath(
                        xsltStyleSheet));
                this.templates = tfactory.newTemplates(xslSource);
            } catch (TransformerConfigurationException tce) {
                throw new ServletException("Error parsing XSLT stylesheet: "
                        + xsltStyleSheet, tce);
            }
View Full Code Here

        if (is == null) {
            throw new ServletException("Cannot find stylesheet: " + xsltStyleSheet);
        }
       
        try {
            TransformerFactory tfactory = TransformerFactory.newInstance();
            Source xslSource = new StreamSource(is);
            if (xsltStyleSheet != null) {
                // Note that if we don't do this, relative URLs can not be
                // resolved correctly!
                xslSource.setSystemId(getServletContext().getRealPath(
                        xsltStyleSheet));
            }
            this.templates = tfactory.newTemplates(xslSource);
        } catch (TransformerConfigurationException tce) {
            throw new ServletException("Error parsing XSLT stylesheet: "
                    + xsltStyleSheet, tce);
        }
View Full Code Here

        if (is == null) {
            throw new ServletException("Cannot find stylesheet: "
                    + xsltStyleSheet);
        }
        try {
            TransformerFactory tfactory = TransformerFactory.newInstance();
            Source xslSource = new StreamSource(is);
            if (xsltStyleSheet != null) {
                // Note that if we don't do this, relative URLs can not be
                // resolved correctly!
                xslSource.setSystemId(getServletContext().getRealPath(
                        xsltStyleSheet));
            }
            this.templates = tfactory.newTemplates(xslSource);
        } catch (TransformerConfigurationException tce) {
            throw new ServletException("Error parsing XSLT stylesheet: "
                    + xsltStyleSheet, tce);
        }
View Full Code Here

    for (Iterator it = ces.iterator(); it.hasNext();) {                          // for every root entry (currently only one)
      CatalogEntry ce = (CatalogEntry) it.next();
      getCatalogSubStructure(doc, root, cm, ce);                                // scan this entry
    }
   
    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

      xslAsString = slurp(xslin);
    } catch (IOException e) {
      log.error("Could not convert xsl to string!", e);
    }
    String replacedOutput = evaluateValue(xslAsString, vcContext);
    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

    private synchronized void writeToFile()
    {
        // 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

TOP

Related Classes of javax.xml.transform.TransformerFactory

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.