Home » Developer & Programmer » JDeveloper, Java & XML » XDB.DBMS_XMLDOM.importNode function doesn't work
icon4.gif  XDB.DBMS_XMLDOM.importNode function doesn't work [message #151508] Thu, 15 December 2005 04:09
plasmanet
Messages: 1
Registered: December 2005
Junior Member
Hi, I have problem with vary important function in dbms_xmldom package "importNode". This function allow import some Node from one document to another.
Situation is following - in 9iR2 database (actually 9.2.0.7) this function work fine, but in 10g it doesn’t work. A already have installed last patch from Oracle MetaLink (10.1.0.4) but result is the same - this function doesn’t work.
Please look at my test package to view how this function work.
After compiling You can just call it in PL/SQL Developer with out any parameters. In the result program must give CLOB with XML document. In 9iR2 test run successfully, but in 10g test return nothing and in PL/SQL Developer output window print error messages..



create or replace package fmk_test is
procedure test_function_importNode (poxml_Responce out clob);
end fmk_test;
/


/*******************************************************************************
* Modification History:
* Rev# Date Reason
* 1.0 2005-12-14 Initial version
* 1.1 2005-12-14 fixed
******************************************************************************/
create or replace package body fmk_test is
-- errors
gvc_error varchar2(2000);
ge_generic_error exception;

/*******************************************************************************
* Modification History:
* Rev# Date Reason
* 1.0 2005-12-14 Initial version
* 1.1 2005-12-14 fixed
******************************************************************************/
procedure test_function_importNode (poxml_Responce out clob)
is
-- XML base DOM
lxml_DocumentHandler xdb.dbms_xmldom.DOMDocument;
lxml_RootNode xdb.dbms_xmldom.DOMNode;
lxml_WorkNode xdb.dbms_xmldom.DOMNode;
lxml_element xdb.dbms_xmldom.DOMElement;

-- XML example DOM
lxml_parser xdb.dbms_xmlparser.parser;
lxml_DocumentHandlerExample xdb.dbms_xmldom.DOMDocument;
lxml_TmpNode xdb.dbms_xmldom.DOMNode;

-- XML example document
lxml_XMLDocument varchar2(1024) := '
<QProcedures>
<QProcedure>
<SYSDATE>13.12.05</SYSDATE>
</QProcedure>
</QProcedures>';

begin
-- create temporary CLOB for output
dbms_lob.createTemporary(lob_loc => poxml_Responce, cache => false);

-- create XML document with root element
lxml_DocumentHandler := xdb.dbms_xmldom.newDOMDocument();
lxml_RootNode := dbms_xmldom.makeNode(lxml_DocumentHandler);
lxml_element := dbms_xmldom.createElement(lxml_DocumentHandler, 'XMLResponce');
lxml_WorkNode := dbms_xmldom.appendChild(lxml_RootNode, dbms_xmldom.makeNode(lxml_element));

-- parse example document
lxml_parser := xdb.dbms_xmlparser.newParser;
xdb.dbms_xmlparser.setValidationMode(lxml_parser, false);
xdb.dbms_xmlparser.parseClob(lxml_parser, lxml_XMLDocument);
lxml_DocumentHandlerExample := xdb.dbms_xmlparser.getDocument(lxml_parser);
xdb.dbms_xmlparser.freeParser(lxml_parser);

-- import XML example document into XMLResponce
lxml_TmpNode := xdb.dbms_xmldom.importNode(lxml_DocumentHandler, dbms_xmldom.makeNode(lxml_DocumentHandlerExample), true);
lxml_WorkNode := xdb.dbms_xmldom.appendChild(lxml_WorkNode, lxml_TmpNode);

-- write result to clob
xdb.dbms_xmldom.writeToClob(lxml_DocumentHandler, poxml_Responce, 'UTF-8');

-- free documents handlers
xdb.dbms_xmldom.freeDocument(lxml_DocumentHandler);
xdb.dbms_xmldom.freeDocument(lxml_DocumentHandlerExample);

exception
when others then
dbms_output.put_line('other error in fmk_test.test_function_importNode');
dbms_output.put_line(SQLERRM);
end test_function_importNode;

end fmk_test;
/

  • Attachment: fmk_test.pkg
    (Size: 2.84KB, Downloaded 1694 times)
Previous Topic: Open cursor limit exceeded
Next Topic: ORA-00020 maximum number of processes exceeded
Goto Forum:
  


Current Time: Thu Nov 28 16:09:48 CST 2024