Reading large XML file using a file event generator and a JPD process
I am using a FileEventGenerator and a JPD Subscription process to read a large XML file. The large XML file basically contains repeated XML elements. My understanding is that the file subscription method reads the whole file in memory which causes lots of problem for huge file size like 1MB. Is there a way to read the file size-wise or is there a way to read chunks of data from a large size file..or any other alternative. I would like to process the file in a loop iteration by iteration.
Hitejain,
Here are a couple of pointers you could try. One is that the file event generator has a pass by reference (filename) functionality which you could use so that you could do the following inside of your process.
1) Read file name from the reference
2) Move the file to a processed directory (so it doesn't get picked up again. Note: I don't know how the embedded archive methods of the file event generator plays with pass by reference.
3) Open a stream to the file.
4) Use a SAX or SAX - DOM combined approach to parse your XML while managing the memory usage inside of your process
There is another possibility which might fit your needs and it is related to the RawData object that BEA provides. If I understand it correctly provides wrapping functionality around a stream object, but depending on your parsing methods might just postpone the problem.
Hope this helps
Chris Falling
Stormforge Software
Similar Messages
-
Hi All,
I am trying to read an XML file which is around 6.4 GB which has around 1000 million records in it.
I need to travel through all the elements and take out the values which matches my criteria.
For Example the XML Looks like :
<ss>
<s>
<m>00:11:22:33:44:55</m>
<o>1244548353223</o>
<f>1244548354223</f>
</s>
<s>
<m>00:11:22:33:44:56</m>
<o>1244548353223</o>
<f>1244548354223</f>
</s>
</ss>I need to get the <s> node which has the <m> value is 00:11:22:33:44:55. It may have around 1024 occurences per file.
I tried XPath, XQuery apis for java and nothing helped me in reading such a huge file.
The actual task is to read 2 to 30 huge files concurrently.
Can anyone help me in this?
Thanks in advance.
Kousik RajendranI tried XOM. It worked fine for 102.4 MILLION data stored in a xml file which has size about 5.5GB.
Checkout [XOM Home Site|http://www.xom.nu/]
Or dowload Zip File with all necessary Zip and Sample file : [XOM Complete Zip|http://www.cafeconleche.org/XOM/xom-1.2.1.zip]
Try out the Sample which uses Streaming Method. -
How to read a xml file created dynamically and use it to to chart
Hi
I am using Fuisonchart in Flex to create 3D charts i have stored my xml in server path as "Data.xml",this xml will be generated when i click on a button,this button passes my http service and frame my xml.
Xml values will get changed as per database values, my problem is my chart fetches xml of old generated values,and not the newly updated xml values,
I need to send my xml atonce when it is updated and changed,Flex part gets that updated value only when i run the application second time.
So please help me to update the chart atonce when it is updated.
Thanks in Advance
Gopinath.A,
Softrware Developer
Chennai.on button click, call sendGenerateService().
private function sendGenerateService():void
var hs:HTTPService = new HTTPService();
hs.url = "generateXML.php?random="+Math.random();//generateXML.php will do necessavry stuff to update Data.xml
hs.method = "post";
hs.addEventListener(FaultEvent.FAULT,fault);
hs.addEventListener(ResultEvent.RESULT,resultGenerateService);
hs.send();
private function resultGenerateService(e:ResultEvent):void
var hs:HTTPService = new HTTPService();
hs.url = "Data.xml?random="+Math.random();
hs.method = "post";
hs.addEventListener(FaultEvent.FAULT,fault);
hs.addEventListener(ResultEvent.RESULT,resultGetXml);
hs.send();
private function resultGetXml(e:ResultEvent):void
// feed your chart with result
private function fault():void
//fault handler -
Problem with parsing large xml files
Hello All,
I am parsing a large xml file of 20MB and I use DocumentBuilder.parse(File). This method works for small xml files with size less than 20MB but the application hangs and doesn't through any error message when parsing 20MB xml files. Please let me know what I have to do at this point ?
Thanks & Regards,
Kumar.Well... i can't agree.
If you have such structure:
<task>
<task/>
<task>
<task>
<task/>
</task>
<task/>
</task>
</task>
...you may always keep stack of tasks (at startElement push to top, and at endElement pop), so at every leaf of tree you will have all parents of that leaf.
for such structure:
<task id="1" parent="0"/>
<task id="2" parent="1"/>
<task id="3" parent="1"/>
<task id="4" parent="2"/>
<task id="5" parent="3"/>
...it will be much faster to go thro document by sax several times to build tree of tasks, than to load all document into memory... -
Performance Problem in parsing large XML file (15MB)
Hi,
I'm trying to parse a large XML file(15 MB) and facing a clear performance problem. A Simple XML Validation using the following code snippet:
DBMS_LOB.fileopen(targetFile, DBMS_LOB.file_readonly);
DBMS_LOB.loadClobfromFile
tempCLOB,
targetFile,
DBMS_LOB.getLength(targetFile),
dest_offset,
src_offset,
nls_charset_id(CONSTANT_CHARSET),
lang_context,
conv_warning
DBMS_LOB.fileclose(targetFile);
p_xml_document := XMLType(tempCLOB, p_schema_url, 0, 0);
p_xml_document.schemaValidate();
is taking 30 mins on a HP-UX (4GB ram, 2 CPU) machine (Oracle version : 9.2.0.4).
Please explain what could be going wrong.
Thanks In Advance,
VineetThanks Mark,
I'll open a TAR and also upload the schema and instance XML.
If i'm not changing the track too much :-) one more thing in continuation:
If i skip the Schema Validation step and directly insert the instance document into a Schema linked XMLType table, what does OracleXDB do in such a case?
i'm getting a severe performance hit here too... the same file as above takes almost 40 mins to Insert.
code snippet:
DBMS_LOB.fileopen(targetFile, DBMS_LOB.file_readonly);
DBMS_LOB.loadClobfromFile
tempCLOB,
targetFile,
DBMS_LOB.getLength(targetFile),
dest_offset,
src_offset,
nls_charset_id(CONSTANT_CHARSET),
lang_context,
conv_warning
DBMS_LOB.fileclose(targetFile);
p_xml_document := XMLType(tempCLOB, p_schema_url, 0, 0);
-- p_xml_document.schemaValidate();
insert into INCOMING_XML values(p_xml_document);
Here table INCOMING_XML is :
TABLE of SYS.XMLTYPE(XMLSchema "http://INCOMING_XML.xsd" Element "MatchingResponse") STORAGE Object-
relational TYPE "XDBTYPE_MATCHING_RESPONSE"
This table and type XDBTYPE_MATCHING_RESPONSE were created using the mapping provided in the registered XML Schema.
Thanks,
Vineet -
Hi,
Am having a file event generator,and the presence one such file[string type] in the folder would trigger one of my JPD's. Now, I want to read the contents of the file as well, in addition to the complete file name..I guess this can be done by reading the meta data, but am having problems doing this..
How do I read this metadata,to know the full file name the the file contents?
Any help would be appreciated.
Thanks In Advance,
RBHi,
I did like this
1. Created a channel where an set the qualifiedMetadataType="eg:FileEventGenerator"
Ex.
<channels xmlns="http://www.bea.com/wli/broker/channelfile"
channelPrefix="/Bilprovningen"
xmlns:eg="http://www.bea.com/wli/eventGenerator"
xmlns:dp="http://www.bea.com/wli/control/dynamicProperties">
<channel name ="FileHandling" messageType="none">
<channel name ="MegadiscInvoiceFileChannel" messageType="xml" qualifiedMessageType="utskrift" qualifiedMetadataType="eg:FileEventGenerator"/>
</channel>
</channels>
2. Create a process with a subscriptin like thist
* @jpd:mb-static-subscription message-metadata="{x1}" channel-name="/Bilprovningen/FileHandling/MegadiscInvoiceFileChannel" message-body="{x0}"
public void subscription(com.bea.xml.XmlObject x0, com.bea.wli.eventGenerator.FileEventGeneratorDocument x1) throws Exception
//#START: CODE GENERATED - PROTECTED SECTION - you can safely add code above this comment in this method. #//
// input transform
// parameter assignment
this.invoiceDocument = (noNamespace.UtskriftDocument) x0;
this.fileEventGeneratorDocument = x1;
//#END : CODE GENERATED - PROTECTED SECTION - you can safely add code below this comment in this method. #//
3. You could then access the x1 I think to read the meta data.
Regards
/Johan -
Reading an xml file in actionscript using flex3
plzz tell me how to read an xml file in actionscript using flex3.......
One possible option to parse an xml-file to a flex XML object:
public function parseConXML(source:String):void
xmlLoader = new URLLoader();
xmlLoader.load(new URLRequest(source));
// Eventlistener: if URL loaded --> onLoadComplete function
xmlLoader.addEventListener(Event.COMPLETE, xmlLoadComplete);
public function xmlLoadComplete(evt:Event):void{
var xml:XML = new XML();
// ignore comments in XML-File
XML.ignoreComments = true;
//ignore whitespaces in XML-File
XML.ignoreWhitespace = true;
// XML-Objekt erstellen
xml = new XML(evt.target.data);
//AFTERWARDS use your xml as your wish -
Loading Large XML files using plsql
I have a process where there is a need to load large xml files (i.e. easily over 500k or more) into Oracle via an interface. Preference would be to use plsql or some plsql based utility if possible. I am looking for any suggestions on the best method to accomplish this. Currently running on 9.2.0.6. Thanks in advance.
I have a process where there is a need to load large xml files (i.e. easily over 500k or more) into Oracle via an interface. Preference would be to use plsql or some plsql based utility if possible. I am looking for any suggestions on the best method to accomplish this. Currently running on 9.2.0.6. Thanks in advance.
-
Parsing large xml file and display using swing
Hi all,
I want to read a large xml file and display graphically in swing as a tree structure.
I implemented it and works fine for files of 5MB size after increasing the jvm heap size (-Xmx). If the file size is larger than 5MB it throws out of memory error. I'm creating a custom datastructure from the xml and I'm using sax parsing.
After displaying the datastructure, the user could do some operation on this, like search etc.
Can any of you suggest a method, to support larger files ? What I'm looking for is create the datastructure in file system, rather than in memory.
Any other tips for memory management would be greatly appreciated
Thanks in Advance.
NishaUse a memory-mapped file?
http://javaalmanac.com/egs/java.nio/CreateMemMap.html -
I need for a simple example of reading a xml file using jdom
Hello
I have been looking for a simple example that uses Jdom to read am xml file and use the information for anything( ), and I just can't find one.since I'm just beggining to understand how things work, I need a good example.thanks
here is just a simple cod for example:
<xmlMy>
<table>
<item name="first" value="123" createdDate="1/1/90"/>
<item name="second" value="456" createdDate="1/4/96"/>
</table>
<server>
<property name="port" value="12345"/>
<property name="maxClients" value="3"/>
</server>
</xmlMy>DaveHi,
FileInputStream fileInputStream = null;
try {
fileInputStream = new FileInputStream("my_xml_file.xml");
} catch (FileNotFoundException e) {
e.printStackTrace();
} finally{
if (fileInputStream == null) return;
SAXBuilder saxBuilder = new SAXBuilder();
saxBuilder.setEntityResolver(new EntityResolver() {
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
return new InputSource(new StringReader(""));
Document document = null;
try {
document = saxBuilder.build(fileInputStream);
} catch (JDOMException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (document == null) return;
Element element = document.getRootElement();
System.out.println(element.getName());
System.out.println(element.getChild("table").getName()); -
Reading my Xml file in Unity using C#
Hi, i have to read a xml file like this:
<UIs>
<UI>
<Titolo>
<Ita>
Mitocondri
</Ita>
<English>
Mitochondrion
</English>
</Titolo>
<Corpo>
<Ita>
I mitocondri sono gli organelli che producono ATP all'interno della cellula,aggiungine di nuovi per aumentare la produzione di ATP
</Ita>
<English>
Mitochondrion
</English>
</Corpo>
<Price>
120
</Price>
<MaxNumber>
1
</MaxNumber>
</UI>
<UIs>
How can i make a simple xml reader in c# to read this structure?
Thanks!Try this. The code writes your sample XML and then reads it back
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Xml;
using System.Xml.Serialization;
using System.Xml.Schema;
using System.IO;
namespace ConsoleApplication1
class Program
const string FILENAME = @"c:\temp\Test.xml";
static void Main(string[] args)
UIs uIs = new UIs()
uI = new UI()
titolo = new Titolo()
Ita = "Mitocondri",
english = "Mitochondrion"
corpo = new Corpo()
ita = "I mitocondri sono gli organelli che producono ATP all'interno della cellula,aggiungine di nuovi per aumentare la produzione di ATP",
english = "Mitochondrion"
price = 120,
maxNumber = 1
XmlSerializer serializer = new XmlSerializer(typeof(UIs));
StreamWriter writer = new StreamWriter(FILENAME);
XmlSerializerNamespaces _ns = new XmlSerializerNamespaces();
_ns.Add("", "");
serializer.Serialize(writer, uIs, _ns);
writer.Flush();
writer.Close();
writer.Dispose();
XmlSerializer xs = new XmlSerializer(typeof(UIs));
XmlTextReader reader = new XmlTextReader(FILENAME);
UIs newUIs = (UIs)xs.Deserialize(reader);
[XmlRoot("UIs")]
public class UIs
[XmlElement("UI")]
public UI uI { get; set; }
[Serializable, XmlRoot("UI")]
public class UI
[XmlElement("Titolo")]
public Titolo titolo { get; set; }
[XmlElement("Corpo")]
public Corpo corpo { get; set; }
[XmlElement("Price")]
public int price { get; set; }
[XmlElement("MaxNumber")]
public int maxNumber { get; set; }
[Serializable, XmlRoot("Titolo")]
public class Titolo
[XmlElement("Ita")]
public string Ita { get; set; }
[XmlElement("English")]
public string english { get; set; }
[Serializable, XmlRoot("Corpo")]
public class Corpo
[XmlElement("Ita")]
public string ita { get; set; }
[XmlElement("English")]
public string english { get; set; }
jdweng -
Problem reading an xml file using java
i have a Com File which is called through .Net application and i made another java application that call the same COM file using JNI . but the problem is that the xml format generated from the Com file in case of the .Net application is approx 49.9K and the same Xml file Contents generated through java is half the size of the previous file in .net about 24.9K . I had figured out that the .Net application generates the xml file as unicode format while the java application generates the same xml format as ANSI format which is approx the half of the .Net counterpart .
but the problem now is that i can't deserialize the java generated xml to convert it into its java object using XMLDecoder because it is ill formed xml whereas its tags are well structured .
even when i try to open that .NEt xml file into the IE browser it structures the xml file successfully
while the java xml file version tells me that the file is ill formed knowing that the file is well structured and all the tags are valid.First of, that's not "Unicode" and "ANSI". Those are not really encodings per-se. "Unicode" is sometimes used to refer to UTF-16/UCS-2, and "ANSI" is sometimes used to refer to whatever the current 1-byte encoding of the machine is. But again: Those are not valid encoding names. The encodings used are probably UTF-16 (or UCS-2) and UTF-8, respectively.
Next: unless you tell us some exact error message we can't tell you what went wrong.
And if you want to find out if any given XML file is valid, just run it through some validator (such as [the one from the W3C|http://validator.w3.org/]). -
Reading from XML file using DOM parser.
Hi,
I have written the following java code to read the XML file and print the values. It reads the XML file. It gets the node NAME and prints it. But it returns null when trying to get the node VALUE. I am unable to figure out why.
Can anyone please help me with this.
Thanks and Regards,
Shweta
import java.io.*;
import java.net.*;
import java.util.*;
import oracle.xml.parser.v2.*;
import org.w3c.dom.*;
import org.xml.sax.SAXException;
public class ReadNodes
private static XMLDocument mDoc;
public ReadNodes () {
try {
DOMParser lParser = new DOMParser();
URL lUrl = createURL("mot.xml");
System.out.println("after creating the URL object ");
lParser.setErrorStream(System.out);
lParser.showWarnings(true);
lParser.parse(lUrl);
mDoc = lParser.getDocument();
System.out.println("after creating the URL object "+mDoc);
lParser.reset();
} catch (Exception e) {
e.printStackTrace();
} // end catch block
} // End of constructor
public void read() throws DOMException {
try {
NodeList lTrans = this.mDoc.getElementsByTagName("TRANSLATION");
for(int i=0;i<lTrans.getLength();i++) {
NodeList lTrans1 = lTrans.item(i).getChildNodes();
System.out.println("lTrans1.item(0).getNodeName : " + lTrans1.item(0).getNodeName());
System.out.println("lTrans1.item(0).getNodeValue : " + lTrans1.item(0).getNodeValue());
System.out.println("lTrans1.item(1).getNodeName : " + lTrans1.item(1).getNodeName());
System.out.println("lTrans1.item(1).getNodeValue : " + lTrans1.item(1).getNodeValue());
} catch (Exception e) {
System.out.println("Exception "+e);
e.printStackTrace();
} catch (Throwable t) {
System.out.println("Exception "+t);
public static URL createURL(String pFileName) throws MalformedURLException {
URL url = null;
try {
url = new URL(pFileName);
} catch (MalformedURLException ex) {
File f = new File(pFileName);
String path = f.getAbsolutePath();
String fs = System.getProperty("file.separator");
System.out.println(" path of file : "+path +"separator " +fs);
if (fs.length() == 1) {
char sep = fs.charAt(0);
if (sep != '/')
path = path.replace(sep, '/');
if (path.charAt(0) != '/')
path = '/' + path;
path = "file://" + path;
System.out.println("path is : "+path);
// Try again, if this throws an exception we just raise it up
url = new URL(path);
} // End catch block
return url;
} // end method create URL
public static void main (String args[]) {
ReadNodes mXML = new ReadNodes();
mXML.read();
The XML file that I am using is
<?xml version = "1.0"?>
<DOCUMENT>
<LANGUAGE_TRANS>
<TRANSLATION>
<CODE>3</CODE>
<VALUE>Please select a number</VALUE>
</TRANSLATION>
<TRANSLATION>
<CODE>5</CODE>
<VALUE>Patni</VALUE>
</TRANSLATION>
<TRANSLATION>
<CODE>6</CODE>
<VALUE>Status Messages</VALUE>
</TRANSLATION>
<TRANSLATION>
<CODE>7</CODE>
<VALUE>Progress</VALUE>
</TRANSLATION>
<TRANSLATION>
<CODE>8</CODE>
<VALUE>Create Data Files...</VALUE>
</TRANSLATION>
<TRANSLATION>
<CODE>9</CODE>
<VALUE>OK</VALUE>
</TRANSLATION>
</LANGUAGE_TRANS>
</DOCUMENT>because what you want is not the node value of CODE but the node value of the text nodes into it!
assuming only one text node into it, try this:
System.out.println("lTrans1.item(0).getNodeName : " + lTrans1.item(0).getFirstChild().getNodeValue()); -
Large XML files, how to split and read them in PI
Hi,
For a specific requirement, we have a 60 MB-90 MB XML file being generated by a legacy application.
This file has to be processed by PI 7.31 Sender File Adapter and should be posted as a ABAP proxy to SAP ECC system.
To address any performance issues, we are planning to read the files in chunks.
Is there a way by which we can configure the file adapter to pick a fixed no.of records to limit the size.
In inputs in this regard will be appreciated.
regards,
YounusHi Younus,
First of all if you are using PI 7.31, then you should be quite able to process XML file of about 100MB scale. Performance issue shall occur in ECC side instead as it can not handle such high volume.
My suggestion will be to pick the whole XML file at one go and do necessary mapping. However on receiver side use SOAP Adapter instead of XI for making proxy calls to ECC.
In SOAP adapter (using HTTP as Transport and XI 3.0 as Message protocol) there's an option as 'XI Packaging' which can be used to send data in packets.
Refer below help doc on it.
Configuring the Receiver SOAP Adapter - Advanced Adapter Engine - SAP Library
Thanks
Bibek -
Exception thrown while reading an XML file using Properties
Exception thrown while reading an XML file using Properties.
Exception in thread "main" java.util.InvalidPropertiesFormatException: org.xml.sax.SAXParseException:
The processing instruction target matching "[xX][mM][lL]" is not allowed.
at java.util.XMLUtils.load(Unknown Source)
<?xml version="1.0"?>
<Config>
<Database>
<Product>FX.O</Product>
<URL>jdbc:oracle:thin:@0.0.0.0:ABC</URL>
</Database>
</Config>Am I missing anything?Thanks a lot for all yr help.I have got the basics of
the DTD
However,when I say thus
<!DOCTYPE Config SYSTEM "c:/PartyConfig">
?xml version="1.0"?>
<Config>
<Database>
<Product>FX</Product>
<URL>jdbc:oracle:thin:@0.0.0.0:ABC</URL>
</Database>
</Config>I get the error
Invalid system identifier: file:///c:/ParyConfig.dtd
Please advise?for goodness sake, how many times do I have to tell you that you can't just expect the Properties class to accept arbitrary XML in any format? it reads XML in the format I linked to, and nothing else. Properties is not a general purpose XML binding. you can't do what you're trying to do with it. read this and in particular pay attention to the following
The XML document must have the following DOCTYPE declaration:
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
Furthermore, the document must satisfy the properties DTD described above.
you are not reading my answers properly, are you? kindly do so
Maybe you are looking for
-
Problems deleting a primary key field in a table.
Hello Guys, I deleted a primary key field in a custom table by clicking 'delete row' icon and then tried activating it through se14 - database utility. It is throwing an error saying 'Primary key change not permited for the value table zxxxx'. What i
-
I currently have an ibook G4 which has a dvd reader but not a burner. I would like to purchase an external dvd burner to make copies of movies and to back up data. What type of external burner would be best and which software do I need to purchase? T
-
How to create reconciliation account
hi gurus, when iam trying to create a customer,system is asking reconciliation account.But,in the selection list,there are no entries found for reconciliation account..can u please tell me how to create reconciliation account,step by step..this is ve
-
Hi there, i was reading all the options how to embeed a Flash into a PDF with Acrobat. I wonder how i can achieve this with LC Designer, or more even through a Form Fragment on a LiveCycle server Anybody got an idea on this ? thank you Dieter
-
Hi, i am new on this, The user indicates "We have a issue with printing of Web dynpro ABAP ALV reports" They are asking in implementing the note 918236 can someone of you explain me how to do the manual work for the note 918236, thanks in advance.