Parser Docs
The URL http://technet.oracle.com/tech/xml/parser_java2/htdocs/relnotes.htm
contains the following sentence:
Important note: Documentation for Oracle XML Parser for Java is located in the doc directory in your install area.
I cannot find any XML documentation in either the doc or the install directories
for my 8.1.5 Oracle installation. Surely this documentation came with the product. What am I overlooking?
Thanks
Kristi Uthoff
This statement is referring to the installation of the parser that you download from this site. It was not included as part of the 8i install.
Oracle XMl Team
Similar Messages
-
How to schema-validate an aleady-parsed-DOC?
Hi,
I want to schema-validate an aleady-parsed-DOC. Is it possible?
nullHi,
I want to schema-validate an aleady-parsed-DOC. Is it possible?
null -
Getting the following error while parsing the values usng xml parser
Hi
I am getting the following error while parsing the values using the code in r12 instance on linux
declare
XML_PARSER XMLPARSER.PARSER;
DOC XMLDOM.DOMDOCUMENT;
DOCELEMENT DBMS_XMLDOM.DOMELEMENT;
BEGIN
-- NEW PARSER
XML_PARSER := XMLPARSER.NEWPARSER;
-- SET SOME CHARACTERISTICS
XMLPARSER.SETVALIDATIONMODE(XML_PARSER, FALSE);
IF P_DIR IS NOT NULL AND P_FILENAME IS NOT NULL
THEN
FND_FILE.PUT_LINE(FND_FILE.LOG,'DIRECTORY FOUND'||'-'||P_DIR);
XMLPARSER.SETBASEDIR(XML_PARSER, P_DIR);
-- PARSE INPUT FILE
FND_FILE.PUT_LINE(FND_FILE.LOG,'FILE FOUND'||'-'||P_FILENAME);
XMLPARSER.PARSE(XML_PARSER, P_DIR || '/' || P_FILENAME);
-- GET DOCUMENT
DOC := XMLPARSER.GETDOCUMENT(XML_PARSER);
LOAD_SUPP(doc);
ELSE
DBMS_OUTPUT.PUT_LINE('DIRACTORY/FILENAME CANNOT BE NULL');
END IF;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('DATA NOTINSERTED'||sqlerrm);
ROLLBACK;
END
I am getting the following error
DIRACTORYL-/home/appldevORA-0000: normal, successful completion
FILE NAME-suppliersample_data.xmlORA-0000: normal, successful completion
DATA NOTINSERTEDORA-31001: Invalid resource handle or path name "/home/appldev/suppliersample_data.xml"
ORA-06512: at "SYS.XDBURITYPE", line 11
ORA-06512: at "XDB.DBMS_XSLPROCESSOR", line 142
ORA-29280: invalid directory path
ORA-29280: invalid directory path
ORA-29280: invalid directory path
It could be great if some one could give a suggestion/solution.
Thanks
AjeshBesides this is not the correct forum try to google the error message first before posting:
http://ora-29280.ora-code.com/
cheers -
?xml version = '1.0' encoding = 'ASCII'? pl/sql xml parser
When ever I parse a document which has the
<?xml version = '1.0' encoding = 'ASCII'?> tag as the first line hangs the pl/sql xml parser . If I remove the "encoding = 'ASCII'" from the file everything works fine ! What is the problem ?
version 8.1.6 / plsql parser v2 / hpux 11x
Here is the input file
<?xml version = '1.0' encoding = 'ASCII'?>
!--- This is a comment -->
<person>
<employee>
<lastname>GHANTASALA</lastname>
<firstname>SREE</firstname>
<age>32</age>
</employee>
<employee>
<lastname>TAMATAM</lastname>
<firstname>SATISH</firstname>
<age>30</age>
</employee>
</person>
Here is my program
declare
p xmlparser.parser;
doc xmldom.DOMDocument;
dir varchar2(100) := '/apps/oracle/drugstore';
errfile varchar2(30) := 'err.txt' ;
inpfile varchar2(30) := 'person.xml';
nl xmldom.DOMNodeList;
len number;
n xmldom.DOMNode;
new_node xmldom.DOMNode;
node_name varchar2(100);
node_value varchar2(100);
begin
-- new parser
p := xmlparser.newParser;
-- Set some characteristics
xmlparser.setValidationMode(p, FALSE);
xmlparser.setErrorLog(p, dir| |'/'| | errfile );
xmlparser.setBaseDir(p, dir);
-- parse input file
xmlparser.parse(p, dir| |'/'| |inpfile);
-- get document
doc := xmlparser.getDocument(p);
-- get all elements
nl := xmldom.getElementsByTagName(doc, '*');
len := xmldom.getLength(nl);
dbms_output.put_line('Length='| |len);
-- loop through elements
for i in 0..len-1 loop
n := xmldom.item(nl, i);
node_name := xmldom.getNodeName(n);
-- get the text node associated with the element node
n := xmldom.getFirstChild(n);
if xmldom.getNodeType(n) = xmldom.TEXT_NODE then
node_value := xmldom.getNodeValue(n);
if node_name='lastname' then
dbms_output.put_line('The value you are looking for is -->:'| |node_value);
if node_value = 'GHANTASALA' then
xmldom.setNodeValue(n,'TEST2');
end if;
end if;
end if;
end loop;
new_node := xmldom.makeNode(doc);
xmldom.writeToFile(new_node, dir | |'/'| |'mod.xml');
end ;
nullThe encoding header is actually generated by
by the following piece of code in my pl/sql program .
new_node := xmldom.makeNode(doc);
xmldom.writeToFile(new_node, dir | |'/'| |'mod.xml');
Since this is a document created by the pl/sql parser, I assume there is some meaning to it !
Also why is it hanging ? PL/sql parser should tell me that it is not a valid string ! -
JSTL - Problem parsing XML file w/ XML schema declarations
I'm having trouble parsing an xml document that contains XML schema declarations in the root element. I've included 2 snippets, the XML files they're supposed to parse, and their output below. The first one works and the second one doesn't. Could someone please tell me why? I find it hard to believe that no one's run into this before.
I'm running Tomcat 5.5 and I'm using JSP 2.0, jakarta standard taglibs jars (1.1.2), jdk 1.5.0_04, and the Xalan 2.7.0 jars.
Here's the first snippet:
<c:import url="/WEB-INF/config/schools.xml" var="xml" />
<x:parse doc="${xml}" var="schoolList"/>
There are <x:out select="count($schoolList//school)"/> schools in the file:<br/>
<x:forEach select="$schoolList//school">
<x:out select="name"/><br/>
</x:forEach>it parses the following xml file:
<?xml version="1.0" encoding="UTF-8"?>
<schools>
<school id="34033">
<name>Tumwater Middle School</name>
<district>Tumwater</district>
<type>middle</type>
<active>false</active>
</school>
<school id="17001">
<name>Garfield High School</name>
<district>Seattle</district>
<type>high</type>
<active>true</active>
</school>
<school id="00023">
<name>Tigard High School</name>
<district>Tigard-Tualatin</district>
<type>high</type>
<active>true</active>
</school>
</schools>and it outputs:
There are 3 schools in the file:
Tumwater Middle School
Garfield High School
Tigard High School-----------------------------------------
The second snippet:
<c:import url="/WEB-INF/config/schools2.xml" var="xml2" />
<x:parse doc="${xml2}" var="schoolList2"/>
There are <x:out select="count($schoolList2//school)"/> schools in the file:<br/>
<x:forEach select="$schoolList2//school">
<x:out select="name"/><br/>
</x:forEach>parses this xml file (note the xml schema declarations):
<?xml version="1.0" encoding="UTF-8"?>
<schools xmlns="http://www.serenus.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.serenus.com schools.xsd">
<school id="34033">
<name>Tumwater Middle School</name>
<district>Tumwater</district>
<type>middle</type>
<active>false</active>
</school>
<school id="17001">
<name>Garfield High School</name>
<district>Seattle</district>
<type>high</type>
<active>true</active>
</school>
<school id="00023">
<name>Tigard High School</name>
<district>Tigard-Tualatin</district>
<type>high</type>
<active>true</active>
</school>
</schools>and its output is:
There are 0 schools in the file:That's it! No errors at all! I'm 100% certain the variable names, filenames, etc. are correct. I've looked everywhere for an existing answer to this problem, but I can't find one. Is this a known issue? Please help.
-BenHi Ben,
I got exactly the same problem and also could not find any solution.
Did you find a way out for this problem meanwhile?
Any help is welcome! -
Hi,
I have to produce and manipulate XML documents in PL/SQL. I have downloaded the XML Parser for PL/SQL from Oracle's web site.
Can anyone please:
1. Point me to some examples illustrating XML DOM manipulation with PL/SQL.
2. Any information about PL/SQL packages used for XML manipulation.
I am using Oracle 8i version 8.1.6
Thanks,
Rossen<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Rossen Petkov ([email protected]):
Hi,
I have to produce and manipulate XML documents in PL/SQL. I have downloaded the XML Parser for PL/SQL from Oracle's web site.
Can anyone please:
1. Point me to some examples illustrating XML DOM manipulation with PL/SQL.
2. Any information about PL/SQL packages used for XML manipulation.
I am using Oracle 8i version 8.1.6
Thanks,
Rossen<HR></BLOCKQUOTE>
Hope this will do something
set serveroutput on
create or replace procedure domsample(dir varchar2, inpfile varchar2, errfile varchar2) is
p xmlparser.parser;
doc xmldom.DOMDocument;
-- Print elements
procedure printElements( doc xmldom.DOMDocument) is
nl xmldom.DOMNodeList;
len number;
n xmldom.DOMNode;
t xmldom.DOMNode;
begin
-- get all elements.
nl := xmldom.getElementsByTagName(doc,'*');
len := xmldom.getLength(nl);
-- loop through elements.
for i in 0..len-1 loop
if xmldom.isnull(nl) = FALSE then
n := xmldom.item(nl,i);
IF xmldom.hasChildNodes(n) then
t := xmldom.getFirstChild(n);
dbms_output.put(xmldom.getNodeName(n) | |':');
dbms_output.put_line(xmldom.getNodeValue(t));
end if;
end if;
end loop;
dbms_output.put_line(' ');
end printElements;
-- print the attributes of each element in a document.
procedure printElementAttributes(doc xmldom.DOMDocument) is
nl xmldom.DOMNodelist;
len1 number;
len2 number;
n xmldom.DOMNode;
e xmldom.DOMElement;
nnm xmldom.DOMNamedNodeMap;
attrname varchar2(100);
attrval varchar2(100);
begin
-- get all Elements
nl := xmldom.getElementsByTagName(doc,'*');
len1 := xmldom.getLength(nl);
-- loop through elements.
for j in 0 .. len1 - 1 loop
n := xmldom.item(nl,j);
e := xmldom.makeElement(n);
dbms_output.put_line(xmldom.getTagName(e) | | ':');
-- get all attributes of element
nnm := xmldom.getAttributes(n);
if (xmldom.isNull(nnm) = FALSE) then
len2 := xmldom.getLength(nnm);
-- loop through attributes
for i in 0..len2 -1 loop
n := xmldom.item(nnm,i);
attrname := xmldom.getNodeName(n);
attrval := xmldom.getNodeValue(n);
dbms_output.put(' '| |attrname| |' = '| |attrval);
end loop;
dbms_output.put_line(' ');
end if;
end loop;
end printElementAttributes;
begin
-- new parser.
p := xmlparser.newParser;
-- set some charecterstics.
xmlparser.setValidationMode(p,FALSE);
xmlparser.setErrorLog(p, dir| |'/'| |errfile);
xmlparser.setBaseDir(p,dir);
-- parse input file
xmlparser.parse(p,dir| |'/'| |inpfile);
-- get document
doc := xmlparser.getDocument(p);
-- print document elements.
dbms_output.put_line('The elements are: ');
printElements(doc);
-- print document element attributes
dbms_output.put_line('The attributes of each element are: ');
printElementAttributes(doc);
-- deal with exception
exception
when xmldom.INDEX_SIZE_ERR then
raise_application_error(-20120,'Index Size Error');
when xmldom.DOMSTRING_SIZE_ERR then
raise_application_error(-20120,'String Size Error');
when xmldom.HIERARCHY_REQUEST_ERR then
raise_application_error(-20120,'Hierarchy Request Error');
when xmldom.WRONG_DOCUMENT_ERR then
raise_application_error(-20120,'Worng Document Error');
when xmldom.INVALID_CHARACTER_ERR then
raise_application_error(-20120,'Invalid Character Error');
when xmldom.NO_DATA_ALLOWED_ERR then
raise_application_error(-20120,'No Data Allowed Error ');
when xmldom.NO_MODIFICATION_ALLOWED_ERR then
raise_application_error(-20120,'No Modification Allowed Error');
when xmldom.NOT_FOUND_ERR then
raise_application_error(-20120,'Not Found Error');
when xmldom.NOT_SUPPORTED_ERR then
raise_application_error(-20120,'Not Supported Error');
when xmldom.INUSE_ATTRIBUTE_ERR then
raise_application_error(-20120,'In Use Attribute Error');
end domsample;
show errors;
Cheers
Srianth -
XML Parser for PLSQL and BIG5/UTF-8
I'm trying store data in traditional chinese submitted by IE5 (through oXMLHttpRequest.send() and javascript), I tried both 'encoding="BIG5"' and 'encoding="UTF-8"'.
It seems that the parser ignore all characters that are not ascii regardless of their encoding.
Any thoughts will be much appreciated
procedure UpdateXMLProc(xmlSrc varchar2)
is
p xmlparser.parser;
doc xmldom.DOMDocument;
nlist xmldom.DOMNodeList;
list_len pls_integer;
node1 xmldom.DOMNode;
node2 xmldom.DOMNode;
node3 xmldom.DOMNode;
begin
p := xmlparser.newParser;
xmlparser.parseBuffer(p, xmlSrc);
doc := xmlparser.getDocument(p);
nlist := xmldom.getElementsByTagName(doc, 'ROW');
list_len := xmldom.getLength(nlist);
-- loop through elements
for j in 0..list_len-1 loop
node1 := xmldom.item(nlist, j);
-- get primary key values
node2 := xmldom.getFirstChild(node1);
loop
-- get the text node and if not null get value
node3 := xmldom.getFirstChild(node2);
if not xmldom.isNull(node3) then
-- THIS OUTPUT MAY ALTER CHARACTER IF IT'S NOT ASCII
htp.p(xmldom.getNodeValue(node3));
end if;
-- get next field
node2 := xmldom.getNextSibling(node2);
exit when (xmldom.isNull(node2));
end loop;
end loop;
-- THIS OUTPUT WILL BE IN THE SAME ENCODING AS THE ORIGINAL
htp.p(xmlSrc);
end;
nullI just ran the initjvm.sql,initdbj.sql and
initsqlj.sql.
Still getting the error.
Please help!!!!
Thanks
Jay
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Jay ([email protected]):
I have Oracle8i Release 8.1.5.0.0 - ProductionWith the Java option
PL/SQL Release 8.1.5.0.0 - Production version
runnig in sun sparc server.
While I am loading Oracle XML Parser for PLSQL(using plxmlparser_V1_0_1.tar.gz) have a problem. When I try to load the xmlparser.jar class and I get the
following messages:
initialization complete
Error while accessing MD5 table
ORA-00942: table or view does not exist
loading : org/w3c/dom/DOMImplementation
Error while loading org/w3c/dom/DOMImplementation
ORA-04068: existing state of packages has been discarded
ORA-04063: package body "TEST.LOADLOBS" has errors
ORA-06508: PL/SQL: could not find program unit being called
ORA-06512: at line 1
creating : org/w3c/dom/DOMImplementation
Error while creating class org/w3c/dom/DOMImplementation
ORA-00406: COMPATIBLE parameter needs to be 8.1.0.0.0 or greater
Error while accessing MD5 table
ORA-00942: table or view does not exist
loading : org/w3c/dom/html/HTMLDivElement
Error while loading org/w3c/dom/html/HTMLDivElement
ORA-04068: existing state of packages has been discarded
ORA-04063: package body "TEST.LOADLOBS" has errors
ORA-06508: PL/SQL: could not find program unit being called
and so on.
Could anyone please tell me if I need to do any pre-installation steps.
Thanks
Jay<HR></BLOCKQUOTE>
null -
Hi,
I'm using DOM parser to parse XML satement which is in CLOB column. Node names are displaying correct and data is not displayed..
basically i want to retrive empnuber and emp salary. Any suggestions please?
declare
p xmlparser.parser;
doc xmldom.DOMDocument;
nl xmldom.DOMNodeList;
len1 number;
len2 number;
n xmldom.DOMNode;
e xmldom.DOMElement;
nnm xmldom.DOMNamedNodeMap;
attrname varchar2(100);
attrval varchar2(100);
l_c_lob clob ;
l_v_var varchar2(32000) := '<?xml version="1.0" encoding="utf-8"?>
<EMPETAILS>
<EMP>
<NUM>7369</NUM>
<SAL>180</SAL>
</EMP>
<EMP>
<NUM>7369</NUM>
<SAL>180</SAL>
</EMP>
<EMP>
<NUM>7369</NUM>
<SAL>180</SAL>
</EMP>
</EMPDETAILS>';
begin
dbms_lob.createtemporary(l_c_lob,TRUE);
dbms_lob.OPEN(l_c_lob,dbms_lob.lob_readwrite);
DBMS_LOB.WRITE (l_c_lob, LENGTH (l_v_var), 1,l_v_var);
-- new parser
p := xmlparser.newParser;
xmlparser.setValidationMode(p, FALSE);
xmlparser.parseClob(p,l_c_lob);
doc := xmlparser.getDocument(p);
nl := xmldom.getElementsByTagName(doc, '*');
len1 := xmldom.getLength(nl);
-- loop through elements
for j in 0..len1-1 loop
n := xmldom.item(nl, j);
e := xmldom.makeElement(n);
dbms_output.put_line(xmldom.getTagName(e) || ':');
-- get all attributes of element
nnm := xmldom.getAttributes(n);
if (xmldom.isNull(nnm) = FALSE) then
len2 := xmldom.getLength(nnm);
-- loop through attributes
for i in 0..len2-1 loop
n := xmldom.item(nnm, i);
attrname := xmldom.getNodeName(n);
attrval := xmldom.getNodeValue(n);
dbms_output.put(' ' || attrname || ' = ' || attrval);
end loop;
dbms_output.put_line('');
end if;
end loop;
EXCEPTION
when OTHERS then
RAISE;
end;
Thanks,
kannanbasically i want to retrive empnuber and emp salary. Any suggestions please?ORA-19202: Error occurred in XML processing
LPX-00225: end-element tag "EMPDETAILS" does not match start-element tag "EMPETAILS"
I guess this was justa typo when posting the XML. If I change that, then we can do the same logic in SQL using an XPATH expression.
example
with xtab as (select xmltype('<?xml version="1.0" encoding="utf-8"?>
<EMPDETAILS>
<EMP>
<NUM>7369</NUM>
<SAL>181</SAL>
</EMP>
<EMP>
<NUM>7370</NUM>
<SAL>182</SAL>
</EMP>
<EMP>
<NUM>7371</NUM>
<SAL>183</SAL>
</EMP>
</EMPDETAILS>') xml from dual)
select column_value emprow,
to_number(extractvalue(column_value,'/EMP/NUM')) emp_no,
to_number(extractvalue(column_value,'/EMP/SAL')) emp_sal
from xtab, table(xmlsequence(extract(xml,'//EMP')));
EMPROW EMP_NO EMP_SAL
<EMP><NUM>7369</NUM><SAL>181</SAL></EMP> 7369 181
<EMP><NUM>7370</NUM><SAL>182</SAL></EMP> 7370 182
<EMP><NUM>7371</NUM><SAL>183</SAL></EMP> 7371 183Edited by: Sven W. on Sep 3, 2010 3:37 PM - changed data values to see diferent entries -
Error in xml parse procedure :
hi,
I am trying to read an xml file and insert data into a database table.
When I compile the code I get the following warnings :
PL/SQL: Item ignored
PLS-00201: identifier 'XMLPARSER.PARSER' must be declared
PL/SQL: Item ignored
PLS-00201: identifier 'XMLDOM.DOMDOCUMENT' must be declared
PL/SQL: Item ignored
PLS-00201: identifier 'DBMS_XMLDOM.DOMELEMENT' must be declar
PL/SQL: Item ignored
PLS-00201: identifier 'XMLDOM.DOMDOCUMENT' must be declared
PL/SQL: Statement ignored
I have a local 10g se data base installed on my system.
The code I am using is mentioned below.
I checked the database and the package xmlparser does not exist. Can someone please help me on this..
Regards,
Siddharth
create or replace procedure domsample3(dir varchar2, inpfile varchar2)
is
p xmlparser.parser;
doc xmldom.DOMDocument;
docelem dbms_xmldoM.DOMElement;
procedure printelements(doc xmldom.DOMDocument) is
nl1 xmldom.DOMNodeList;
nl2 xmldom.DOMNodeList;
nl3 xmldom.DOMNodeList;
nl4 xmldom.DOMNodeList;
len1 number;
len2 number;
len3 number;
len4 number;
n1 xmldom.DOMNode;
n2 xmldom.DOMNode;
n3 xmldom.DOMNode;
n4 xmldom.DOMNode;
nnm xmldom.DOMNamedNodeMap;
attrname varchar2(1000);
attrval varchar2(1000);
account varchar2(100);
opptyname varchar2(100);
opptyid varchar2(100);
begin
nl1 := xmldom.getElementsByTagName(doc,'Opportunity');
nl2 := xmldom.getElementsByTagName(doc,'Account');
nl3 := xmldom.getElementsByTagName(doc,'Name');
nl4 := xmldom.getElementsByTagName(doc,'OpptyId');
len1 := xmldom.getLength(nl1);
len2 := xmldom.getLength(nl2);
len3 := xmldom.getLength(nl3);
len4 := xmldom.getLength(nl4);
for i in 0..len1-1
loop
n1 := xmldoc.item(nl1,i);
n2 := xmldoc.item(nl2,i);
n3 := xmldoc.item(nl3,i);
n4 := xmldoc.item(nl4,i);
dbms_output.put(xmldoc.getNodeName(n2));
dbms_output.put(xmldoc.getNodeName(n3));
dbms_output.put(xmldoc.getNodeName(n4));
n2 := xmldom.getFirstChild(n2);
n3 := xmldom.getFirstChild(n3);
n4 := xmldom.getFirstChild(n4);
account := xmldom.getNodeValue(n2);
opptyname := xmldom.getNodeValue(n3);
opptyid := xmldom.getNodeValue(n4);
insert into synergyOpptyVals values (accountid, opptyname, opptyid);
end loop;
end printelements;
begin
p := xmlParser.newParser;
xmlparser.setValidationMode(p,FALSE);
xmlparser.setBaseDir(p,dir);
xmlparser.parse(p,dir || '/' || inpfile);
doc := xmlparser.getDocument(p);
dbms_output('The elements are: ');
printElements(doc);
end;
/Hi,
i found the problem :-)
I used the function apex_web_service.parse_xml to parse the SOAP response. The return datatype of this function is VARCHAR2. Therefore i get the error when the return value overflows.
Now i use the function apex_web_service.parse_xml_clob and it works fine.
Regards,
Martin -
How to parse an XML document with oracle8i
Has anyone a good link or an example how to decode and store an XML document into an oracle8i database.
I' ve found only good things for oracle9i.
Thank you
RogerHere is an example of parsing xml taken fro Oracle8i 8.1.7 xdk.
This one uses external OS files to pase, but could be easily converted to
use CLOB or VARCHAR2 string for parsing XML documents.
IF you wanted to use CLOB to store and manipulate xml documents you can use XMLParser and XMLDom
packages along with the DBMS_LOB package to do that.
-- This file demonstates a simple use of the parser and DOM API.
-- The XML file that is given to the application is parsed and the
-- elements and attributes in the document are printed.
-- The use of setting the parser options is demonstrated.
set serveroutput on;
create or replace procedure domsample(dir varchar2, inpfile varchar2,
errfile varchar2) is
p xmlparser.parser;
doc xmldom.DOMDocument;
-- prints elements in a document
procedure printElements(doc xmldom.DOMDocument) is
nl xmldom.DOMNodeList;
len number;
n xmldom.DOMNode;
begin
-- get all elements
nl := xmldom.getElementsByTagName(doc, '*');
len := xmldom.getLength(nl);
-- loop through elements
for i in 0..len-1 loop
n := xmldom.item(nl, i);
dbms_output.put(xmldom.getNodeName(n) || ' ');
end loop;
dbms_output.put_line('');
end printElements;
-- prints the attributes of each element in a document
procedure printElementAttributes(doc xmldom.DOMDocument) is
nl xmldom.DOMNodeList;
len1 number;
len2 number;
n xmldom.DOMNode;
e xmldom.DOMElement;
nnm xmldom.DOMNamedNodeMap;
attrname varchar2(100);
attrval varchar2(100);
begin
-- get all elements
nl := xmldom.getElementsByTagName(doc, '*');
len1 := xmldom.getLength(nl);
-- loop through elements
for j in 0..len1-1 loop
n := xmldom.item(nl, j);
e := xmldom.makeElement(n);
dbms_output.put_line(xmldom.getTagName(e) || ':');
-- get all attributes of element
nnm := xmldom.getAttributes(n);
if (xmldom.isNull(nnm) = FALSE) then
len2 := xmldom.getLength(nnm);
-- loop through attributes
for i in 0..len2-1 loop
n := xmldom.item(nnm, i);
attrname := xmldom.getNodeName(n);
attrval := xmldom.getNodeValue(n);
dbms_output.put(' ' || attrname || ' = ' || attrval);
end loop;
dbms_output.put_line('');
end if;
end loop;
end printElementAttributes;
begin
-- new parser
p := xmlparser.newParser;
-- set some characteristics
xmlparser.setValidationMode(p, FALSE);
xmlparser.setErrorLog(p, dir || '/' || errfile);
xmlparser.setBaseDir(p, dir);
-- parse input file
xmlparser.parse(p, dir || '/' || inpfile);
-- get document
doc := 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 xmldom.INDEX_SIZE_ERR then
raise_application_error(-20120, 'Index Size error');
when xmldom.DOMSTRING_SIZE_ERR then
raise_application_error(-20120, 'String Size error');
when xmldom.HIERARCHY_REQUEST_ERR then
raise_application_error(-20120, 'Hierarchy request error');
when xmldom.WRONG_DOCUMENT_ERR then
raise_application_error(-20120, 'Wrong doc error');
when xmldom.INVALID_CHARACTER_ERR then
raise_application_error(-20120, 'Invalid Char error');
when xmldom.NO_DATA_ALLOWED_ERR then
raise_application_error(-20120, 'Nod data allowed error');
when xmldom.NO_MODIFICATION_ALLOWED_ERR then
raise_application_error(-20120, 'No mod allowed error');
when xmldom.NOT_FOUND_ERR then
raise_application_error(-20120, 'Not found error');
when xmldom.NOT_SUPPORTED_ERR then
raise_application_error(-20120, 'Not supported error');
when xmldom.INUSE_ATTRIBUTE_ERR then
raise_application_error(-20120, 'In use attr error');
end domsample;
show errors; -
I got following error while parsing clob :
ORA-20100: Error occurred while parsing: ORA-00942: table or view does not exist
ORA-06512: at "SYSTEM.XMLPARSER", line 22
ORA-06512: at "SYSTEM.XMLPARSER", line 98
Any Ideas ? What Table or View it is looking for ?Code :
DECLARE
doctoparse clob;
p Xmlparser.Parser;
doc Xmldom.DOMDocument;
nl Xmldom.DOMNodeList;
len NUMBER;
len2 NUMBER;
n Xmldom.DOMNode;
m Xmldom.DOMNode;
e Xmldom.DOMElement;
nnm Xmldom.domNamedNodeMap;
attrname VARCHAR2(100);
attrval VARCHAR2(100);
BEGIN
SELECT detaildata
INTO doctoparse
FROM USERDATA
WHERE userid = 50650;
p := Xmlparser.newParser;
Xmlparser.setValidationMode(p, FALSE);
Xmlparser.parseclob(p, doctoparse);
doc := Xmlparser.getDocument(p);
Xmlparser.freeParser (p);
nl := Xmldom.getElementsByTagName(doc, '*');
len := Xmldom.getLength(nl);
dbms_output.put_line('LENGTH OF DOM = ' | | TO_CHAR(len));
FOR i IN 0..len-1 LOOP
n := Xmldom.item(nl, i);
e := Xmldom.makeElement(n);
dbms_output.put_line(Xmldom.getTagName(e) | | ':' );
m := Xmldom.getFirstChild(n);
dbms_output.put(Xmldom.getNodeValue(m));
m := xmldom.getparentnode(n);
e := xmldom.makeelement(m);
dbms_output.put_line('Parent = ' | | Xmldom.getTagName(e) | | CHR(13)) ;
nnm := Xmldom.getAttributes(n);
len2 := Xmldom.getlength(nnm);
FOR j IN 0 ..len2 - 1 LOOP
m := Xmldom.item(nnm, j);
attrname := Xmldom.getNodeName(m);
attrval := Xmldom.getNodeValue(m);
dbms_output.put(' ' | | attrname | | ' = ' | | attrval);
END LOOP;
dbms_output.put_line('');
END LOOP;
xmldom.freedocument(doc);
END;
Data in CLOB :
<Data><Country>nklmdnl</Country><Fax>6788267882</Fax><City>sdfsdf</City><WorkPhone>6788267882</WorkPhone><State>nn</S tate><Zip>12343</Zip></Data>
Thanks, -
Need help on processing XML doc using Java store procedure
I am currently working on project to read, parse XML document and store data in XML document into database columns. I use JAVA API-OracleXMLSave in my java store procedure to do it, which use URL of XML doc to read, parse doc and store the data to database columns. My java store procedure works fine when XML doc is saved in server, but got "ORA-29532: Java call terminated by uncaught Java exception:
oracle.xml.sql.OracleXMLSQLException: No such file or directory" if XML doc is in client's PC instead of in server. I think the problem comes from the URL that created using OracleXMLSave
--createURL(fileName) based on the filename. what will be the filename if XML document located in Client PC like C:\myprojects\xmldoc.xml?
Thank you in advance if anyone can give some hints.I am currently working on project to read, parse XML document and store data in XML document into database columns. I use JAVA API-OracleXMLSave in my java store procedure to do it, which use URL of XML doc to read, parse doc and store the data to database columns. My java store procedure works fine when XML doc is saved in server, but got "ORA-29532: Java call terminated by uncaught Java exception:
oracle.xml.sql.OracleXMLSQLException: No such file or directory" if XML doc is in client's PC instead of in server. I think the problem comes from the URL that created using OracleXMLSave
--createURL(fileName) based on the filename. what will be the filename if XML document located in Client PC like C:\myprojects\xmldoc.xml?
Thank you in advance if anyone can give some hints. -
Adding external DOCTYPE causes "UnknownHostException" in x:parse
Hi,
I am using the following JSTL to parse and retrieve data from an xml file:
<c:import url="starfleet.xml" var="sf"/>
<x:parse doc="${sf}" varDom="dom"/>This works great but I am needing to add a DOCTYPE to the XML document:
<!DOCTYPE starship SYSTEM "starfleet.dtd" >As soon as that line is added I get the following error message on the JSP page:
org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: java.net.UnknownHostException: starfleet.dtdHowever placing the DOCTYPE internally brings up no problems e.g.
<!DOCTYPE starship [
]>
Any ideas why adding an external doctype is causing an "UnknownHostException"?
Thanks
Edited by: 4fingers on Jan 7, 2010 10:09 PMHi Dev,
When you create an external dimension, whether by creating it directly in an XML file or by transforming it from a source file, the dimension must conform to Endeca’s external_dimensions.dtd file before you import it into your project. The dtd file can be found here: $ENDECA_ROOT/conf/dtd. Also make sure to declare the dtd file in your XML:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE external_dimensions SYSTEM "external_dimensions.dtd">
HTH,
Pankaj. -
Hi All,
I am trying to a parse an XML File whose contents are given below:
<?xml version="1.0"?>
<inquiryresult sessionname="TheDataEnquiry" code="0" subcode="0">
<indexqueryresult code="0" subcode="0" queryname="AISClient range query">
<item objectname="Ncompass_SVS" mediastatus="m">
<rfield name="Amount" value="79427"/>
<rfield name="PostingDate" value="20030708"/>
<rfield name="Account" value="79427"/>
<rfield name="DRN" value="79427"/>
</item>
</indexqueryresult>
</inquiryresult>
In the above code i have to retrieve the "name" and "value" attributes of <rfield/> tag in each <item/>element.
The PL/SQL Procedure i used for data extraction is:
CREATE OR REPLACE PROCEDURE ParseXMLFile(xmlfile varchar2)
IS
p xmlparser.parser;
doc xmldom.DOMDocument;
nl2 xmldom.DOMNodeList;
nl3 xmldom.DOMNodeList;
n3 xmldom.DOMNode;
n4 xmldom.DOMNode;
e xmldom.DOMElement;
len2 number;
len3 number;
attrname varchar2(100);
attrval varchar2(100);
BEGIN
-- new parser
p := xmlparser.newParser;
-- parse input file
xmlparser.parse(p, xmlfile);
-- get document
doc := xmlparser.getDocument(p);
-- Free resources associated with the Parser as now it is no longer needed.
xmlparser.freeParser(p);
nl2 := xmldom.getElementsByTagName(doc, 'item');
len2 := xmldom.getLength(nl2);
-- loop through elements of item
FOR k IN 0..len2-1 LOOP
n3 := xmldom.item(nl2, k);
nl3 := xmldom.getElementsByTagName(xmldom.makeElement(n3), 'rfield');
len3 := xmldom.getLength(nl3);
-- loop through elements of rfield
FOR l IN 0..len3-1 LOOP
n4 := xmldom.item(nl3, l);
attrname := xslprocessor.valueOf(n4, '@name');
attrval := xslprocessor.valueOf(n4, '@value');
END LOOP;
END LOOP;
END;
But as soon I Parse an XML File greater than 10 MB, it takes a lot of time and gives me the java out of memory error.
Please advise me whether the above method I use to extract data from the XML file is efficient or not.
Thank You,
SUNIL BABUHi,
When compared with SAX parsers, DOM parsers are a bit slow. They are best suited for small sized XML documents, but still going ahead with it, I have a suggestion that might improve the performance if the time taken for parsing the document into a DOM is very less when compared with the time taken for getting the values by looping thro' the DOM nodes.
Instead of finding the item nodes and then the rfield nodes you may directly check for them using the XPATH syntax like as follows
-- Getting a list of the RFIELD nodes in the document using the XPATH syntax.
v_nl := sys.xslprocessor.selectNodes(sys.xmldom.makeNode(v_doc),'/ITEM/RFIELD');
that should help you in avoiding lot many loops there by decreasing the time taken.
HTH
Elango. -
Pb with tag x:parse... JSTL
Hello,
I am begining in JSTL, I went to parse documents xml with the tags JSTL, but it doesn't work ...
I have a version of tomcat 5.0.25 and JDK 1.4.2
my Pb is as follows: that one I use the tags jstl for parser xml, according to the code below: essai.jsp
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/xml" prefix="x" %>
<c:import url="essai.xml" var="xml" />
<HTML>
<BODY>
<x:parse doc="${xml}" var="test" scope="application" />
</BODY>
</HTML>
in the execution, I have the following error: "the attribute "doc". is incorrect for the tag parse according to the TLD indicated"
the same error when I change the attribute "doc" by "xml":
<x:parse xml="${xml}" var="test" scope="application" />
thank you for your help.There is no attribute "doc" for <x:parse> in JSTL. The correct attribute name is "xml".
If you still get the error after you make the change, try restarting the servlet/JSP engine again. Perhaps it's hanging onto a cached version of the page.
Maybe you are looking for
-
ITunes reports Shuffle with 40GB - Help
I am at a complete loss on this one. After upgrading to iTunes 7.1, my working Shuffle (1st gen) has gone south. iTunes reports it has 30.11GB in use with a capacity of 39.15GB. But this is only a 512MB Shuffle. I have tried everything I can think of
-
Assume an employee gets paid 1,500 for August. Now payroll comes to know that his salary is actually 2,000 and not 1,500. The following are the steps required to be performed. 1. Define a new element which can be used to pay the Retro amount 2. Make
-
Document availability after deletion from R3 System
Hello Experts, We used to schedule datasource 0FI_AR_4 daily overnight. So in each delta there can be some new documents or update in available documents. In this scheduling, is this possible Document alr
-
Importing flash as3 animation: stop commands are ignored in Captivate
I have created a Flash animation in Flash CS5 which has some interactive buttons to go to frames and then stop. The problem is Captivate seems to ignore the stop commands. When I preview in Flash it works fine, when I preview in Captivate it just kee
-
How do i save a frame to a image file?
im trying to save a frame from Final Cut Pro 5 to my hard disk to save and edit with an editor such as Photoshop. how do i save it. what menu options do i use?