Hi there,

>Is anybody have HOWTO for using xsl stylesheets for jsp output in Tomcat?
>I think about something like xtp in Resin.

Don't know anything about xtp or Resin, but there are a couple of possible answers to 
your question:

1. Take a look at Cocoon, if you're insterested in trying XSP instead of JSP.

2. To stick with JSP try the x-tags library (also from jakarta.apache.org).  It allows 
you to parse XML within your 
JSP page, and format it using XSL.  Alternatively you can just include an XSL 
formatted XML file in your output.  
x-tags also suppots XPath and a sortof dynamic XSL-in-JSP syntax, allowing some pretty 
funky stuff:

(If your browser displays HTML the following may not work too well...)
--
<xtags:parse id="doc1">
        <root>
                <author name="Twylite" />
        </root>
</xtags:parse>
<xtags:valueOf select="//author/@name" />
--
This will parse the inline XML document, and then output (to the current JSP output 
stream) the name attribute 
of the author element.  Combining that with other elements of JSP, you can do stuff 
like:

--
<xtags:parse id="doc1">
        <root>
                <article title="<%= article.getTitle() %>" keywords="<%= 
article.getKeywords() %>" />
                <author name="<%= article.getAuthor() %>" />
        </root>
</xtags:parse>
<xtags:style xsl="/style/article.xsl"/>
--

This will parse the inline XML, then apply the specified stylesheet and include the 
results in the output stream.
(Note: before you tear out your hair trying to use xtags:style ... the xsl= path MUST 
have a leading / )


3. You can generate XML from the JSP page, and allow the browser to do the XSL 
formatting by associating 
the appropriate stylesheet with the xml generated:

<?xml version="1.0" standalone="yes"?>
<?xml-stylesheet href="mystyle.xsl" type="text/xsl"?>
<SomeRootElement xmlns="http://www.mydomain.com";>
        <!-- blah -->
</SomeRootElement>


Hope this helps 

Twylite


Reply via email to