You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by David Legg <da...@searchevent.co.uk> on 2008/09/25 02:04:02 UTC

[C2.2] Overriding default properties?

I'm a little confused about the best way to change or override default 
settings for properties in Cocoon 2.2.

Out of the box the 'html' serializer is set to produce Transitional 4.01 
HTML.  So if I put the following in sitemap.xmap:
  ...
    <map:serialize type="html"/>
  ...
then that's what I get.

Now if I try overriding the defaults by explicitly adding extra 
parameters to the sitemap as follows:
  ...
    <map:serialize type="html">
      <doctype-public>-//W3C//DTD HTML 4.01//EN</doctype-public>
      <doctype-system>http://www.w3.org/TR/html4/strict.dtd</doctype-system>
    </map:serialize>
  ...


I get no change in the output.  Is this because the spring beans which 
define the default settings have a higher priority than the sitemap?

I've looked at the Block directory structure documentation [1] and get 
the feeling that that page is trying to tell me something about the 
order of priority that a property has depending on which directory it is 
defined in... but am I right?  and what is the order?

If I explicitly define my own spring bean and place it in 
[block]/src/main/resources/META-INF/cocoon/spring/something.xml and 
refer to this bean from the sitemap then all is well and the properties 
get set.

It seems to me that the priorities are a little askew.  I would have 
thought the local sitemap settings should have more sway than the Cocoon 
defaults stored as beans in another block somewhere?

Regards,
David Legg


[1] http://cocoon.apache.org/2.2/core-modules/core/2.2/1263_1_1.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: [C2.2] Overriding default properties? - SOLVED

Posted by David Legg <da...@searchevent.co.uk>.
I wrote:

> I'm a little confused about the best way to change or override default 
> settings for properties in Cocoon 2.2.

I'm less confused now ;-)

> Out of the box the 'html' serializer is set to produce Transitional 
> 4.01 HTML.  So if I put the following in sitemap.xmap:
>  ...
>    <map:serialize type="html"/>
>  ...
> then that's what I get.
>
> Now if I try overriding the defaults by explicitly adding extra 
> parameters to the sitemap as follows:
>  ...
>    <map:serialize type="html">
>      <doctype-public>-//W3C//DTD HTML 4.01//EN</doctype-public>
>      
> <doctype-system>http://www.w3.org/TR/html4/strict.dtd</doctype-system>
>    </map:serialize>
>  ...
> I get no change in the output.  Is this because the spring beans which 
> define the default settings have a higher priority than the sitemap?

I realize now that doing things this way is the 'old' or pre-cocoon 2.2 
way and I must empty my head of such thoughts!

As an experiment I located the following file:

  
[cocoontrunk]/core/cocoon-pipeline/cocoon-pipeline-components/src/main/resources/META-INF/cocoon/spring/cocoon-core-serializers.xml

which I believe to be the file responsible for setting the default 
properties of the 'xml', 'html' and 'xhtml' serializers as well as some 
others.  I then copied this file to my own block here:

  [myblock]/src/main/resources/META-INF/cocoon/spring/serializers.xml

I then edited this file to remove all the other bean definitions except 
the one with the name: 
'org.apache.cocoon.serialization.Serializer/html'.  I also changed the 
doctype-public and doctype-system to the HTML 4.01 strict definition.  
After restarting my C2.2 application I was pleased to see that the 
pipeline which had been outputting 4.01 loose doctype was now outputting 
4.01 strict HTML as required.

So it works!  I have successfully overridden the default config for a 
Cocoon component without having to resort to the sitemap.xmap file.  
Having read other user's comments on this I can see how useful this is.

Regards,
David Legg


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org