> From: Jon Stevens [mailto:[EMAIL PROTECTED]]
> 
> 
> on 12/1/2000 12:58 PM, "Jose  Alberto Fernandez" 
> <[EMAIL PROTECTED]>
> wrote:
> 
> > Hummm, I wonder if at some point we could have implicit filtering
> > (i.e encoding) of the expansions generated from context information.
> > What I mean is that rather me writing in my template:
> > 
> > <element>$escape.getText($x.getFieldwithText())
> > $escape.getText($y)</element>
> > 
> > over and over all over the template. And instead The script 
> writer will do
> > 
> > <element>$x.getFieldwithText() $y</element>
> > 
> > and make the engine do the escaping as it does the expansion.
> > Do people see any value in something like that?
> 
> In that case, then that is what YOU should do in your object 
> code. You can
> call the Escape code from anywhere, so I would imagine that in your
> $x.getFieldwithText(), you would call that method.
> 

Well, I could argue that the need for encoding is part of the View and
not of the model or the controler. In other words, if I where in need to
generate some other text format, which I can do using Vel, I should not
need to change my model. I would expect I can use "$x.getFieldwithText()"
and this time getting not escaped output.

> The problem is that not everything should be filtered.

True, but what I am suggesting is that only "variable"/"method" output
be filtered. Not the template itself (the argument being that template 
encoding is for the writer of the template to do).

If the filters can be installed dynamically, it would be up to
the script to control it. For example, lets assume there is a directive
#filter the argument being an object implementing certain interface:

XMLScript.vtl

#filter($filter)
<?xml ...?>

<stuff>
 $x.getValue()
<cdatastuff>$filter.turnOff()<![CDATA[>
here goes unscaped stuff & this happens because I dynamically
switched off my filter, because I ddesigned it that way.
<!]]>$filter.turnOn()</cdatastuff>
More filtered stuff for $y here.
</stuff>

So what do you think, what I am asking is a definition and way
to set this filter interfaces, it is up to the developer to provide
the smarts required by it.

public class XMLFilter implements Filter
{
  private boolean off = false;

  public String process(String in) { //Filter interface
   if (off) return in;
   return Escape.getText(in);
  }

  public void turnOn() { off = false; }
  public void turnOff() { off = true; }
}


Jose Alberto

Reply via email to