You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by Will Hartung <wi...@msoft.com> on 2002/01/23 02:20:41 UTC

Getting a list of reference Identifiers from a Template

Hi all,

When we're getting ready to process a template, we want to map identifiers
referenced in the templates directly to our internal database.

So, for example, say the template is something simple like:

The users first name is $FIRSTNAME

might translate into something silly like

SELECT strValue FROM UserData where User = internalUserId AND ElementName =
'FIRSTNAME'

Now, in our system, there are literally thousands of potential elements for
a user, and while the above SQL is indicitive of what happen, it isn't
really that simple.

It's also "cheaper" for us to bulk load several data elements at one time
rather than one at a time.

So, the thinking is that we could scan the template first to see what is
being referenced, grab 'em all from the DB, populate the context and then
render the template.

It seems that node.ASTReference would be the place to go and fetch such
thing.

So, my question, is what would be the best way to go about getting this
information?

Is there a routine that simply converts the template into an AST that is
then easily walkable to pull out the Identifiers? It seems to me that the
interpreter and AST are pretty tightly bound.

But, I must admit, I'm not that familiar with javacc, so this may be readily
obvious and easy to do.

The other solution is an ugly hack which I'd rather not do.

So, if anyone has the time to give me a rough direction about how this can
be done, I'd appreciate it.

Thanx!

Will Hartung
(willh@msoft.com)



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Getting a list of reference Identifiers from a Template

Posted by Will Hartung <wi...@msoft.com>.
> I think I wrote this a while ago - look in contrib under template tool...
>
> --
> Geir Magnusson Jr.                       geirm@optonline.net


Yup, that's a great start to exactly what I need. As I looked around a bit
at the javacc, I saw this was probably not going to be too super hard, and
this shows that it really isn't.

Thanx!

Will Hartung
(willh@msoft.com)



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Getting a list of reference Identifiers from a Template

Posted by Geir Magnusson Jr <ge...@optonline.net>.
On 1/22/02 8:20 PM, "Will Hartung" <wi...@msoft.com> wrote:

> Hi all,
> 
> When we're getting ready to process a template, we want to map identifiers
> referenced in the templates directly to our internal database.
> 
> So, for example, say the template is something simple like:
> 
> The users first name is $FIRSTNAME
> 
> might translate into something silly like
> 
> SELECT strValue FROM UserData where User = internalUserId AND ElementName =
> 'FIRSTNAME'
> 
> Now, in our system, there are literally thousands of potential elements for
> a user, and while the above SQL is indicitive of what happen, it isn't
> really that simple.
> 
> It's also "cheaper" for us to bulk load several data elements at one time
> rather than one at a time.
> 
> So, the thinking is that we could scan the template first to see what is
> being referenced, grab 'em all from the DB, populate the context and then
> render the template.
> 
> It seems that node.ASTReference would be the place to go and fetch such
> thing.
> 
> So, my question, is what would be the best way to go about getting this
> information?
> 
> Is there a routine that simply converts the template into an AST that is
> then easily walkable to pull out the Identifiers? It seems to me that the
> interpreter and AST are pretty tightly bound.
> 
> But, I must admit, I'm not that familiar with javacc, so this may be readily
> obvious and easy to do.
> 
> The other solution is an ugly hack which I'd rather not do.
> 
> So, if anyone has the time to give me a rough direction about how this can
> be done, I'd appreciate it.

I think I wrote this a while ago - look in contrib under template tool...

-- 
Geir Magnusson Jr.                       geirm@optonline.net
System and Software Consulting
You're going to end up getting pissed at your software
anyway, so you might as well not pay for it. Try Open Source.



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Getting a list of reference Identifiers from a Template

Posted by Jason van Zyl <jv...@zenplex.com>.
On 1/22/02 8:20 PM, "Will Hartung" <wi...@msoft.com> wrote:


> 
> But, I must admit, I'm not that familiar with javacc, so this may be readily
> obvious and easy to do.
> 
> The other solution is an ugly hack which I'd rather not do.
> 
> So, if anyone has the time to give me a rough direction about how this can
> be done, I'd appreciate it.

This might be what you need:

http://cvs.apache.org/viewcvs/jakarta-velocity/contrib/temporary/templatetoo
l/

 
> Thanx!
> 
> Will Hartung
> (willh@msoft.com)
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

-- 

jvz.

Jason van Zyl

http://tambora.zenplex.org
http://jakarta.apache.org/turbine
http://jakarta.apache.org/velocity
http://jakarta.apache.org/alexandria
http://jakarta.apache.org/commons



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>