Good doc
http://saturn.uab.es/appdev.920/a96620/xdb05obj.htm
XMLType is Oracle's XML data type.
Single columns and entire tabes can be of type XMLType.
To insert, you have to use the XMLTYPE() function, like
INSERT INTO xmlcol VALUES (xmltype(''));
OR
INSERT INTO xmlcol VALUES (xmltype.createxml(''));
Sample extraction:
SELECT extractValue(p.purchase_order, '/PurchaseOrder/User')
FROM purchase_order_tagble p
WHERE existsNode(p.purchase_order, '/PurchaseOrder[CostCenter="S30"]) - 1;
SELECT tea.xt.extract('/rootel/midel.text()').getStringVal()
FROM t2 tea where...
Registering an XML Schema.
PL/SQL procedure
dbms_xmlschema.registerschema('http://id_refd_by_instance_docs.xsd', doc);
[There are 4 optional boolean args too:
FORCE (allow out-of-order additions), GENTYPES, GENTABLES, GENBENS.]
The reference URL is also coded as the targetNamespace inside the doc.
(Oracle also uses this path to generate its own path to save it to).
"doc" may be xdbURIType('/path/to/file.xsd').getClob() or a varchar value.
After the schema is registered, you link a TABLE to the schema like this.
XMLTYPE COLUMN colname XMLSCHEMA "http://id_refd_by_instance_docs.xsd"
element "Element 'name' in document";
OR (this makes more sense to me)
CREATE TABLE t1 OF XMLTYPE XMLSCHEMA "ref-url" ELEMENT "element";
I don't know how to link just a column to a schema. If I add a column
to the table created above, it completes successfully but the new column
never shows up.
Use "Global" schemas, because Locals are only visible to the owner.
GLOBAL SCHEMAS
Stored under /sys/schemas/PUBLIC/ + ref-url
(minus protocol but w/ hostname).
They say that there's a registerschema() arg to make a schema global,
but I don't see it.
TODO: See if using owner of sys for xmlschema makes it global, i.e.
create table t1 (id number, sys.xmltype xmlschema 'schema' element'emp');