Hi, To use a service from a Velocity template, create a tool to access the service indirectly. Depending on how your application is set up, you'd probably want to do all of the XSLT transformation inside the tool, and not expose it to velocity.
To set up the XSLT Service, change this property in your TurbineResources.properties (in WEB-INF/conf of your generated app) services.XSLTService.path = /path/to/stylesheets to services.XSLTService.path = /xslt or whatever. Use the pull model HOWTO to help you add a tool to Turbine. I'd configure the tool as global scope, but this really depends on your application. The tool can access your database to pick up XML for a product or what have you. For instance, if you stored a piece of XML as a description of a product, you could write a method in your tool with a signature like getProductDescriptionHTML(String productID). This method would call another method which got the XML out of your database and returned it as a String. Use a StringReader to get your XML ready for the XSLTService. Inside the tool, use the static XSLTService helper utility class org.apache.turbine.services.xslt.TurbineXSLT to call the transform methods on the service. Call the transform method on the service, which returns a String. Use the filename of your XSLT style sheet for the xslName parameter. >From inside your Velocity template, call $xsltTool.getProductDescriptionHTML($productID), which will return HTML. Jeff ----- Original Message ----- From: "daniel robinson" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, July 03, 2002 7:00 PM Subject: Action/Service/Upload/XSLT Noobie Woes > I've been at this all day, and I give up :). > > What I'm trying to do: > -Generate HTML using a stylesheet and XML from a database. > > Strategy: > -Use the XSLTService to perform this. > -Use doco and examples to figure out how. > > Issues: > - I don't understand how to use the XSLTService within Turbine. I've > read the doc (not much there), looked at the examples (none for > XSLTService), searched the listserv archives (still nothing), and posted > a message (still not working). > - I decided to take it one step at a time and figure out how to use a > documented and exampled service - I chose upload. > - From what I can tell the Upload example does not use the UploadService > :(. But defines a application level action to do this. > > Assumptions: > - A service can be called directly from within a template using Velocity > and I don't need to write an action. > > What I would like: > - A clean example of an application that uses XSLTService, or > - A clean example of an application that uses some service that I can > use to figure out how to use XSLTService, or > - Someone to spell out exactly what I need to do. > > Help appreciated, > > Dan > > > > > -- > 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]>
