Urgent - Need an answer - XML Java API

This is the 3rd time I've posted this question in last week - Oracle Support: How can I get an answer to this?
This question is about how to free up the memory of XMLDocuments, Parsers, etc using the Java APIs - not the PLSQL wrappers.
I'm writing an app using the DocumentSplitter class (from Steve M.'s book) that allows for the SAX parsing of large XML documents. But this question is really about the Oracle Java XML API.
Is there a way to free the memory of each of the "temporary" XMLDocuments that get created? I know there's a XMLNodeCover.freeDocument(int id)
method in the xmlplsql.jar- where do you get the id from? I'm trying XMLNodeCover.getDocumentId(curDoc) - but that doesn't seem to work.
And can I use that same method for each Node and Element that gets created also?
Also, would like to free the memory for the XSL processor, SAXParser, and XSLStylesheet - but this is even less obvious (although not as critical).
I'm actually getting out-of-memory errors even sooner when using the SAX parser then when using the DOM parser, and I think its due to this issue.
I know that there are PL/SQL wrappers for all these, but I'm trying to use the DocumentSplitter and associated custom classes
in only Java stored procs, and then writing a single XSLT.transform wrapper. This way its largely invisible to the PLSQL layer.
Thanks

Hi - thanks for your response.
Actually, yes, I did change the split method to return a CLOB. The big picture is I'm trying to use the DocumentSplitter
class to assist in the transformation of large XML documents to html or tab-delimited output. Using the standard DOM parser,
I eventually get an out-of-memory situation. So now I'm trying the DocumentSplitter to do a "mini" XSL transform on each <ROW>.
The good news is it works for small to medium size reports. But its slower and runs out of memory quicker.
Below is some of the relevant code. I also wrote associated classes to wrap the DocumentSplitter and to be the 'handler' that transfoms the XML when a <ROW> is found, and returns a string (see 'endElement' method below).
I'm freeing the CLOBS in PLSQL after reading them - do I need to free them from JVM memory seprately? If so, how can I do that if I need to pass them to PLSQL?
Thanks much,
Eric
// Split a large XML document into N subdocuments, each one identified
// by the an opening 'splitElement' element. Invoke an XMLDocumentHandler
// to process each subdocument encountered.
public CLOB split(String splitElement, CLOB inputCLOB, CLOB outputCLOB)
throws Exception, SAXParseException,SAXException,IOException, SQLException {
this.inputCLOB = inputCLOB;
this.outputCLOB = outputCLOB;
this.splitOnElement = splitElement;
// Create a new SAXParser
SAXParser parser = new SAXParser();
// Register the current instance of this class as the Document Handler
parser.setDocumentHandler(this);
// Create ascii stream from CLOB source
InputStream inputStream = inputCLOB.getAsciiStream();
// Start parsing the stream of XML
parser.parse(inputStream);
Writer out = this.outputCLOB.getCharacterOutputStream();
// Set buffer to be the optimal size
int chunk = outputCLOB.getChunkSize();
char[] buffer = new char[chunk];
// Create a reader from the output string
StringReader reader = new StringReader(this.outputString);
int length = -1;
// Now write from output string to output CLOB
while ((length = reader.read(buffer)) != -1) {
out.write(buffer, 0, length);
// Close streams
reader.close();
out.close();
inputStream.close();
return outputCLOB;
portion of endElement method:
// Handle the </Element> "end-element" parsing event
public void endElement(String name) throws SAXException {
// If we're NOT building a subdocument, we don't care. Just return.
if (curDoc == null) return;
// If this is the endElement event for the subdocument splitElement
// then we're done with the subdocument and are ready to call the
// handler to handle it.
if (name.equals(splitOnElement)) {
if (curDoc != null) {
try {
// Call the XMLDocumentHandler.handle() method for current subdoc
//Append the output to the growing output string
if (this.outputString == null) {
this.outputString = handler.handleDocument(curDoc);
} else {
this.outputString = this.outputString + handler.handleDocument(curDoc);
catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}

Similar Messages

  • Urgent - Big POC: SAP Adapter Java API !

    Hi,
    I'm trying to get from an SAP BAPPI values using SAP Adapter Java API.
    I had tested at BEA and it worked fine.
    the code is:
    try {
    InitialContext ic = new InitialContext(env);
    // Create an object that provides the services established during
    configuration
    ApplicationView applicationView = new
    ApplicationView(ic,SapConstants.APPVIEW_NAME);
    // First, get the schema for the request document and use it to
    construct a default document.
    IDocumentDefinition requestDocumentDef =
    applicationView.getRequestDocumentDefinition(SapConstants.APPVIEW_SERVICE);
    IDocument requestDocument = requestDocumentDef.createDefaultDocument();
    requestDocument.setStringInFirst("/Material.GETDETAIL/MATERIAL",
    "000000000000001667");
    requestDocument.setStringInFirst("/Material.GETDETAIL/PLANT", "0001");
    // Problem at this line
    responseDocument =
    applicationView.invokeService(SapConstants.APPVIEW_SERVICE,
    requestDocument);
    On site, the plateforme has no Internet connexion. limitation
    Is there type limitation: here it's only a String.
    I get this error message:
    <Material.GETDETAIL><MATERIAL>000000000000001667</MATERIAL><eda:control
    xmlns:eda="http://www.iwaysoftware.com/iwse" clip="yes"
    by="SAPIFRService"><eda:expire>2003-01-10T19:53:14Z</eda:expire><eda:attempt
    1</eda:attempt></eda:control></Material.GETDETAIL>
    DEBUG 09 Jan 2003 19:53:14,468 BEA_SAP_1_0.AppViewSapDev - DEEP
    [SAPIFRService] localWorker: Agent review SNIP <eda:control
    xmlns:eda="http://www.iwaysoftware.com/iwse" clip="yes" by="SAPIFRService">
    [parent=Material.GETDETAIL]
    DEBUG 09 Jan 2003 19:53:14,484 BEA_SAP_1_0.AppViewSapDev - DEEP
    [SAPIFRService] localWorker: Agent review result <Material.GETDETAIL>
    <MATERIAL>000000000000001667</MATERIAL>
    </Material.GETDETAIL>
    DEBUG 09 Jan 2003 19:53:14,484 BEA_SAP_1_0.AppViewSapDev - DEBUG
    [SAPIFRService] localWorker: SafIFRAgent rootname: Material.GETDETAIL
    ExecuteThread: '10' for queue: 'default': com.ibi.sapjco.SapDriver: connect
    ExecuteThread: '10' for queue: 'default': com.ibi.sapjco.SapConnection:
    Initializing connection ...
    ExecuteThread: '10' for queue: 'default': Create callable statement: {CALL
    IDOC_INBOUND_ASYNCHRONOUS(?)}
    DEBUG 09 Jan 2003 19:53:14,515 BEA_SAP_1_0.AppViewSapDev - DEBUG
    [SAPIFRService] localWorker:
    IFRXML=<Material.GETDETAIL><MATERIAL>000000000000001667</MATERIAL></Material
    .GETDETAIL>
    java.util.NoSuchElementException
    at java.util.Vector.lastElement(Vector.java:449)
    at
    com.ibi.sapjco.SapIdocXmlParser.endElement(SapIdocXmlParser.java:189)
    at
    org.apache.xerces.parsers.AbstractSAXParser.endElement(AbstractSAXParser.jav
    a:559)
    at
    org.apache.xerces.impl.XMLNamespaceBinder.handleEndElement(XMLNamespaceBinde
    r.java:853)
    at
    org.apache.xerces.impl.XMLNamespaceBinder.endElement(XMLNamespaceBinder.java
    :643)
    at
    org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(XMLDTDValidator.
    java:2978)
    at
    org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(XMLDTDValidator.java:9
    18)
    at
    org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.handleEndElement(XMLDo
    cumentFragmentScannerImpl.java:1145)
    at
    org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocu
    mentFragmentScannerImpl.java:988)
    I'm on site so could you send me the answer directly : [email protected]
    Thanks
    Christophe

    Hi,
    I don't know how much it will help but it must add some value.
    please check these links
    http://help.sap.com/saphelp_nw04/helpdata/en/57/0b2c4142aef623e10000000a155106/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/78/759f3cad1e3251e10000000a114084/content.htm
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/50061bd9-e56e-2910-3495-c5faa652b710
    Regards
    Aashish Sinha

  • Need information about OCR Java API

    Hi,
    I am looking for Java API to read OCR. Can anyone have idea about it please tell me. It will be very useful.
    Thanks in advance.
    Thanks & Regards
    Veeraraghavan P

    Since you claim you already google, I can possibly interest you in another web page: [How To Ask Questions The Smart Way|http://www.catb.org/~esr/faqs/smart-questions.html]

  • Auto indent XML Java API

    Is the "Auto Indent XML" context menu function available as an API.
    I have several JDeveloper Addin's that generate XML, but would prefer to use the built-in formatter.
    Thanks
    Pat

    There is an API for manipulating XML in the product, but unfortunately it's not public yet.
    In the meantime, probably the easiest way to reformat XML (or any file) in 10.1.3 is to programmatically invoke the Reformat command. This will work on any context where the document or selection is an XMLSourceNode.
    // !! The CodingStyleController.FORMAT_CMD constant is not guaranteed
    // !! to stay the same in future releases.
    IdeAction action = IdeAction.find( Ide.findCmdID( "CodingStyleController.FORMAT_CMD" ) );
    action.performAction( context );Thanks,
    Brian

  • URGENTLY NEED AN ANSWER PLEASE VERY IMPORTANT FOR EVIDENCE!

    Please could somebody tell me what time did iPhone 5's go back and on what day this weekend?Need to know for evidence please could somebody answer for me ASAP ? Thank you in advance :)

    "Go back" where?

  • User defined Metadata for XML DB using Java API

    I have been looking through and reading the documentation for Oracle XML DB. I am trying to find out if there is a way to create user define metadata using a Java API. when I look in the XML "Java API Reference (Javadoc)" setProperty(java.lang.String name, java.lang.String value, int type) it states: Sets the specified (single-value) property to the specified value. If the property does not yet exist, it is created. I have tried several ways to do this and have not been successful. I have looked for java examples in the XML DB Developer's Guide, XML Developer's Kit Programmer's Guide.
    Is there a good example out there as to how to create user-defined metadata that can be populated using the JCR API.
    Thanks in advance.

    We need to create the 2 xml schemas, one for request and the other for response of selected operation in the WSDL.
    This we need to do dynamically. There will not be any java classes generated, the xsd files need to be created on the fly.
    Please suggest xml schema creation in this sequence.

  • Link to download java api?

    Hi,
    I've needed to download the java api a couple of times in the past, and I remember the download was impossible to find on sun's website. Once again I can't figure out where it is. Can anyone help me?
    I wonder why sun doesn't put a link to where you can download the api at the top of their web page that lets you view the api online?

    You mean, like the "Downloads" link at the top of this page?No. I looked through all the downloads, and I didn't find what I was looking for
    Downloads->Java Se->Java SE 6 Documentation
    how hard was that?Not too hard if you know that what you are after is called Java SE 6 Documentation.
    Use google next time... "Java API Download"I did--and with those exact words in a different order. It wasn't helpful.
    http://java.sun.com/javase/reference/api.jspThose are links to the online docs--not downloadable docs.
    Thanks for the help, but lose the attitude--especially for something so trivial for someone who knows their way around the sun website. Sorry for putting you all out.

  • Java API to fill in a MS Word file template

    Ola,
    Please help me on the following topic:
    I need a kind of Java API which allows me to read Ms Word 2003 .doc files, replace a few strings/keywords and save the doc back.
    Ideal feature would also be to allow me in the end to convert to TXT or RTF, after the strings have been replaced.
    A first search on Google takes me to Apache POI, but the api looks really heavy for a beginner.
    Do you have any other suggestions for another API? I do not mind if not open-source.
    Thanks.

    FileInputStream fis = new FileInputStream(new File("/cory/test.doc"));
    FileOutputStream fos = new FileOutputStream(new File("/cory/my_result.pdf"));
    officetools.OfficeFile f = new officetools.OfficeFile(fis,"localhost","8100", false);
    f.replaceAll("Yahoo","Google"); // will replace all string Yahoo with string Google

  • How to change the parameter 'Default Servers To Use For Viewing And Modification' using java api dynamically.

    Hi,
    I need to change the Crystal Reports setting 'Default Servers To Use For Viewing And Modification' to a particular server.this i need to do using java api.
    could you pls provide me the sample code for this.
    Regards
    Srinivas

    The IReport interface extends IViewingServerGroupInfo interface, that allows you to specify the server group. 
    The choice selection for that interface is as follows:  0 = first available, 1 = prefer the selected server group, and 2 =  only use the selected server group.
    The server group selection is by the SI_ID for that server group InfoObject.
    Sincerely,
    Ted Ueda - Developer Support

  • Is there Java API available for third-party integrations with SCCM 2012? I went through the "Developer's Survival Guide", and it seems that SCCM 2012 SDKs only support C# and PowerShell

    Hi All,<o:p></o:p>
    My team and I are developing a software using java that works closely with IT management software such as SCCM. Our software will be highly dependent on data stored in SCCM. Basically
    our software will talk to SCCM to get information about a system managed by SCCM. To be able to do that, our software needs to use a java API that talks to SCCM. Is there a java API for SCCM 2012 that we can use? If there is not, what is the work around to
    this issue (integrate a java project with SCCM SDKs)? Any help is appreciated! Thanks!<o:p></o:p>

    Hi,
    As you mentioned, it seems that there is no available Java API for SCCM .
    Just curious, what's information you want to get from SCCM.
    Based on my experience, you could query the SCCM site database to get almost all the information.
    Otherwise, your question seems to be related to SCCM 2012. You may also choose to post there to get more effictive help.
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Calling a java API from XI

    Hi
    We need to call a java API on a J2EE system from SAP XI. What is the approach to be followed for these scenarios.
    Thanks
    Sabyasachi

    Hi Stefan
    Is there any other way of doing this using java proxies or HTTP adapters.Please Advise.Thanks

  • MDM JAVA API SCA file for MDM 7.1 SP04

    I need to download MDM JAVA API SCA file for MDM 7.1 SP04. When I added to the download basket through service marketplace it is looking for the approval process, just for the API file. I was able to get the other files though like webdynpro framework, change tracker. We haven't setup the Solution Manager yet. It might take a while. Meanwhile is there any other way to get the SCA file.
    Thanks

    Opened message with SAP and they have approved the download basket. Now able to download the sca file.

  • Need JAVA API to list down all the Proxy Services in OSB Console 11g

    Hi,
    I need a java API to List down all the Proxy Services present in OSB Console for SOA 11g (11.1.1.5). I am in a situation where I cant use python script for the same.
    any help will be much appreciated.
    Thanks in Advance,
    Ravi
    Edited by: 899443 on Oct 1, 2012 4:13 AM

    AFAIK it is proprietary.
    What I do in a similar situation is to form XML for the services, package them into JAR the same way as an import JAR is packaged (creating ExportInfo resource, ...) and deploy with standard WSLT script. Works for simplest services only (direct proxies mostly) but I can also form security, alerts, throttling etc etc etc -- all in one shot.
    Out of sheer interest, may I ask you a question? Why do you need to create OSB services from Java?
    Vlad
    http://vladimirdyuzhev.com

  • Need Java API's to create OSB proxy and Business Services

    Hi All,
    I need to create OSB proxy and business services using Java API's. Does any one have reference to the OSB APIs??

    AFAIK it is proprietary.
    What I do in a similar situation is to form XML for the services, package them into JAR the same way as an import JAR is packaged (creating ExportInfo resource, ...) and deploy with standard WSLT script. Works for simplest services only (direct proxies mostly) but I can also form security, alerts, throttling etc etc etc -- all in one shot.
    Out of sheer interest, may I ask you a question? Why do you need to create OSB services from Java?
    Vlad
    http://vladimirdyuzhev.com

  • Want the link to open EAS IN WEb mode and also the Java API details needed

    Want the link to open EAS IN WEb mode and also the Java API details needed to get it up and running.
    Kindly provide the answer if knows.
    Thanks .

    Yes, you can have single sign on enabled on multiple essbase servers,
    It works like using single userid and password across mulple servers. you can configure essbase server to read from active directory.
    you can configure css.xml file in bin folder
    sample CSS FILE
    here is an example of a css.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <css xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <spi>
    <provider>
    <msad name="msad1"> <trusted>false</trusted>
    <url>ldap://ldapserver:389/dc=CompanyName,dc=com</url>
    <userDN>CN=#######,OU=Security Accounts,OU=IT,DC=CompanyName,DC=com</userDN>
    <password>########</password>
    <authType>simple</authType>
    <identityAttribute>dn</identityAttribute>
    <user>
    <loginAttribute>sAMAccountName</loginAttribute>
    <fnAttribute>givenname</fnAttribute>
    <snAttribute>sn</snAttribute>
    <emailAttribute>mail</emailAttribute>
    <objectclass>
    </objectclass>
    </user>
    <group>
    <url>cn=LostAndFound</url>
    </group>
    </msad>
    </provider>
    </spi>
    <searchOrder>
    <el>msad1</el>
    </searchOrder>
    <token>
    <timeout>60</timeout>
    </token>
    <logger>
    <priority>ERROR</priority>
    </logger>
    </css>

Maybe you are looking for

  • How to find out from which device sms or calls has...

    Hello! I want to check from which of my devices some particular calls and sms in particular period has been made. I use several devices: few laptops and androide phone. Can I check from which device sms and calls has been sent? Thanks in advance !  i

  • Track Master Data Changes for Multiple countries

    Hi experts, I am in a Global HR Implementation & Rollout Project. We are creating Outbound Interfaces for 3 countries to export pay, time and general data to the 3rd party systems in those local countries. (Payroll is outsourced there). As well as se

  • QM_Control on Required start date in quality notifications

    Dear QM experts, Requirement is, For Q2 notification type the entries in required start date filed (QMEL-STRMN) to be restricted in such a way so that user can not do entry for last month. Foe example, 1.     Today is June 12, 2009. If a user is crea

  • FNM3 Balance in local currency F5 703

    Hi Support Team, When I try to  reversal a Loan documento the system show the message F5 703 Balance in local currency. I 've been looking for oss notes but there is nothing to this component about the issue. Before to write any note i want to know i

  • Cannot run the macro 'YIELD'. The macro may not be available in this workbook or all macros may be disabled.

    Dear Sir,           While i am calling Excel function through asp.net  using Excel 2003 i  was not facing any kind of issue it's working fine but while i am calling  Excel functions through asp.net using  Excel 2010  i am facing an issue even after e