You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Matt Raible <ma...@yahoo.com> on 2002/01/14 13:55:34 UTC

RE: XML/XSL and Transformation - My Solution

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



--- Taylor Cowan <t....@usa.net> wrote:
> Matt,
> 
> That sounds like an interesting approach.  Don't get sidetracked thinking of
> an action "emiting" something.  You'll want to forward to a view component
> that does what you like.  Cocoon might be of interest to you as well.
> 
> I like server side styling.
> My actions forward to a view which gets the content from request/session
> scope.  That way entire sites are composed of one main content JSP.  Here's
> an example of how I've been styling content.  I just turn in into a string
> and place that into request or session scope.  The jsp ( could be anything,
> templates, whatever ) picks it up and inlines it.  So it's similar to
> getting string properties from beans.
> 
> In this example I'm styling only a particular node of an XML document, which
> of course could be the root node, or a child node withing a dom.
> 
> Vic C. likes client side styling as well.  I'm trying to understand that
> point of view but currently I think it's just not a good idea.
> 
> Taylor
> 
> 
> ----------------
>     protected String getContent (Element node, String xsl) throws
> IOException,
>             TransformerException {
>         ServletContext context = getServlet().getServletContext();
>         // check if style sheet exists at specified location
>         if (context.getResource(xsl) == null)
>             throw  new IOException("Style sheet named " + xsl + " cannot be
> found.");
>         StreamSource styleSheet = new
> StreamSource(context.getResourceAsStream(xsl));
>         DOMSource xmlSource = new DOMSource(node);
>         StringWriter sw = new StringWriter();
>         StreamResult result = new StreamResult(sw);
>         TransformerFactory factory = TransformerFactory.newInstance();
>         Transformer t = factory.newTransformer(styleSheet);
>         t.transform(xmlSource, result);
>         return  sw.toString();
>     }
> 
> -----Original Message-----
> From: Matt Raible [mailto:matt_raible@yahoo.com]
> Sent: Friday, January 11, 2002 11:17 AM
> To: struts-user@jakarta.apache.org
> Subject: XML/XSL and Transformation using Struts/Expresso
> 
> 
> I'm getting ready to develop an application and would love to emit XML from
> my
> action classes and apply an XSL stylesheet - then transfer to the browser.
> 
> I've seen many discussions about this on this list - but alas, no examples -
> so
> I'm getting ready to "roll my own."
> 
> I've seen that Expresso supports XML/XSL - so hopefully I can use that do
> accomplish this.
> 
> I'd like to be able to "turn off" transformation on the server-side though,
> and
> emit an XML document which refers to an XSL stylesheet - for the clients
> that
> support client-side XSL transformation.  This would be a application-wide
> setting - so I'm not worried about dynamically figuring out which clients
> transform and such.
> 
> This e-mail is meant as a request for any examples or thoughts on this
> issue.
> If much interest is generated by this thread (and a base example would be
> great) - I'd be happy to contribute a further refined example with the
> ability
> to turn on/off client side rendering.
> 
> Thanks,
> 
> Matt
> 
> __________________________________________________
> Do You Yahoo!?
> Send FREE video emails in Yahoo! Mail!
> http://promo.yahoo.com/videomail/
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: XML/XSL and Transformation - My Solution

Posted by Jeff Pennal <je...@openroad.ca>.
No, I did not convert any of the other struts-*.war file to use the 
XML/XSLT extensions. That would have requirement more time that I had to 
put this together.

However, there is no reason why (other than bugs) that the struts-*.war 
files should not still work as they were intended (using form-beans, etc)

You're right about the reference implementation, something else I'll 
have to do when I get time. In the meantime, I've written a quick and 
dirty example here:

http://www.openroad.ca/opencode/stxx/documentation.html

It's not quite what you're looking for but it might help.

As for your last question, would I use this framework to build an 
application like struts-example? Yes, you could, the only difference is 
that I would not use JSP or Struts taglibs.

There is no reason why these two technologies could not co-exist.

However, one of the main motivation for my writing of the extension to 
struts was because I -really- do not like taglibs, I'm not overly fond 
of JSP anymore and I really like XML/XSLT for handling presentation logic.

Matt Raible wrote:
> Did you convert all the struts-*.war files to use your new framework? 
> Initially looking at these war files, it doesn't appear so.  Reference
> implementation of a framework are always nice to look at ;)
> 
> Also, would you use your framework to construct an application like the
> struts-example - where there are html-based forms, validation, and messages
> from the ApplicationResources.properties file?  
> 
> Thanks,
> 
> Matt
> 
> 

-- 
Jeff Pennal                         p:604-694-0554(x107)
Software Developer                  f:604-694-0558
Openroad Communications             e:jeffp@openroad.ca
Vancouver, BC


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: XML/XSL and Transformation - My Solution

Posted by Matt Raible <ma...@yahoo.com>.
Did you convert all the struts-*.war files to use your new framework? 
Initially looking at these war files, it doesn't appear so.  Reference
implementation of a framework are always nice to look at ;)

Also, would you use your framework to construct an application like the
struts-example - where there are html-based forms, validation, and messages
from the ApplicationResources.properties file?  

Thanks,

Matt


--- Jeff Pennal <je...@openroad.ca> wrote:
> Hi Matt,
> 
> I did not rename the war files, though I probably should have. The file 
> struts.jar contains all of my changes. I'll make a note to rename it for 
>   the next release.
> 
> As for the source, it'll be handy to download if you need to do any 
> debugging.
> 
> Let me know how it works for you and feel free to email me if you have 
> any questions.
> 
> Jeff
> 
> Matt Raible wrote:
> > Jeff - thanks for posting this - I've been eagerly waiting for this. 
> However,
> > when I try to download the binary versions, it appears that all the wars
> are
> > original struts-*.war files.  I don't see any new files, such as
> > struts-stxx.war??
> > 
> > Should I download the source distribution?
> > 
> > Thanks,
> > 
> > Matt
> > 
> > 
> > --- Jeff Pennal <je...@openroad.ca> wrote:
> > 
> >>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:jeffp@openroad.ca
> >>Vancouver, BC
> >>
> >>
> >>--
> >>To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> >>For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >>
> > 
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Great stuff seeking new owners in Yahoo! Auctions! 
> > http://auctions.yahoo.com
> > 
> > --
> > To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> > 
> 
> 
> -- 
> Jeff Pennal                         p:604-694-0554(x107)
> Software Developer                  f:604-694-0558
> Openroad Communications             e:jeffp@openroad.ca
> Vancouver, BC
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions! 
http://auctions.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: XML/XSL and Transformation - My Solution

Posted by Jeff Pennal <je...@openroad.ca>.
Hi Matt,

I did not rename the war files, though I probably should have. The file 
struts.jar contains all of my changes. I'll make a note to rename it for 
  the next release.

As for the source, it'll be handy to download if you need to do any 
debugging.

Let me know how it works for you and feel free to email me if you have 
any questions.

Jeff

Matt Raible wrote:
> Jeff - thanks for posting this - I've been eagerly waiting for this.  However,
> when I try to download the binary versions, it appears that all the wars are
> original struts-*.war files.  I don't see any new files, such as
> struts-stxx.war??
> 
> Should I download the source distribution?
> 
> Thanks,
> 
> Matt
> 
> 
> --- Jeff Pennal <je...@openroad.ca> wrote:
> 
>>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:jeffp@openroad.ca
>>Vancouver, BC
>>
>>
>>--
>>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>>For additional commands, e-mail: <ma...@jakarta.apache.org>
>>
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Great stuff seeking new owners in Yahoo! Auctions! 
> http://auctions.yahoo.com
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 


-- 
Jeff Pennal                         p:604-694-0554(x107)
Software Developer                  f:604-694-0558
Openroad Communications             e:jeffp@openroad.ca
Vancouver, BC


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: XML/XSL and Transformation - My Solution

Posted by Matt Raible <ma...@yahoo.com>.
Jeff - thanks for posting this - I've been eagerly waiting for this.  However,
when I try to download the binary versions, it appears that all the wars are
original struts-*.war files.  I don't see any new files, such as
struts-stxx.war??

Should I download the source distribution?

Thanks,

Matt


--- Jeff Pennal <je...@openroad.ca> wrote:
> 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:jeffp@openroad.ca
> Vancouver, BC
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions! 
http://auctions.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: XML/XSL and Transformation - My Solution

Posted by Jeff Pennal <je...@openroad.ca>.
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:jeffp@openroad.ca
Vancouver, BC


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>