Hi:
I'm trying to read large XML documents using the Context.getXMLParser() from where I expect to retrieve a JDOM parser for navegating through the XML tree. Unfortunately, I get a "Java heap space" error which finishes, abruptly, the execution of the script, probably due to the size of those documents.
Known some disadvantages of using DOM-like APIs for reading XML documents (like a proved high memory consumption), I'm figuring how to achieve my goal with other alternatives, like using a (Java) SAX-compliant XML Parser...
Did anyone do this before? Any suggestions?
All the help you can provide me will be highly appreciated.
Best regards,
Ricardo
Hi Ricardo,
it is possible to use an alternative XML parser like SAX. In a report script you can call Java.Packages. To load a XML file for example:
this.init2 = function() { try { var locale = Packages.com.idsscheer.utils.locale.ALocaleConverter.getLocale( Context.getSelectedLanguage() ).getLanguage(); var filedata = Context.getFile("filename.xml", Constants.LOCATION_COMMON_FILES); var factory = new Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance(); factory.setValidating(true); var builder = factory.newDocumentBuilder(); propertiesfile = builder.parse( new java.io.ByteArrayInputStream( new java.lang.String( filedata ).getBytes("UTF-8") ) ); } catch(e) { //do nothing } }
Regards,
Jens
Hi Jens,
First of all, thank you very much for your help.
Many years have passed since the last time I use SAX in a development, so some of my statements may not be as exact as I would like. Sorry for that...
The main issue I have to face with is the creation of the ContentHandler(DefaultHandler)-derived type, in order to implement the startElement(), endElement(), characters(),... methods which manage the XML document in a proper way, that is:
1) Read the XML structure (XML nodes or nodesets)
2) Create some ARIS structures (models, objects and connections) using the previously read data. At this point, the ARIS Javascript-based API should be used in order to do the expected work but... within a Java type?
From my current point of view, that's something I am not able to understand about how to carry it out...
Any idea?
Thanks, in advance, for all your help.
Regards,
Ricardo
Hi Ricardo,
I have quiet the same pbm i want to parse the xml file of a database :
var xmlExportOptionsWrapper = xmlExport.createDefaultXMLExportRootOptions(sourceDb.RootGroup(), [1033]);
but the xmlExportResultWrapper2.getFileResult(); --> JAVA HEAP SPACE
I tried -Xmx in launcher.cfg...
I you have any suggestion... i'll take it...