473,505 Members | 16,940 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error parsing xml files - Help urgently needed.

2 New Member
Hello,

I am running Oracle 10g R2 in our office. I created the following procedure. It is suppose to access an xml file ( family.xml). The procedure is compiled and when I try to run it, i get the following error.

SQL> execute domsample('c:\','song.xml','error.txt')
BEGIN domsample('c:\','song.xml','error.txt

*
ERROR at line 1:
ORA-31001: Invalid resource handle or path
ORA-06512: at "SYS.XDBURITYPE", line 11
ORA-06512: at "XDB.DBMS_XSLPROCESSOR", line
ORA-29280: invalid directory path
ORA-29280: invalid directory path
ORA-29280: invalid directory path
ORA-06512: at "XDB.DBMS_XMLPARSER", line 11
ORA-06512: at "BRREG.DOMSAMPLE", line 81
ORA-06512: at line 1



Source Code:
============

create or replace procedure domsample(dir varchar2, inpfile varchar2,
errfile varchar2) is
p DBMS_XMLPARSER.parser;
doc dbms_xmldom.DOMDocument;

-- prints elements in a document
procedure printElements(doc xmldom.DOMDocument) is
nl xmldom.DOMNodeList;
len number;
n dbms_xmldom.DOMNode;

begin
-- get all elements
nl := dbms_xmldom.getElementsByTagName(doc, '*');
len := dbms_xmldom.getLength(nl);

-- loop through elements
for i in 0..len-1 loop
n := dbms_xmldom.item(nl, i);
dbms_output.put(dbms_xmldom.getNodeName(n) || ' ');
end loop;

dbms_output.put_line('');
end printElements;

-- prints the attributes of each element in a document
procedure printElementAttributes(doc dbms_xmldom.DOMDocument) is
nl dbms_xmldom.DOMNodeList;
len1 number;
len2 number;
n dbms_xmldom.DOMNode;
e dbms_xmldom.DOMElement;
nnm dbms_xmldom.DOMNamedNodeMap;
attrname varchar2(100);
attrval varchar2(100);

begin

-- get all elements
nl := dbms_xmldom.getElementsByTagName(doc, '*');
len1 := dbms_xmldom.getLength(nl);

-- loop through elements
for j in 0..len1-1 loop
n := dbms_xmldom.item(nl, j);
e := dbms_xmldom.makeElement(n);
dbms_output.put_line(dbms_xmldom.getTagName(e) || ':');

-- get all attributes of element
nnm := dbms_xmldom.getAttributes(n);

if (dbms_xmldom.isNull(nnm) = FALSE) then
len2 := dbms_xmldom.getLength(nnm);

-- loop through attributes
for i in 0..len2-1 loop
n := dbms_xmldom.item(nnm, i);
attrname := dbms_xmldom.getNodeName(n);
attrval := dbms_xmldom.getNodeValue(n);
dbms_output.put(' ' || attrname || ' = ' || attrval);
end loop;
dbms_output.put_line('');
end if;
end loop;

end printElementAttributes;

begin

-- new parser
p := DBMS_XMLPARSER.newParser;

-- set some characteristics
DBMS_XMLPARSER.setValidationMode(p, FALSE);
DBMS_XMLPARSER.setErrorLog(p, dir || '/' || errfile);
DBMS_XMLPARSER.setBaseDir(p, dir);

-- parse input file
DBMS_XMLPARSER.parse(p, dir || inpfile);

-- get document
doc := DBMS_XMLPARSER.getDocument(p);

-- Print document elements
dbms_output.put('The elements are: ');
printElements(doc);

-- Print document element attributes
dbms_output.put_line('The attributes of each element are: ');
printElementAttributes(doc);

-- deal with exceptions
exception when others then null;

end domsample;


Family.xml
==========
<?xml version="1.0"?>
<!DOCTYPE SONG SYSTEM "c:\song.dtd">
<SONG>
<TITLE>Hot Cop</TITLE>
<COMPOSER>Jacques Morali</COMPOSER>
<COMPOSER>Henri Belolo</COMPOSER>
<COMPOSER>Victor Willis</COMPOSER>
<PRODUCER>Jacques Morali</PRODUCER>
<PUBLISHER>PolyGram Records</PUBLISHER>
<LENGTH>6:20</LENGTH>
<YEAR>1978</YEAR>
<ARTIST>Village People</ARTIST>
</SONG>

family.dtd
-----------

<!ELEMENT SONG (TITLE, COMPOSER+, PRODUCER*, PUBLISHER*,
LENGTH?, YEAR?, ARTIST+)>

<!ELEMENT TITLE (#PCDATA)>

<!ELEMENT COMPOSER (#PCDATA)>
<!ELEMENT PRODUCER (#PCDATA)>
<!ELEMENT PUBLISHER (#PCDATA)>
<!ELEMENT LENGTH (#PCDATA)>
<!-- This should be a four digit year like "1999",
not a two-digit year like "99" -->
<!ELEMENT YEAR (#PCDATA)>

<!ELEMENT ARTIST (#PCDATA)>



Help is needed urgently. Please solve my problem.


Thanks,

Venkat
Jun 22 '07 #1
1 4906
debasisdas
8,127 Recognized Expert Expert
Since this question was in Article section Moved to Oracle Forum.
Jun 22 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
423
by: ex laguna | last post by:
I have run into this problem below with py2exe version 0.5.0 and python 2.3.3. Does anyone know a solution or workaround for this? Thanks much! ## Begin of test.py import shelve f =...
67
4193
by: Steven T. Hatton | last post by:
Some people have suggested the desire for code completion and refined edit-time error detection are an indication of incompetence on the part of the programmer who wants such features. ...
4
2703
by: Don Wash | last post by:
Hi All! I'm getting the following Error: No DLLs has been compiled yet and nothing in the \bin directory. So it is not the versioning problem or anything like that. And here are the...
6
3861
by: ST | last post by:
Hi, I keep getting the parser error, and I have no idea why. I've tried a number of things including: 1)building/rebuilding about 100x 2)making sure all dll's are in the bin folder in the root...
8
1886
by: Brett Romero | last post by:
I get this error when I try to run my ASP.NET app on our server: Server Error in '/' Application. -------------------------------------------------------------------------------- Parser Error...
3
4359
by: toton | last post by:
Hi, I have some ascii files, which are having some formatted text. I want to read some section only from the total file. For that what I am doing is indexing the sections (denoted by .START in...
0
4026
by: janakivenk | last post by:
Hello, I am running Oracle 10g R2 in our office. I created the following procedure. It is suppose to access an xml file ( family.xml). The procedure is compiled and when I try to run it, i get the...
0
2007
by: poojamangal | last post by:
I want to upload images or pdf files. but i m unable to do so. i got error. please help me to sort it out.. my code is: <% 'on error resume next Class FreeASPUpload Public UploadedFiles...
3
4493
by: GazK | last post by:
I have been using an xml parsing script to parse a number of rss feeds and return relevant results to a database. The script has worked well for a couple of years, despite having very crude...
0
7218
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7307
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7370
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7021
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1532
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
409
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.