ACE Director Alum Daniel Morgan, founder of Morgan's Library, is scheduling
complimentary technical Workshops on Database Security for the first 30
Oracle Database customers located anywhere in North America, EMEA, LATAM, or
APAC that send an email to
asra_us@oracle.com. Request a Workshop for
your organization today.
Purpose
Parses (accesses) the contents of data stored in XML documents. Default parser behavior changes must be made prior to calling procedure in this package.
This is a no-op procedure added strictly for compatibility with XDK
dbms_xmlparser.retainCDataSection(
p IN dbms_xmlparser.parser,
flag IN BOOLEAN);
In violation to the W3C spec, XDK allows a CDATA section to be parsed.
If the appl does not want this behavior then a value of FALSE is passed to this procedure. Since XDB will never parse CDATA sections, calling this procedure has no effect.
-- parse the document
dbms_xmlparser.parseClob(pVar, clobVar);
-- create a new DOM document
DOMDoc := dbms_xmlparser.getDocument(pVar);
-- free resources associated with the CLOB and Parser
dbms_lob.freeTemporary(clobVar);
dbms_xmlparser.freeParser(pVar);
-- generate a list of EMP nodes in the DOM document
DomNL := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(DOMDoc), '/EMPLOYEES/EMP');
-- load into an array for insert from the DOM document
FOR cur_emp IN 0 .. dbms_xmldom.getLength(DomNL) - 1 LOOP
DomN := dbms_xmldom.item(DomNL, cur_emp);
-- increase the array size by 1 for each loop
emptab_t.extend;
-- use XPATH syntax to assign values to the collection elements
dbms_xslprocessor.valueOf(DomN, 'EMPNO/text()', emptab_t(emptab_t.last).empno);
dbms_xslprocessor.valueOf(DomN, 'ENAME/text()', emptab_t(emptab_t.last).ename);
dbms_xslprocessor.valueOf(DomN, 'JOB/text()', emptab_t(emptab_t.last).job);
dbms_xslprocessor.valueOf(DomN, 'MGR/text()', emptab_t(emptab_t.last).mgr);
dbms_xslprocessor.valueOf(DomN, 'HIREDATE/text()', emptab_t(emptab_t.last).hiredate);
dbms_xslprocessor.valueOf(DomN, 'SAL/text()', emptab_t(emptab_t.last).sal);
dbms_xslprocessor.valueOf(DomN, 'COMM/text()', emptab_t(emptab_t.last).comm);
dbms_xslprocessor.valueOf(DomN, 'DEPTNO/text()', emptab_t(emptab_t.last).deptno);
-- optionally access an element for validation
dbms_output.put_line(emptab_t(emptab_t.COUNT).empno);
END LOOP;
-- perform an array insert of the XML into the relational table
FORALL i IN emptab_t.FIRST .. emptab_t.LAST
INSERT INTO emp VALUES emptab_t(i);
COMMIT;
-- release resources
dbms_xmldom.freeDocument(DOMDoc);
EXCEPTION
WHEN OTHERS THEN
dbms_lob.freetemporary(clobVar);
dbms_xmlparser.freeParser(pVar);
dbms_xmldom.freeDocument(DOMDoc);
END;
/