Joseph White wrote:
Here are my questions:
* [fop] How do I replace the fop 0.20 integrationwiht fop 0.03
integration in cocoon 2.1.10?
* [MS SQL Server] Is it sufficient to include the appropriate Class
4 jdbc driver (of my choice) for MS SQL Server in the area where
the oracle and odbc classes are listed?
* [Saxon] how do I replace the xalan integration wiht Saxon 8.9.03?
I apologize if I have missed the documentation on this -- I have
searched for discussion groups, books etc.
ErstwhileIII
Hi Joseph,
Attached you'll find a serializer for fop 0.93.
Create a new block called fop-0.93 and put the files in the following
directories:
src/blocks/fop-0.93/conf/fop-0.93.xmap
src/blocks/fop-0.93/java/org/apache/cocoon/serialization/FOPSerializer.java
Add the following to lib/jars.xml:
<file>
<title>XML FO 0.93 processor</title>
<description>
FOP is a Java application that reads a formatting object tree
conforming to
the XSL recommendation and then turns it into a PDF document.
</description>
<used-by>FOP serializer (fop-0.93 block)</used-by>
<lib>optional/fop-0.93.jar</lib>
<homepage>http://xml.apache.org/fop-0.93/</homepage>
</file>
Add the following to gump.xml:
<project name="cocoon-block-fop-0.93" status="unstable"
dir="src/blocks/fop-0.93">
<package>org.apache.cocoon</package>
<description><link href='xml.apache.org/fop/'>FOP</link> reads an
<link href='www.w3.org/TR/xsl/'>XSL-FO</link> document and turns
it into a PDF,
PS or PCL format document using FOPSerializer. Include libraries
and docs.
Include FOP libraries, components and samples.</description>
<ant target="gump-block">
<property name="block-name" value="fop-0.93"/>
<property name="version" value="@@DATE@@"/>
</ant>
<depend project="cocoon" inherit="all"/>
<depend project="xml-fop-maintenance"/>
<depend project="cocoon-block-batik"/>
<depend project="cocoon-block-xsp" type="samples"/>
<library name="fop-0.93"/>
<work nested="tools/anttasks"/>
<home nested="build/cocoon-@@DATE@@"/>
<jar name="blocks/fop-block.jar"/>
<nag from="Gump <[EMAIL PROTECTED]>"
to="[EMAIL PROTECTED]"/>
<nag from="Gump <[EMAIL PROTECTED]>"
to="[EMAIL PROTECTED]"/>
</project>
Make the following settings in local.blocks.properties:
#-----[dependency]: "fop" depends on "batik", "xsp" (for samples).
#-----[dependency]: "fop" is needed by "tour".
include.block.fop=false
#-----[dependency]: "fop-0.93" depends on "batik"
#include.block.fop-0.93=false
Regarding the MS SQL Server, I guess you declare the driver to be loaded
in web.xml. And define you datasources in cocoon.xconf. Make sure the
drivers are in the class path or lib directory and it should work. But I
must confess I don't have experience with MS SQL in cocoon.
You can replace xalan with saxon by changing the class of the xslt
transformer in sitemap.xmap. But I've never tried it myself.
regards,
Pieter
<?xml version="1.0"?>
<!--
Copyright 1999-2004 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<xmap xmlns:map="http://apache.org/cocoon/sitemap/1.0"
xpath="/sitemap/components/serializers" unless="[EMAIL PROTECTED]'fo2pdf']">
<map:serializer name="fo2pdf" logger="sitemap.serializer.fo2pdf" src="org.apache.cocoon.serialization.FOPSerializer" mime-type="application/pdf">
<!-- This element specifies URL to FOP user configuration file.
It can be absolute file URL or relative to the servlet context.
Examples:
<user-config>file:/C:/cocoon/fop-config.xml</user-config>
<user-config>WEB-INF/fop-config.xml</user-config>
-->
<!-- Should serializer set content length header or not?
Default is true.
<set-content-length>true</set-content-length>
-->
</map:serializer>
<map:serializer logger="sitemap.serializer.fo2ps" name="fo2ps" src="org.apache.cocoon.serialization.FOPSerializer" mime-type="application/postscript"/>
<map:serializer logger="sitemap.serializer.fo2pcl" name="fo2pcl" src="org.apache.cocoon.serialization.FOPSerializer" mime-type="vnd.hp-PCL"/>
</xmap>
package org.apache.cocoon.serialization;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Serializable;
import org.apache.cocoon.serialization.AbstractSerializer;
import org.apache.cocoon.caching.CacheableProcessingComponent;
import org.apache.cocoon.CascadingIOException;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceResolver;
import org.apache.excalibur.source.SourceValidity;
import org.apache.excalibur.source.impl.validity.NOPValidity;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.MimeConstants;
import org.xml.sax.SAXException;
public class FOPSerializer extends AbstractSerializer implements
Configurable, Serviceable, CacheableProcessingComponent {
protected FopFactory fopFactory;
/**
* The current <code>mime-type</code>.
*/
protected String mimetype;
/**
* Should we set the content length ?
*/
protected boolean setContentLength = true;
/**
* Manager to get URLFactory from.
*/
protected ServiceManager manager;
/**
* @return
* @see org.apache.cocoon.sitemap.SitemapOutputComponent#getMimeType()
*/
public String getMimeType() {
return mimetype;
}
/**
* @param out OutputStream
* @throws IOException java.io.IOException
* @see
org.apache.cocoon.sitemap.SitemapOutputComponent#setOutputStream(java.io.OutputStream)
*/
public void setOutputStream(OutputStream out) throws IOException {
if (getLogger().isDebugEnabled())
getLogger().debug("setOutputStream() - invoking method...");
try {
Fop fop = fopFactory.newFop(getMimeType(), out);
this.setContentHandler(fop.getDefaultHandler());
} catch (FOPException e) {
getLogger().error("Can not create FOP instance!", e);
throw new CascadingIOException("Can not create FOP instance!", e);
}
if (getLogger().isDebugEnabled())
getLogger().debug(getClass() + ".setOutputStream() - exiting
method...");
}
/**
* @return
* @see
org.apache.cocoon.sitemap.SitemapOutputComponent#shouldSetContentLength()
*/
public boolean shouldSetContentLength() {
return this.setContentLength;
}
/**
* @param manager
* @throws ServiceException
* @see
org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
*/
public void service(ServiceManager manager) throws ServiceException {
this.manager = manager;
}
/**
* @param configuration
* @throws ConfigurationException
* @see
org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
*/
public void configure(Configuration configuration) throws
ConfigurationException {
this.fopFactory = FopFactory.newInstance();
this.mimetype = configuration.getAttribute("mime-type",
MimeConstants.MIME_PDF);
this.setContentLength =
configuration.getChild("set-content-length").getValueAsBoolean(true);
String configUrl = configuration.getChild("user-config").getValue(null);
if (configUrl != null) {
Source configSource = null;
SourceResolver resolver = null;
try {
resolver = (SourceResolver)
this.manager.lookup(SourceResolver.ROLE);
configSource = resolver.resolveURI(configUrl);
this.fopFactory.setUserConfig(configSource.getURI());
/*if (this.configURI != null) try {
fopFactory.setUserConfig(this.configURI);
} catch (SAXException e) {
getLogger().warn("Can not set FOP user config!", e);
}*/
//this.configURI = configSource.getURI();
} catch (Exception e) {
getLogger().warn("Cannot load configuration from " + configUrl);
throw new ConfigurationException("Cannot load configuration
from " + configUrl, e);
} finally {
if (resolver != null) {
resolver.release(configSource);
manager.release(resolver);
}
}
}
if (getLogger().isDebugEnabled()) {
getLogger().debug("configure() - mimetype: " + this.mimetype);
getLogger().debug("configure() - user config file: " + configUrl);
}
}
/**
* Generate the unique key.
* This key must be unique inside the space of this component.
* This method must be invoked before the generateValidity() method.
*
* @return The generated key or <code>0</code> if the component
* is currently not cacheable.
*/
public Serializable getKey() {
return "1";
}
/**
* Generate the validity object.
* Before this method can be invoked the generateKey() method
* must be invoked.
*
* @return The generated validity object or <code>null</code> if the
* component is currently not cacheable.
*/
public SourceValidity getValidity() {
return NOPValidity.SHARED_INSTANCE;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]