To add information from outside of the NotesXSLTransformer Object, (that’s information available to the agent), you can add values to the transformer using:
Dim transformer As NotesXSLTransformer
Set transformer=session.CreateXSLTransformer
Call transformer.AddParameter(“globalparameter” , “God”)
To reference that parameter in the Stylesheet, after it has been added to the Transformer, use this XSLT:
<?xml version="1.0"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dxl="http://www.lotus.com/dxl" version="1.0">
<xsl:output method="text"/>
<xsl:param name="globalparameter"/>
<xsl:template match="/*">
<xsl:apply-templates select="dxl:item[@readers='true'][descendant::dxl:text]">
<xsl:with-param name="globalparameter" select="$globalparameter"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="dxl:item[@readers='true'][descendant::dxl:text]">
<xsl:param name="globalparameter"/>
<xsl:for-each select="descendant::dxl:text">
<xsl:text/><xsl:value-of select="$globalparameter"/><xsl:value-of select="normalize-space(.)"/>;<xsl:text/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
This XSLT in my case was put on a page called “readers.xsl”. Although I didn’t call the page from the browser, as an XSLT, using its URL; I changed the Page Properties box (Alt+Enter) >> Web Access (part of the first Tab), and set the values to “Other: text/xsl”
How I got LotusScript to pull the XSLT off the page and how I got the readers fields off a Domino Document is listed below for those of you who might want to see the whole enchilada:
p.s. I left the rem’d out lines so you can un-rem them and see what out put you get when running the agent with Debug LotusScript ON
Sub Initialize
On Error Goto InitializeError
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Set s = session
s.ConvertMIME = False ' Do not convert MIME to rich text
session.ConvertMIME = False ' Do not convert MIME to rich text
REM Open xml
Dim xml As NotesStream
Set xml = session.CreateStream
Call xml.Truncate
REM Open xslt
Dim xslt As NotesStream
Set xslt = session.CreateStream
Call xslt.Truncate
REM Open output
Dim xmlout As NotesStream
Set xmlout = session.CreateStream
Call xmlout.Truncate
REM Create note collection and use a selectionFormula to get the Page that has the xslt on it
Dim nc As NotesNoteCollection
Set nc = db.CreateNoteCollection(True) 'False)
’ Call nc.SelectAllAdminNotes(False)
’ Call nc.SelectAllCodeElements(False)
’ Call nc.SelectAllDataNotes(False)
’ Call nc.SelectAllDesignElements(False)
’ Call nc.SelectAllFormatElements(False)
’ Call nc.SelectAllIndexElements(False)
’ Call nc.SelectAllNotes(False)
’ nc.SelectActions=False
’ nc.SelectForms=False
’ nc.SelectFrameSets=False
’ nc.SelectImageResources=False
’ nc.SelectJavaResources=False
’ nc.SelectMiscFormatElements=False
’ nc.SelectPages=True
’ nc.SelectStyleSheetResources=False
’ nc.SelectSubforms=False
nc.SelectionFormula = {@Contains($Title;"readers.xsl")}
Call nc.BuildCollection
REM Modify the collection - take out test documents
Dim doc As notesdocument
nid = nc.GetFirstNoteId
For i = 1 To nc.Count
Set doc = db.GetDocumentByID(nid)
nid = nc.GetNextNoteId(nid)
Next
REM Open file to hold some NotesStream data
Dim stream As NotesStream
Set stream = session.CreateStream
filename$ = "c:\docsxml.xml"
If Not stream.Open(filename$) Then
Messagebox "Cannot open " & filename$,, "Error"
Exit Sub
End If
Call stream.Truncate
REM Get the contents of a Page Object for the Stylesheet XSL
Dim body As NotesRichTextItem
Set body = doc.GetFirstItem("$Body")
Call xslt.WriteText(body.text)
’ Call xslt.Close
REM Create Transformer once set, style and out
Dim transformer As NotesXSLTransformer
Set transformer=session.CreateXSLTransformer
Call transformer.SetStylesheet(xslt)
Call transformer.SetOutput(xmlout)
Call transformer.AddParameter("globalparameter" , "God")
transformer.InputValidationOption=0
REM Use Page Stream in Transformer
REM Export Orgs View documents as DXL Dim exporter As NotesDXLExporter
Dim dxlExporter As NotesDXLExporter
Set dxlExporter = session.CreateDXLExporter
Call dxlExporter.SetOutput(xml)
Dim vc As NotesViewEntryCollection
Dim vcDoc As NotesDocument
Set view = db.GetView("Orgs")
Set vc = view.AllEntries
For x=2 To vc.Count
Set vcDoc = vc.GetNthEntry(x).document
Call dxlExporter.SetInput(vcDoc)
Call dxlExporter.Process
Print transformer.Transform(xml ) ', xslt )
’ Print “============”
’ Print xml.ReadText()
’ Call transformer.SetInput(xml)
’ Call transformer.Process
’ Print vcDoc.UniversalID
’ Print xmlout.ReadText()
’ Print “===================”
Call xml.Truncate
Next
Call stream.Close
ExitSub:
Exit Sub
InitializeError:
Print transformer.log
Print ( "InitializeError: Got error " & Error$ & " on line " & Cstr(Erl) & "; Error" & Str(Err) & " :InitializeError")
Resume Next
End Sub