Examples of TransformerFactory


Examples of javax.xml.transform.TransformerFactory

    }

    public static void printDocument(Document document, String fname){
        try{

            TransformerFactory tf = TransformerFactory.newInstance();
            Transformer transformer = tf.newTransformer();
            DOMSource source = new DOMSource(document);
            StreamResult result;

            if (fname == null)
                result = new StreamResult(System.out);
View Full Code Here

Examples of javax.xml.transform.TransformerFactory

      if (content == null)
         return null;

      // Get a parsable representation of this elements content
      DOMSource source = new DOMSource(content);
      TransformerFactory tFactory = TransformerFactory.newInstance();
      Transformer transformer = tFactory.newTransformer();
      StringWriter sw = new StringWriter();
      StreamResult result = new StreamResult(sw);
      transformer.transform(source, result);
      sw.close();
      return sw.getBuffer();
View Full Code Here

Examples of javax.xml.transform.TransformerFactory

      String xml = (String)formattedStats;
    
      DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
      Document doc = builder.parse(new InputSource(new StringReader(xml)));  
     
      TransformerFactory transformerFactory = TransformerFactory.newInstance();
      Transformer transformer = transformerFactory.newTransformer();
     
      StringWriter xmlout = new StringWriter();
      StreamResult result = new StreamResult(xmlout);

      transformer.transform(new DOMSource(doc.getFirstChild()), result);
View Full Code Here

Examples of javax.xml.transform.TransformerFactory

        InputStream xsl = XslTransformer.class
                .getResourceAsStream("/entagged/listing/xml/resource/"
                        + transformTarget.getXslFilename());

        TransformerFactory tf = TransformerFactory.newInstance();

        StreamSource source = new StreamSource(xsl);
        Templates templates = tf.newTemplates(source);

        Transformer trf = templates.newTransformer();

        trf.transform(new StreamSource(input), new StreamResult(output));
    }
View Full Code Here

Examples of javax.xml.transform.TransformerFactory

    this.cacheStyleSheet(file);
  }

  private void cacheStyleSheet(File f) throws TransformerConfigurationException{
    Source xsltSource = new StreamSource(f);
    TransformerFactory transFact = TransformerFactory.newInstance();

    if(uriResolver != null){
      transFact.setURIResolver(uriResolver);
    }

    this.templates = transFact.newTemplates(xsltSource);
    this.file = f;
  }
View Full Code Here

Examples of javax.xml.transform.TransformerFactory

        // find a TRAX factory that works
        final String[] traxFactories = getPreferredTransformerFactories();
        for (int i = 0; traxFactories != null && i < traxFactories.length; i++) {
//          if (DEBUG) System.err.println("trying TRAX=" + traxFactories[i]);
          try {
            TransformerFactory factory = (TransformerFactory) ClassLoaderUtil.newInstance(traxFactories[i]);
            initFactory(factory);
            if (DEBUG) System.err.println("using TRAX TransformerFactory=" + factory.getClass().getName());
            return factory;
          } catch (ClassNotFoundException e) {
            continue; // keep on trying
          } catch (NoClassDefFoundError err) {
            continue; // keep on trying
          } catch (Throwable e) {
            continue; // keep on trying
          }
        }
       
        // try default TRAX initialization
//        if (DEBUG) System.err.println("trying default TRAX");
        TransformerFactory factory = TransformerFactory.newInstance();
        initFactory(factory);
        if (DEBUG) System.err.println("using default TRAX TransformerFactory=" + factory.getClass().getName());
        return factory;
      }
    };
  }
View Full Code Here

Examples of javax.xml.transform.TransformerFactory

    return (Document)result.getNode();
  }

  public final void print(Document document) throws Exception
  {
    TransformerFactory factory = TransformerFactory.newInstance();
    javax.xml.transform.Transformer serializer = factory.newTransformer();
    serializer.transform(new DOMSource(document), new StreamResult(System.out));
    System.out.println();
  }
View Full Code Here

Examples of javax.xml.transform.TransformerFactory

  {
    NodeList list =
      step.getElementsByTagNameNS("http://chaperon.sourceforge.net/schema/text/1.0", "text");
    Node node = list.item(0);

    TransformerFactory streamerfactory = TransformerFactory.newInstance();
    Transformer streamer = streamerfactory.newTransformer();

    SAXTransformerFactory serializerfactory =
      (SAXTransformerFactory)SAXTransformerFactory.newInstance();
    TransformerHandler serializer = serializerfactory.newTransformerHandler();
    DOMResult result = new DOMResult();
View Full Code Here

Examples of javax.xml.transform.TransformerFactory

    Node node = list.item(0);

    if (node==null)
      return null;

    TransformerFactory streamerfactory = TransformerFactory.newInstance();
    Transformer streamer = streamerfactory.newTransformer();

    DOMResult result = new DOMResult();

    streamer.transform(new DOMSource(node), result);
View Full Code Here

Examples of javax.xml.transform.TransformerFactory

    return (Document)result.getNode();
  }

  public final void print(Document document) throws Exception
  {
    TransformerFactory factory = TransformerFactory.newInstance();
    javax.xml.transform.Transformer serializer = factory.newTransformer();
    serializer.transform(new DOMSource(document), new StreamResult(System.out));
    System.out.println();
  }
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.