NotesXSLTransformer driving me mad

I’m having problems with the following code. Code is running in web agent, browser is IE5.5

Sub Initialize

Dim s As New NotesSession

Dim xmlTr As NotesXSLTransformer

Dim xmlin As NotesStream, xslin As NotesStream, htmlout As NotesStream



Set xmlin=s.createStream

Set xslin=s.createStream

Set htmlout=s.createStream



If Not xmlin.Open("c:\dxl\roster.xml") Then

	Print "Cannot open roster.xml"

	Exit Sub

End If

If xmlin.Bytes = 0 Then

	Print "Roster.xml does not exist or is empty"

	Exit Sub

End If



If Not xslin.Open("c:\dxl\roster.xsl") Then

	Print "Cannot open stylesheet"

	Exit Sub

End If





If Not htmlout.Open("c:\dxl\roster.txt") Then

	Messagebox "Cannot create TXT file"

	Exit Sub

End If

htmlout.Truncate

'ORIGINAL ATTEMPT - WON’T WORK EITHER

’ Set xmlTr=s.CreateXSLTransformer(xmlin, xslin, htmlout)

’ Call xmlTr.process

Set xmlTr=s.CreateXSLTransformer

Print xmlTr.Transform(xmlin, xslin)

End Sub

I’ve checked printing xmlin.readtext, xslin.readtext and the original xml and xsl are being picked up fine by notes.

However, the output is only ever the stylesheet text. I’ve reduced the stylesheet to the following:

<?xml version="1.0" ?>

<xsl:stylesheet xmlns:xsl=“Extensible Stylesheet Language (XSL) Version 1.1” >

<xsl:template match=“/”>

Week commencing <xsl:value-of select=“QRYRESULTS/RECORD[@count=‘1’]/WORKDATE”/>

</xsl:template>

</xsl:stylesheet>

But I can’t get anything to transform.

Any suggestions would be appreciated.

Subject: NotesXSLTransformer driving me mad…

First off, you may be getting errors that you don’t know about because one of your if statements is using Messagebox - you can’t use that on the web; it’s a ui class. Second, you don’t have any actual error-trapping; I would do something like this:

Sub Initialize

on error goto errhand

Dim s As New NotesSession

Dim xmlTr As NotesXSLTransformer

Dim xmlin As NotesStream, xslin As NotesStream, htmlout As NotesStream

Set xmlin=s.createStream

Set xslin=s.createStream

Set htmlout=s.createStream

If Not xmlin.Open(“c:\dxl\roster.xml”) Then

Print "Cannot open roster.xml"

Exit Sub

End If

If xmlin.Bytes = 0 Then

Print "Roster.xml does not exist or is empty"

Exit Sub

End If

If Not xslin.Open(“c:\dxl\roster.xsl”) Then

Print "Cannot open stylesheet"

Exit Sub

End If

If Not htmlout.Open(“c:\dxl\roster.txt”) Then

Print "Cannot create TXT file"

Exit Sub

End If

htmlout.Truncate 'ORIGINAL ATTEMPT - WON’T WORK EITHER

’ Set xmlTr=s.CreateXSLTransformer(xmlin, xslin, htmlout)

’ Call xmlTr.process

Set xmlTr=s.CreateXSLTransformer

Print xmlTr.Transform(xmlin, xslin)

exit sub

errhand:

Print "error at line " & erl & ": " & error & “

exit sub

End Sub

Third, does your RECORD element actually have an attribute called count, or are you trying to get the first RECORD element? For that, you’d use RECORD[1].

Subject: Sorry Esther, MsgBox or MessageBox does work on the web. It writes to the Log.NSF

file on the server under Miscellaneous Events.

Subject: RE: Sorry Esther, MsgBox or MessageBox does work on the web. It writes to the Log.NSF

Yes, I’m aware of that. I should have said that you don’t get immediate visible output when using it on the web, as you do with Print.

Subject: RE: NotesXSLTransformer driving me mad…

Thanks Esther, I should have said - I did write it with error trapping code but minimalised it for posting on the web.

No errors were being thrown. Good point on the messagebox (serves me right for copying it out of the help), although that file is being opened because I can see it on the os (it contains the XSLT contents rather than transformed HTML).

Although looking at it again here has given me an idea…

…yes, it would appear the main problem was between the chair and the keyboard.

I want to do the transforms on the server as a workaround to using Microsoft.XMLDOM and Javascript in the browser.

What I forgot to do was change the namespace on all my stylesheets to the proper one, not the IE5 one.

Things are happening now. Fantastic. Raise that bat Boonie. Ton up.