Fatalerror in XSLTransformer. Possible memory leak?

I’m using DXLExporter and XSLTransformer to make a .fo file with a xsl stylesheet and then transform it to a pdf file.

That all works good, but only once per session. I must restart my client to run the script again. If I don’t then I get this error:

"<?xml version='1.0'?>

<fatalerror line='2' column='57'>

	An exception occurred!

	Type:XMLPlatformException, Message:Could not open file: xmlschemas\domino_6_5_1.dtd

</fatalerror>

<error>

	XSL transform operation failed

</error>

This is the code (part of it):

Sub ExportAndApplyXSL (doc As NotesDocument, XSLName As String, OutputFilename As String)

Dim session As New NotesSession

Dim exporter As NotesDXLExporter

Dim OutputStream As NotesStream

Dim Transformer As NotesXSLTransformer

Dim Stylesheet As String



' Create a stream object to access the output file

Set OutputStream = session.CreateStream

isopen = OutputStream.Open (OutputFilename, "UTF-8")

If Not isopen Then

	Messagebox "Gat ekki opnað XSL-straum"

	Exit Sub

End If

OutputStream.Truncate



Set exporter = session.CreateDXLExporter (doc, OutputStream)



' Set up the processing pipeline

If XSLName = "" Then

	' No transformations specified -- export the DXL directly to the output file

	exporter.SetOutput OutputStream

Else

	' Pipe the DXL from the exporter into an XSL transformer

	Stylesheet = GetStylesheet (XSLName)

	Set Transformer = session.CreateXSLTransformer (exporter, Stylesheet)

	Transformer.SetOutput OutputStream

End If



' Fire up the export -> {transform} -> {transform} pipeline

On Error Goto errh

exporter.process

done:

OutputStream.Close

Exit Sub

errh: ’ On error, dump the xml logs

Msgbox exporter.log

If XSLName <> "" Then

	Msgbox Transformer.log

End If



Resume done

End Sub

Subject: There seem to be 2 errors happening here

The first one is that the file xmlschemas\domino_6_5_1.dtd was not found. The second one is probably more serious because it is just the generic error message “XSL transform operation failed” which is basically a catch-all for errors that aren’t handled specifically. Or it could just be the first error percolating up to the higher layers. So let’s focus on the first error.

The Notes binary directory should have a subdirectory xmlschemas that contains all of the dtd files that have ever shipped with the product to date. Normally, the relative path xmlschemas\domino_6_5_1.dtd will resolve to that directory because N/D are normally launched from the binary directory. Recently it has come to our attention that if you launch a server using the Java console, it lauches it from the Notes data directory, not the binary directory. In a scenario like that, it would not resolve the relative path. Possible workarounds include any of the following:

copy the xmlschemas subdirectory to the directory from which N/D is launched

copy the xmlschemas subdirectory to the Notes data directory (the code to try to open the dtd searches the data dir)

put the binary directory on the system PATH (the code to try to open the dtd file also searches the PATH)

make sure N/D is launched from the Notes binary directory

modify the code that generates the DXL to not include a dtd reference. There is a DXLExporter option to do this. Of course, this way, you lose validation when importing.