Package javax.xml.transform

Examples of javax.xml.transform.Templates


     * @throws TransformerConfigurationException
     */
    public XMLFilter newXMLFilter(Source src)
  throws TransformerConfigurationException
    {
  Templates templates = newTemplates(src);
  if (templates == null) return null;
  return newXMLFilter(templates);
    }
View Full Code Here


   
      // Parse the stylesheet.                      
      reader.parse("birds.xsl");

      //Get the Templates object from the ContentHandler.
      Templates templates = templatesHandler.getTemplates();
      // Create a ContentHandler to handle parsing of the XML source. 
      TransformerHandler handler
        = saxTFactory.newTransformerHandler(templates);
      // Reset the XMLReader's ContentHandler.
      reader.setContentHandler(handler)
View Full Code Here

        String translet = args[1];

        try {
      StreamSource document = new StreamSource(xml);
           StreamResult result = new StreamResult(new OutputStreamWriter(System.out));
      Templates templates = readTemplates(translet);
      Transformer transformer = templates.newTransformer();
            transformer.transform(document, result);
        }
  catch (Exception e) {
            System.err.println("Exception: " + e);
      e.printStackTrace();
View Full Code Here

     */
    private Templates readTemplates(String file) {
  try {
      FileInputStream ostream = new FileInputStream(file);
      ObjectInputStream p = new ObjectInputStream(ostream);
      Templates templates = (Templates)p.readObject();
      ostream.close();
      return(templates);
  }
  catch (Exception e) {
      System.err.println(e);
View Full Code Here

      StreamSource stylesheet = new StreamSource(xsl);

      // The TransformerFactory will compile the stylesheet and
      // put the translet classes inside the Templates object
      TransformerFactory factory = TransformerFactory.newInstance();
      Templates templates = factory.newTemplates(stylesheet);

      // Send the Templates object to a '.translet' file
      dumpTemplate(getBaseName(xsl)+".translet", templates);
        }
  catch (Exception e) {
View Full Code Here

    try
    {
      // Instantiate the TransformerFactory, and use it along with a SteamSource
      // XSL stylesheet to create a translet as a Templates object.
      TransformerFactory tFactory = TransformerFactory.newInstance();
      Templates translet = tFactory.newTemplates(new StreamSource(xslInURI));
   
      // Perform each transformation
      doTransform(translet, "../../xsltc_todo.xml", "todo-xsltc.html");
      System.out.println("Produced todo-xsltc.html");
   
View Full Code Here

        "<?xml version='1.0'?><xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'><xsl:template match='foo'><out/></xsl:template></xsl:stylesheet>");
      PrintWriter pw = new PrintWriter(new StringWriter());

      synchronized (m_tfactory)
      {
        Templates templates = m_tfactory.newTemplates(new StreamSource(xslbuf));
        Transformer transformer = templates.newTransformer();
        transformer.transform(new StreamSource(xmlbuf), new StreamResult(pw));
      }
      System.out.println("Primed the pump!");
      this.showStatus("Ready to go!");
    }
View Full Code Here

      _xsltcFactory.setErrorListener(_errorlistener);     
  }
  if (_uriresolver != null) {
      _xsltcFactory.setURIResolver(_uriresolver);
  }
  Templates templates = _xsltcFactory.newTemplates(src);
  if (templates == null ) return null;
  return newXMLFilter(templates);
    }
View Full Code Here

     * @throws TransformerConfigurationException
     */
    public Transformer newTransformer(Source source) throws
  TransformerConfigurationException
    {
  final Templates templates = newTemplates(source);
  final Transformer transformer = templates.newTransformer();
  if (_uriResolver != null) {
      transformer.setURIResolver(_uriResolver);
  }
  return(transformer);
    }
View Full Code Here

     * @throws TransformerConfigurationException
     */
    public XMLFilter newXMLFilter(Source src)
  throws TransformerConfigurationException
    {
  Templates templates = newTemplates(src);
  if (templates == null) return null;
  return newXMLFilter(templates);
    }
View Full Code Here

TOP

Related Classes of javax.xml.transform.Templates

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.