Platforms to show: All Mac Windows Linux Cross-Platform
/XML/Saxon/Saxon Visualize electronic Invoices/Saxon Visualize electronic Invoices
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
Download this example: Saxon Visualize electronic Invoices.zip
Project "Saxon Visualize electronic Invoices.xojo_binary_project"
Class App Inherits DesktopApplication
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Opening()
// 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 MainWindow Inherits DesktopWindow
Control VisitButton Inherits DesktopButton
ControlInstance VisitButton Inherits DesktopButton
EventHandler Sub Pressed()
ShowURL "https://github.com/itplr-kosit/xrechnung-visualization/releases"
End EventHandler
End Control
Control Label1 Inherits DesktopLabel
ControlInstance Label1 Inherits DesktopLabel
End Control
Control Label2 Inherits DesktopLabel
ControlInstance Label2 Inherits DesktopLabel
End Control
Control OpenInvoiceButton Inherits DesktopButton
ControlInstance OpenInvoiceButton Inherits DesktopButton
EventHandler Sub Pressed()
// you can use DynaPDF functions to extract XML from PDF
Var f As FolderItem = FolderItem.ShowOpenFileDialog(FileTypeGroup1.XML)
If f = Nil Then Return
Var b As BinaryStream = BinaryStream.Open(f)
Var XML As String = b.Read(b.Length, 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 EventHandler
End Control
Control HTMLViewer1 Inherits DesktopHTMLViewer
ControlInstance HTMLViewer1 Inherits DesktopHTMLViewer
End Control
Control PickXSLButton Inherits DesktopButton
ControlInstance PickXSLButton Inherits DesktopButton
EventHandler Sub Pressed()
Var f As FolderItem = FolderItem.ShowSelectFolderDialog
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
OpenInvoiceButton.Enabled = true
End If
End EventHandler
End Control
Sub Run(XML as string, XSLFile as FolderItem)
// Apply XSLT to create html and show invoice.
// 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.LoadPage InvoiceHTML, xf
End Sub
Property CIIFile As FolderItem
Property UBLFile As FolderItem
Property XSLFolder As FolderItem
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
MenuItem WindowMenu = "Window"
MenuItem HelpMenu = "&Help"
End MenuBar
Sign
End Sign
FileTypeGroup1
Filetype XML
End FileTypeGroup1
End Project
See also:
- /XML/Saxon/Saxon test
- /XML/Saxon/Saxon Visualize electronic Invoices/Saxon Visualize electronic Invoices Web
- /XML/Saxon/Saxon ZUGFeRD Validation
Download this example: Saxon Visualize electronic Invoices.zip
The items on this page are in the following plugins: MBS XML Plugin.