This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Displaying HTML after transformation



I am having trouble displaying the output of my translator, does anyone
have any experience that could lead me in the right direction?  I have
tested my stylesheet, and it is working as expected.  I am gathering my XML
input from a servlet call.  I have written JSP to take the XML, write it to
a file, that then gets used as input to the Xalan translator.  But when I
am writing the servlet to the file, it outputs the XML to the browser,
instead of the translated HTML.  I tried sending the Servlet response to a
pre-compiled class file, where the servlet response is written to a  file
on the server-side, and returning the output of the translation to the
browser.  I'm finding in either case, only the XML is being dispayed on the
browser.  The HTML page is being created on the server, but is not
displaying.  Does anyone have an example of a similar implementation that
would help me?

Any help would be appreciated - Thanks! Melanie

JSP Example:
     //some servlet call to create XML which returns the XML to the
response stream
     ServletOutputStream op = response.getOutputStream();
     StreamResult output = new StreamResult();

     response.reset();

     SimpleTransform trans = new SimpleTransform();
     trans.CreateOutputFile(op, output);

SimpleTransform:

     public void CreateOutputFile(ServletOutputStream op, StreamResult
output)
    throws TransformerException, TransformerConfigurationException,
           FileNotFoundException, IOException
  {

     String OSName = System.getProperty("os.name");
     String path=null;
     path = "ContractDetails.xml";
     File f = new File(path);
    byte[] buf = new byte[512];
     FileInputStream in = new FileInputStream(f);
   int length=0;

     //Read the data from the input stream
          while ((in != null) && ((length = in.read(buf)) != -1))
          {
               op.write(buf,0,length);
          }
          try
     {
          // XML for this file is stored in file f
        TransformerFactory tFactory = TransformerFactory.newInstance();
        Transformer transformer = tFactory.newTransformer(new StreamSource
("ContractDetails.xsl"));
        transformer.transform(new StreamSource(f), output);

     }
         catch (Exception e)
         {
           System.out.println(e.getMessage());
          }

  }


This message is for the designated recipient only and may contain
privileged, proprietary, or otherwise private information.  If you have
received it in error, please notify the sender immediately and delete the
original.  Any other use of the email by you is prohibited.


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]