Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Dynamyc URL extracted from XML - BIRT(URL extracted from XML - BIRT)
Dynamyc URL extracted from XML - BIRT [message #718815] Thu, 25 August 2011 08:14 Go to next message
Fabricio  is currently offline Fabricio
Messages: 2
Registered: August 2011
Junior Member
Hi,
I am using BIRT 2.6.2
and I need to extract my database source's URL from and XML file in a remote location.
I have no idea how to do it, since the XML cannot be use as a source for another source.
Maybe a script on before open. But I have no idea how to implement it... I'll appreciate any help...
Re: Dynamyc URL extracted from XML - BIRT [message #718921 is a reply to message #718815] Thu, 25 August 2011 11:37 Go to previous message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Can you try a beforeFactory script similar to this?

importPackage( Packages.javax.xml.parsers);
importPackage( Packages.org.xml.sax);
importPackage( Packages.org.w3c.dom);
importPackage( Packages.java.io);
importPackage(Packages.java.net);


function getTagValue(file, tagName) {

factory = DocumentBuilderFactory.newInstance();
builder = factory.newDocumentBuilder();
document = builder.parse( new InputSource( new FileInputStream( file ))
);
nlist = document.getElementsByTagName(tagName);
return nlist.item(0).getFirstChild().getNodeValue();
}

mydburl = getTagValue("c:/test/parms.xml", "dburl");


If it is a url instead of the FileInputStream try:

dataURL = new URL("myurl");
dataConnection = dataURL.openConnection();
document = builder.parse( new InputSource(
dataConnection.getInputStream() )) );


Make sure to close the connection/file


Jason

On 8/25/2011 8:14 AM, Fabricio wrote:
> Hi,
> I am using BIRT 2.6.2
> and I need to extract my database source's URL from and XML file in a
> remote location.
> I have no idea how to do it, since the XML cannot be use as a source for
> another source.
> Maybe a script on before open. But I have no idea how to implement it...
> I'll appreciate any help...
Previous Topic:java dates and birt dates
Next Topic:Calendar Gif Artifact
Goto Forum:
  


Current Time: Thu Jul 24 11:39:30 EDT 2014

Powered by FUDForum. Page generated in 0.02400 seconds