. Parse XML with XPath in BIRT Report
You need to get SatNum, Priority and SatName from an XML file. Here is the XML file:
<? xml version = "1.0" encoding = "utf-8" standalone = "yes"?>
<sats xmlns = "http://test/data">
<sat SatNum = "900">
<satName Priority = "1">
<SatName>JOSH</SatName>
</satName>
</sat>
</sats>
Solution:
1). Using XML Data Source in BIRT. Define the column mapping, you can select the XML element or attribute that represents a column and add every column to the data set.
If your BIRT edition must support XPath 2.0 syntax (If it only supports XPath 1.0, this won’t work.)
Column mappings defined in a data set.
//sats/(sat/@SatNum,.//satName/@Priority,//SatName/text())
or
//sats[1]/(sat/data(@SatNum),sat/satName/data(@Priority),sat/satName/SatName/data(text()))
Output:
900
1
JOSH
2) Using esProc as Data Source in BIRT.
esProc SPL’s implementation is like this:
A | |
1 | =file("./sats.xml").read() |
2 | =xml@s(A1).sats |
3 | =A2.new(~.SatNum:SatNum,ifn(sat.Priority):Priority,ifn(sat.satName.SatName):SatName) |
A3:
The report can be designed in the same way as you would if you were retrieving the data from a database. For detail SPL integration with BIRT, see How to Call an SPL Script in BIRT. If you have any questions or comments please leave them below.
SPL Official Website 👉 https://www.scudata.com
SPL Feedback and Help 👉 https://www.reddit.com/r/esProcSPL
SPL Learning Material 👉 https://c.scudata.com
SPL Source Code and Package 👉 https://github.com/SPLWare/esProc
Discord 👉 https://discord.gg/cFTcUNs7
Youtube 👉 https://www.youtube.com/@esProc_SPL