Hi Matt,

I had a similar problem in that I wanted a framework that would allow me 
to write Struts Actions that pump out XML and convert them to XSL.

I looked for a while to find something that did what I wanted. Cocoon2 
was close but not quite what I was looking for.

In the end I rewrote Struts to support xml and xsl transformations, 
called struts-stxx. You can download it here,
http://www.openroad.ca/opencode/index.html

Let me know if you find it useful.

This is how it works:
        - In the struts-config.xml file, you add an new tag, nested
           under the <forward> tag called <transform> will contain
           the xsl file to transform the Action classes XML against.
           (You can specify zero-many <transform> tags). The <transform>
           tags can be specific to a particular user-agent if you'd like,
           or a "default" one.

        - In your Action class you would run your business logic
           as usual. Then once that is complete, you would create
           an XML document of the output (using JDOM) and assign
           it to the Actions new class variable "Document"

        - The ActionServlet will take the Actions XML, check the
          browsers user-agent and determine what XSL file to
           transform against. The resulting HTML is sent back to
           the broswer.

Currently, struts-stxx does not support sending the xml back to the 
browser to do client side xsl transformation. That's one of my planned 
features that I have not got around to implementing yet.


List of changes to the struts code:
---------------------------------------------
struts-config.xml gets:
     <!--
     the transform tag defines the browser user agent to match
         against to run a particular xsl file
     -->
     <action    path="/menu"
                type="com.oroad.mail.actions.MenuAction"
                scope="request">
       <forward name="success">
         <transform name="default" path="/menu_default.xsl"/>
         <transform name="Mozilla" path="/menu_netscape.xsl"/>
         <transform name="MSIE" path="/menu_ie.xsl"/>
       </forward>
     </action>
---------------------------------------------
org.apache.struts.action.Action gets:
A document (JDOM) class variable to store the XML created in an action 
class.
---------------------------------------------
org.apache.struts.action.ActionTransform and 
org.apache.struts.action.ActionTransforms
(basically modified org.apache.struts.action.ActionForward(s) classes)
---------------------------------------------
org.apache.struts.action.ActionServlet gets:
processActionTransform which basically handles getting the correct xsl 
file for the user agent being passed in, does the transform on the 
action.document variable and dumps the resulting html(or whatever) to 
the client.

Hope this helps,
Jeff


Matt Raible wrote:
> Thanks to everyone who has contributed to this thread.  I've been advocating
> client-side XSL to myself for a few months now, but discovered a fairly major
> roadblock this morning - client XSLT does not work on the latest version of IE
> on the Mac (5.1).  I've tested this and found supporting information at
> http://www.hut.fi/u/hsivonen/os-x-browsers.html.  Therefore, I will be doing
> server-side styling as many of you suggest.
> 
> My initial go around will involve trying to use the "Standard" Tag library to
> wrap my XML that I emit from JSPs.  I figure it's better to use my JSPs w/ XML
> for the view so I can get labels from ApplicationResources, and use html:form
> to do the retrieval of values from my beans.  
> 
> One concern I have with this type of transformation is that it's easy to pick
> the stylesheet with clien-side styling.  For instance, with client-side
> styling, you can do:
> 
> <?xml-stylesheet href="default.xsl" type="text/xsl"?>
> <?xml-stylesheet href="wap.xsl" type="text/xsl" media="wap"?>
> 
> And I don't think this is possible with the current JSTL.  Maybe so, I'll have
> to check.
> 
> Any further comments are appreciated.
> 
> Thanks,
> 
> Matt
> 
> 

-- 
Jeff Pennal                         p:604-694-0554(x107)
Software Developer                  f:604-694-0558
Openroad Communications             e:[EMAIL PROTECTED]
Vancouver, BC


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to