Entity resolution with catalogs is well documented for Cocoon 2.1 [1] but it works a little bit different with a Cocoon 2.2 Maven project:

CHANGING THE VERBOSITY OF CATALOG RESOLVER
You just have to create src/main/resources/META-INF/cocoon/spring/ override.properties with following content [2]:
org.xml.sax.EntityResolver/verbosity=10

In CatalogManager.properties [3] the different verbosity levels are explained and the verbosity is set to 1.

LOCAL CATALOG FILE ON FILE SYSTEM
If your local catalog file and DTDs, ... are available on the file system on dev, test and prod you can also use the property override mechanism in src/main/resources/META-INF/cocoon/spring/ override.properties:
org.xml.sax.EntityResolver/localCatalog=file:/folder/catalog

LOCAL CATALOG FILE IN JAR
The catalog resolver can only work with files on the file system not with files which are inside JARs. Therefore CocoonSystemResolver deploys all JAR resources in META-INF/cocoon/entities to a working directory [4]. Using that you can put your catalog with the DTDs, ... into src/main/resources/META-INF/cocoon/entities/yourCompany. Unfortunately you can't use the property override mechanism now because the location of the working directory depends on the servlet container. I solved this with an extra singleton bean which sets the local catalog file and reinitializes the entity resolver:

<bean name="yourCompany.entityResolving" class="yourCompany.entityResolving.LocalCatalogConfigurator" scope="singleton">
        <constructor-arg ref="org.xml.sax.EntityResolver" />
</bean>

import org.apache.cocoon.core.xml.impl.DefaultEntityResolver;

public class LocalCatalogConfigurator {
        
        final private DefaultEntityResolver cocoonEntityResolver;

public LocalCatalogConfigurator(final DefaultEntityResolver cocoonEntityResolver) throws Exception {
                super();
                this.cocoonEntityResolver = cocoonEntityResolver;
                cocoonEntityResolver.setLocalCatalog(getDeployedCatalogFile());
                cocoonEntityResolver.init(); // requires reinitialization
        }
        
        String getDeployedCatalogFile() {
return getEntitiesDirectory() + "sfcore-component-cocoon/ catalog";
        }

        /**
* @return Cocoon entity resolver working directory with backslash at the end
         */
        String getEntitiesDirectory() {
                return cocoonEntityResolver.getCatalog().replaceAll("catalog$", 
"");
        }

}

The getEntitiesDirectory() method is a little bit ugly. This could be improved if the CocoonSystemResolver provided a getEntitiesDirectory() method.

If you want to make sure that your system does not retrieve any DTDs via the net something like a NoNetEntityResolver would be useful which throws an exception if it can't find the DTD in the local catalog files. Is anybody aware of such an entity resolver?

Hope that this is helpful to somebody.

Alex

[1] http://cocoon.apache.org/2.1/userdocs/concepts/catalog.html
[2] 
http://cocoon.apache.org/subprojects/configuration/1.0/spring-configurator/2.0/1310_1_1.html
[3] 
http://svn.apache.org/repos/asf/cocoon/tags/cocoon-2.2/cocoon-xml-resolver/cocoon-xml-resolver-1.0.0/src/main/resources/CatalogManager.properties
[4] 
http://svn.apache.org/repos/asf/cocoon/tags/cocoon-2.2/cocoon-xml-resolver/cocoon-xml-resolver-1.0.0/src/main/java/org/apache/cocoon/core/xml/resolver/CocoonSystemResolver.java

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to