Matt, Yes, these two lines are taken directly from within my perform method, and make use of the example method I sent previously. They perform the styling and make the text available to the view layer.
String content = getContent(getCurrentFormElement(req, map), getStyleSheet()); req.getSession().setAttribute(CONTENT, content); Taylor -----Original Message----- From: Matt Raible [mailto:[EMAIL PROTECTED]] Sent: Friday, January 11, 2002 1:07 PM To: Struts Users Mailing List Subject: RE: XML/XSL and Transformation using Struts/Expresso Do you have an example of calling this from your action class? --- Taylor Cowan <[EMAIL PROTECTED]> 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:[EMAIL PROTECTED]] > Sent: Friday, January 11, 2002 11:17 AM > To: [EMAIL PROTECTED] > 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: > <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > __________________________________________________ Do You Yahoo!? Send FREE video emails in Yahoo! Mail! http://promo.yahoo.com/videomail/ -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>