| Oracle9i XML Database Developer's Guide - Oracle XML DB Release 2 (9.2) Part Number A96620-02 |
|
|
View PDF |
This chapter describes how to install and use the Oracle XML DB Basic Demo. It contains the following sections:
You can also view and run this XML DB demonstration (demo) from: http://otn.oracle.com/tech/xml/content.html
Before you run the XML DB Basio demo ensure you have installed the following software:
Before installing and running the XML DB Basic demo, it is recommended that you install the following non-Oracle software:
http://www.altova.com.http://www.ftpplanet.com/download.htm.cscript interpreter version 5.6 or later. You can verify the version of cscript installed on your machine by typing the command cscript at a DOS command prompt. The cscript processor is used to create shortcuts used during the demonstration and to copy files from the install directory structure to the demonstration directory structure. You should be able to download the software from: http://msdn.microsoft.com/downloads/default.asp?URL=/downloads/sample.asp?url=/msdn-files/027/001/733/msdncompositedoc.xmlhttp://msdn.microsoft.com/downloads/default.asp?url=/downloads/sample.asp?url=/msdn-files/027/001/766/msdncompositedoc.xmlBefore installing and running the XML DB demo, it is recommended that you install the following Oracle software:
Before starting the installation verify that Oracle Net Services, FTP, and HTTP are correctly configured using the following steps:
basicDemo directory, and use SQL*PLUS to connect to the target database as "SYS".
c:\...\BasicDemo>sqlplus "sys@ORCL92 as sysdba"
SQL> @?\rdbms\admin\utlsampl.sql
SQL> set long 100000
SQL> set pagesize 0
SQL> select XDBUritype('/xdbconfig.xml').getXML()
2 from dual
3 /
If XML DB is correctly installed XML DB configuration documents will be displayed.
XDB_UTILITY package by running the following script:
C:\...\basicDemo>sqlplus "sys@ORCL92 as sysdba" SQL*Plus: Release 9.2.0.1.0 - Production on Fri Aug 16 12:09:42 2002 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. Enter password: Connected to: Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production With the Partitioning, OLAP and Oracle Data Mining options JServer Release 9.2.0.1.0 - Production SQL> @SQL/xdbUtility View created. PL/SQL procedure successfully completed. Package created. No errors. Package body created. No errors. Synonym created. Grant succeeded. SQL>
XDB_PORTS package:
SQL> grant execute on XDB_UTILITY to SCOTT
2 /
XDB_DATABASE_SUMMARY view:
SQL> set long 10000 SQL> select value(x) from XDB_DATABASE_SUMMARY (x) 2 /
This should generate the following output:
VALUE(X)
-----------------------------------------------------------------
<Database Name="ORCL92" HTTP="8080" FTP="2100">
<Services>
<ServiceName>ORCL92.xp.mark.drake.oracle.com</ServiceName>
</Services>
<Hosts>
<HostName>MDRAKE-LAP</HostName>
</Hosts>
</Database>
In these preceding examples nnnn represents the target port number. The chosen FTP and HTTP port numbers cannot:
In general the selected port numbers should not be privileged port numbers (0-1023). After resetting the port numbers validate the new numbers have been accepted by repeating step 4.
C:\TEMP>lsnrctl status
If you are running against a remote database you should check the status from a DOS Command Prompt session or Telnet session attached to the remote machine.
Status command should generate output similar to the following:
LSNRCTL for 32-bit Windows: Version 9.2.0.1.0 - Production on 05-AUG-2002
16:01:37
Copyright (c) 1991, 2002, Oracle Corporation. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC0)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for 32-bit Windows: Version 9.2.0.1.0 -
Production
Start Date 03-AUG-2002 21:45:08
Uptime 1 days 18 hr. 16 min. 28 sec
Trace Level off
Security OFF
SNMP OFF
Listener Parameter File C:\oracle\ora92\network\admin\listener.ora
Listener Log File C:\oracle\ora92\network\log\listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC0ipc)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=mdrake-lap)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=mdrake-lap)(PORT=8080))
(Presentation=HTTP)(Session=RAW))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=mdrake-lap)(PORT=2100))
(Presentation=FTP)(Session=RAW))
Services Summary...
Service "ORCL92.xp.mark.drake.oracle.com" has 2 instance(s).
Instance "ORCL92", status UNKNOWN, has 1 handler(s) for this service...
Instance "ORCL92", status READY, has 2 handler(s) for this service...
Service "ORCL92XDB.xp.mark.drake.oracle.com" has 1 instance(s).
Instance "ORCL92", status READY, has 1 handler(s) for this service...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
If the output from the Status command shows multiple entries for the HTTP and FTP presentations, check that no port number appears more than once. If a given port number appears more than once, it means that two or more database instances are trying to service that port. This is not permitted. All of the database instances running on a given host must be assigned unique FTP and HTTP port numbers.
Connect to each instance in turn, and repeat steps 4, 5, 6, and 7, providing appropriate values for the FTP and HTTP ports. You can stop a database from servicing FTP and HTTP requests by setting the port number to 0. Once all of the database instances have been reconfigured, use the Listener Status command to check that each database instance has been reconfigured to service unique FTP and HTTP port numbers.
Verify that Oracle Net Services (NET*8), FTP, and HTTP protocols are configured as expected using the following procedure. This example assumes that the TNSALIAS ORCL92 can be used to establish a connection to the target database.
C:\temp >ftp -n ftp> open localhost 2100 Connected to mdrake-lap. 220 mdrake-lap FTP Server (Oracle XML DB/Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production) ready. ftp> user scott tiger 331 pass required for SCOTT 230 SCOTT logged in
When connecting to the FTP Server ensure that you replace:
databaseSummary.xml file using the following commands:
ftp> get /sys/databaseSummary.xml 200 PORT Command successful 150 ASCII Data Connection <Database Name="ORCL92" HTTP="8080" FTP="2100"><Services><ServiceName>ORCL92.xp.mark.drake.oracle.com</ServiceNa me></Services><Hosts><HostName>MDRAKE-LAP</HostName></Hosts></Database>226 ASCII Transfer Complete ftp: 183 bytes received in 0.01Seconds 18.30Kbytes/sec. ftp>
http://MDRAKE-LAP:8080/sys/databaseSummary.xml
The Browser will prompt for a username and password. Enter the name and password of the database user that will be used when running the XML DB Basic Demo. If the HTTP configuration is correct the Browser should display the contents of the file:
- <Database Name="ORCL92" HTTP="8080" FTP="2100">
- <Services>
<ServiceName>ORCL92.xp.mark.drake.oracle.com</ServiceName>
</Services>
- <Hosts>
<HostName>MDRAKE-LAP</HostName>
</Hosts>
</Database>
To install XML DB Basic Demo unzip the file XDBBasicDemo.zip into a folder of your choice. When you unzip the installation file it creates folder basicDemo/. This folder contains a sub-folder install/. which in turn contains file install.vbs. install.vbs installs the XML DB Basic Demo.
Open a DOS Command Prompt session in the basicDemo/ directory. The following information is required in order to install this XML DB demonstration:
ORACLE_HOME.TNSALIAS that can be used to establish an Oracle Net Services connection to the target database.CONNECT and RESOURCE privileges on the target database.install/ folder also contains file installParameters.xml that drives the installation process. This file contains arguments used to tailor the installation.
installParameters.xml using a text or XML editor. The file is simple enough that it can easily be edited in Notepad. The file has the following format:
<demoConfig>
<oracleHome>c:\oracle\ora92</oracleHome>
<oracleUser>SCOTT</oracleUser>
<oraclePassword>TIGER</oraclePassword>
<oracleSID>ORCL92</oracleSID>
<sqlPort>1521</sqlPort>
<listenerName>LISTENER</listenerName>
<hostName>localhost</hostName>
<httpPort>8080</httpPort>
<ftpPort>2100</ftpPort>
<msWordPath>
c:\Program Files\Microsoft Office\Office\WINWORD.EXE
</msWordPath>
<ftpPath>c:\Program Files\WS_FTP\WS_FTP95.exe</ftpPath>
<shortCutFolderName>XML DB Basic Demo</shortCutFolderName>
</demoConfig>
installationParameters.xml file verify that the file still contains well-formed XML by opening it in Internet Explorer.Carry out these steps to run the XML DB demo installation script:
install.vbs script. See Figure 26-1. The script prompts you for confirmation before starting the configuration process:
At the end of the installation process the script will report installation complete.
Oracle XML DB is the term for set of features in Oracle9i Release 2 (9.2) database that deliver high-performance storage and retrieval of XML. These features allow the database to absorb the W3C XML data model. The technology included with Oracle9i Release 2 means that the database is now a native XML database in addition to being the most complete relational database.
Oracle XML DB provides organization with a storage independent, content independent, and programming language independent infrastructure to store and manage XML data. It also provides new methods for navigating and querying XML content stored inside the database. With Oracle XML DB, you get all the advantages of relational database technology and XML technology at the same time.
Oracle XML DB offers a number of options for managing how XML documents will be stored in the database. Options include:
As anyone who has worked with XML quickly realizes, XML is closely tied to hierarchical metaphors. The standard mechanism used to query or access content contained in an XML Document is XPath. XPath is a W3C standard that defines a language for addressing parts of an XML document. XPath uses a path-based notation to navigate through the hierarchical structure of an XML document. When an XML document needs to refer to another XML document, the standard way to reference the target document is using a URL. Like XPath, URLs uses a path-based notation to identify the document in question. Oracle XML DB provides full support for these access methods.
A number of the features provided by Oracle XML DB allow you to use XPath expressions to query and update content in XML Documents. Oracle XML DB also includes a simple, light-weight, Repository that allows the relationships between XML documents to be expressed using a URL. This Repository also makes it possible to access XML content using a URL. This means that you have the option of accessing XML objects using both relational and hierarchical mechanisms.
The major components of Oracle XML DB are:
XMLType also provide methods that allow common operations such as XML schema validation and XSL Transformation to be performed on XML content.To start the XML DBBasic Demo, open the folder XML DB Basic Demo. If the demo has been installed correctly this folder will be located on your Desktop. Figure 26-3 displays the icons you will see when you open the BasicDemo/ folder.
Text description of the illustration image003.jpg
As you can see, the icons in this folder are numbered. The demonstration is given by clicking on each of the icons in this folder in turn.
Before giving the demonstration for the first time you must run this script.
This script does not need to be run again unless the database is dropped and re-created. The script does the following:
Some of these operations may generate errors if the demo is run as user SCOTT. You can ignore these.
Prior to giving the demonstration it is necessary to run this script. This script will remove all files under the chosen user's home folder and ensure that the environment is clean. Operations like deleteSchema() may generate errors. These can be safely ignored.
This step demonstrates the native WebDAV support included as part of Oracle XML DB. Click the 1.0 localhost icon to open a Web Folders (WebDAV) session to XML DB Repository. You will be prompted for username and password. Enter the appropriate database user and password and click OK. Figure 26-4 shows the displayed window.
Text description of the illustration image004.jpg
Key Points:
This can be shown by opening a command window on the server machine and issuing the command:
c:\temp> lsnrclt status
Open the home folder. This should contain a folder called SCOTT/, assuming that SCOTT was the name of the demonstration user. Open the SCOTT/ folder. The SCOTT/ folder should be empty. Create a new folder by using right mouse button. Select New -> Folder.
Text description of the illustration image005.jpg
Give the new folder a clearly identifiable name.
Key Points:
Do not close the window at this point.
This step demonstrates that Oracle XML DB Repository can be accessed and updated from SQL, as well as through protocols. It also shows that, when accessed using SQL, Repository operations are transactional.
Text description of the illustration image006.jpg
The script create a set of folders inside folder /home/SCOTT.
Key Points:
DBMS_XDB can be used to perform operations on the Repository from SQL. This means that any program that can call a PL/SQL procedure can work with Oracle XML DB Repository./home/SCOTT. Click the Refresh option. Note that the folders that were created by executing the PL/SQL script are NOT visible, even after refreshing the display.
Key points:
/home/SCOTT. Click the Refresh option. Note that the folders created by executing the PL/SQL script are now visible.
This shows how a standard FTP client can load documents into Oracle XML DB Repository. This step assumes that you are using WS_FTP95 from Ipswitch software. The reason this client was used is that it can be configured to make it easy to run the demonstration. In practice any FTP client can be used. If you choose to use WS_FTP ensure that you have a legal license.
If you choose to use a different FTP tool then you need to ensure that all the files and folders under local SCOTT folder are copied to the /home/SCOTT folder in Oracle XML DB Repository. The local version of the SCOTT folder is located in basicDemo\LOCAL\Configuration Files.
Key Points:
This step introduces the concept of XML Schema and Oracle XML DB's ability to shred and store XML documents using structured storage based on SQL99 object types. It uses XMLSpy from Altova.
Key Points:
XMLType data type. The XMLType makes the database XML aware and provides a convenient abstraction for storing, retrieving, querying and manipulating XML.
Oracle XML DB provides two options for storing XML in the database:
In this demo, one of the documents loaded into the database was an XML schema. This step uses XMLSpy to demonstrate the key features of Oracle XML DB's support for the W3C XML Schema Recommendation.
http://mdrake-lap:8080/home/SCOTT/xsd/purchaseOrder.xsd. Double click this item to open it.Enter the password and Click OK.
XMLSpy displays a graphical representation of the elements and types defined by the PurchaseOrder XML schema.
PurchaseOrder element. Then click the + sign next to the lineItems element, followed by the + sign next to the lineItem element. Finally click the part element.
At this point XMLSpy displays a graphical representation of the PurchaseOrder XML schema.
Text description of the illustration image012.jpg
Key Points:
PurchaseOrder is an instance of the complexType PurchseOrderType. PurchaseOrderType defines a set of elements that make up a PurchaseOrder document. One of these is LineItems which contains a collection of LineItem elements.Description and Part.Id, Quantity, and UnitPrice.
Text description of the illustration image014.jpg
Key Points:
http://www.w3c.org/2001/XMLSchema, is the namespace reserved by the W3C consortium for the Schema for Schemas. This namespace is used to define the structure of the XML document.http://xmlns.oracle.com/xdb is the namespace reserved by Oracle for Oracle XML DB annotations schema annotations. This namespace is used to add annotations to the schema that control how the instance documents will be stored in the database.The annotation mechanism is the W3C approved mechanism for adding Vendor-specific information to a W3C XML Schema.
defaultTable annotation is used in the PurchaseOrder element to define that XML documents, compliant with this schema will be stored in a table called PURCHASEORDER.SQLType annotation is used to provide an explicit name for the SQL Type that will be generated form the complexType PurchaseOrderType.
Text description of the illustration image016.jpg
Key Points:
PurchaseOrderType complexType.This step demonstrates how to make Oracle XML DB aware of an XML schema. At this point in the demonstration the XML schema has simply been stored in the Oracle XML DB Repository. The database is not aware of the existence of the XML schema.
Text description of the illustration image017.jpg
Key Points:
registerSchema() procedure is responsible for creating all of the objects and type defined by the XML schema.This step shows some of the objects created as a result of registering the XML schema.
Text description of the illustration image018.jpg
Key Points:
PurchaseOrder table is an Object table. Each row in the table is represented by an Object. The Object in question is an XMLType.PurchaseOrder. The definition of a PurchaseOrder element is defined by the XML schema registered under the URL http://mdrake-lap:8080/home/SCOTT/xdb/purchaseOrder.xsdXDBPO_TYPE object.XDBPO_TYPE object are derived from the elements and attributes defined by the complexType PurchaseOrderType.XDBPO_TYPE with XMLSpy's graphical representation of the complexType.This step demonstrates that the sampleData folders on your local hard-drive contain instance documents that conform with the registered XML schema.
sampleData folder. Open folder 1999. Open the folder Apr. Right click the document ADAMS-20011127121040988PST.xml and select Open.
This should launch Internet Explorer and display the document. If the document opens with some other application use the FolderOptions feature of Windows Explorer to adjust the file association.
Text description of the illustration image019.jpg
Key Points:
This step involves using FTP to copy the 1999 folder tree into Oracle XML DB Repository. It demonstrates how Oracle XML DB recognizes the documents as instances of the registered XML schema, and processes them accordingly.
1999 folder in the Local System pane, and then click the lower arrow to copy the 1999 folder, and all of it's subfolders from the local hard drive to the home/SCOTT/purchaseOrders folder in Oracle XML DB Repository. When the operation has completed click Exit.
Key Points:
noNameSpaceSchemaLocation attribute that identified them as a instance of the registered XML schema, the documents were shredded and stored as a set of objects in the database.This step involves showing how you can leverage SQL functionality when storing XML documents in Oracle XML DB. Adding constraints to the table constrains the XML data. This step also enables full XML schema validation of the XML documents.
Key Points:
CHECK CONSTRAINT or Trigger.
Text description of the illustration image021.jpg
Key Points:
XMLType table has to referred to as SYS_NC_ROWINFO$ from within a Trigger.schemaValidate() method on the XMLType. Using a Trigger makes it possible to for the validation to return meaningful error messages, and for you to catch these errors and attempt corrective action where appropriate./PurchaseOrder/Reference is unique across all PurchaseOrder documents stored in the PURCHASEORDER table./PurchaseOrder/User can be found in the ENAME column of the table SCOTT.EMP.PURCHASEORDER.This step involves using FTP to (attempt to) upload a set of documents that violate constraints created in the previous step.
purchaseOrders folder in Oracle XML DB Repository:
Text description of the illustration image023.jpg
When the document is uploaded the following error is displayed:
ORA-00604: error occurred at recursive SQL level 1 ORA-00001: unique constraint (SCOTT.REFERENCE_IS_UNIQUE) violated
Uploading this document resulted in a violation of the REFERENCE_IS_UNIQUE constraint created in step 3.2. This is because the value of the node PurchaseOrder/Reference/text() in this document is identical to the value of the node in one of the documents that was loaded during step 3.1. Consequently the operation fails.
purchaseOrders folder in Oracle XML DB Repository.
Text description of the illustration image024.jpg
When the document is uploaded the following error is displayed
ORA-00604: error occurred at recursive SQL level 1 ORA-02291: integrity constraint (SCOTT.USER_IS_VALID) violated - parent key not found
Uploading this document resulted in a violation of the USER_IS_VALID constraint created in step 3.2. This is because the value of the node PurchaseOrder/User/text() in this document is "HACKER", and this value was not found in the ENAME column in SCOTT.EMP. Consequently the operation fails.
purchaseOrders folder in Oracle XML DB Repository.
Text description of the illustration image025.jpg
When the document is uploaded the following error is displayed
ORA-00604: error occurred at recursive SQL level 1 ORA-31154: invalid XML document ORA-19202: Error occurred in XML processing LSX-00221: "ADAMS-20011127PST" is too short (minimum length is 18) ORA-06512: at "SYS.XMLTYPE", line 0 ORA-06512: at "SCOTT.VALIDATE_PURCHASEORDER", line 5 ORA-04088: error during execution of trigger 'SCOTT.VALIDATE_PURCHASEORDER'
Uploading this document resulted in the VALIDATE_PURCHASEORDER Trigger being fired. The XML schema=validation processing performed in the Trigger detected that the value of the node /PurchaseOrder/Reference/text() did not conform to the rules set out in the XML schema. The schema defines that the minimum length of this node should be 18 characters. Since the document is not a valid instance of the class of documents defined by the XML schema, the operation fails.
Key Points:
This step demonstrates ways to execute simple XPath queries against XML documents.
Text description of the illustration image026.jpg
Key Points:
existsNode() SQL/XML operator can be used in the WHERE clause to restrict the set of documents returned by a query. existsNode() applies an XPath expression to an XML document and returns true (1) or false (0) depending on whether or not the document contains a node that matches the XPath expression.PurchaseOrder table. There will be one row in the table for each document.existsNode() function and a simple XPath expression to find the number of PurchaseOrder documents where the value of the node PurchaseOrder/User/text() contains the value "SMITH".value() operator to display the entire contents of a document stored as a row in an XMLType (object) table. It also show how to use the existsNode() operator to restrict the result to the row where the node /PurchaseOrder/Reference/text() contains the value "ADAMS-20011127121040988PST".This example shows how to use the extractValue() clause to get the value of a node in a document based on an XPath expression. It also shows that Oracle XML DB is capable of evaluating complex XPath expressions that involve deep navigation of an XML document.
Text description of the illustration image027.jpg
Key Points:
existsNode() function is used to restrict the set of documents returned by the query to those that by that contain a lineItem element that contains a part element with an Id attribute containing the value "037429139523".
The lineItem element occurs multiple times within each document.
/PurchaseOrder/LineItems/LineItem/Part[@Id="037429139523"] does not explicitly identify which occurrences to search, all instances of the lineItem element are searched to see if they meet the specified condition.extractValue() function is used to return just the value of the node identified by the XPath expression: /PurchaseOrder/Reference/text()This step looks at the EXPLAIN plans generated by executing queries against tables of XML documents.
Text description of the illustration image029.jpg
Key Points:
/PurchaseOrder[Reference="ALLEN-2001101709512118PDT.
Text description of the illustration image030.jpg
Key Points:
"/PurchaseOrder[User="SMITH"]".This step looks at how to use an XPath expression to create an index. You can eliminate the table scan by building an index to support the second query in the previous example.
Text description of the illustration image031.jpg
Key Points:
CREATE INDEX statement on the appropriate attribute(s) of the underlying object(s). A conventional B-Tree index is then created on these attributes.This step demonstrates that the newly created index is used to resolve the query.
Text description of the illustration image032.jpg
Key Points:
Previous steps have shown how FTP can be used to load XML content in Oracle XML DB, and how the content can be accessed using the familiar SQL Table/Row metaphor. This step shows how HTTP protocol can be used to access content stored in Oracle XML DB using a Path-based (Folder/File) metaphor.
Text description of the illustration image033.jpg
The PurchaseOrder document is displayed on the Browser. See Figure 26-30.
Text description of the illustration image034.jpg
Key Points:
This step demonstrates that the File/Folder metaphor can be used to access content even when working in SQL.
Text description of the illustration image035.jpg
Key Points:
XDBUriType makes it possible to use a path-based metaphor to access content stored in Oracle XML DB Repository.XDBUriType provides a set of methods that make it possible to access different types of contents. Any path provided to XDBUriType is assumed to originate from the root of Oracle XML DB Repository.This step illustrates Oracle XML DB's WebDAV support and how you can use standard WebDAV-enabled tools to access and update content stored in the Repository.
Text description of the illustration image036.jpg
Use Microsoft Word to edit the document. Update the value of the node /PurchaseOrder/Actions[1]/Action/User/text() to "VISHU". Be very careful when typing the value VISHU, as later steps in the demonstration depend on your making this change correctly. Save the changed document.
|
Note: You cannot use Notepad or WordPad currently. You must use a WebDAV aware editor such as Word/2000 or Word/XP. |
Key Points:
This step shows that the changes made using Microsoft Word are visible from SQL.
Text description of the illustration image037.jpg
Key Points:
This step shows how an XML Document can be updated using SQL. It shows the use of the updateXML() function to update the contents of an XML document stored as XMLType. It refers to the target node using an XPath expression.
Text description of the illustration image038.jpg
Key Points:
updateXML() function can be used to update the contents of an XML document stored as an XMLType.updateXML() uses an XPath expression to identify the element, attribute or node that is to be updated.updateXML() works with both XML schema-based and non-schema based content.
For XML schema-based content, Query Rewrite allows updateXML() to perform in-place updates. If the XPath expression can be mapped onto an attribute of one of the underlying SQL Objects the update is performed as an SQL operation.
updateXML() is a much more efficient way of updating XML schema-based documents.
updateXML() updates a document, only the parts of the document that change are updated.updateXML() is used to update non-schema-based XML the update is done by instantiating a DOM and performing the update on the DOM. The DOM is then printed, and written back to the underlying CLOB storage.updateXML() are just like any other changes made using SQL. They must be committed before they become visible to other database users.This step shows the duality of the SQL and XML approaches.
Text description of the illustration image039.jpg
Key Points:
This step provides more detail about Oracle XML DB Repository and shows how SQL programmers can use RESOURCE_VIEW to query the Repository contents.
Key Points:
RESOURCE_VIEW and PATH_VIEW. Public synonyms make these views available to all database users. Oracle XML DB also provides a set of SQL functions that allow for efficient, path-based queries against the contents of Oracle XML DB Repository.
For XML DB the metadata is simply persisted as a set of XML documents compliant with the Oracle XML DB XDBResource XML schema.
Text description of the illustration image040.jpg
Key Points:
RESOURCE_VIEW provides the primary public view of Oracle XML DB Repository. It contains 1 row for each document or folder in the Repository. Each row contains 2 columns, RES and ANY_PATH:
RESOURCE_VIEW and PATH_VIEW can be accessed just like any other views. For instance to count the document of documents in the Repository simply count the number of rows in the RESOURCE_VIEW.
UNDER_PATH make it easy to efficiently restrict a query to a particular sub-tree of the Repository.
Text description of the illustration image041.jpg
Key Points:
RES column contains an XML document that conforms with the XDBResource XML schema. This schema defines the set of metadata required to implement the IETF WebDAV standard.EQUALS_PATH() function to retrieve the metadata for the user's purchaseOrder folder.DisplayName, Creator, Owner, LastModifier, CreationDate, and ModificationDate.extractValue() and existsNode() can be used for performing queries against the RESOURCE_VIEW.
Text description of the illustration image042.jpg
Key Points:
extractValue() can be used to access the metadata. Operations that involve updating the metadata, such as changing the owner of a document can be performed using updateXML().existsNode(), UNDER_PATH() and EQUALS_PATH().This example uses extractValue() and UNDER_PATH() to walk the directory tree starting from the user's purchaseOrders/ folder.
This demonstrates how you can query against XML DB Repository and use the Hierarchical Index feature to efficiently resolve path-based queries.
Text description of the illustration image043.jpg
Key Points:
WHERE clause that searches for all documents starting with "ADAMS" but uses the UNDER_PATH() function to restrict the result to those document under the user's purchaseOrders folder.
Text description of the illustration image044.jpg
Key Points:
Owner or ModificationDate, as well as XML content. This is achieved by joining the RESOURCE_VIEW with the tables that contain the XML content.PURCHASEORDER table with the RESOURCE_VIEW to obtain a path to each row in returned by the query.
Text description of the illustration image046.jpg
Key Points:
This step demonstrates how tools and products that only understand the relational view of data can access XML content managed by Oracle XML DB.
Key Points:
Text description of the illustration image047.jpg
Key Points:
CREATE VIEW statement that uses XPath expressions to map text nodes or attribute values in the XML document to columns declared in the CREATE VIEW statement.PURCHASE_ORDER_MASTER_VIEW that contains one row for each document in the PURCHASEORDER table.
Text description of the illustration image048.jpg
Key Points:
PURCHASE_ORDER_DETAIL_VIEW that exposes the contents of the lineitem elements as a set of rows. The view will contain one row for each lineitem element in the PURCHASEORDER table.extractValue() function to generate an XML Fragment from each document in the PURCHASEORDER table. An XML Fragment is an XML document containing multiple root level nodes. In this case the XML Fragment will consist of a set of lineitem nodes. The fragment will contain one root level node for each member of the lineitems collection.XMLSequence() function to create a separate row from each of the root level nodes in the Fragment.TABLE operator to turn the set of rows into a table that can be used in the FROM clause of a SELECT statement.PURCHASEORDER table and the set of rows generated by the TABLE operator.This step demonstrates that relational views over XML look and behave like relational views over other data.
Text description of the illustration image049.jpg
Key Points:
XMLType table. The tool or person creating the query does not need to understand the XML-specific operators and syntax required to access XML content.This step demonstrates how using relational views over XML you can use any SQL-based feature of the Oracle database against content managed by Oracle XML DB.
Text description of the illustration image050.jpg
Key Points:
This step demonstrates both how you can use DBUriServlet to access content using a Schema/Table metaphor. This also shows Oracle XML DB's ability to perform XSL transformations.
This launches Internet Explorer and uses a Repository-based URL to display the contents of the document "ADAMS-20011127121040988PST.xml". The URL uses Oracle XML DB's HTTP Server to display the content based on a resource in Oracle XML DB Repository.
This displays a set of internet shortcuts used during the next phase of the demonstration.
Text description of the illustration image051.jpg
Key Points:
This step demonstrates Oracle XML DB's DBUriServlet.
http://mdrake-lap:8080/oradb/SCOTT/PURCHASEORDER/ROW /PurchaseOrder[Reference="ADAMS-20011127121040988PST"] ?contenttype=text/xml
Text description of the illustration image052.jpg
Key Points:
DBUriServlet leverages the DBUriType feature of Oracle XML DB. The DBUriType allows a row in a table to be identified using a URL which consists of a Schema, Table, Row and Column. XPath like syntax allows the URL to be extended to subset which rows in the target table match the URL.
PurchaseOrder XMLType table using a DBUri. The URI consists of the following components:
/oradb: The default mount point for the DBUriServlet/SCOTT: The database schema name/PURCHASEORDER: The table name/ROW: The default Row separator/PurchaseOrder: The root node of the document in question[Reference="ADAMS-20011127121040988PST"]: An XPath expression that determines which row or rows should be returned.?contenttype=text/xml: The contenttype parameter allows the developer to specify the MIME type to be returned to the Browser.XMLType table or view, the DBUriServlet allows an XPath expression to be used to determine which rows in the table are returned. This is very similar in functionality to the W3C XPOINTER Recommendation.DBUriServlet allows an XPath-like expression, based on the columns in the table, to determine which rows should be included in the resulting document.This step shows a Standard style sheet that can be used to transform the PurchaseOrder document from XML to HTML.
Text description of the illustration image053.jpg
Key Points:
XSL allows display logic to be separated from processing logic. Different Style sheets can be used to format a given XML document different ways. For instance one Style sheet could format a document for display in a PC Browser, another Style sheet could format the same document for display on a WAP-enabled phone.
In this example the Style sheet was loaded into Oracle XML DB Repository so that the database can perform the XSLT processing.
This step shows Oracle XML DB's Style sheet processor being used to transform a PurchaseOrder document from XML into HTML.
Key Points:
Text description of the illustration image055.jpg
Key Points:
XMLType's transform() method or the SQL xmltransform() function. The transformation is performed by Oracle XML DB XSLT processor at the database level.This step introduces you to SQL/XML (SQLX) operators and functions used to create XMLType views and generate XML from an SQL query.
DEPTVIEW XMLType view.
Text description of the illustration image056.jpg
Key Points:
XMLType view, which provides a persistent XML View of the contents of the EMP and DEPT tables in the SCOTT sample schema.DNAME and LOC, as well as collection of Employee nodes containing the details of each employee in the department.XMLForest() is so named because it contains a collection of "Trees".This step shows how to use DBUriServle to display DEPTVIEW contents.
DEPTVIEW XMLType view.
Text description of the illustration image057.jpg
Key Points:
This step shows how to use a Style sheet to transform a PurchaseOrder document from XML to HTML.
DEPTVIEW.
Text description of the illustration image059.jpg
Key Points:
Do not close the Browser window at this point.
This step shows how you can use a Style sheet to transform a PurchaseOrder document from XML to HTML.
Text description of the illustration image061.jpg
Key Points:
DEPT and EMP as an HTML document.XMLType view that format the contents of the relational tables as an XML document then apply an XSLT style sheet to transform the XML document into HTML.This step illustrates how OracleText functionality can be applied to XML content stored in Oracle XML DB using Structured Storage techniques.
Text description of the illustration image062.jpg
Key Points:
existsNode() looks for a B-Tree or function-based index and then is used to resolve the query. If no such index exists it performs a functional evaluation of each document in the table to see if it contains a node that matches the supplied XPath expression.ctxsys.ctxxpath index has been created then existsNode() uses this index as a primary filter when resolving an XPath expression that cannot be resolved with a B-Tree or function-based Index. This is much faster than performing a functional evaluation of every document in the table.ctxsys.context) index on the PURCHASEORDER table and then using the Oracle Text contains() function to perform a Text-based search over the PurchaseOrder XML documents.