Here is a simple way to do it...
===========================================================
Put your content in XML:

<article>
    <title>My title</title>
    <para>This is a paragraph</para>
</article>
===========================================================

Put your presentation in XSL:

<xsl:template match="article">
    <xsl:apply-templates/>
</xsl:template>

<xsl:template match="title">
    <H1><xsl:value-of select="."/></H1>
</xsl:template>

<xsl:template match="para">
    <P><xsl:value-of select="."/></P>
</xsl:template>
===========================================================

Use a  (very simple) servlet (look under xalan at org.apache.com) to
transform them into HTML. The servlet can send parameters to the XSL if
necessary.

Here is some code:

PrintWriter out = new PrintWriter (res.getOutputStream());
res.setContentType("text/html");
try {
         TransformerFactory tFactory = TransformerFactory.newInstance();
         Transformer transformer = tFactory.newTransformer(new
StreamSource(nextXSL));
        //example for setting params in the XSL
         transformer.setParameter("id",theID);
         transformer.setParameter("xml-fileref",nextXML);
         transformer.transform (new StreamSource(nextXML), new
StreamResult(out));
} catch (Exception e) {
         out.write(e.getMessage());
         e.printStackTrace(out);
}
============================================================

hth,
Rob

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to