You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Peter Sojan <il...@gmx.net> on 2002/04/07 17:46:33 UTC

[DVSL] named templates and pendant ...

... are there any plans for them in the near future?

IMHO this would be great for code-reuse within templates:

I have two very similar elements A and B whereas B generates 
the same output as A plus additional output.

The template for B could therefore "call" the template for 
A and generate the extra output afterwards.

of course since we are in VTL we can do this style of code 
reuse already if we put code for A in a macro and simply 
call it from B. 

The former would just be more XSLT-ish and I would not have to
wrap everything in macros ...

any suggestions!?

so long
Peter


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


Re: [DVSL] named templates and pendant ...

Posted by Peter Sojan <il...@gmx.net>.
On Sun, Apr 07, 2002 at 12:15:17PM -0400, Geir Magnusson Jr. wrote:
> On 4/7/02 12:07 PM, "Peter Sojan" <il...@gmx.net> wrote:
> 
> 
> So you might phrase as
> 
>   $context.callTemplate( $node, templatename)
> 
> As you then can do things like
> 
>   #foreach($n in $node.selectNodes("foo/bar"))
>       $context( $n, "foobartempalte")
>   #end
> 

would be cool :)

> Well, we could have that as an attribute map of some type?

hmmm...yes 

Peter


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


Re: [DVSL] named templates and pendant ...

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 4/7/02 12:07 PM, "Peter Sojan" <il...@gmx.net> wrote:

> On Sun, Apr 07, 2002 at 11:52:07AM -0400, Geir Magnusson Jr. wrote:
> 
>> You mean just something like :
>>    $context.callTemplate( $node.selectNode("foo/bar"), "templatename")
>> 
> 
> As far as I can see, there is only one attribute in the call-template
> directive in XSLT and optional parameters in the body:
> 
> -------------------------------------------
> <xsl:call-template
> name = qname>
> <!-- Content: xsl:with-param* -->
> </xsl:call-template>
> ------------------------------------------
> 
> 
>> How do you think the syntax should be?
> 
> In DVSL a template definition begins with the #match clause, so that must
> be extended to support an optional name for the template:
> 
> #match(<matching-element>, [<templatename>])
> 
> which could then be called via:
> 
> $context.callTemplate(<templatename>)

That's easily doable - I assume the current value of $node would then be the
value of $node which called it?

So you might phrase as

  $context.callTemplate( $node, templatename)

As you then can do things like

  #foreach($n in $node.selectNodes("foo/bar"))
      $context( $n, "foobartempalte")
  #end


> I have absolutely no clue how parameters which are enclosed in the body
> of the XSLT call-template tag should be handled in DVSL.


Well, we could have that as an attribute map of some type?

Thx

> 
> see http://www.w3.org/TR/xslt#element-with-param for an example how this
> is done in XSLT ...
> 
> so long 
> Peter
> 
> 
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
Be a giant.  Take giant steps.  Do giant things...


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


Re: [DVSL] named templates and pendant ...

Posted by Peter Sojan <il...@gmx.net>.
On Sun, Apr 07, 2002 at 11:52:07AM -0400, Geir Magnusson Jr. wrote:

> You mean just something like :
>    $context.callTemplate( $node.selectNode("foo/bar"), "templatename")
> 

As far as I can see, there is only one attribute in the call-template
directive in XSLT and optional parameters in the body: 

-------------------------------------------
<xsl:call-template
  name = qname>
  <!-- Content: xsl:with-param* -->
</xsl:call-template> 
------------------------------------------


> How do you think the syntax should be?

In DVSL a template definition begins with the #match clause, so that must
be extended to support an optional name for the template: 

  #match(<matching-element>, [<templatename>])

which could then be called via: 

  $context.callTemplate(<templatename>)

I have absolutely no clue how parameters which are enclosed in the body 
of the XSLT call-template tag should be handled in DVSL. 

see http://www.w3.org/TR/xslt#element-with-param for an example how this 
is done in XSLT ...

so long 
Peter



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


Re: [DVSL] named templates and pendant ...

Posted by Peter Sojan <il...@gmx.net>.
On Sun, Apr 07, 2002 at 11:52:07AM -0400, Geir Magnusson Jr. wrote:
> On 4/7/02 11:46 AM, "Peter Sojan" <il...@gmx.net> wrote:
> 
> > 
> > ... are there any plans for them in the near future?
> > 
> > IMHO this would be great for code-reuse within templates:
> > 
> > I have two very similar elements A and B whereas B generates
> > the same output as A plus additional output.

Note that my first naive approach was, to generate element A from 
the B template. However since this newly generated element is never 
handled again in the same transformation process, one would have 
to to a second-stage transformation. 

I always wondered why this was not implemented in XSLT as this would 
make XSLT even more powerful. Maybe a case for DVSL !?

so long
Peter  


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


Re: [DVSL] named templates and pendant ...

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 4/7/02 11:46 AM, "Peter Sojan" <il...@gmx.net> wrote:

> 
> ... are there any plans for them in the near future?
> 
> IMHO this would be great for code-reuse within templates:
> 
> I have two very similar elements A and B whereas B generates
> the same output as A plus additional output.

You mean just something like :


   $context.callTemplate( $node.selectNode("foo/bar"), "templatename")


> 
> The template for B could therefore "call" the template for
> A and generate the extra output afterwards.
> 
> of course since we are in VTL we can do this style of code
> reuse already if we put code for A in a macro and simply
> call it from B. 
> 
> The former would just be more XSLT-ish and I would not have to
> wrap everything in macros ...

That's a decent idea - the hope with DVSL was to ignore all the xslt stuff
until people asked for it.

How do you think the syntax should be?

-- 
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>