ORA-31011: XML parsing failed [message #92622] |
Fri, 22 October 2004 00:21 |
Bhavesh Patel
Messages: 3 Registered: February 2002
|
Junior Member |
|
|
Hi,
I have written an Oracle procedure which creates an XML on UNIX Server. When i try to read from the created XML file then it gives me error (ORA-31011: XML parsing failed). But when i copy the same file on windows xp server and try to read the xml file it works perfectly. Find below the code written by me to read the xml file:
-----
PROCEDURE spi_read_from_xml_file(p_filename IN VARCHAR2,
o_error OUT NUMBER,
o_error_code OUT VARCHAR2,
o_error_text OUT VARCHAR2)
IS
v_bfile BFILE;
v_clob CLOB;
v_parser DBMS_XMLPARSER.PARSER;
v_doc DBMS_XMLDOM.DOMDOCUMENT;
v_pres_nl DBMS_XMLDOM.DOMNODELIST;
v_pres_n DBMS_XMLDOM.DOMNODE;
v_ins_nl DBMS_XMLDOM.DOMNODELIST;
v_ins_n DBMS_XMLDOM.DOMNODE;
v_attriMap DBMS_XMLDOM.DOMNAMEDNODEMAP;
v_attriVal DBMS_XMLDOM.DOMNODE;
TYPE rec_type IS RECORD
(p VARCHAR2(100),
n NUMBER);
TYPE tab_type IS TABLE OF rec_type;
t_tab tab_type := tab_type();
BEGIN
o_error := 30.1;
v_bfile := BFILENAME('ETP_DIR',p_filename);
DBMS_LOB.CREATETEMPORARY(v_clob, cache=>TRUE);
DBMS_LOB.OPEN(v_bfile, DBMS_LOB.LOB_READONLY);
DBMS_LOB.LOADFROMFILE(v_clob,v_bfile,DBMS_LOB.GETLENGTH(v_bfile));
DBMS_LOB.CLOSE(v_bfile);
-- Create a parser.
v_parser := DBMS_XMLPARSER.NEWPARSER;
-- Parse the document and create a new DOM document.
DBMS_XMLPARSER.PARSECLOB(v_parser, v_clob);
v_doc := DBMS_XMLPARSER.GETDOCUMENT(v_parser);
-- Free resources associated with the CLOB and Parser now they are no longer needed.
DBMS_LOB.FREETEMPORARY(v_clob);
DBMS_XMLPARSER.FREEPARSER(v_parser);
-- Get a list of all the Item nodes in the document using the XPATH syntax.
v_pres_nl := DBMS_XSLPROCESSOR.SELECTNODES(DBMS_XMLDOM.MAKENODE(v_doc),'/soap:Envelope/soap:Body/nasp:batchManifest/item/referenceId[[@root="urn:spine:types:prescriptionId"]]');
v_ins_nl := DBMS_XSLPROCESSOR.SELECTNODES(DBMS_XMLDOM.MAKENODE(v_doc),'/soap:Envelope/soap:Body/nasp:batchManifest/item/referenceId[[@root="urn:spine:types:prescriptioninstanceno"]]');
dbms_output.put_line(32);
-- Loop through the list and create a new record in a table collection for each 'P' value.
FOR i IN 0 .. DBMS_XMLDOM.GETLENGTH(v_pres_nl) - 1
LOOP
v_pres_n := DBMS_XMLDOM.ITEM(v_pres_nl,i);
v_ins_n := DBMS_XMLDOM.ITEM(v_ins_nl, i);
t_tab.EXTEND;
-- Use XPATH syntax to assign values to the elements of the collection.
-- Assign Prescription_Guid to t_tab
BEGIN
v_attriMap := DBMS_XMLDOM.GETATTRIBUTES(v_pres_n);
v_attriVal := DBMS_XMLDOM.GETNAMEDITEM(v_attriMap,'extension);
t_tab(t_tab.LAST).p := DBMS_XMLDOM.GETNODEVALUE(v_attriVal);
END;
-- Assign Instance_No to t_tab
BEGIN
v_attriMap := DBMS_XMLDOM.GETATTRIBUTES(v_ins_n);
v_attriVal := DBMS_XMLDOM.GETNAMEDITEM(v_attriMap,extension);
t_tab(t_tab.LAST).n := DBMS_XMLDOM.GETNODEVALUE(v_attriVal);
EXCEPTION
WHEN OTHERS THEN
t_tab(t_tab.LAST).n := 1;
END;
END LOOP;
dbms_output.put_line(33);
-- Free any resources associated with the document now it is no longer needed.
DBMS_XMLDOM.FREEDOCUMENT(v_doc);
o_error_code := '0';
o_error := 0;
EXCEPTION
WHEN OTHERS THEN
DBMS_LOB.FREETEMPORARY(v_clob);
DBMS_XMLPARSER.FREEPARSER(v_parser);
DBMS_XMLDOM.FREEDOCUMENT(v_doc);
END spi_read_from_xml_file;
-----
|
|
|
Re: ORA-31011: XML parsing failed [message #92744 is a reply to message #92622] |
Mon, 03 January 2005 09:44 |
MJS
Messages: 5 Registered: May 2003
|
Junior Member |
|
|
I also got this error and
XML Parser Messages (LPX)
I had created a textpad file that I called.
After removing spaces att he end and beginning of file, the error dod not occur again.
must have been ascii character.
My file used UTF character set.
|
|
|