Re: A generator with sitemap parameter in C3

Francesco Chicchiriccò <[email protected]>
Newsgroups gmane.text.xml.cocoon.user
Message-ID <[email protected]>
On 11/02/2013 12:07, gelo1234 wrote:
> Question 1:
> Can we have some example of this one ?
>
> <map:generate type="some-custom">
>    <map:parameter name="a" value="1"/>
>    <map:parameter name="b" value="2"/>
> </map:generate>
>
> I mean, how to get sitemap parameter value from Java Generator code ?
> btw. Request Parameters are obtained by the use of HttpContextHelper, 
> is this correct ?

No: you can access map:parameter elements from within Java code in the 
same way how this is done in the XSLTTransformer [1]: consider that 
"source" is the only pre-defined parameter you have in any pipeline 
component, mapped to the 'src' XML attribute.

> Question 2:
> What is the best (optimal) way to include XML content generated from
> servlet/controller?
>
> <x:include .... src="servlet:/..."/>
>
> If the servlet is calling a REST controller there are 2 invocations 
> involved (one to gather data, the other one (with e.g. 
> string-template) to actually serialize the data). Is there any way 
> that REST controller could serialize the data itself ? without 
> invoking another servlet/Page ?

Not that I know: anyway I am using similar includes in different 
production environments with high load and I've experienced no troubles 
so far.

> Question 3:
> If the generator is included in some transformer phase (via x:include)
> does it still have access to original Request Parameters when invoked 
> with:
>
> <x:include ... src="servlet:/generate?par1=a&par2=b/>
>
> or they are lost (original request params) and substituted by new ones 
> (par1, par2 from the line above)?

They are lost: you need to explicitly pass them though.

Regards.

[1] 
https://svn.apache.org/repos/asf/cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/XSLTTransformer.java

-- 
Francesco Chicchiriccò

ASF Member, Apache Syncope PMC chair, Apache Cocoon PMC Member
http://people.apache.org/~ilgrosso/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.