Package javax.xml.transform

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


    try {
      // Create transformer factory
      TransformerFactory factory = TransformerFactory.newInstance();

      // Use the factory to create a template containing the xsl file
      Templates template = factory.newTemplates(new StreamSource(
          new FileInputStream(xslfile)));

      // Use the template to create a transformer
      Transformer xformer = template.newTransformer();
     
View Full Code Here


  }

  private Templates parseXslt(String xsltValue) throws Exception {
    Source source = new StreamSource(new StringReader(xsltValue));
    TransformerFactory factory = TransformerFactory.newInstance();
    return factory.newTemplates(source);
  }

  private void setParams(Transformer transformer, TransformContext context) {
    for (ParamTag param : parameterList) {
      String paramName = param.getVar();
View Full Code Here

        if (translet == null ) {
            String templateUrl = (String)context.get("templateUrl");
            String templateString = (String)context.get("templateString");
            Document templateDocument = (Document)context.get("templateDocument");
            Source templateSource = getSource(templateDocument, templateUrl, templateString);
            translet = tFactory.newTemplates(templateSource);
            if (UtilValidate.isNotEmpty(templateName)) {
                    xslTemplatesCache.put(templateName, translet);
            }
        }
        if (translet != null ) {
View Full Code Here

          final StreamSource xslStreamSource = new StreamSource(xslStream);
          xslStreamSource.setSystemId(xslSystemId);

          /* save the template */
          templates.put(xslSystemId, transformerFactory.newTemplates(xslStreamSource));
         
          System.out.println("Done Initialising Templates for " + xslSystemId);
        }

        template = templates.get(xslSystemId);
View Full Code Here

        
        try {
            TransformerFactory factory
              = TransformerFactory.newInstance();
            factory.setErrorListener(errorsAreFatal);
            this.templates = factory.newTemplates(source);
        }
        catch (TransformerFactoryConfigurationError error) {
           throw new XSLException(
             "Could not locate a TrAX TransformerFactory", error
           );   
View Full Code Here

                    "Could not find " + xslResourcePath);
        }

        Source source = new StreamSource(xslURL.toExternalForm());
        try {
            templates = transformerFactory.newTemplates(source);
        } catch (TransformerConfigurationException e) {
            throw new ResourceMigrationException(
                    "Cannot create XSLT transformer", e);
        }
View Full Code Here

            dfactory.setNamespaceAware(true);

            DocumentBuilder docBuilder = dfactory.newDocumentBuilder();
            Node xslDOM = docBuilder.parse(new InputSource(xslFileName));

            stylesheet = tfactory.newTemplates(new DOMSource(xslDOM,
                    xslFileName));
          }
          else
          {
            // System.out.println("Calling newTemplates: "+xslFileName);
View Full Code Here

                    xslFileName));
          }
          else
          {
            // System.out.println("Calling newTemplates: "+xslFileName);
            stylesheet = tfactory.newTemplates(new StreamSource(xslFileName));
            // System.out.println("Done calling newTemplates: "+xslFileName);
          }
        }

        PrintWriter resultWriter;
View Full Code Here

          Source source =
            stf.getAssociatedStylesheet(new StreamSource(inFileName), media,
                                        null, null);

          if (null != source)
            stylesheet = tfactory.newTemplates(source);
          else
          {
            if (null != media)
              throw new TransformerException(XSLMessages.createMessage(XSLTErrorResources.ER_NO_STYLESHEET_IN_MEDIA, new Object[]{inFileName, media})); //"No stylesheet found in: "
                                            // + inFileName + ", media="
View Full Code Here

        }

        // Check that the call to newTemplates() returns a valid template instance.
        // In case of an xslt parse error, it will return null and we should stop the
        // deployment and raise an exception as the route will not be setup properly.
        Templates templates = factory.newTemplates(source);
        if (templates != null) {
            setTemplate(templates);
        } else {
            throw new TransformerConfigurationException("Error creating XSLT template. "
                    + "This is most likely be caused by a XML parse error. "
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.