Jump to content
Changes to the Jaspersoft community edition download ×

XML as datasource - DOMElementDataSource

2005 IR Help

Recommended Posts

By: meiga - meiga

XML as datasource - DOMElementDataSource

2004-05-12 07:00

Does anyone know where I can find examples about how DOMElementDataSource is used??

Thanks and best regards to the jaseper report team.





By: newbie - atlas100

RE: XML as datasource - DOMElementDataSource

2004-05-13 23:19

I have implemented DOMElementDataSource. The documentation in the code is given quite well. as for integrating it..I did the integration with iReport-visual designer. I added it in the package - it.businesslogic.ireport.connection. A factory class has to be created new and placed in the same package. The factory class would as folls:


package it.businesslogic.ireport.connection;


import org.w3c.dom.*;

import it.businesslogic.ireport.connection.DOMElements;

import it.businesslogic.ireport.connection.DOMElementDataSource;


public class DOMCustomDataSourceFactory {


public dori.jasper.engine.JRDataSource getDOMDatasource( )


Element e = null;



//DOMElements dom = new DOMElements("D:\purge\xml\Ticket01\157_200000006.xml");

DOMElements dom = new DOMElements("D:\purge\xml\Ticket01\157_200000015.xml");

//DOMElements dom = new DOMElements("D:\purge\xml\Sample.xml");

e = dom.getRootNode();


catch(Exception ex)




return new DOMElementDataSource(e);





The DOMElements class is a class which uses XML parser to get the contents of XML file...I am giving only the method that does this:


public Element getRootNode() throws Exception


DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

DocumentBuilder builder = factory.newDocumentBuilder();

document = builder.parse(new FileInputStream(xmlSource));

return document.getDocumentElement();




In iReport, all u have to do it is, in tab DataSource->Connections/DataSources, select Custom Datasource and give the factory name and the method of this factory as static method.Test the connection and save it.

I hope this has been of some use to you...since when i started i was badly struggling with this integration.

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...