Salve a tutti e complimenti vivissimi per questo sito che tante volte è stata un ancora di salvezza. Vi espongo il mio problema: -Ho realizzao un agente java per la creazione di un file xml, tutto funziona alla grande tranne il metodo createCDATASection che non si comporta come dovrebbe. Per chiarire il concetto posto il codice e l\'ouput XML: import lotus.domino.*; import java.io.*; import java.util.*; import java.text.*; import java.lang.Object.*; //IMPORT PER XML; import org.w3c.dom.*; import com.ibm.xml.parsers.*; import org.apache.xml.serialize.*; import org.w3c.dom.CDATASection; import java.net.URL; public class JavaAgent extends AgentBase { public void NotesMain() { String testo; String tempPath; int numAllegati = 0; String destinatario; String mittente; String testoSubject; String testoMessage; try { Session session = getSession(); AgentContext agentContext = session.getAgentContext(); Database db = agentContext.getCurrentDatabase(); lotus.domino.Document doc = agentContext.getDocumentContext(); String nomeDirectory = "c:\\xmlExport"; String nomeFileXml = "\\Archivio.xml"; //CREAZIONE Documento XML org.w3c.dom.Document docXML = (org.w3c.dom.Document)Class.forName("com.ibm.xml.dom.DocumentImpl").newInstance( ); //Creazione Elemento RADICE org.w3c.dom.Element mailRecordSet = docXML.createElement("mailRecordSet"); mailRecordSet.setAttribute("xmlns", "http://tempuri.org/mailRecordSet.xsd"); mailRecordSet.setAttribute("exported", ""); //Ciclo sui documenti selezionati DocumentCollection dc = agentContext.getUnprocessedDocuments(); lotus.domino.Document docCur = dc.getFirstDocument(); while (docCur != null) { //Creo il nodo principale org.w3c.dom.Element mailRecord = docXML.createElement("mailRecord"); destinatario = docCur.getItemValueString("SendTo"); mittente=docCur.getItemValueString("INetFrom"); mailRecord.setAttribute("from",mittente); mailRecord.setAttribute("to",destinatario); //Leggo i valori dal documento domino - Campo Subject testoSubject = docCur.getItemValueString("subject"); if (testoSubject==null) { org.w3c.dom.Element subject = docXML.createElement("subject"); subject.appendChild(docXML.createCDATASection(" ")); mailRecord.appendChild(subject); } else { org.w3c.dom.Element subject = docXML.createElement("subject"); subject.appendChild(docXML.createCDATASection(testoSubject)); mailRecord.appendChild(subject); } mailRecordSet.appendChild(mailRecord); docCur = dc.getNextDocument(); } //Appendo la Radice all\'oggetto documentoXML docXML.appendChild(mailRecordSet); //Salvo il file XML OutputStream out = new FileOutputStream(new File(nomeDirectory + nomeFileXml)); OutputFormat fmt = new OutputFormat(docXML); fmt.setEncoding(null); fmt.setVersion("1.0"); XMLSerializer ser = new XMLSerializer(out, fmt); ser.serialize(docXML); } catch(Exception e) { e.printStackTrace(); } } } Questo è l\'XML di output: [img]http://www.guasila.com/xml.gif[/img] Se apro il file xml con Notepad quello che noto è che dei tag relativi al CDATA non c\'è neanche l\'ombra... [img]http://www.guasila.com/html.gif[/img] Avete qualche idea? Dove sbaglio? Grazie
|