Hi all,
    I am trying to create a html based template with xslt transformation.The string result returned by the transformer is perfectly fine.but when i try to send it to display, the browser is not interpreting it. The output looks like<html><body>...</body></html>.
when i do view source it is displaying <html>... How can i resolve it?Please help.
Thanks in advance
views:
44answers:
2Did you specify the output method correctly? It should be set to HTML:
<xsl:output method="html" encoding="UTF-8" />
<xsl:output value="html"/>
  <xsl:template match="mail[@type='pinReset']">  
    <html><body>
    <xsl:variable name="userService" select="java:new()"/>
    <i><u>Message body </u><xsl:value-of select="mailMessage/mail/body/prefix"/></i>
        <a><xsl:attribute name="href">
       <xsl:value-of select="java:getResetPinUrl($userService)"/></xsl:attribute> 
        reset pin
       </a>
      <i><xsl:value-of select="mailMessage/body/suffix"/></i><br/>
    </body>
    </html>
  </xsl:template>
</xsl:stylesheet>
This is my XSl.
public String getXformedString(int type){
        String xFormedString = "";
        String xsltFile = "D:\\SitesContent\\sitescontent_war\\JavaSource\\com\\tgt\\mobile\\gc\\controller\\email.xsl";
        String xmlFile="D:\\SitesContent\\sitescontent_war\\JavaSource\\com\\tgt\\mobile\\gc\\controller\\emailBody.xml";
        StringWriter stWr = new StringWriter();
        File xsltfile = new File(xsltFile);
        File xmlfile = new File(xmlFile);
        Source xmlSource = new StreamSource(xmlfile);
        Source xsltSource = new StreamSource(xsltfile);
        Result result = new StreamResult(stWr);
        TransformerFactory transFact = TransformerFactory.newInstance();
        try {
                   Transformer transformer= transFact.newTransformer(xsltSource);
                   transformer.setParameter("type",new Integer(type));
                   transformer.transform(xmlSource, result);
                   xFormedString = stWr.toString();
                   System.out.println("Str->"+xFormedString);
       } catch (TransformerConfigurationException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
       } catch (TransformerException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
       }
        return xFormedString;
    }
This is the code to get the formed string from xml and xslt.