This discussion is archived
3 Replies Latest reply: Dec 19, 2012 7:01 AM by Jason_(A_Non) RSS

Regarding schema validation and dbms_xmlparser, dbms_xmldom

vikram(959352) Newbie
Currently Being Moderated
Hi All,

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
+(XMLSEQUENCE+
+(XMLTYPE+
+('<?xml version="1.0"?>+
+<employee>+
+<details>+
+<emp_id>1001</emp_id>+
+</details>+
+</employee>'+
+).EXTRACT ('/employee/details')+
+)+
+) t;+

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?

Thanks
Vikram
  • 1. Re: Regarding schema validation and dbms_xmlparser, dbms_xmldom
    Jason_(A_Non) Expert
    Currently Being Moderated
    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 9.2.0.3. 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.
  • 2. Re: Regarding schema validation and dbms_xmlparser, dbms_xmldom
    vikram(959352) Newbie
    Currently Being Moderated
    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
  • 3. Re: Regarding schema validation and dbms_xmlparser, dbms_xmldom
    Jason_(A_Non) Expert
    Currently Being Moderated
    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 11.1.0.6 and default for XMLType columns in 11.2.0.2) and that data is queried/accessed.

    You can find some information on it here
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28369/xdb01int.htm
    (Search for "streaming")
    and here as well
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28369/xdb_xquery.htm#CBAIIEFG

    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
    {message:id=10737315}

    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.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points