Oracle XML problem - difference in 9i and 10g



I work primarily on a database which manages XML documents. I've been
looking into migrating some of our client applciation XML code to
Oracle, but seem to be getting worrying results between Oracle 9i and
10g.

the following anonymous procedure should show why

set serveroutput on


DECLARE
--v_xml SYS.XMLTYPE;
v_doc CLOB;

v_parser DBMS_XMLPARSER.parser;

v_xmldoc DBMS_XMLDOM.DOMDocument;

v_xmlNodeList DBMS_XMLDOM.DOMNodeList;

v_xmlpi DBMS_XMLDOM.DOMProcessingInstruction;

i integer;

data varchar2(2000);
BEGIN


-- XMLTYPE created from a CLOB
v_doc := '<?xml version="1.0"?><TABLE_NAME><?lbsref
123?><Warning>MY_TABLE</Warning></TABLE_NAME>';

v_parser := DBMS_XMLPARSER.newParser;

DBMS_XMLPARSER.setValidationMode(v_parser, FALSE);
DBMS_XMLPARSER.setPreserveWhiteSpace(v_parser, TRUE);
DBMS_XMLPARSER.parseClob(v_parser, v_doc);

v_xmldoc := DBMS_XMLPARSER.getDocument(v_parser);

v_xmlNodeList:= DBMS_XMLDOM.getElementsByTagName(v_xmldoc,'*');

i := 0;

while (i<DBMS_XMLDOM.getLength(v_xmlNodeList)) loop

if
DBMS_XMLDOM.getNodeType(DBMS_XMLDOM.item(v_xmlNodeList,i))=DBMS_XMLDOM.PROCESSING_INSTRUCTION_NODE
then
v_xmlpi
:=DBMS_XMLDOM.makeProcessingInstruction(DBMS_XMLDOM.item(v_xmlNodeList,i));

data:=DBMS_XMLDOM.getData(v_xmlpi);
end if;
i:=i+1;
DBMS_OUTPUT.PUT_LINE(TO_CHAR(i)||' Nodes');
end loop;

--DBMS_XMLDOM.writeToBuffer(v_xmldoc,data);
DBMS_OUTPUT.PUT_LINE(data);

END;
/

If you run that on a 9i database you get the following output

1 Nodes
2 Nodes
3 Nodes
4 Nodes
lbsref 123

in SQLPlus

on a 10g DB you get

1 Nodes
2 Nodes

It appears that the Processing instructions are no longer counted. Ive
tried this on Windows 9i, Linux 9i, Windows 10g and Linux 10g databases
and the results are consistant - which would lead me to belive that it
was an intentional change. If this is so, how would i go about
extracting all the PI's from the document if its not possible to use
the wildcard in getElementsByTagName()? I cant use the XMLTYPE as I
need to update the docuement and from what i can see thats not possible
unless i load into the dom using dbms_xmldom.

Any help would be extremly appreciated!

Neil

.



Relevant Pages

  • Re: XML in a Relational Database
    ... But i cannot use oracle because it is expensive, ... a cheap and light database. ... > Recent versions of major DBMS supports XML in a way you save each XML ... >> The focus of this application is the XML documents could be whatever. ...
    (microsoft.public.dotnet.xml)
  • Re: XML databases
    ... I've looked for XML databases, but most that I've looked at don't seem ... but the project is not big enough to warrant an Oracle ... So what are people using to store & query XML documents these days? ... you can use any database including a bunch of free database. ...
    (comp.lang.java.programmer)
  • Re: What so special about PostgreSQL and other RDBMS?
    ... That's exactly the link the licence agreement for the database points to when it ... comes to what wecan expect for paying support. ... > "Oracle may provide additional releases or versions of its programs ... If the requirements are volatile I'd do a long term contract detailing what ...
    (comp.lang.php)
  • A cool DBA job wanted
    ... 7, Oracle 6, Sybase, SQL Server ... Proposed proactive database monitoring through ... strategies to administer remote Oracle databases ... Trained installation and support personnel in basic ...
    (comp.databases.oracle.server)
  • Re: I want to add to myknowledge
    ... 7, Oracle 6, Sybase, SQL Server ... Oracle Database Administrator ... Trained installation and support personnel in basic ... Senior Oracle Database Administrator ...
    (comp.databases.oracle.server)