XML / XSLT: How to transform a DomParser document?

I’ve created a hand-rolled domparser document to match my XSL, and I hope to transform the contents into a Word document. I’ve done these transforms numerous times with two string objects, or a string and a file, etc, but never with a dom XML document.

Here’s what I’m trying to do to get the transform working, with no luck:

Once I have my XSL in rich text, and my XML in a valid notesdomparser document, how do I transform them? This is the closest I’ve come, but still getting errors:

Dim streamXSL As NotesStream

Set streamXSL = session.CreateStream()

Call streamXSL.WriteText( xslRtItem.GetUnformattedText )

Dim streamOutput As NotesStream

Set streamOutput = session.CreateStream()

Call transformer.SetStylesheet( streamXSL )

Call transformer.setinput ( domparser )

If Not streamOutput.Open(“p:\out.text”) Then

Messagebox "blah",, "Open failed - check that file is not already open"

Exit Sub

End If

streamOutput.Truncate 'delete any current file contents

Call transformer.setoutput ( streamoutput )

Call domparser.Process

I get my XSL from a rich text field with this, which works fine:


set view = db.GetView(“xmldocs”)

Set xsldoc = view.GetDocumentByKey(“WordDoc.xsl”)

Set xslRtItem = xsldoc.GetFirstItem(“xSource”)

I build my XML document like this:


’ generate our XML Source document

Dim domparser As NotesDOMParser

Dim domdoc As NotesDOMDocumentNode

Set domparser = session.CreateDOMParser

Call domparser.setinput ( xslRtItem )

Call domparser.setoutput( transformer )

domparser.AddXMLDeclNode = True

Set domdoc = domparser.Document

Dim activityNode As NotesDOMElementNode

Dim categoryNode As NotesDOMElementNode

Dim projectNode As NotesDOMElementNode

Dim updatedByNode As NotesDOMElementNode

Dim projectTextNode As notesDOMTextNode

Dim updatedByTextNode As notesDOMTextNode

Dim theActivityNode As NotesDOMElementNode

Dim activityTextNode As notesDOMTextNode

Set activityNode = domdoc.CreateElementNode( “Activity” )

Set categoryNode = domdoc.CreateElementNode( “Category” )

Set projectNode = domdoc.CreateElementNode( “Project” )

Set updatedByNode = domdoc.CreateElementNode( “UpdatedBy” )

Set theActivityNode = domdoc.CreateElementNode( “theActivity” )

Call domDoc.appendChild( ActivityNode )

Forall a In categoryList

Call activityNode.appendChild( CategoryNode )

Call categoryNode.SetAttribute("Name", a )

Forall b In reportDataList

	If b.Category = a Then

		' output it

		Call categoryNode.appendChild( projectNode )

		Set projectTextNode = domDoc.CreateTextNode( b.ProjectName )

		Call projectNode.appendChild( projectTextNode )

		Call categoryNode.AppendChild( updatedByNode )

		Set updatedByTextNode = domDoc.CreateTextNode( b.UpdatedBy )

		Call updatedByNode.appendChild( updatedByTextNode )

		Call categoryNode.AppendChild( theActivityNode )

		Set activityTextNode = domDoc.CreateTextNode( b.Activity )

		Call theActivityNode.appendChild( activityTextNode )

	End If

			

End Forall

End Forall