1 Reply Latest reply on Nov 13, 2010 7:32 AM by Sudeep R

    Trouble implementing XSLT in seam application

    Raghavan TV Newbie

      We are implementing a generic dynamic view generation layer that can render the output using XSLT. We extract the SOAP body from the soap response, apply XSLT to generate template based html output.

      The same implementation works fine using a simple JSP/Servlet implementation.

      But when we implement the same logic within seam, we get an exception

      2010-09-28 00:18:27,709 ERROR [STDERR] (http- [Fatal Error] :-1:-1: Premature end of file.
      2010-09-28 00:18:27,711 ERROR [STDERR] (http- javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: org.xml.sax.SAXParseException: Premature end of file.
      2010-09-28 00:18:27,712 ERROR [STDERR] (http-      at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:936)
      2010-09-28 00:18:27,712 ERROR [STDERR] (http-      at org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:774)

      Code snippet

          private String processXML() throws IOException {
                StringWriter out = new StringWriter();
                if(this.xmlinputString != null && this.xsltemplate != null)
                try {
                     TransformerFactory tFactory = TransformerFactory.newInstance();
                     Transformer transformer = tFactory.newTransformer(new StreamSource(
                               new StringReader(getXsltemplate())));
                     transformer.transform(new StreamSource(new StringReader(
                               getXmlinputString())), new StreamResult(out));
                } catch(Exception e) {
                     throw new IOException(e);
                return (out.toString());

        • 1. Re: Trouble implementing XSLT in seam application
          Sudeep R Newbie

          Hi Raghav,
                   I have tried the same and able to generate dynamic html

          public static void translate(String xmlFile, String xslFileName,StreamResult result) throws Exception
                  File xmlFile = new File(xmlFile);
              File xsltFile = new File(xslFileName);

              // JAXP reads data using the Source interface
              Source xmlSource = new StreamSource(xmlFile);
              Source xsltSource = new StreamSource(xsltFile);

              // the factory pattern supports different XSLT processors
              TransformerFactory transFact =
              Transformer trans = transFact.newTransformer(xsltSource);

               trans.transform(xmlSource, result);
                  catch (Exception e)