简体   繁体   中英

Jasper Reports Parse XML column-blob

I am using postgresql as database. In db i have one column which contains xml with language codes. I want to parse that xml and get value trough the report language.

select o.name,o.price from bookdefinations o This o.name contains that xml value:

<?xml version="1.0" encoding="UTF-8"?>
<values>
    <en-us>en value</en-us>
    <es>es value</es>
    <ru>ru value</ru>
    <tr>tr value</tr>
</values>

Can i parse this with jasper's expressions or can i parse while selecting from db (i dont have any idea how to get report language in select query and parse xml in select)

There is a xmldatasource for jasperreport, you can do a subreport and send the blob to that subreport as an xmldatasource, then you can parse the xml in the subreport and show the content, I'm not sure if you want to show the values or the entire xml, if it is a report I guess you should show the values in a pretty way I mean not as xml, check this link

http://jasperreports.sourceforge.net/sample.reference/xmldatasource/

You could do this directly in postgresql during the select. PostgreSql has an XML Type and various XML functions .
If you take a look at those functions, you'll see the xpath function which can be used to extract data from XML types during a select statement.

For a reference to xPath, take a look at the tutorial from W3Schools .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM