Package javax.xml.transform

Examples of javax.xml.transform.Templates


          } catch (FileNotFoundException e) {
            res.sendError(404);
            throw e;
          }

          Templates stylesheet = compileStylesheet(req, doc);

          // the new stylesheet affects the vary name
          varyName = generateVaryName(req);

          page = getPrecompiledPage(req, varyName);
View Full Code Here


  private Templates compileStylesheet(CauchoRequest req, CauchoDocument doc)
    throws IOException, ServletException
  {
    String ssName = (String) req.getAttribute("caucho.xsl.stylesheet");

    Templates stylesheet = null;

    try {
      if (ssName == null)
        ssName = getStylesheetHref(doc, null);
   
View Full Code Here

    Path pwd = appDir.lookupNative(webApp.getRealPath(servletPath));
    pwd = pwd.getParent();
   
    String fullStyleSheet = pwd.toString() + "/" + href;

    Templates stylesheet = null;

    long now = Alarm.getCurrentTime();

    SoftReference<Templates> templateRef = _xslCache.get(fullStyleSheet);
View Full Code Here

   * @return the compiled stylesheet
   */
  public javax.xml.transform.Transformer newTransformer(Source source)
    throws TransformerConfigurationException
  {
    Templates templates = newTemplates(source);

    return templates.newTransformer();
  }
View Full Code Here

   * @param source the source file
   */
  public XMLFilter newXMLFilter(Source source)
    throws TransformerConfigurationException
  {
    Templates templates = newTemplates(source);
   
    return newXMLFilter(templates);
  }
View Full Code Here

  public void testResolverWithXSLT() {
    try {
      OdfXMLHelper helper = new OdfXMLHelper();
      OdfTextDocument odt = (OdfTextDocument) OdfDocument.loadDocument(ResourceUtilities.getAbsolutePath(SIMPLE_ODT));
      InputSource inputSource = new InputSource(ResourceUtilities.getURI(XSL_CONCAT).toString());
      Templates multiFileAccessTemplate = TransformerFactory.newInstance().newTemplates(new SAXSource(inputSource));
      File xslOut = ResourceUtilities.newTestOutputFile(XSL_OUTPUT);
      helper.transform(odt.getPackage(), "content.xml", multiFileAccessTemplate, new StreamResult(xslOut));
      LOG.info("Transformed ODF document " + SIMPLE_ODT + " to " + xslOut.getAbsolutePath() + "!");
      File testOutputFile = new File(xslOut.getAbsolutePath());
      if (testOutputFile.length() < 100) {
View Full Code Here

      final ByteArrayInputStream xslStream = new ByteArrayInputStream(xsl.getBytes());
      final ByteArrayOutputStream retValueStream = new ByteArrayOutputStream();

      /* http://xml.apache.org/xalan-j/usagepatterns.html#basic */

      Templates template = null;
      synchronized (templates)
      {
        if (templates.containsKey(xslSystemId))
        {
          template = templates.get(xslSystemId);
        }
        else
        {
          System.out.println("Initialising Templates for " + xslSystemId);

          /*
           * Instantiate a TransformerFactory. make sure to get a
           * org.apache.xalan.processor.TransformerFactoryImpl instead
           * of the default
           * org.apache.xalan.xsltc.trax.TransformerFactoryImpl. The
           * latter doesn't work for docbook xsl.
           */
          final TransformerFactory transformerFactory = TransformerFactory.newInstance("org.apache.xalan.processor.TransformerFactoryImpl", null);

          /*
           * Set the URIResolver that will handle request to external
           * resources
           */
          transformerFactory.setURIResolver(new XSLTResolver(resources));

          /*
           * see http://nlp.stanford.edu/nlp/javadoc/xalan-docs/
           * extensionslib .html#nodeinfo
           */
          transformerFactory.setAttribute(TransformerFactoryImpl.FEATURE_SOURCE_LOCATION, Boolean.TRUE);
          // transformerFactory.setAttribute(TransformerFactoryImpl.FEATURE_INCREMENTAL,
          // Boolean.TRUE);

          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);
      }

      /*
       * Use the TransformerFactory to process the stylesheet Source and
       * generate a Transformer.
       */
      final Transformer transformer = template.newTransformer();

      /* set the global variables */
      if (globalParameters != null)
        for (final String varibleName : globalParameters.keySet())
          transformer.setParameter(varibleName, globalParameters.get(varibleName));
View Full Code Here

            throws TransformerException,
            ParserConfigurationException,
            IOException,
            SAXException {

        Templates templates = getTemplates(xslt);

        doTransform(failureMessage, templates, input, expected);
    }
View Full Code Here

    public void addTemplate(String templateURI, Boolean compilable,
                            boolean transformation)
            throws SAXException {
        String absoluteURI = templateURI; // just in case of exception
        try {
            Templates templates = null;

            absoluteURI = resolveHref(templateURI);
            boolean isCompilable = isCompilable(compilable, transformation);

            boolean isCached = configuration.isTemplateCacheRequired();
View Full Code Here

            throw new IllegalStateException("No templates handler to unload");
        }

        if (templatesHandler != null) {
            templatesHandler.endDocument();
            Templates templates = templatesHandler.getTemplates();
            addTemplates(templates, compilable);
            templatesHandler = null;
            setContentHandler(getNextProcess());
        }
    }
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.