You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Leon Messerschmidt <le...@opticode.co.za> on 2001/06/21 15:03:56 UTC
Re: VelocityXsl
Hi Adonis,
Please remember that Turbine does not do the $HelloLeon or #parse directives
or anything like that. This is done by Velocity (another Jakarta Project).
Velocity is a templating engine that allows you to replace stuff like
$HelloLeon with object which you place into the context.
We Turbine users use Velocity so much that we created a Turbine Service to
easily do any Velocity Rendering. The VelocityScreen and VelocityLayout
(which you set in your TurbineResources.properties) makes use of this
service, but you as a programmer can also use this service.
For example if you have a directory <webapp>/templates/xml and a file
<webapp>/templates/xml/leon.vm which looks something like this:
<text>$HelloLeon</text>
First you need to do the Velocity Part. For this you need to create a
context and then render the Velocity template like so:
// Remember to include the relevant packages
// This line gives you a new Velocity context. This is where you
add stuff
// which will be replaced in the final template
Context context = TurbineVelocity.getContext(data);
// Now you need to add parameters needed for the template to the
context.
// You can add any object here. For more information about
templates
// see the Velocity site.
context.put ("HelloLeon","This is a hello message for Leon");
// Now you execute the template with the context
String content = TurbineVelocity.handleRequest
(context,"xml/leon.vm");
After this step the content variable should hold a string with the rendered
template. This string you can feed through an XSL transformation.
Something like this
String result = TurbineXSLT.transform ("myxslfile",content);
The result variable should now contain the rendered and transformed content
of the whole process. Hope this helps.
~ Leon
> Hi Leon,
>
> sorry that I take so much of your time!
>
> Perhaps I should say, that I work with turbine (does it help you ;-).
> A Javafile transform a xml file with a xsl file, which includs
> velocitystuff, to a html file(I hope you won't get to confused).
> I store these html file in a stringvariable $HelloLeon.
> These $HelloLeon is called in a .vm file. I hoped turbine would render
> the content of $HelloLeon automaticly, but it didn't.
> So I tried to render it with #parse($HelloLeon) but all I got was an
> empty screen (no error, nothing!)
> What can I do?
>
> Thank you very, very much
>
> Adonis
>
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org