Category: SQL*Net, Protocol Server

December 7

Michael McLaughlin had written last week some nice small blog posts on XML DB. I couldn’t resist to see if I could make this one easier… 😉

The package DBMS_EPG is sole based on the xdbconfig.xml file, which is the configuration file for the XML DB Protocol Server, which is not, by the way, an Apache Server configured inside the database, but a custom build protocol server hook-in into the Oracle listener, that passes its data to the Shared Server SQL*Net Architecture.

So I made some attempts on my 11gR2 database, without using the nowadays “extract” deprecated functions… After fiddling around with the XMLTABLE function, using DBMS_XDB.CFG_GET() to get the content of the xdbconfig.xml XML document (its result is an xmltype datatype), the following simplified code that results the DAD’s in a varchar2(15) list.

SQL> SELECT u.dad as "PL/SQL DAD List"
  2  FROM   XMLTable(XMLNAMESPACES (
  3                                  default 'http://xmlns.oracle.com/xdb/xdbconfig.xsd'
  4                                ),
  5                  '//servlet-list/*[servlet-language="PL/SQL"]'
  6                  PASSING DBMS_XDB.CFG_GET()
  7                  COLUMNS DAD varchar2(15) PATH '/servlet/servlet-name/text()'
  8                 ) u
  9  ;

PL/SQL DAD List
---------------
APEX

1 row selected.

SQL>  EXECUTE dbms_epg.create_dad('MARCO','/XFiles/*');

PL/SQL procedure successfully completed.

SQL> SELECT u.dad as "PL/SQL DAD List"
  2  FROM   XMLTable(XMLNAMESPACES (
  3                                  default 'http://xmlns.oracle.com/xdb/xdbconfig.xsd'
  4                                ),
  5                  '//servlet-list/*[servlet-language="PL/SQL"]'
  6                  PASSING DBMS_XDB.CFG_GET()
  7                  COLUMNS DAD varchar2(15) PATH '/servlet/servlet-name/text()'
  8                 ) u
  9  ;

PL/SQL DAD List
---------------
APEX
MARCO

2 rows selected.
July 14
June 17

I wondered, for a long time, if it were possible to shred automatically XML documents, via Binary XML XMLType storage, the same way as you are able with Object Relational XMLType storage since the Oracle 9.2.0.3.0 version (the first officially supported XMLDB database version).

Based on “standard” object relational storage you need the following requirements and/or take the following steps:

  • Annotate an XML Schema with the XDB namespace and xdb:annotations to your liking
  • Register this XML Schema in the XDB Repository
  • During registration automatically generate the needed types and tables (based on your xdb:annotations)
  • An XML document(s) that validates properly, is valid, against your registered XML Schema.

If done properly, drag & dropping your XML documents via for example WebDAV via the enable protocol server, will cause the XDB functionality to check and validate the given XML documents against the registered XML Schema and insert the content automatically in the generated table(s). This mechanism also works via the FTP protocol functionality off the XDB Protocol Server.

I never got it really to work, at least the mechanism was fuzzy to me. Sometimes it did work as expected, sometimes it didn’t. What I didn’t realize, is that I most of the time use XML documents with multiple namespace references. Until one of my students during an XMLDB training, hit a small bug (8473369), regarding using duplicate namespaces in the “wrong” order. XQuery statement don’t have the problem, XML/SQL does, so I reported it via an Service Request. This made me wonder… Would I have the same issue with the namespace references in the registered XML Schema and the XML document. I still have to check the W3C Official XML Namespace Recommendation regarding this issue though…