Hello,
Sorry to send several questions on the mailing list.
I would like to know what I have to configure to make my own class
implementing XSLTTransformer in spring and to use it in the sitemap. I am a
newbie with Cocoon so if somebody would have an example it would be famous.
Here is an extract of my sitemap :
<map:resources>
<map:resource name="transform-my">
<map:transform type="exportXSLTTransformer" />
</map:resource>
</map:resources>
an extract of the applicationContext.xml :
<!-- Export XSLT transformer -->
<bean name="org.apache.cocoon.transformation.Transformer
/exportXSLTTransformer"
scope="prototype"
class="xxxx.ExportXSLTTransformer">
<property name="xmlFormatManager">
<ref bean="xmlFormatManager" />
</property>
</bean>
and my implementation class (code not finalised) :
public class ExportXSLTTransformer extends XSLTTransformer {
/** General log stream */
private static final Log log = LogFactory.getLog(
ExportXSLTTransformer.class);
/** HTTP parameter name for format parameter */
static private final String FORMAT_PARAM_NAME = "format";
static private final String DEFAULT_FORMAT_NAME = "Live";
/** XSD validator implementations */
private XmlFormatManager xmlFormatManager;
/** HTTP request */
private Request request;
@SuppressWarnings("unchecked")
public void setup(SourceResolver resolver,
Map objectModel,
String src,
Parameters parameters) throws SAXException,
ProcessingException, IOException {
request = ObjectModelHelper.getRequest(objectModel);
String formatName = request.getParameter(FORMAT_PARAM_NAME);
if(formatName == null) {
formatName = DEFAULT_FORMAT_NAME;
}
String fileName = xmlFormatManager.getStylesheetMaxmlExportFileName
(formatName);
super.enableLogging(new CLLoggerWrapper(this.log)); // HERE I FORCE
ENABLELOGGING TO MAKE WORK A LITTLE BETTER
super.setup(resolver, objectModel, fileName, parameters);
}
/**
* XSD validators and XSLT stylesheets manager setter
*
* @param xmlFormatManager XSD validators and XSLT stylesheets manager
*/
public void setXmlFormatManager(XmlFormatManager xmlFormatManager) {
this.xmlFormatManager = xmlFormatManager;
}
}
When I execute it there are NullPointerException :
- org.apache.cocoon.transformation.XSLTTransformer.setup(
XSLTTransformer.java:292) if I don't force the enableLogging()
- org.apache.cocoon.transformation.XSLTTransformer.setup(
XSLTTransformer.java:304) if I force the enableLogging()
It seems that my class is not initialized by Cocoon, I looked in the Cocoon
code the XSLTTansformer initialization but didn't found it.
Can somebody help me please ?