Using DXL (Domino XML) to review/modify documents
This tip shows you how to review/modify documents using DXL (Domino XML).
This tip shows you how to review/modify documents using DXL (Domino XML). It is applicable to release 6.5. or later. The agents are using the NotesDXLExporter and NotesDXLImporter classes.
The first agent "NotesDocumetExporter" will create XML file in C:temp. The file will contain the selected document in XML format and can be seen by any text editor, Microsoft Internet Explorer or any XML viewer and editors.
It is quite easy to find the field contents so you can modify them. Beware not to change the file structure.
The second agent "NotesImporter" will replace the document in the data base.
<hr> %REM Agent Properties box ==================== Name : NotesDocumetExporter Event to trigger agent : Action menu selection Target:All selected documents % END REM Option Public Option Explicit Sub Initialize On Error Goto ErrorHandler Dim session As New NotesSession Dim database As NotesDatabase Dim document As NotesDocument Dim filename As String Dim exporter As NotesDXLExporter Set database = session.CurrentDatabase Set document = session.DocumentContext Dim stream As NotesStream Set stream = session.CreateStream REM Make any adjustment if you want to filename = "C:temp" & _ Left(database.FileName, Len(database. FileName) - 3) & "xml" If Not stream.Open(filename) Then Messagebox "Cannot open " & filename$,, "Error" Exit Sub End If REM Deletes the contents of a stream Call stream.Truncate Set exporter = session.CreateDXLExporter (document , stream) exporter.OutputDOCTYPE = False Call exporter.Process Exit Sub ErrorHandler: Const LSI_THREAD_PROC = 1 Const LSI_THREAD_CALLPROC=10 Dim messageString As String messageString = Now & "-" & "Error in " & session.CurrentAgent.name & ". " & _ Getthreadinfo(LSI_THREAD_CALLPROC) & ", Erl()=" & Cstr(Erl()) & _ " ,Err()=" & Cstr(Err()) & " ,Error()=" & Error() Msgbox messageString End Sub <hr> %REM Agent Properties box ==================== Name : NotesImporter Event to trigger agent : Action menu selection Target : none %END REM Option Public Option Explicit Sub Initialize On Error Goto ErrorHandler Dim session As New NotesSession Dim database As NotesDatabase Dim filename As String Dim importer As NotesDXLImporter Set database = session.CurrentDatabase Dim stream As NotesStream Set stream = session.CreateStream filename = "C:temp" & _ Left(database.FileName, Len(database. FileName) - 3) & "xml" If Not stream.Open(filename$) Then Messagebox "Cannot open " & filename,, "Error" Exit Sub End If Set importer = session. CreateDXLImporter(stream,database) importer.DocumentImportOption = DXLIMPORTOPTION_REPLACE_ELSE_CREATE importer.DesignImportOption = DXLIMPORTOPTION_REPLACE_ELSE_CREATE Call importer.Process Exit Sub ErrorHandler: Const LSI_THREAD_PROC = 1 Const LSI_THREAD_CALLPROC=10 Dim messageString As String messageString = Now & "-" & "Error in " & session.CurrentAgent.name & ". " & _ Getthreadinfo(LSI_THREAD_CALLPROC) & ", Erl()=" & Cstr(Erl()) & _ " ,Err()=" & Cstr(Err()) & " , Error()=" & Error() Msgbox messageString End Sub <hr>
Do you have comments on this tip? Let us know.
This tip was submitted to the SearchDomino.com tip exchange by member Eitan Rosenberg. Please let others know how useful it is via the rating scale below. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.