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.

This was first published in December 2004

Dig deeper on XML and Web Services for Lotus Notes Domino

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchWinIT

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.uk

Close