Re: A generator with sitemap parameter in C3

gelo1234 <[email protected]>
Newsgroups gmane.text.xml.cocoon.user
Message-ID <CAPJaKUq_MEnKZ46BJcCH1oVGi2CwgeUitfyNA4xqRPyfh5qGmw@mail.gmail.com>
Ohh...ok that clarifies a problem a bit. So if the generator declaration
inside sitemap.xmap does NOT have src=".." attribute i won't get this piece
of code [1] executed:

if (this.source != null) {
            Object attributesObj = configuration.get("attributes");
            if (attributesObj != null && attributesObj instanceof Map) {
            ...
}

In case of the custom example given before:

<map:generate type="some-custom">
  ...
</map:generate>

it does NOT have src attribute (Not every generator got src attribute). So
the question is still valid, how to get to those <map:parameter .../>
values in such case ? Simply by adding useless src="" attribute to
<map:generate ..> e.g.

<map:generate type="some-custom" src="http://www.w3c.org"> ?

or through the use of some Helper class? as it is in [2] (to Request
Parameters instead of <map:parameter name="a"
value="jexl:cocoon.request.a"/>) with HttpContextHelper - wonder if there
is any equivalent Helper class for Cocoon Sitemap :)


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

Greetings,
Greg




2013/2/11 Francesco Chicchiriccò <[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<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/<http://people.apache.org/~ilgrosso/>
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.**apache.org<[email protected]>
> For additional commands, e-mail: [email protected]
>
>
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.