On Wed, 2003-06-25 at 19:26, Jayram, Ven wrote:
Hi there:
I am trying to use XSLT with velocity macros.. using TurbineXSLT service.. any examples you may have would be greatly appreciated..
I have an XML document that I get in my Action class from a backend service
that I want to render using XSL and VM.
I asked a similar question recently and received the following reply that works for me.
cheers
Jason ----
Solutions 2. > - Use Velocity XML templates. > - pull in the XML > - transform using XSLT on the way back to the user.
The Turbine XSLT service works well. The documentation is a little sparse, but here's a little code snippet from a screen class:
// Get your XML. I'm using a String, but
// but you could simply create a FileReader instead
String xmlSchema = getXMLSchema(); // This is just a filename. The location for the
// templates is defined in TurbineResources.properties
String xslTemplate = "MyTemplate.xsl"; // Set up a StringReader for the XML String:
Reader reader = new StringReader(xmlSchema); // Send the XML and the XSL template to the transformer:
TurbineXSLTService xslt = new TurbineXSLTService();
xslt.init();String sOutput = xslt.transform(xslTemplate, reader);
context.put("formOutput", sOutput);
I'm just writing the HTML output from the XSL transformation to a String, and accessing it in the Velocity template via the Context. I'm sure there are better ways to do this, but this is working just fine (the XSL is generating HTML forms based on the contents of the XML).
HTH b
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
