marc meewis technology sales consultant (marcewis@oracle) oracle belgium
DESCRIPTION
Oracle XML DB Technical Overview. Marc Meewis Technology Sales Consultant ([email protected]) Oracle Belgium. Evolution of Oracle XML Support. 8 i. 9 i R1. 9 i R2. Basic XML Generation and Processing (mid-tier based) Developer Kits. DB-integrated XML Storage And Retrieval. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/1.jpg)
Marc MeewisMarc MeewisTechnology Sales ConsultantTechnology Sales Consultant([email protected])([email protected])
Oracle BelgiumOracle Belgium
Oracle XML DBOracle XML DBTechnical OverviewTechnical Overview
![Page 2: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/2.jpg)
Evolution of Oracle XML Support
8i 9i R1 9i R2
Basic XML Generation andProcessing (mid-tier based)Developer Kits
DB-integrated XML StorageAnd Retrieval
Native XML DB
![Page 3: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/3.jpg)
What is Oracle XML DB?
High Performance storage and retrieval technologie part of Oracle 9i R2 and +
W3C XML data model in Oracle Server Standard access methods for querying
and navigating XML
![Page 4: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/4.jpg)
Why XML in the Database
Enforce and leverage the XML data model– Loosely coupled, flexible applications– XML Schema, DOM
Enable richer semantics and better management for content-oriented applications
– Store as XML vs. Files or LOBs– Queryability, Integrity, etc.
Process XML close to data for high scalability and performance
– Generation, Transformation– Superior memory management for large XML
![Page 5: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/5.jpg)
Why XML in the Database (Contd.) Reduce maintenance costs of extra moving
parts– Eliminate separate ‘XML-processing’ layers
Keep applications standards-based– W3C, IETF, ANSI/ISO, J2EE– Eliminate proprietary file formats, message formats,
delimited columns
![Page 6: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/6.jpg)
Common XML Architectures
Enforce XML Schema
Manage Content & DataUniformly
Eliminate extra movingparts
Get better performance& scalability
Make DB applicationsStandards-based
![Page 7: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/7.jpg)
XML DB Architecture
HTTP FTP WebDAV
HTTP Client FTP Client
Content-oriented Access
Repository XMLTypeViews/Tables
WebDAV Client
Protocol Handlers
XML DBText Index Path Index Text Index B-Tree
Bitmap Index
![Page 8: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/8.jpg)
XML DB Architecture Data-oriented Access
Oracle Net
Application ClientsJAVA Client OCI Client
JDBC/OCI
XQuery XML Schema CacheXML/DOM Parser
Repository
SQL
XMLTypeViews/Tables
9i XML DBText Index Path Index Text Index B-TreeBitmap Index
![Page 9: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/9.jpg)
XML DB Architecture Data-oriented Access
Oracle Net
Application ClientsJAVA Client OCI Client
JDBC/OCI
XQuery XML Schema CacheXML/DOM Parser
Repository
SQL
XMLTypeViews/Tables
9i XML DBText Index Path Index Text Index B-TreeBitmap Index
Format Access
XML to Relational
XML OperatorsXML Views
XPath
XPath
Relational
Document
![Page 10: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/10.jpg)
XML DB Architecture Data-oriented Access
Oracle Net
Application ClientsJAVA Client OCI Client
JDBC/OCI
XQuery XML Schema CacheXML/DOM Parser
Repository
SQL
XMLTypeViews/Tables
9i XML DBText Index Path Index Text Index B-TreeBitmap Index
select extractValue(value(x),'/Movie/@Title') ,extractValue(value(x),'/Movie/@RunningTime')from xml_movies xwhere existsNode(value(x),'/Movie[@Rating="R" and @RunningTime>100]') > 0/
![Page 11: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/11.jpg)
XML DB Architecture Data-oriented Access
Oracle Net
Application ClientsJAVA Client OCI Client
JDBC/OCI
XQuery XML Schema CacheXML/DOM Parser
Repository
SQL
XMLTypeViews/Tables
9i XML DBText Index Path Index Text Index B-TreeBitmap Index
select path(1)from resource_view where under_path(res, '/demo/movie', 1) = 1/
![Page 12: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/12.jpg)
XML DB : Storage
XMLType
Storage Implementation
CLOB Object Relational
![Page 13: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/13.jpg)
XML DB : Storage
XMLType
Storage Implementation
CLOB Object Relational
Xpath : /
•Return contents from clob •Reassemble XML combining data structure and schema cache (tags are not stored in ds)
+ for full retrieval of XML document
![Page 14: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/14.jpg)
XML DB : Storage
XMLType
Storage Implementation
CLOB Native (=OR)
Xpath : /a/b[c=“2”]/d
•Read XML document from clob
•Parse Document (create DOM)
•Resolve xPath
•Return result
•Rewrite xPath to SQL
•Return Result
+ very fast for all partial manipulation, no DOM involved- resource consuming
![Page 15: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/15.jpg)
XML DB Native XML Storage
Object Relational TechnologyIntroduction
![Page 16: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/16.jpg)
Object - relational
Order (1) / Orderlines (M) : 2 relational tables
– Order(id, cust_id, po_no)– Orderlines (id, order_id, prod_id, qty)
select o.cust_id, l.prod_id, l.qty, l.price from orders o, orderlines lwhere l.order_id = o.idand l.qty > 20
![Page 17: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/17.jpg)
Object - relational
OR:– OrderlineType (UDT)
Prod_id integer Qty float Price float
– Order (Object relational table) Id number Cust_id number Po_no number Lines nested table of OrderlineType
![Page 18: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/18.jpg)
Object - relational
ID CUST_ID PO_NO LINES
Record in Orders table :
ID CUST_ID PO_NO LINES
![Page 19: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/19.jpg)
Object - relational
ID CUST_ID PO_NO
Record in Orders table :
ID CUST_ID PO_NO LINES
PROD_ID QTY PRICE
PROD_ID QTY PRICE
PROD_ID QTY PRICE
PROD_ID QTY PRICE
Collection
![Page 20: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/20.jpg)
Object - relational
ID CUST_ID PO_NO
select o.cust_id, l.prod_id, l.qty, l.price from orders o, table(o.lines) lwhere l.qty > 20
Record in Orders table :
ID CUST_ID PO_NO LINES
PROD_ID QTY PRICE
PROD_ID QTY PRICE
PROD_ID QTY PRICE
PROD_ID QTY PRICE
Collection
Implicit Join
![Page 21: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/21.jpg)
XML Schema Compilation Can Be Done Automatically, or Fully/Partially Assisted
Via Schema Annotation When Schema is Used, Tables of Types are Created
AttrAttrAttrAttr
SimpleTypeSimpleTypeSimpleTypeSimpleType
ComplexTypeComplexTypeComplexTypeComplexType
Complex TypeComplex Type
ComplexTypeComplexTypeComplexTypeComplexTypeComplexTypeComplexTypeComplexTypeComplexTypeComplexTypeComplexTypeComplexTypeComplexType
AttributeAttributeAttributeAttribute
AttributeAttributeAttributeAttribute
ObjectTypeObjectTypeObjectTypeObjectType
Oracle Object TypeOracle Object Type
ComplexTypeComplexTypeComplexTypeComplexTypeComplexTypeComplexTypeComplexTypeComplexTypeCollectionTypeCollectionTypeCollectionTypeCollectionType
![Page 22: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/22.jpg)
Oracle and XML : More info? OTN:
– XML Technology centerhttp://otn.oracle.com/tech/xml/index.html
– XML DBhttp://otn.oracle.com/tech/xml/xmldb/index.html
![Page 23: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/23.jpg)
Oracle XML DB
DEMOFor a complete overview of the features
![Page 24: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/24.jpg)
Oracle XML DB
Oracle & XMLOverview
XML Type XMLRepository
Summary
Data Content
![Page 25: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/25.jpg)
Oracle XML DB
Oracle & XMLOverview
XML Type XMLRepository
Summary
Data
![Page 26: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/26.jpg)
Oracle XML DB
XML Type (data management) XML Repository (content management)
![Page 27: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/27.jpg)
XML DB
XML Type
![Page 28: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/28.jpg)
XML Type
XML Type– Native datatype– methods
XML Type as column XML Type table
![Page 29: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/29.jpg)
XML Type
XML Type– Native datatype– methods
XML Type as column XML Type table
![Page 30: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/30.jpg)
XML Type– Native datatype– methods
XML Type as column XML Type table (XML table)
XML Type • createXML• extract• existsNode• isFragment • getClobVal• getStringVal• getNumberVal• transform• toObject• isSchemabased • getSchemaURL• getRootElement• getNameSpace• schemaValidate• isSchemaValidated
![Page 31: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/31.jpg)
XML Type
XML Type– Native datatype– methods
XML Type as column XML Type table
![Page 32: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/32.jpg)
XML Type
XML Type– Native datatype– methods
XML Type as column XML Type table
create table purchaseorder ( id integer ,data xmltype
)
insert into purchaseorder values ( 1,xmltype.createXML(‘<>… </>’)
)
![Page 33: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/33.jpg)
XML Type
XML Type– Native datatype– methods
XML Type as column XML Type table (XML table)
![Page 34: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/34.jpg)
XML Type
XML Type– Native datatype– methods
XML Type as column XML Type table (XML table)
create table purchaseorder of xmltype
insert into purchaseorder values (xmltype.createxml(‘<>…</>’)
)
![Page 35: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/35.jpg)
XML Type
XML Type– Native datatype– methods
XML Type as column XML Type table (XML table)
Creating XMLType Instances
Literal Docs or Fragments from String or CLOB– xmltype('<foo bar="3"/>')
From a File– xmltype(getDocument('AmericanBeauty.xml'))
From a URL or Stream– Using HTTPUriType and Methods on It
From Scratch Using DOM API– Via dbms_xmldom Package or Java API
![Page 36: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/36.jpg)
XML Type
xPath XML Schema XML consistency XML integrity XML indexing XML Updating Relational Views
![Page 37: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/37.jpg)
XML Type
xPath XML Schema XML consistency XML integrity XML indexing XML Updating Relational Views
• Full xPath support SQL
select count(*) from purchaseorder x
where existsNode(
value(x),'/PurchaseOrder[User="SMITH"]‘
) = 1;
Select extractValue(
value(x),'/PurchaseOrder/Reference‘
)
from purchaseorder x
where existsNode(
value(x),
'/PurchaseOrder/LineItems/
LineItem/Part[@Id="037429139523"]‘
) = 1;
![Page 38: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/38.jpg)
XML Type
xPath XML Schema XML consistency XML integrity XML indexing XML Updating Relational Views
• Full xPath support DB URI
http://…/oradb/schema/table/row/xpath
http://…/oradb/scott/emp/row[ename=“KING”]
http://…/oradb/scott/emp/row[ename=“KING”]?transform
<?xml version="1.0"?> <ROW> <EMPNO>7839</EMPNO> <ENAME>KING</ENAME> <JOB>PRESIDENT</JOB> <HIREDATE>17-NOV-81</HIREDATE> <SAL>5000</SAL> <DEPTNO>10</DEPTNO> </ROW>
![Page 39: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/39.jpg)
![Page 40: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/40.jpg)
XML Type
xPath XML Schema XML consistency XML integrity XML indexing XML Updating Relational Views
• Register XML schema
dbms_xmlschema.registeruri( 'http://www.oracle.com/xdb/orderSchema.xsd’,'/home/SCOTT/xsd/puchaseOrder.xsd' );
• Constrain XMLType to schemaCREATE TABLE xmlorder ( info XMLTYPE )XMLSCHEMA 'http://www.oracle.com/xdb/orderSchema.xsd‘ELEMENT 'PurchaseOrder‘/
![Page 41: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/41.jpg)
XML Type
xPath XML Schema XML consistency XML integrity XML indexing XML Updating Relational Views
• Storage– CLOB (White Space fidelity)– Object Relational (DOM fidelity)
(annotations)• XMLType : abstracts storage details
![Page 42: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/42.jpg)
![Page 43: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/43.jpg)
![Page 44: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/44.jpg)
![Page 45: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/45.jpg)
XML Type
xPath XML Schema XML consistency XML integrity XML indexing XML Updating Relational Views
• Use triggers for full or partial checkscreate or replace trigger PURCHASEORDERVALIDATIONbefore insert on PURCHASEORDER
If (:new.PODOCUMENT.existsnode('//LineItem') > 0) THEN raise MISSING_PARTNUMBER;
end if;
...
![Page 46: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/46.jpg)
XML Type
xPath XML Schema XML consistency XML integrity XML indexing XML Updating Relational Views
• Use FK for referential integrityalter table xdb_departments
add constraint IS_VALID_LOCATION
foreign key (xmldata."Location" ) references locations
/
<Department id="93" name="Labtest3">
<Location>Diegem</Location>
<Employees>
<Employee empno="310" name="Peter">
<Job>MANAGER</Job>
![Page 47: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/47.jpg)
XML Type
xPath XML Schema XML consistency XML integrity XML indexing XML Updating Relational Views
• Functional indexes xPath indexes
create unique index iPurchaseOrderReference on PurchaseOrder x (
extractValue(
value(x)
,'/PurchaseOrder/Reference‘
)
)
/
• Full text Search (Oracle Text)
![Page 48: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/48.jpg)
XML Type
xPath XML Schema XML consistency XML integrity XML indexing XML Updating Relational Views
• Partial update of XML data
update purchaseorder p set value(p) =
updateXml(
value(p)
,'/PurchaseOrder/User/text()‘
,'DRAKE‘
)where existsNode(
value(p), '/PurchaseOrder/Actions/Action[position()=1
and
User="VISHU"]‘
) = 1;
![Page 49: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/49.jpg)
XML Type
xPath XML Schema XML consistency XML integrity XML indexing XML Updating Relational Views
xml_movies = xmltype table : schema related = object relational storage
create or replace view movie_info asselect extractValue(value(x),'/Movie/@Title') as TITLE ,extractValue(value(x),'/Movie/@imdbCode') as IMDBCODE ,extractValue(value(x),'/Movie/@rating') as RATING ,extractValue(value(x),'/Movie/Review/@quotation') AS QUOTATIONfrom xml_movies x/
SQL> desc movie_info Name Null? Type ----------------------------------------- -------- ---------------------------- TITLE VARCHAR2(100) IMDBCODE NUMBER(38) RATING VARCHAR2(1) QUOTATION FLOAT(126)
![Page 50: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/50.jpg)
XML DB – XMLType
XSL-T XML Views (relational to XMLType) Memory Management (lazy loaded
virtual DOM) Schema cache Programming model
– Client side JDBC/OCI, Javabeans– Server side Java, PL/SQL
![Page 51: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/51.jpg)
Querying with XML as result
SQL/XML (SQLX group, www.sqlx.org)– Relational to XML
xQuery (W3C XML Query working group)– XML documents
![Page 52: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/52.jpg)
SQL/XML
SQL/XML compliant XMLAgg XMLConcat XMLElement XMLAttributes XMLForest
Oracle Extensions XMLSequence XMLTransform ExtractValue Extract
![Page 53: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/53.jpg)
SQL/XML
SELECT XMLElement("Department", XMLForest(deptno "DeptNo", d.dname "DeptName", d.loc
"Location")
,(SELECT XMLAGG(XMLElement("Employee",
XMLForest(e.empno "EmployeeId",
e.ename "Name",
e.job "Job",
e.mgr "Manager",
e.hiredate "Hiredate",
e.sal "Salary",
e.comm "Commission")))
FROM emp e
WHERE e.deptno = d.deptno))
FROM dept d;
![Page 54: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/54.jpg)
SQL/XML<Department> <DeptNo>10</DeptNo> <DeptName>ACCOUNTING</DeptName> <Location>NEW YORK</Location> <Employee> <EmployeeId>7782</EmployeeId> <Name>CLARK</Name> <Job>MANAGER</Job> <Manager>7839</Manager> <Hiredate>09-JUN-81</Hiredate> <Salary>2450</Salary> </Employee> <Employee> <EmployeeId>7839</EmployeeId> <Name>KING</Name> <Job>PRESIDENT</Job> <Hiredate>17-NOV-81</Hiredate> <Salary>5000</Salary> </Employee> <Employee> <EmployeeId>7934</EmployeeId> <Name>MILLER</Name> <Job>CLERK</Job> <Manager>7782</Manager> <Hiredate>23-JAN-82</Hiredate> <Salary>1300</Salary> </Employee></Department>
![Page 55: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/55.jpg)
XQuery
FOR $i IN sqlquery("select * from scott.emp")/ROW RETURN <EMP empno="{$i/EMPNO}"> $i/ENAME, $i/SALARY </EMP>
FOR $i IN sqlquery("select * from scott.emp")/ROW, $j IN document("dept.xml") WHERE $j/deptno = $i/DEPTNO RETURN <EMP empno="{$i/EMPNO}" deptno="{$j/deptno}"/>
![Page 56: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/56.jpg)
Xquery –1 // get the connection (for example, using the thick JDBC Driver)
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn =
DriverManager.getConnection("jdbc:oracle:@","scott","tiger");
// create a context using that connection..
XQueryContext ctx = new XQueryContext(conn);
// create a string from the file
Reader strm = new StringReader(
"FOR $i IN sqlquery(\"select * from scott.emp\")/ROW "+
" RETURN <EMP empno=\"{$i/EMPNO}\">$i/ENAME,$i/SALARY</EMP>");
// prepare the query
PreparedXQuery xq = ctx.prepareXQuery(strm);
// get a resultset
![Page 57: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/57.jpg)
Xquery -2
XQueryResultSet rset = xq.executeQuery();
while (rset.next()) { XMLNode node = rset.getNode(); // get result nodes System.out.println(" NODE "+ node.getNodeName()); node.print(System.out); }
![Page 58: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/58.jpg)
SQL/XML XQuery• XQUERY
<results> { FOR $a IN distinct(document("bib.xml")//author) RETURN <result> { $a } { FOR $b IN document("bib.xml")/bib/book[author = $a] RETURN $b/title } </result> } </results>
• SQL/XML
SELECT xmlelement("results", xmlagg(b2.column_value))
FROM (SELECT xmlelement("result",b.column_value.extract('//author'),
xmlagg(b.column_value.extract('/title')))
FROM TABLE(xmlseq(xmldocument('/bib.xml').extract('/bib/book'))) b
GROUP BY b.column_value.extract('//author')) b2
![Page 59: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/59.jpg)
Oracle XML DB
Oracle & XMLOverview
XML Type XMLRepository
Summary
Content
![Page 60: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/60.jpg)
XML DB - Repository
WebDAV, FTP and HTTP SQL Repository search (under_path,
depth)
select extractValue(r.res,'/Resource/DisplayName') "./purchaseOrders/1999/Apr"
from resource_view R
where under_path(r.res, 1, '/home/SCOTT/purchaseOrders/1999/Apr', 1) = 1
order by extractValue(r.res,'/Resource/DisplayName');
![Page 61: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/61.jpg)
![Page 62: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/62.jpg)
![Page 63: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/63.jpg)
XML DB - Repository
Hierarchical Index– Speed up pathname resolution and folder
search– Map connect by data into folders
Navigational API (JNDI) to access objects via pathname, rename, delete and copy files
![Page 64: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/64.jpg)
Oracle XML DB
Oracle & XMLOverview
XML Type XMLRepository
Summary
![Page 65: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/65.jpg)
Oracle9iR2: XML DB Enhanced XMLType
– XMLSchema Support – Object-Relational Storage Maintaining DOM fidelity– XML-specific memory mgmt for better scalability and
performance Lazily loaded virtual DOM, Schema caching
– Built-in XML operators for SQL/XML interchangability– XPath Search in the server, and piecewise update of XML via
XPath– XSL Transforms in the server– Enhanced XML Views for creating your own efficient
representations of XML New XML Repository
– FTP, WebDAV, HTTP protocol servers to move XML content in and out
– ‘Foldering’ and Repository view over XML Content including access control Hierarchical Index, SQL Versioning
– SQL Repository Search
![Page 66: Marc Meewis Technology Sales Consultant (marcewis@oracle) Oracle Belgium](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812a82550346895d8e16fc/html5/thumbnails/66.jpg)
9 Benefits of XML DB XML SQL ‘duality’
– SQL operations over XML data, XML operations over SQL data Native support for XML data model
– XML Schema Constraints, other constraints, RI Storage and Structure Independence Strong data management over XML content vs. file storage Repository Functionality Multiple XML views over relational data Ease of Presentation and Interchange
– Native XSLT, built-in generation Popular API access
– DOM, SQL, PL/SQL, Java, … XML-specific performance and scalability