[EMAIL PROTECTED] wrote:

I was trying to post reply on the mailing list thread but it shows read only access. Although I had logged in using sourceforge account.

[Replied to this in a private email.]

The java custom processor code is : (The constructor is getting executed but generateDouble is not getting called )

In the XPL file, you have declared a "data" input and a "data" output to the Java processor. So your Java code must use those names as well:


1) In the constructor, you need to declare the input/output with the appropriate names:

   addInputInfo(new ProcessorInputOutputInfo("data"));
   addOutputInfo(new ProcessorInputOutputInfo("data"));

2) When you read the input document, you must use the appropriate name:

   Document numberDocument = readInputAsDOM4J(context, "data");

3) The name of your "generate" method must match the name of the output. Here you want to read from an output called "data", so your generate method should be called "generateData".

I have attached an updated version of your Java file.

Alex
import org.xml.sax.helpers.AttributesImpl;
import org.xml.sax.SAXException;
import org.xml.sax.ContentHandler;
import org.dom4j.Document;
import org.orbeon.oxf.pipeline.api.PipelineContext;
import org.orbeon.oxf.processor.ProcessorInputOutputInfo;
import org.orbeon.oxf.processor.SimpleProcessor;

public class MyProcessor extends SimpleProcessor {

   public MyProcessor() {
       addInputInfo(new ProcessorInputOutputInfo("data"));
       addOutputInfo(new ProcessorInputOutputInfo("data"));
   }

   public void generateData(PipelineContext context,
                             ContentHandler contentHandler)
           throws SAXException {

       // Get number from input using DOM4J
       Document numberDocument = readInputAsDOM4J(context, "data");
       String numberString = (String)
           numberDocument.selectObject("string(/number)");
       int number = Integer.parseInt(numberString);
       String doubleString = Integer.toString(number * 2);

       // Generate output document with SAX
       contentHandler.startDocument();
       contentHandler.startElement("", "number", "number",
                                   new AttributesImpl());
       contentHandler.characters(doubleString.toCharArray(), 0,
                                 doubleString.length());
       contentHandler.endElement("", "number", "number");
       contentHandler.endDocument();
   }
}

Reply via email to