DXLExporter

Good Day all,

It’s been years since I touched LS or Domino really (I do miss it).

I have been asked to export some Notes documents to XML for migration to another system. (sad I know)

Anyway, I am using the NotesDXLExporter and with a simple script am able to produce XML files for the documents (they want each document as a separate XML file).

Here is the code:


Option Public

Option Explicit

Dim filename As String

Sub Initialize

Dim s As New NotesSession

Dim db As NotesDatabase

Dim col As NotesDocumentCollection

Dim exporter As NotesDXLExporter 

Dim doc As NotesDocument

Dim vw As NotesView

Dim sPath As String

Dim count As integer



Set db = s.CurrentDatabase

Set col = db.UnprocessedDocuments

If col.Count = 0 Then

	MessageBox "No document selected",, "No document"

	Exit Sub

End If







Set doc = col.GetFirstDocument

While Not (doc Is Nothing)

	count = count +1 

	Dim stream As NotesStream

	Set stream = s.CreateStream

	sPath =  "c:\CMD\Export\"  

	filename$ = sPath & doc.UniversalID & "dxl"

	If Not stream.Open(filename$) Then

		MessageBox "Cannot open " & filename$,, "Error"

		Exit Sub

	End If

	

	Set stream = s.CreateStream 

	Call stream.Open(filename$) 

	

	Call stream.Truncate 

	Set exporter = s.CreateDXLExporter  

	exporter.ConvertNotesBitmapsToGIF = true 

	Call exporter.SetInput(doc)

	Call exporter.SetOutput(stream) 

	Call exporter.Process 

	Call stream.Close

	Set doc = col.GetNextDocument(doc)

	Print "Processing: " & CStr(count)& " of " & CStr(col.count)



wend

Exit Sub

End Sub


For some reason the exported XML uses single quotes instead of double quotes for all the item names (fields) and in many other places. I am not an XML expert but I thought these should be enclosed in double quotes for properly formatted XML. I also have some lines which appear to wrap and break the end tags also causing malformatted XML.

I included a little bit of the output (header and item) for you to see:

<?xml version='1.0' encoding='utf-8'?>

<document xmlns=‘http://www.lotus.com/dxl’ version=‘9.0’ maintenanceversion=‘1.0’

replicaid=‘86257E7A00546DD4’ form=‘Main Topic’>

.

.

.

.

In Progress

.

.

Any assistance is much appreciated

Cheers,

Mark

PS. This output is from my designer 9.0.1 client but I also tried with 8.5.2 and 8.5.3 with the same result

Subject: DXLExporter

No, both single and double quotes are allowed (since they’re allowed under SGML, and SGML-compatibility is one of the MUST entries in the XML spec), and both can be found in the XML 1.0 Recommendation document. Single quotes are less likely to cause quotation collisions (they don’t need to be escaped as often) when assembling strings, so finding them in a cross-language library’s output isn’t unusual. You may actually find that the single quotes are transformed to double quotes when viewing the document in some viewers that “pretty print” the document (adding things like non-significant whitespace to make hierarchies more visible and so forth).

Subject: RE: DXLExporter

Thanks Stan (guess you are still the man!)

Is there a straight forward way to change from single to double quotes?

I am trying to appease the other side of this equation (the team importing the data) and they are pushing for double quotes.

Cheers,

Mark

Subject: RE: DXLExporter

I’m not so sure about the “straightforward” part; to avoid munging things, the safe way would be to run things through a SAX parser and write the string data out yourself. There’s a potential problem with nested quotes, but that should be minimal with data documents (design documents would almost be a guaranteed mess) – unless there are JavaScript hotspots in rich text, there shouldn’t be a worry with data docs. Frankly, though, if they’re consuming XML, their XML library/libraries should be able to handle single quotes with aplomb – unless they’ve built their own out of RegExps or some such, in which case all bets are off. (It can never be your fault that their code sucks. If they’re just assuming that their libs can’t munch on XML data with single quotes, tell them to taste it before they decide they don’ like it.)

Subject: RE: DXLExporter

Thanks again Stan,

I was hoping it was just an undocumented flag I could change but this validates what I was thinking also.

I really appreciate your guidance.

Cheers,

Mark