Recently I came across one scenario, where I need to register XSD and validate all incoming xml agaist registered XSD and then access its contents and process them as per business needs.
To accomplish this:
1. Simply I have registered XSD using registerschema+ .
2. To validate xmls, used schemaValidate+ .
3. Once this is done then to fetch value from xml, I used below statement: SELECT EXTRACTVALUE (COLUMN_VALUE, '/details/emp_id') "Employee_ID" FROM TABLE
This works fine.
But I was browsing the same requirement over forum, got solutions related to DBMS_XMLPARSER and DBMS_XMLDOM.
I tried to go through its details but didnt get much idea on the same.
Can anyone please help me to understand about use of dbms_xmlparser and dbms_xmldom and about DOM.
In which scenario we need to use them?
DBMS_XMLPARSER and DBMS_XMLDOM are from at least the 8i days (back then called XMLParse and XMLDOM). XMLType and all the other features we now know did not start appearing until 220.127.116.11. DOM loads the entire XML document into memory before parsing and the newer features can avoid this by streaming the XML when parsing it. This prevents the entire XML content from being loaded into memory at once. This is the general direction Oracle has been going for some time now and so their performance/improvement efforts have been in those newer areas.
Depending upon your version, if it is >= 10.2, you would want to use XMLTable or XMLQuery to retrieve data from the XML.
So in other words, ignore the DBMS_XMLPARSER and DBMS_XMLDOM functionality for now and use the newer functionality Oracle provides.
Note: This is only the observation of an outsider as I do not work for Oracle nor speak for them.
Thanks for giving clear picture on the same with version details also.
----- DOM loads the entire XML document into memory before parsing and the newer features can avoid this by streaming the XML when parsing it+
Could you please explain this sentence +"specially streaming the xml means"+ as this will help us to get more idea on this.
Edited by: vikram (959352) on 18-Dec-2012 21:46
Where I was thinking with that sentence is the "streaming evaluation" that Oracle now offers. This option is available when XML is stored in an XMLType column of SECUREFILE BINARY format (introduced in 18.104.22.168 and default for XMLType columns in 22.214.171.124) and that data is queried/accessed.
You can find some information on it here
(Search for "streaming")
and here as well
Streaming is basically reading the data as Oracle scans past it since it knows, based on the binary storage format, what the XML looks like, so it does not need to create the whole document to find the sections the XPath/XQuery specifies. You can see that a SQL statement is using streaming evaluation when "XPATH EVALUATION" shows up in the explain plan as shown by
This option is only available when the XML is stored in the DB in the correct format. If the XML is stored in a PL/SQL variable, Oracle cannot use streaming evaluation on it.