in a java agent i want to run through all the records in a view and transform all the rtf into xml and shove them out in a browser. When I get to the transformXML method it throws an Exception that says (and I quote)NotesException: Not implemented.
Does anyone know what ive done wrong?
import lotus.domino.*;
import java.io.*;
import java.io.PrintWriter;
import java.util.*;
import org.apache.regexp.*;
import org.w3c.dom.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
// (Your code goes here)
Database db = agentContext.getCurrentDatabase();
DxlExporter exporter = session.createDxlExporter();
exporter.setDoctypeSYSTEM("");
DocumentCollection dc = db.search("SELECT form = \"nope\"");
View view = db.getView("Document\\By Number");
lotus.domino.Document doc = view.getFirstDocument();
doc = view.getNextDocument(doc);
PrintWriter pw = getAgentOutput();
pw.println("content-type: text/xml\n");
pw.println("<?xml version='1.0'?>\n");
pw.println("<docs>\n");
int i = 0;
while(doc != null)
{
pw.println("<doc>\n");
pw.println("<index>"+(++i)+"</index>\n");
String subj = doc.getItemValueString("utitle");
pw.println("<subject>"+genValidXML(subj)+"</subject>\n");
Item inBody = doc.getFirstItem("ubody");
if (inBody != null) {
try {
StringWriter sw = new StringWriter();
XSLTResultTarget out = new XSLTResultTarget(sw);
pw.println("<t>targeted</t>\n");
inBody.transformXML(xsl,out);
pw.println("<body>completed</body>\n");
} catch(Exception e) {
pw.println("<body>"+e.toString()+"</body>\n");
}
} else {
pw.println("<body>no</body>\n");
}
pw.println("</doc>\n");
doc = view.getNextDocument(doc);
}
pw.println("</docs>\n");
} catch(Exception e) {
e.printStackTrace();
}
}
public String genValidXML(String s) {
RE regexp = new RE("&");
if (regexp.match(s))
{
return("has &");
} else {
return(s);
}
}
private String xsl =
"<?xml version='1.0'?>"+
"<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>"+
" <xsl:template match=\"node()|@*\">"+
" <xsl:copy>"+
" <xsl:apply-templates select=\"node()|@*\"/>"+
" </xsl:copy>"+
" </xsl:template>";
}
my method was to go through get the rich text and use the transformXML to run it aginst a stylesheet that just said create all the elements in the tree. I hope I get it right.