Package javax.xml.transform

Examples of javax.xml.transform.Templates


      throw new FileNotFoundException(sFilePath);
    }
    long lastMod = oFile.lastModified();

    TransformerFactory oFactory;
    Templates oTemplates;
    StreamSource oStreamSrc;
    SheetEntry oSheet = (SheetEntry) oCache.get(sFilePath);

    if (null!=oSheet) {
      if (DebugFile.trace) {
View Full Code Here


    ByteArrayOutputStream oOutputStream = new ByteArrayOutputStream();

    TransformerFactory oFactory = TransformerFactory.newInstance();
    StreamSource oStreamSrc = new StreamSource(oStyleSheetStream);
    Templates oTemplates = oFactory.newTemplates(oStreamSrc);
    Transformer oTransformer = oTemplates.newTransformer();

    if (null!=oProps) setParameters(oTransformer, oProps);
    StreamSource oStreamSrcXML = new StreamSource(oXMLInputStream);
    StreamResult oStreamResult = new StreamResult(oOutputStream);
    if (DebugFile.trace) DebugFile.writeln("Transformer.transform(StreamSource,StreamResult)");
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

        concurrently across multiple threads. Creating a Templates object
        allows the TransformerFactory to do detailed performance optimization
        of transformation instructions, without penalizing runtime
        transformation.
      */
      Templates templates = transformerFactory.newTemplates( template );

      Transformer transformer = templates.newTransformer();
      if( outputProps != null )
      {
         transformer.setOutputProperties( outputProps );
      }

View Full Code Here

   {
      StreamSource source = new StreamSource( srcIs );
      StreamResult result = new StreamResult( destOs );
      StreamSource template = new StreamSource( templateIs );

      Templates templates = transformerFactory.newTemplates( template );

      // set output properties
      Transformer transformer = templates.newTransformer();
      if(outputProps != null)
      {
         transformer.setOutputProperties(outputProps);
      }
View Full Code Here

                        + 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

  private void cacheStyleSheet(Class<?> resourceClass, String path) throws TransformerConfigurationException{
    InputStream inputStream = resourceClass.getResourceAsStream(path);
    Source xsltSource = new StreamSource(inputStream);
    TransformerFactory transFact = TransformerFactory.newInstance();
    Templates templates = transFact.newTemplates(xsltSource);

    try {inputStream.close();} catch (IOException e) {}

    this.templates = templates;
    this.resourceClass = resourceClass;
View Full Code Here

        {
            return 0;
        }

        SAXTransformerFactory saxtf = (SAXTransformerFactory) tf;
        Templates templates = null;
        if (xslt != null) {
            templates = saxtf.newTemplates(xslt);
        }

        // configuring outHandlerFactory
View Full Code Here

      else
        xsl = new StyleScript();

      xsl.setStylePath(stylePath);

      Templates stylesheet;

      stylesheet = xsl.newTemplates(xslName);

      for (; i < args.length; i++) {
        String name = args[i];

        Path xmlPath = Vfs.lookup(name);

        HashMap<String,Object> argMap = new HashMap<String,Object>();

        String []childArgs = new String[argList.size() + 1];
        argList.toArray(childArgs);
        childArgs[childArgs.length - 1] = name;

        argMap.put("arguments", childArgs);
        argMap.put("File", Vfs.lookup());

        ReadStream is = xmlPath.openRead();
        Document doc = null;
        try {
          if (isStrict)
            doc = new Xml().parseDocument(is);
          else {
            XmlParser parser = new Html();
            parser.setEntitiesAsText(true);
            doc = parser.parseDocument(is);
          }
        } finally {
          is.close();
        }

        //Document result = xsl.transform(doc, argMap);
        Document result = null;

        Path destPath = null;
        if (dest != null)
          destPath = Vfs.lookup(dest);
        else if (suffix != null)
          destPath = xmlPath.getParent();
        else
          destPath = Vfs.lookup("stdout:");

        if (suffix != null) {
          int p = name.lastIndexOf('.');
          if (p == -1) {
            System.err.println("suffix missing for `" + name + "'");
            System.exit(1);
          }

          String destName = name.substring(0, p);
          if (dest == null) {
            p = destName.lastIndexOf('/');
            if (p >= 0)
              destName = destName.substring(p + 1);
          }

          if (! destPath.isFile())
            destPath = destPath.lookup(destName + '.' + suffix);
          else {
            System.err.println("illegal output combination");
            System.exit(1);
          }
        }
        else if (destPath.isDirectory())
          destPath = destPath.lookup(name);

        try {
          destPath.getParent().mkdirs();
        } catch (IOException e) {
        }

        WriteStream os = destPath.openWrite();

        try {
          Properties output = stylesheet.getOutputProperties();

          String encoding = (String) output.get("encoding");
          String mimeType = (String) output.get("mime-type");
          String method = (String) output.get("method");

          if (encoding == null && (method == null || ! method.equals("html")))
            encoding = "UTF-8";

          TransformerImpl transformer =
            (TransformerImpl) stylesheet.newTransformer();

          if (encoding != null)
            os.setEncoding(encoding);

          transformer.setProperty("caucho.pwd", Vfs.lookup());
View Full Code Here

          href = getStylesheetHref(doc);

        if (href == null)
          href = "default.xsl";

        Templates stylesheet = null;
       
        //Path path = Vfs.lookup(href);
        try {
          //ReadStream sis = path.openReadAndSaveBuffer();

          TransformerFactory factory;
         
          if (_chainingType.equals("x-application/stylescript"))
            factory = new StyleScript();
          else {
            factory = TransformerFactory.newInstance();
          }

          if (factory instanceof AbstractStylesheetFactory)
            ((AbstractStylesheetFactory) factory).setStylePath(_stylePath);

          Path path = null;

          if (href.startsWith("/"))
            path = Vfs.getPwd().lookup(_application.getRealPath(href));
          else {
            String servletPath = RequestAdapter.getPageServletPath(req);

            Path pwd = Vfs.getPwd();
            pwd = pwd.lookup(_application.getRealPath(servletPath));
            path = pwd.getParent().lookup(href);
          }

          if (! path.canRead()) {
            Thread thread = Thread.currentThread();
            ClassLoader loader = thread.getContextClassLoader();

            URL url = loader.getResource(href);

            if (url != null) {
              Path newPath = Vfs.getPwd().lookup(url.toString());
              if (newPath.canRead())
                path = newPath;
            }
          }

          Source source;
          if (path.canRead())
            source = new StreamSource(path.getURL());
          else
            source = new StreamSource(href);

          if (log.isLoggable(Level.FINE))
            log.fine(L.l("'{0}' XSLT filter using stylesheet {1}",
                         req.getRequestURI(), source.getSystemId()));

          stylesheet = factory.newTemplates(source);
        } finally {
          // is.close();
        }
       
        Transformer transformer = null;

        transformer = (Transformer) stylesheet.newTransformer();

        TransformerImpl cauchoTransformer = null;
        if (transformer instanceof TransformerImpl)
          cauchoTransformer = (TransformerImpl) transformer;
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.