You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Lorenzo De Sio <l....@w4b.it> on 2002/07/30 11:46:53 UTC

Multiple map:resource calls

Hi all,

it seems to me like it is not possible to perform multiple <map:call
resource="xxx"/> calls in a single matcher.

Fragments from my sitemap:

[...]

 <map:resources>
	<map:resource name="aspetto-finale">
	    <map:transform src="_xsl/style.xsl">
		<map:parameter name="nome" value="{nome}"/>
		<map:parameter name="cognome" value="{cognome}"/>
		<map:parameter name="doc_name" value="{../1}"/>
	    </map:transform>
	    <map:serialize/>
	</map:resource>
	<map:resource name="crea-form-dati">
		<map:transform src="_xsl/data0.xsl"/>
		<map:transform src="_xsl/data.xsl"/>
	    <map:serialize/>
	</map:resource>
 </map:resources>

[...]

	<map:match pattern="data/*">
		
		[...]

		<map:call resource="crea-form-dati"/>
		<map:call resource="aspetto-finale"/>
		<map:serialize/>
	</map:act>
	</map:match>

[...]

Both resources work, if used only one at a time. But, as soon as I try to
use both of them in a single matcher, I get the following exception:

	duplicate definition of variable methodName in method matchN10092
[...] duplicate definition of variable argTypes in method matchN10092 [...]
duplicate definition of variable argValues in method matchN10092 [...]

which is obvious, if we look at the generated sitemap.java:

      map = new HashMap(1);
      
      String methodName = "resource_" + substitute(listOfMaps,
"crea_form_dati");
      listOfMaps.add(map);
      this.dumpParameters(listOfMaps);
      Class[] argTypes = new Class[] {StreamPipeline.class,
EventPipeline.class, List.class, Environment.class, String.class,
Boolean.TYPE};
      Object[] argValues = new Object[] {pipeline, eventPipeline,
listOfMaps, environment, cocoon_view, new Boolean(internalRequest)};
      if (true) return invokeMethod(methodName, argTypes, argValues);
  
       map = new HashMap(1);
      
      String methodName = "resource_" + substitute(listOfMaps,
"aspetto_finale");
      listOfMaps.add(map);
      this.dumpParameters(listOfMaps);
      Class[] argTypes = new Class[] {StreamPipeline.class,
EventPipeline.class, List.class, Environment.class, String.class,
Boolean.TYPE};
      Object[] argValues = new Object[] {pipeline, eventPipeline,
listOfMaps, environment, cocoon_view, new Boolean(internalRequest)};
      if (true) return invokeMethod(methodName, argTypes, argValues);


Any hints? Am I doing wrong in trying to call two resources in a matcher?
Are there any correct alternatives?

Thanks in advance to anyone,

L.

---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

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


RE: Multiple map:resource calls

Posted by Vadim Gritsenko <va...@verizon.net>.
> From: Lorenzo De Sio [mailto:l.desio@w4b.it]
> 
> Hi all,
> 
> it seems to me like it is not possible to perform multiple <map:call
> resource="xxx"/> calls in a single matcher.
> 
> Fragments from my sitemap:
> 
> [...]
> 
>  <map:resources>
> 	<map:resource name="aspetto-finale">
> 	    <map:transform src="_xsl/style.xsl">
> 		<map:parameter name="nome" value="{nome}"/>
> 		<map:parameter name="cognome" value="{cognome}"/>
> 		<map:parameter name="doc_name" value="{../1}"/>
> 	    </map:transform>
> 	    <map:serialize/>
> 	</map:resource>
> 	<map:resource name="crea-form-dati">
> 		<map:transform src="_xsl/data0.xsl"/>
> 		<map:transform src="_xsl/data.xsl"/>
> 	    <map:serialize/>
> 	</map:resource>
>  </map:resources>
> 
> [...]
> 
> 	<map:match pattern="data/*">
> 
> 		[...]
> 
> 		<map:call resource="crea-form-dati"/>

BTW, this (second call to resource) will never be executed because of
<map:serialize/> in first call to resource):

> 		<map:call resource="aspetto-finale"/>
> 		<map:serialize/>
> 	</map:act>
> 	</map:match>
> 
> [...]
> 
> Both resources work, if used only one at a time. But, as soon as I try
to
> use both of them in a single matcher, I get the following exception:
> 
> 	duplicate definition of variable methodName in method
matchN10092
> [...] duplicate definition of variable argTypes in method matchN10092
[...]
> duplicate definition of variable argValues in method matchN10092 [...]
> 
> which is obvious, if we look at the generated sitemap.java:
> 
>       map = new HashMap(1);
> 
>       String methodName = "resource_" + substitute(listOfMaps,
> "crea_form_dati");
>       listOfMaps.add(map);
>       this.dumpParameters(listOfMaps);
>       Class[] argTypes = new Class[] {StreamPipeline.class,
> EventPipeline.class, List.class, Environment.class, String.class,
> Boolean.TYPE};
>       Object[] argValues = new Object[] {pipeline, eventPipeline,
> listOfMaps, environment, cocoon_view, new Boolean(internalRequest)};
>       if (true) return invokeMethod(methodName, argTypes, argValues);
> 
>        map = new HashMap(1);
> 
>       String methodName = "resource_" + substitute(listOfMaps,
> "aspetto_finale");
>       listOfMaps.add(map);
>       this.dumpParameters(listOfMaps);
>       Class[] argTypes = new Class[] {StreamPipeline.class,
> EventPipeline.class, List.class, Environment.class, String.class,
> Boolean.TYPE};
>       Object[] argValues = new Object[] {pipeline, eventPipeline,
> listOfMaps, environment, cocoon_view, new Boolean(internalRequest)};
>       if (true) return invokeMethod(methodName, argTypes, argValues);
> 
> 
> Any hints? Am I doing wrong in trying to call two resources in a
matcher?
> Are there any correct alternatives?

Congratulations, you found a bug!
Temporary work-around could be:


<map:match pattern="data/*">
  <map:match pattern="*">
    <map:call resource="crea-form-dati"/>
  </map:match>
  <map:match pattern="*">
    <map:call resource="aspetto-finale"/>
  </map:match>
  <map:serialize/>
</map:match>


Vadim


> 
> Thanks in advance to anyone,
> 
> L.


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

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