Examples of StreamResult


Examples of javax.xml.transform.stream.StreamResult

         return in;
      }
      else {
         StreamSource xmlStreamSource = new StreamSource(new ByteArrayInputStream(in));
         ByteArrayOutputStream baos = new ByteArrayOutputStream(in.length);
         StreamResult resultStream = new StreamResult(baos);
         transformer.transform(xmlStreamSource, resultStream);
         return baos.toByteArray();
      }
   }
View Full Code Here

Examples of javax.xml.transform.stream.StreamResult

         log.warning("Transformer for file '" + filename + "' not found");
         return in;
      } else {
         StreamSource xmlStreamSource = new StreamSource(in);
         ByteArrayOutputStream baos = new ByteArrayOutputStream(2048);
         StreamResult resultStream = new StreamResult(baos);
         transformer.transform(xmlStreamSource, resultStream);
         ByteArrayInputStream bin = new ByteArrayInputStream(baos.toByteArray());
         return bin;
      }
   }
View Full Code Here

Examples of javax.xml.transform.stream.StreamResult

                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);
                    final byte[] outputResult = output.toByteArray();
                    if (StringUtils.isNotBlank(outputLocation))
View Full Code Here

Examples of javax.xml.transform.stream.StreamResult

                        {
                            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);
   
                            // if we have an output location specified, write the result
View Full Code Here

Examples of javax.xml.transform.stream.StreamResult

    public DOMSource invoke(DOMSource request) {
        DOMSource response = new DOMSource();
        try {
            System.out.println("Incoming Client Request as a DOMSource data in PAYLOAD Mode");
            Transformer transformer = TransformerFactory.newInstance().newTransformer();
            StreamResult result = new StreamResult(System.out);
            transformer.transform(request, result);
            System.out.println("\n");
           
            InputStream is = getClass().getResourceAsStream("GreetMeDocLiteralResp3.xml");
           
View Full Code Here

Examples of javax.xml.transform.stream.StreamResult

                it.setOutputProperty("{http://xml.apache.org/xslt}indent-amount",
                                     Integer.toString(this.indent));
            }
            it.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, omitXmlDecl);
            it.setOutputProperty(OutputKeys.ENCODING, charset);
            it.transform(new DOMSource(node), new StreamResult(os));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
View Full Code Here

Examples of javax.xml.transform.stream.StreamResult

           
            it.setOutputProperty(OutputKeys.METHOD, "xml");
            it.setOutputProperty(OutputKeys.INDENT, "yes");
            it.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
            it.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
            it.transform(new DOMSource(element), new StreamResult(writer));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
View Full Code Here

Examples of javax.xml.transform.stream.StreamResult

   */
  public Vector buildSite(String sBasePath, String sOutputPath, Properties oEnvironmentProps, Properties oUserProps)
      throws FileNotFoundException,IOException, DOMException, TransformerException, TransformerConfigurationException {

    Transformer oTransformer;
    StreamResult oStreamResult;
    StreamSource oStreamSrcXML;
    InputStream oXMLStream = null;
    String sMedia;
    Page oCurrentPage;
    long lElapsed = 0;

    final String sSep = System.getProperty("file.separator");

    if (DebugFile.trace) {
      lElapsed = System.currentTimeMillis();

      DebugFile.writeln("Begin PageSet.buildSite(" + sBasePath + "," + sOutputPath + "...)");
      DebugFile.incIdent();
    }

    oLastXcpt = null;

    if (!sBasePath.endsWith(sSep)) sBasePath += sSep;

    Vector vPages = pages();

    // Move to containers node
    if (DebugFile.trace)
      DebugFile.writeln("seekChildByName(,[Node], \"containers\")");

    Node oContainers = oMSite.seekChildByName(oMSite.getRootNode().getFirstChild(), "containers");

    if (oContainers==null) {
      if (DebugFile.trace)
        DebugFile.writeln("ERROR: <containers> node not found.");

      throw new DOMException(DOMException.NOT_FOUND_ERR, "<containers> node not found");
    }

    // Load XML data stream only once for all containers
    if (DebugFile.trace)
      DebugFile.writeln("oXMLStream = new FileInputStream(" + sURI + ")");

    // For each Page do XSL Transformation
    for (int c=0; c<vPages.size(); c++) {
      oCurrentPage = (Page) vPages.get(c);

      oXMLStream = new FileInputStream(sURI);
      oStreamSrcXML = new StreamSource(oXMLStream);

      // XSL Transformation
      try {
        if (DebugFile.trace)
          DebugFile.writeln("oTransformer = StylesheetCache.newTransformer(" + sBasePath + "xslt" + sSep + "templates" + sSep + oMSite.name() + sSep + oCurrentPage.template() + ")");

        // Get a copy of Stylesheet from cache
        oTransformer = StylesheetCache.newTransformer(sBasePath + "xslt" + sSep + "templates" + sSep + oMSite.name() + sSep + oCurrentPage.template());

        sMedia = oTransformer.getOutputProperty(OutputKeys.MEDIA_TYPE);
        if (null==sMedia)
          sMedia = "html";
        else
          sMedia = sMedia.substring(sMedia.indexOf('/')+1);

        if (DebugFile.trace)
          DebugFile.writeln("Pages[" + String.valueOf(c) + "].filePath(" + sOutputPath + oCurrentPage.getTitle().replace(' ','_') + "." + sMedia + ")");

        oCurrentPage.filePath(sOutputPath + oCurrentPage.getTitle().replace(' ','_') + "." + sMedia);

        if (DebugFile.trace)
          DebugFile.writeln("oStreamResult = new StreamResult(" + oCurrentPage.filePath() + ")");

        oStreamResult = new StreamResult(oCurrentPage.filePath());

        // Set environment parameters for stylesheet
        StylesheetCache.setParameters(oTransformer, oEnvironmentProps);

        // Set user defined parameters for stylesheet
View Full Code Here

Examples of javax.xml.transform.stream.StreamResult

    throws FileNotFoundException, IOException, DOMException, TransformerException,
           TransformerConfigurationException, MalformedURLException {

    Transformer oTransformer;
    StreamResult oStreamResult;
    StreamSource oStreamSrcXML;
    StringWriter oStrWritter;
    File oXMLFile,oXSLFile;
    InputStream oXMLStream = null;
    String sTransformed;
    StringBuffer oPostTransform;
    String sKey;
    String sMedia;
    String sXSLFile;
    Object sVal;
    Page oCurrentPage;

    int iCloseHead, iOpenBody, iCloseBody;
    int iReaded;
    char CharBuffer[] = new char[8192];
    String sCharBuffer;
    long lElapsed = 0;

    final String sSep = System.getProperty("file.separator");

    if (DebugFile.trace) {
      lElapsed = System.currentTimeMillis();

      DebugFile.writeln("Begin Pageset.buildPageForEdit(" + sBasePath + "," + sOutputPath + "," + sCtrlPath + "," + sMenuPath + ")");
      DebugFile.incIdent();
    }

    FileSystem oFS = new FileSystem();

    if (!sBasePath.endsWith(sSep)) sBasePath += sSep;

    String sWebServer = oEnvironmentProps.getProperty("webserver", "");

    if (DebugFile.trace && sWebServer.length()==0) DebugFile.writeln("WARNING: webserver property not set at EnvironmentProperties");

    if (!sWebServer.endsWith("/")) sWebServer+="/";


    // Posicionarse en el nodo de contenedores
    Node oContainers = oMSite.seekChildByName(oMSite.getRootNode().getFirstChild(), "containers");

    if (oContainers==null) {
      if (DebugFile.trace)
        DebugFile.writeln("ERROR: <containers> node not found.");

      throw new DOMException(DOMException.NOT_FOUND_ERR, "<containers> node not found");
    }

    // Cagar el stream de datos XML una sola vez
    if (DebugFile.trace)
      DebugFile.writeln("new FileInputStream(" + (sURI.startsWith("file://") ? sURI.substring(7) : sURI) + ")");

    // Para cada contenedor (página) realizar la transformación XSLT

      oCurrentPage = this.page(sPageGUID);

    oXMLFile = new File (sURI.startsWith("file://") ? sURI.substring(7) : sURI);
    if (!oXMLFile.exists()) {
        if (DebugFile.trace) DebugFile.decIdent();
      throw new FileNotFoundException("PageSet.buildPageForEdit() File not found "+sURI);
    }

      oXMLStream = new FileInputStream(oXMLFile);
      oStreamSrcXML = new StreamSource(oXMLStream);

      // Asignar cada stream de salida a su stream temporal
      oStrWritter = new StringWriter();
      oStreamResult = new StreamResult(oStrWritter);

      // Transformacion XSLT
      try {

        // Obtener la hoja de estilo desde el cache
View Full Code Here

Examples of javax.xml.transform.stream.StreamResult

    throws IOException, DOMException, TransformerException,
           TransformerConfigurationException, MalformedURLException {

    Transformer oTransformer;
    StreamResult oStreamResult;
    StreamSource oStreamSrcXML;
    StringWriter oStrWritter;
    InputStream oXMLStream = null;
    String sTransformed;
    StringBuffer oPostTransform;
    String sKey;
    String sMedia;
    Object sVal;
    Page oCurrentPage;

    int iCloseHead, iOpenBody, iCloseBody;
    int iReaded;
    char CharBuffer[] = new char[8192];
    String sCharBuffer;
    long lElapsed = 0;

    final String sSep = System.getProperty("file.separator");

    if (DebugFile.trace) {
      lElapsed = System.currentTimeMillis();

      DebugFile.writeln("Begin Pageset.buildSiteForEdit(" + sBasePath + "," + sOutputPath + "," + sCtrlPath + "," + sMenuPath + ")");
      DebugFile.incIdent();
    }

    FileSystem oFS = new FileSystem();

    Vector vPages = pages();

    if (!sBasePath.endsWith(sSep)) sBasePath += sSep;

    String sWebServer = oEnvironmentProps.getProperty("webserver", "");

    if (DebugFile.trace && sWebServer.length()==0) DebugFile.writeln("WARNING: webserver property not set at EnvironmentProperties");

    if (!sWebServer.endsWith("/")) sWebServer+="/";


    // Posicionarse en el nodo de contenedores
    Node oContainers = oMSite.seekChildByName(oMSite.getRootNode().getFirstChild(), "containers");

    if (oContainers==null) {
      if (DebugFile.trace)
        DebugFile.writeln("ERROR: <containers> node not found.");

      throw new DOMException(DOMException.NOT_FOUND_ERR, "<containers> node not found");
    }

    // Cagar el stream de datos XML una sola vez
    if (DebugFile.trace)
      DebugFile.writeln("new FileInputStream(" + (sURI.startsWith("file://") ? sURI.substring(7) : sURI) + ")");


    // Para cada contenedor (página) realizar la transformación XSLT
    for (int c=0; c<vPages.size(); c++) {

      oCurrentPage = (Page) vPages.get(c);

      oXMLStream = new FileInputStream(sURI.startsWith("file://") ? sURI.substring(7) : sURI);
      oStreamSrcXML = new StreamSource(oXMLStream);

      // Asignar cada stream de salida a su stream temporal
      oStrWritter = new StringWriter();
      oStreamResult = new StreamResult(oStrWritter);

      // Transformacion XSLT
      try {

        // Obtener la hoja de estilo desde el cache
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.