If you’ve suffered the insanity of client side xml transformations using Microsoft.XMLDOM and some javascript along the lines of:
loadXML(document.all.item(“pageHeader”).innerHTML, “./ssEmpDetails.xsl”, “pageHeader”);
or some such and would prefer to do the tranform on the server this may be of interest.
The main stumbling block for me was that our xsl pages are stored in Domino pages. The method above lets you point to a URL, notes doesn’t so I’ve written the following function to get the page text from my xsl so that it can be passed to the NotesXSLTransformer.Transform method (which doesn’t appear in my help???).
The function is:
Function getPageText(db As NotesDatabase, pageName As String) As String
'Gets a notes page design element and returns the text of the page. Designed for apps where XSLT info is stored in a page.
Dim nCol As NotesNoteCollection
Dim doc As NotesDocument
Dim title As NotesItem, body As NotesItem
Dim noteID As String
'Build a NotesNoteCollection of all page design elements in the database
Set nCol=db.CreateNoteCollection(False)
nCol.SelectPages=True
Call nCol.BuildCollection
'Find page that corresponds to pagename
noteID=nCol.getFirstNoteID
Do Until noteID=""
Set doc=db.GetDocumentByID(noteID)
Set title=doc.GetFirstItem("$TITLE")
Set body=doc.GetFirstItem("$Body")
If title.Text=pageName Then
getPageText=body.Text
Exit Function
End If
noteID=nCol.GetNextNoteId(noteID)
Loop
getPageText=""
End Function
Following is a sample of an agent that takes XML and uses the function to get the XSL and sends the output to the browser:
Sub Initialize
On Error Goto errHandler
Dim s As New NotesSession
Dim xmlTr As NotesXSLTransformer
Set xmlTr=s.CreateXSLTransformer
' In this case rawXML is a constant defined in the Declarations section.
Print xmlTr.Transform(rawXML, getPageText(s.CurrentDatabase, "ssRoster.xsl"))
Exit Sub
errHandler:
Print Err & ": " & Error
Resume Next
End Sub
If you put the getPageText function in a script library you’ll obviously need to include it in the ‘Options’.
FINALLY, if you’re existing XSLs use the IE5 namespace change them over to the proper one. Dopey here wasted much time figuring that one out.
This will look like pretty simple stuff to the gurus out there, but I spent heaps of time getting it working for us and messing around with NotesStreams I didn’t need in the end - so hopefully this will save someone else some time.