Platforms to show: All Mac Windows Linux Cross-Platform

/XML/Saxon/Saxon Visualize electronic Invoices/Saxon Visualize electronic Invoices Web


Required plugins for this example: MBS XML Plugin

You find this example project in your MBS Xojo Plugin download as a Xojo project file within the examples folder: /XML/Saxon/Saxon Visualize electronic Invoices/Saxon Visualize electronic Invoices Web

Download this example: Saxon Visualize electronic Invoices Web.zip

Project "Saxon Visualize electronic Invoices Web.xojo_binary_project"
Class App Inherits WebApplication
EventHandler Sub Opening(args() As String) // load library #If TargetMacOS Var path As String = "/Users/cs/Dokumente/Libs Downloads/saxon/SaxonCEE-12.9/SaxonCEE-macos-universal-12-9-0/libsaxonc-core-ee.12.9.0.dylib" #ElseIf TargetWindows Var path As String = "saxonc-core-ee.dll" #ElseIf TargetLinux Then Var path As String = "libsaxonc-core-ee.so.12.9.0" #Else // not supported #EndIf Var bb As Boolean = SaxonMBS.LoadLibrary(path) // we have libraries here: // https://www.monkeybreadsoftware.com/filemaker/files/Libs/Saxon/ If bb Then // okay Else MessageBox "Failed to load Saxon library. Did you download it and adjust path in this example?"+EndOfLine+SaxonMBS.LoadErrorString Break Return End If End EventHandler
End Class
Class Session Inherits WebSession
End Class
Class MainPage Inherits WebPage
Control Label1 Inherits WebLabel
ControlInstance Label1 Inherits WebLabel
End Control
Control VisitButton Inherits WebButton
ControlInstance VisitButton Inherits WebButton
EventHandler Sub Pressed() self.GoToURL "https://github.com/itplr-kosit/xrechnung-visualization/releases" End EventHandler
End Control
Control Label2 Inherits WebLabel
ControlInstance Label2 Inherits WebLabel
End Control
Control FileUploader1 Inherits WebFileUploader
ControlInstance FileUploader1 Inherits WebFileUploader
EventHandler Sub FileAdded(filename As String, bytes As UInt64, mimeType As String) me.StartUpload End EventHandler
EventHandler Sub UploadAborted() End EventHandler
EventHandler Sub UploadError(error As RuntimeException) End EventHandler
EventHandler Sub UploadFinished(files() As WebUploadedFile) For Each file As WebUploadedFile In files run file.Data next End EventHandler
EventHandler Sub UploadProgressed(percent As Integer) End EventHandler
EventHandler Sub UploadStarted(fileCount As Integer) End EventHandler
End Control
Control HTMLViewer1 Inherits WebHTMLViewer
ControlInstance HTMLViewer1 Inherits WebHTMLViewer
End Control
EventHandler Sub Opening() Var xrechnungFolder As FolderItem = FindFile("xrechnung-3.0.2-xrechnung-visualization-2025-07-10") If xrechnungFolder <> Nil Then Var f As FolderItem = xrechnungFolder.Child("xsl") if f <> nil then Var cii As FolderItem = f.Child("cii-xr.xsl") If cii <> Nil And cii.Exists Then CIIFile = cii Else MessageBox "Failed to find the cii-xr.xsl file." Return End If Var ubl As FolderItem = f.Child("ubl-invoice-xr.xsl") If ubl <> Nil And ubl.Exists Then ublFile = ubl Else MessageBox "Failed to find the ubl-invoice-xr.xsl file." Return End If XSLFolder = f FileUploader1.Enabled = True Return End If End If MessageBox "xrechnung-visualization folder not found?" End EventHandler
Function FindFile(name As String) As FolderItem // Look for file in parent folders from executable on Var parent As FolderItem = app.ExecutableFile.Parent While parent<>Nil Var file As FolderItem = parent.Child(name) If file<>Nil And file.Exists Then Return file End If parent = parent.Parent Wend End Function
Sub Run(Data as MemoryBlock) Var xml As String = DefineEncoding(data, encodings.UTF8) // is it an UBL or CII file? If XML.InStr("urn:oasis:names:specification:ubl:schema:xsd:Invoice") > 0 Then Run XML, UBLFile ElseIf XML.InStr("unece:uncefact:data:standard:CrossIndustryInvoice") > 0 Then Run XML, CIIFile End If End Sub
Sub Run(XML as string, XSLFile as FolderItem) // Run XSLT In file Saxon Visualize electronic Invoices // Set the folder To find related files SaxonMBS.CWD = XSLFolder.NativePath // read the XSLT To convert Var b As BinaryStream = BinaryStream.Open(XSLFile) Var styleSheet As String = b.Read(b.Length, Encodings.UTF8) // Apply the XSLT // we use the quick function here. For more options use Xslt30ProcessorMBS class. var IntermediateXML as string = SaxonMBS.XSLT(XML, styleSheet) // now read second XSL to convert to html var xf as FolderItem = XSLFolder.Child("xrechnung-html.xsl") Var b2 As BinaryStream = BinaryStream.Open(xf) Var HTMLXSLT As String = B2.Read(b2.Length, encodings.UTF8) // Generate the HTML var InvoiceHTML as string = SaxonMBS.XSLT(IntermediateXML, HTMLXSLT) HTMLViewer1.LoadHTML InvoiceHTML End Sub
Property CIIFile As FolderItem
Property UBLFile As FolderItem
Property XSLFolder As FolderItem
End Class
Sign
End Sign
End Project

See also:

Download this example: Saxon Visualize electronic Invoices Web.zip

The items on this page are in the following plugins: MBS XML Plugin.


The biggest plugin in space...