Domino on Linux/Unix, Troubleshooting, Best Practices, Tips and more ...

Export/Import DXL needs to discard doc object before accessing updated information

Daniel Nashed  22 April 2010 23:01:08

I ran into some very behaviour today. I have used DXL export and import to change some information in the document and wanted to access the updated document afterwards.
Accessing the document after a re-open via db.GetDocumentByUNID gave me the old document instead of the updated document.
The only way I found to re-load the document was to set the doc to nothing to close the older instance of the document.
I thought the GetDocumentByUNID would re-open the database but it gets a reference to the existing document instead.

Isn't that odd?


-- Daniel


--- do some work with document ---

call doc.save (true, false)
doc_unid = doc.UniversalID
                        
Dim stream As NotesStream
Dim out_str As String
Dim replace_str As String
Dim exporter As NotesDXLExporter
                        
Set stream = session.CreateStream
Set exporter = session.CreateDXLExporter
Call exporter.SetInput(doc)
Call exporter.SetOutput(stream)
Call exporter.Process
                        
out_str = stream.ReadText        
replace_str = Replace (out_str, newline_string, "<break/>")
                        
Dim importer As NotesDXLImporter
Set importer = session.CreateDXLImporter
importer.DocumentImportOption = DXLIMPORTOPTION_UPDATE_ELSE_IGNORE
Call importer.Import(replace_str, db)
                        
Set doc = Nothing

Set updated_doc = db.GetDocumentByUNID( doc_unid )

--- do some work with updated_doc ---

Comments

1Daniel J├Ąger  23.04.2010 0:48:21  Export/Import DXL needs to discard doc object before accessing updated information

Had the same behavior when I was calling an agent via LS that modified a document which was already referenced before the agent ran.

I used the following code to get the updated Version of the document:

Delete doc ' Delete the notesDocument Object

2Daniel Nashed  23.04.2010 8:38:51  Export/Import DXL needs to discard doc object before accessing updated information

@Daniel, you are right the delete doc would have been the cleaner way. the doc = nothing only cleans the reference but if there are other references the backend document might be still open if there is another reference.

I have done some additional testing this morning (it was quite late when I posted). The delete doc destroys the complete object. If you have another reference the other doc will be also nothing. I wasn't aware before that Lotus Script does it this way. Even if you have many instances of the same document open it will be only one open note in the backend (I have tested with a loop opening the same document many times and checking a NSD that only one open note was present in memory).

-- Daniel

3Doug Finner  24.04.2010 13:00:31  Export/Import DXL needs to discard doc object before accessing updated information

I don't use dxl at all so your post has me curious; what are you doing that makes dxl a reasonable choice? If I'm not doing something that is better/more efficient/more flexible than standard LS doc manipulation, I'd like to start.

4Daniel Nashed  28.04.2010 9:27:11  Export/Import DXL needs to discard doc object before accessing updated information

@Doug, Now that we have almost round-trip possible for all kind of operations DXL can be used to manipulate design and data in many ways.

In my case I am doing conversion-operations in places where you cannot use the richtext classes.

But there are many other areas where DXL can help you. The whole document with all items is represented in XML which allows basically any kind of operation.

And you can either write it back to the existing document, a new document or you can also insert/update individual items into a document.

For design elements you can use it to modify the design of a database. for example to apply a new style for views and folder etc ... and much more ...

-- Daniel

Archives


  • [IBM Lotus Domino]
  • [Domino on Linux]
  • [Nash!Com]
  • [Daniel Nashed]