On 19.Dec.2002 -- 11:21 AM, Jeremy Quinn wrote:
>
> On Thursday, Dec 19, 2002, at 10:55 Europe/London, Konstantin Piroumian
> wrote:
>
> >From: "Jeremy Quinn" <[EMAIL PROTECTED]>
> >>On Thursday, Dec 19, 2002, at 09:14 Europe/London, Konstantin
> >>Piroumian
> >>>From: "Geoff Howard" <[EMAIL PROTECTED]>
>
> <snip/>
>
> >>Is it possible to use the XMLModule in such a way that values from the
> >>XML conf file can be overridden by request parameters?
> >
> >Yes, that was the intention for creating the ChainMetaModule. See how
> >it is
> >configured in cocoon.xconf and add a similar configuration for your
> >case.
> >
>
> Something like this in cocoon.xconf? :
>
> <component-instance
> class="org.apache.cocoon.components.modules.input.XMLFileModule"
> logger="core.modules.xml" name="myxml">
> <file src="context://my-conf.xml"/>
> </component-instance>
>
> <component-instance
> class="org.apache.cocoon.components.modules.input.ChainMetaModule"
> logger="core.modules.input" name="chain">
> <input-module name="request-param"/>
> <input-module name="myxml"/>
> </component-instance>
>
>
> Then how do you access the variables in the sitemap?
> Like this?:
>
> {chain:/*/my-var} if I want it overridden by request params
Assume that the parameter is named "my-var" and the my-conf.xml looks
like
<my-var>value</my-var>
note: this is the only node.
Then you'd access it through
{chain:/my-var} or {chain:my-var}
If a request parameter with the same name exists, it would be
preferred over the value from the file.
> and
>
> {myxml:/*/myvar} if I do not want an override?
Yes, {myxml:/myvar} or {myxml:myvar} in this case.
So, if your my-conf.xml looks like
<root>
<my-var>value</my-var>
<section>
<other-var>value</other-var>
</section>
</root>
it would be {chain:root/section/other-var} and the request parameter
would need to be "root/section/other-var". If you don't like that,
consider adding the SimpleMappingMetaModule around the myxml in the
chain config: (I assume that the component has been declared as simple-map)
<component-instance
class="org.apache.cocoon.components.modules.input.ChainMetaModule"
logger="core.modules.input" name="chain">
<input-module name="simple-map">
<prefix>/root/section/</prefix>
<input-module name="request-param"/>
</input-module>
<input-module name="myxml"/>
</component-instance>
which would result is {chain:other-var} being looked up as
{myxml:/root/section/other-var} and {request-param:other-var} but of
course {chain:my-var} would turn into {myxml:/root/section/my-var}
which is not desired here. SimpleMappingMetaModule supports some more
mapping options if you need it.
Chris.
--
C h r i s t i a n H a u l
[EMAIL PROTECTED]
fingerprint: 99B0 1D9D 7919 644A 4837 7D73 FEF9 6856 335A 9E08
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]