on 11/21/2000 5:46 AM, "Theo Keyzer" <[EMAIL PROTECTED]> wrote:

> Interesting idea. Here is a shot at it.
> 
> 
> xsl example:
> 
> <xsl:template match="items">
> <xsl:for-each select="item">
> <xsl:sort select="."/>
> <p>
> <xsl:number value="position()" format="1. "/>
> <xsl:value-of select="."/>
> </p>
> </xsl:for-each>
> </xsl:template>
> 
> Velocity example:
> 
> #template_match( "items", $result )
> {
> #set $item = sort_select("item", $result)
> #foreach $i in $item
> <p>
> $Counter $i
> </p>
> #end
> }

It would have to be $sort_select or something like that and it would be
#macro instead of #template_match.

Ok, I spent a lot of time dreaming about this last night and I think I have
a pretty good handle on what it would take:

An Ant task to do the following:
    gather a list of .xml files to process
    passed in a .vsl (instead of .xsl) template for the processing

    the task would then use JDOM to build up an object representation of the
    .xml file which would then be put into velocity's context and made
    available to the .vsl file.

Then, the Ant task would execute the .vsl page using Velocity and that page
would work from top to bottom in execution. Within the page would be
#macro's similar to the above one. The page would execute against the JDOM
object in the context and do the substitutions there. You could refer to
your specific objects like <body> from within the object in the context to
get the values.

With the recent addition of Velocitimacro's I think that this is going to
make the .vsl page look and work excellently and be very similar in concept
to a .xsl page.

So, I think that I have a way to get 100% (and actually more because of the
ability to stuff whatever I want into Velocity's Context object) of the
functionality of XSL, but without ANY of the headache.

On top of it, I can do stuff within the Ant task such as only process the
files which have changed by comparing the timestamp of the .xml file with
the timestamp of the output file and if it has changed, then only
process/output as necessary.

Summary: Essentially, I'm replacing the Xalan bit with Velocity. The entire
overall big picture concept of XSLT execution is still there.

Comments? Someone want to help me code this up? :-)

thanks,

-jon

-- 
twice of not very much is still a lot more than not very much

Reply via email to