You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Leon Messerschmidt <le...@opticode.co.za> on 2000/08/29 14:25:35 UTC

[Proposal] ProcessVisitor Base Class

Hi,

This might be totally the wrong idea, so please correct me if I'm wrong...

I want to use Velocity for XML templates.  I'd like two basic
functionalities for this (1) the ability to replace xml entities when
variables are inserted (2) to get the output through a PrintWriter.  The
rest should be exactly the same.

What I would like to propose is a base class for ProcessVisitor - maybe
something called Processor (??) .  This base class has two abstract methods:

protected void print(String text, int x, int y, int columnAdjustment)
protected String parseVariable (String var)

A derived ProcessVisitor does the same in the print() method and nothing for
the parseVariable() method.  Other visitors that extend the base class can
print to a PrintWriter in the print() method and replace xml entities in the
parseVariable() method.  This way I (and some other people) can add some
speciality functions without duplicating the Processor code.

Does this sound useful or am I completely missing the boat?

If it is worthwhile I'd be happy to implement it.

~ Leon




Re: [Proposal] ProcessVisitor Base Class

Posted by Jason van Zyl <jv...@periapt.com>.
On Tue, 29 Aug 2000, Leon Messerschmidt wrote:

> Hi,
> 
> This might be totally the wrong idea, so please correct me if I'm wrong...
> 
> I want to use Velocity for XML templates.  I'd like two basic
> functionalities for this (1) the ability to replace xml entities when
> variables are inserted (2) to get the output through a PrintWriter.  The
> rest should be exactly the same.
> 
> What I would like to propose is a base class for ProcessVisitor - maybe
> something called Processor (??) .  This base class has two abstract methods:
> 
> protected void print(String text, int x, int y, int columnAdjustment)
> protected String parseVariable (String var)
> 
> A derived ProcessVisitor does the same in the print() method and nothing for
> the parseVariable() method.  Other visitors that extend the base class can
> print to a PrintWriter in the print() method and replace xml entities in the
> parseVariable() method.  This way I (and some other people) can add some
> speciality functions without duplicating the Processor code.
> 
> Does this sound useful or am I completely missing the boat?

Yes I want to make a base class, but I sort leaving everything
in "expanded" format until we basically decide what the total
syntax is going to be because that affects the visitors.

I am also trying to think of ways to somehow eliminate all
the Node visitors and somehow use polymorphism. Collapse
everything down and optimize as Bob has suggested. But
it would be good to have a document that we agree on.
Jon has documented the script elements on the Velocity
web site. We should decide what else is desired, once
that is settled then we can start collapsing, and cleaning
up the code. The visitors are a bit messy right now,
but they are in their most flexible state that
way.

jvz.

-- 

Jason van Zyl
jvanzyl@periapt.com