Examples of TransformerFactory


Examples of javax.xml.transform.TransformerFactory

  public static void transform(byte[] xmlDoc, String outputURL, String xslDocUri)
  throws java.io.IOException,
         java.net.MalformedURLException,
         org.xml.sax.SAXException  {

    TransformerFactory tFactory = TransformerFactory.newInstance();
    Transformer transformer = null;
    try {
      transformer = tFactory.newTransformer(new StreamSource(xslDocUri));
//      transformer = tFactory.newTransformer(new StreamSource(new ByteArrayInputStream(xslDoc.getBytes())));
      transformer.transform(
        new StreamSource(new ByteArrayInputStream(xmlDoc)),
        new StreamResult(outputURL));
    }
View Full Code Here

Examples of javax.xml.transform.TransformerFactory

         org.xml.sax.SAXException  {

    ByteArrayInputStream iStream = new ByteArrayInputStream(xmlDoc);
    ByteArrayOutputStream boutArray = new ByteArrayOutputStream();

    TransformerFactory tFactory = TransformerFactory.newInstance();
    Transformer transformer = null;
    try {
      transformer = tFactory.newTransformer(new StreamSource(xslDocUri));
    }
    catch (Exception e) {
      logger.fatal(e.getMessage(), e);
      throw new IOException(e.getMessage());
    }
View Full Code Here

Examples of javax.xml.transform.TransformerFactory

      }
      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) {
        DebugFile.writeln("Cache hit: Cached stylesheet date "+new Date(oSheet.lastModified).toString() + " Disk file date "+new Date(lastMod).toString());
      }
      if (lastMod>oSheet.lastModified) {
        oSheet = null;
        oCache.remove(sFilePath);
      }
    } // fi (oSheet)

    if (null==oSheet) {
      if (DebugFile.trace) DebugFile.writeln("TransformerFactory.newInstance()");
      oFactory = TransformerFactory.newInstance();
      if (DebugFile.trace) DebugFile.writeln("new StreamSource("+sFilePath+")");
      oStreamSrc = new StreamSource(sFilePath);
      if (DebugFile.trace) DebugFile.writeln("TransformerFactory.newTemplates(StreamSource)");
      oTemplates = oFactory.newTemplates(oStreamSrc);
      oSheet = new SheetEntry(lastMod, oTemplates);
      if (DebugFile.trace) DebugFile.writeln("WeakHashMap.put("+sFilePath+", SheetEntry)");
      oCache.put(sFilePath, oSheet);
    } // fi
View Full Code Here

Examples of javax.xml.transform.TransformerFactory

      throw new NullPointerException("StylesheetCache.transform() XML input stream may not be null");
    }

    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);
View Full Code Here

Examples of javax.xml.transform.TransformerFactory

        } else {
            throw new IllegalArgumentException("HTMLwithXSLBuilder2::transform : Illegal argument for HTML output");
        }

      try {
          TransformerFactory tFactory = TransformerFactory.newInstance();
          Transformer transformer = tFactory.newTransformer(tXslSource);

            // Set the Stylesheet params (if any)
            if (aParamList != null) {
                String tKey;
                Object tValue;
View Full Code Here

Examples of javax.xml.transform.TransformerFactory

      if (transformer == null)
      {
        XMLHelper.setTransformerProperties();

        TransformerFactory tFactory = TransformerFactory.newInstance();
        transformer = tFactory
            .newTransformer(new StreamSource(xslFile));
        mTransformers.put(Thread.currentThread().getName() + xslFile,
            transformer);
      }
    }
View Full Code Here

Examples of javax.xml.transform.TransformerFactory

      if (transformer == null)
      {
        XMLHelper.setTransformerProperties();

        TransformerFactory tFactory = TransformerFactory.newInstance();
        transformer = tFactory
            .newTransformer(new StreamSource(xslFile));
        mTransformers.put(Thread.currentThread().getName() + xslFile,
            transformer);
      }
    }
View Full Code Here

Examples of javax.xml.transform.TransformerFactory

      return buf.toString();
   }


   private static Transformer newTransformer(String systemId, String xslString, URIResolver uriResolver, Map params) throws Exception {
      TransformerFactory transformerFactory = TransformerFactory.newInstance();
      if (uriResolver != null)
         transformerFactory.setURIResolver(uriResolver);
      StreamSource xslStreamSource = null;
      if(systemId != null)
          xslStreamSource = new StreamSource(new StringReader(xslString), systemId);
      else
          xslStreamSource = new StreamSource(new StringReader(xslString));

      Transformer transformer = transformerFactory.newTransformer(xslStreamSource);
      if(params != null) {
          Iterator iter = params.entrySet().iterator();
          while(iter.hasNext()) {
              Map.Entry entry = (Map.Entry)iter.next();
              transformer.setParameter((String)entry.getKey(), (String)entry.getValue());
View Full Code Here

Examples of javax.xml.transform.TransformerFactory

        try
        {
            if (StringUtils.isNotBlank(xmlDocument))
            {
                final Source xmlSource = new DOMSource(this.urlToDocument(xmlDocument));
                final TransformerFactory factory = TransformerFactory.newInstance();
                final URL xslt = new File(transformation).toURL();
                if (xslt != null)
                {
                    final Source xsltSource = new StreamSource(xslt.openStream());
                    final javax.xml.transform.Transformer transformer = factory.newTransformer(xsltSource);
                    final ByteArrayOutputStream output = new ByteArrayOutputStream();
                    final Result result = new StreamResult(output);
                    transformer.transform(
                        xmlSource,
                        result);
View Full Code Here

Examples of javax.xml.transform.TransformerFactory

                final URL modelUrl = new URL(modelUri);
                if (xsltTransformations != null && xsltTransformations.length > 0)
                {
                    Source modelSource = new StreamSource(modelUrl.openStream());
                    final List xslts = Arrays.asList(xsltTransformations);
                    final TransformerFactory factory = TransformerFactory.newInstance();
                    final TransformerURIResolver resolver = new TransformerURIResolver();
                    factory.setURIResolver(resolver);
                    for (final Iterator xsltIterator = xslts.iterator(); xsltIterator.hasNext();)
                    {
                        final Transformation transformation = (Transformation)xsltIterator.next();
                        final URL xslt = new URL(transformation.getUri());
                        resolver.setLocation(xslt);
                        if (xslt != null)
                        {
                            AndroMDALogger.info("Applying transformation --> '" + xslt + "'");
                            final Source xsltSource = new StreamSource(xslt.openStream());
                            final javax.xml.transform.Transformer transformer = factory.newTransformer(xsltSource);
                            final ByteArrayOutputStream output = new ByteArrayOutputStream();
                            final Result result = new StreamResult(output);
                            transformer.transform(modelSource, result);
                            final byte[] outputResult = output.toByteArray();
                            stream = new ByteArrayInputStream(outputResult);
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.