Example: NotesXSLTransformer class

This agent uses the style sheet file XSL_SS.XSL to transform the input file XML_IN.XML into a text output file XML_OUT.TXT.

(Options)
%INCLUDE "lsxbeerr.lss"


Sub Initialize
  On Error lsERR_NOTES_XSLT_INPUT_OBJECT Goto err_IN
  On Error lsERR_NOTES_XSLT_OUTPUT_OBJECT Goto err_OUT
  On Error lsERR_NOTES_XSLT_STYLESHEET_OBJECT Goto err_SS
  
  Dim session As New NotesSession
  filename$ = "hello"
  pathname$ = "c:\dxl\"
  
  Dim XML_in As NotesStream    ' input file
  Set XML_in=session.CreateStream
  If Not XML_in.Open(pathname$ & filename$ & ".xml") Then
    Messagebox "Cannot open " & filename$,, "XML file error"
    Exit Sub
  End If
  If XML_in.Bytes = 0 Then
    Messagebox filename$ & " does not exist or is empty",, "XML file error"
    Exit Sub
  End If
  
  Dim XSL_ss As NotesStream    ' style sheet
  Set XSL_ss=session.CreateStream
  If Not XSL_ss.Open(pathname$ & filename$ & ".xsl") Then
    Messagebox "Cannot open " & filename$,, "XSL file error"
    Exit Sub
  End If
  
  Dim XML_out As NotesStream    ' output file
  Set XML_out=session.CreateStream
  If Not XML_out.Open(pathname$ & filename$ & ".txt") Then
    Messagebox "Cannot create " & filename$,, "TXT file error"
    Exit Sub
  End If
  XML_out.Truncate
  
  Dim transformer As NotesXSLTransformer
  Set transformer=session.CreateXSLTransformer(XML_in, XSL_ss, XML_out)
  transformer.Process
  Exit Sub
err_IN:
  Messagebox "XSL Input error", , "XSLTransformer Process"
  Exit Sub
err_OUT:
  Messagebox "XSL Output error", , "XSLTransformer Process"
  Exit Sub
err_SS:
  Messagebox "Style Sheet error", , "XSLTransformer Process"
  Exit Sub
End Sub