Skip Headers
Oracle® XML DB Developer's Guide
11g Release 1 (11.1)
Part Number B28369-01
Home
Book List
Index
Master Index
Contact Us
Next
View PDF
Contents
List of Examples
List of Figures
List of Tables
Title and Copyright Information
Preface
Audience
Documentation Accessibility
Related Documents
Conventions
Code Examples
Syntax Descriptions
What's New In Oracle XML DB?
Oracle Database 11
g
Release 1 (11.1) New Features in Oracle XML DB
Part I Oracle XML DB Basics
1
Introduction to Oracle XML DB
Features of Oracle XML DB
Oracle XML DB Architecture
XMLType Storage
APIs for XML
Catalog Views Related to XML
Views RESOURCE_VIEW and PATH_VIEW
Overview of Oracle XML DB Repository
Accessing and Manipulating XML in the Oracle XML DB Repository
XML Services
Oracle XML DB Repository Architecture
How Does Oracle XML DB Repository Work?
Oracle XML DB Protocol Architecture
Programmatic Access to Oracle XML DB (Java, PL/SQL, and C)
Oracle XML DB Features
XMLType Data Type
XML Schema Support
XMLType Storage Models
XML/SQL Duality
SQL/XML INCITS Standard SQL Functions
Rewriting of XQuery and XPath Expressions
How XPath Expressions Are Evaluated by Oracle XML DB
Rewriting SQL Code That Contains XQuery and XPath Expressions
When Can XPath Rewrite Occur?
What is the XPath-Rewrite Process?
Oracle XML DB Benefits
Unifying Data and Content
Exploiting Database Capabilities
Exploiting XML Capabilities
Efficient Storage and Retrieval of Complex XML Documents
Integrate Applications
Use XMLType Views If Your Data Is Not XML
Searching XML Data Using Oracle Text
Building Messaging Applications using Oracle Streams Advanced Queuing
Requirements for Running Oracle XML DB
Standards Supported by Oracle XML DB
Oracle XML DB Technical Support
Oracle XML DB Examples Used in This Manual
Further Oracle XML DB Case Studies and Demonstrations
2
Getting Started with Oracle XML DB
Oracle XML DB Installation
When to Use Oracle XML DB
Designing Your XML Application
Application Design with Oracle XML DB
Data
Access
Application Language
Processing
Storage
How Structured Is Your Data?
Access Models
Application Language
Processing Models
Messaging Options
Storage Models
Oracle XML DB Performance
XML Storage Requirements
XML Memory Management
XML Parsing Optimizations
Node-Searching Optimizations
XML Schema Optimizations
Load Balancing Through Cached XML Schema
Reduced Bottlenecks From Code That Is Not Native
Reduced Java Type Conversion Bottlenecks
3
Using Oracle XML DB
Storing XML as XMLType
What is XMLType?
Benefits of XMLType Data Type and API
When to Use XMLType
Creating XMLType Tables and Columns
Using Virtual Columns to Constrain Data Stored as Binary XML
Loading XML Content into Oracle XML DB
Loading XML Content Using SQL or PL/SQL
Loading XML Content Using Java
Loading XML Content Using C
Loading Large XML Files That Contain Small XML Documents
Loading Large XML Files Using SQL*Loader
Loading XML Documents into the Repository Using DBMS_XDB
Loading Documents into the Repository Using Protocols
Character Sets of XML Documents
XML Encoding Declaration
Character-Set Determination When Loading XML Documents into the Database
Character-Set Determination When Retrieving XML Documents from the Database
Overview of the W3C XML Schema Recommendation
XML Instance Documents
XML Schema for Schemas
Editing XML Schemas
XML Schema Features
Text Representation of the PurchaseOrder XML Schema
Graphical Representation of the Purchase-Order XML Schema
Using XML Schema with Oracle XML DB
Why Use XML Schema With Oracle XML DB?
Validating Instance Documents with XML Schema
Constraining Instance Documents for Business Rules or Format Compliance
Defining How XMLType Contents Must be Stored in the Database
Structured Storage of XML Documents
Annotating an XML Schema to Control Naming, Mapping, and Storage
Controlling How Collections are Stored for Object-Relational XMLType Storage
Declaring the Oracle XML DB Namespace
Registering an XML Schema with Oracle XML DB
SQL Types and Tables Created During XML Schema Registration
Working with Large XML Schemas
Working with Global Elements
Creating XML Schema-Based XMLType Columns and Tables
Default Tables
Identifying XML Schema Instance Documents
Attributes noNamespaceSchemaLocation and schemaLocation
Dealing with Multiple Namespaces
Using the Database to Enforce XML Data Integrity
Comparing Partial to Full XML Schema Validation
Partial Validation
Full Validation
Using SQL Constraints to Enforce Referential Integrity
DML Operations on XML Content Using Oracle XML DB
XPath and Oracle XML
Querying XML Content Stored in Oracle XML DB
PurchaseOrder XML Document
Retrieving the Content of an XML Document Using Pseudocolumn OBJECT_VALUE
Accessing Fragments or Nodes of an XML Document Using EXTRACT
Accessing Text Nodes and Attribute Values Using XMLCAST and XMLQUERY
Performing SQL Operations on XMLType Fragments with XMLTABLE
Searching the Content of an XML Document Using XMLEXISTS
Using XMLEXISTS in a SQL WHERE Clause
Relational Access to XML Content Stored in Oracle XML DB Using Views
Breaking Up a Single Level of XML Data
Breaking Up Multiple Levels of XML Data
Querying XML Content As Relational Data
Updating XML Content Stored in Oracle XML DB
Updating XML Schema-Based and Non-Schema-Based XML Documents
Namespace Support in Oracle XML DB
Processing XMLType Methods and XML-Specific SQL Functions
Understanding and Optimizing XPath Rewrite
Using EXPLAIN PLAN to Tune XPath Rewrite
Using Indexes to Improve the Performance of XPath-Based Functions
Accessing Members of Collections of Repeating Elements
Using Indexes to Tune Queries on Collections Stored as OCTs
EXPLAIN PLAN with ACL-Based Security Enabled: SYS_CHECKACL Filter
Accessing Relational Database Content Using XML
Generating XML From Relational Tables Using DBURIType
XSL Transformation and Oracle XML DB
Using Oracle XML DB Repository
Installing and Uninstalling Oracle XML DB Repository
Oracle XML DB Provides Name-Level Locking
Use Protocols or SQL to Access and Process Repository Content
Using Standard Protocols to Store and Retrieve Content
Uploading Content to Oracle XML DB Using FTP
Accessing Oracle XML DB Repository Programmatically
Accessing and Updating XML Content in the Repository
Accessing the Content of Documents Using SQL
Accessing the Content of XML Schema-Based Documents
Using Element XMLRef in Joins to Access Resource Content
Updating the Content of Documents Stored in the Repository
Updating Repository Content Using Protocols
Updating Repository Content Using SQL
Updating XML Schema-Based Documents in the Repository
Controlling Access to Repository Data
Oracle XML DB Transactional Semantics
Querying Metadata and the Folder Hierarchy
RESOURCE_VIEW and PATH_VIEW
Querying Resources in RESOURCE_VIEW and PATH_VIEW
Oracle XML DB Hierarchical Repository Index
How Documents are Stored in the Repository
Viewing Relational Data as XML From a Browser
Using DBUri Servlet to Access Any Table or View From a Browser
XSL Transformation Using DBUri Servlet
Part II Storing and Retrieving XML Data in Oracle XML DB
4
XMLType Operations
Selecting and Querying XML Data
Searching XML Documents with XPath Expressions
Oracle Extension XPath Function Support
Selecting XML Data Using XMLType Methods
Querying XMLType Data with SQL Functions
XMLEXISTS SQL Function
EXISTSNODE SQL Function
EXTRACT SQL Function
XMLCAST SQL Function
EXTRACTVALUE SQL Function
Querying XML Data With SQL
Updating XML Instances and XML Data in Tables
Updating an Entire XML Document
SQL Functions to Update XML Data
UPDATEXML SQL Function
UPDATEXML and NULL Values
Updating the Same XML Node More Than Once
Preserving DOM Fidelity When Using UPDATEXML
Optimization of SQL Functions that Modify XML Data
Creating Views of XML With SQL Functions that Modify XML Data
INSERTCHILDXML SQL Function
INSERTXMLBEFORE SQL Function
APPENDCHILDXML SQL Function
DELETEXML SQL Function
5
Indexing XMLType Data
Oracle XML DB Tasks Involving Indexes
Overview of Indexing XMLType Data
Problem: Fine-Grained Structure of XML Data
B-tree Indexes Are Appropriate for Structured Storage
Unstructured and Hybrid Storage Present an Indexing Problem for XML Data
Solution: XMLIndex
Other Indexes for XML Data
Function-Based Indexes
Oracle Text Indexes
CTXXPath Indexes
Optimization Chooses Indexes
Function-Based Indexes on XMLType Data
Creating Function-Based Indexes on Unstructured XMLType Tables and Columns
Creating Function-Based Indexes on Structured XMLType Tables and Columns
XPath Rewrite for EXTRACTVALUE Indexes on Singleton Elements or Attributes
No XPath Rewrite for EXTRACTVALUE Applied to a Collection
XMLIndex
Advantages of XMLIndex
XPath Expressions Not Indexed by XMLIndex
Components of an XMLIndex Index
Ignore the Path Table; It Is Transparent
Column VALUE of the XMLIndex Path Table
Creating Secondary Indexes on Column VALUE
Data Dictionary Static Public Views Related to XMLIndex
Creating, Dropping, Altering, and Examining an XMLIndex Index
Creating Additional Secondary Indexes on an XMLIndex Path Table
How to Tell If XMLIndex is Used
Turning Off Use of XMLIndex
XMLIndex Path Subsetting: Specifying the Paths You Want to Index
Examples of XMLIndex Path Subsetting
XMLIndex Path-Subsetting Rules
Using XMLIndex on Oracle XML DB Repository
Creating an XMLIndex Index on Repository Resources
Removing Repository Resources From Indexing With XMLIndex
Querying Repository Data and Metadata Indexed With XMLIndex
Dropping an XMLIndex Index on Created on Repository Resources
XMLIndex Parallelism
Asynchronous (Deferred) Maintenance of XMLIndex Indexes
Collecting Statistics on XMLIndex Objects For the Cost-Based Optimizer
Guidelines for Using XMLIndex
PARAMETERS Clause for CREATE INDEX and ALTER INDEX
PARAMETERS Clause Syntax for CREATE INDEX and ALTER INDEX
Usage of XMLIndex_parameters
Usage of XMLIndex_parameter_clause for ALTER INDEX
Usage of PATHS Clause
Usage of create_index_paths_clause and alter_index_paths_clause
Usage of xml_index_value_clause
Usage of ASYNC Clause
Oracle Text Indexes on XML Data
Creating and Using Oracle Text Indexes
Oracle Text Indexes Are Used Independently of Other Indexes
6
XML Schema Storage and Query: Basic
Overview of XML Schema and Oracle XML DB
Using Oracle XML DB With XML Schema
Why XML Schema?
DTD Support in Oracle XML DB
Inline DTD Definitions
External DTD Definitions
Managing XML Schemas with DBMS_XMLSCHEMA
Registering an XML Schema
Delete and Reload Documents, Before Registering an XML Schema They Reference
Storage and Access Infrastructure
Atomic Nature of XML Schema Registration
Managing and Storing XML Schemas
Debugging XML Schema Registration for XML Data Stored Object-Relationally
SQL Object Types Created During XML Schema Registration, for Structured Storage
Default Tables Created During XML Schema Registration
Generated Names are Case Sensitive
Database Objects That Depend on Registered XML Schemas
Listing All Registered XML Schemas
Deleting an XML Schema
DBMS_XMLSCHEMA.DELETESCHEMA Options
XMLType Methods Related to XML Schema
Local and Global XML Schemas
Local XML Schema
Global XML Schema
DOM Fidelity
What is DOM Fidelity?
SYS_XDBPD$ and DOM Fidelity for Structured Storage
XML Translations
Changing an XML Schema and XML Instance Documents for Translation
Indicating Translatable Elements in an XML Schema
Indicating Translation Language Attributes in an XML Instance Document
Making XML Documents Translatable
Operations on Translated Documents
Creating XMLType Tables and Columns Based on XML Schema
Specifying XMLType Storage Options for XML Schema-Based Data
Binary XML Storage of XML Schema-Based Data
Unstructured Storage of XML Schema-Based Data
Structured Storage of XML Schema-Based Data
Specifying Relational Constraints on XMLType Tables and Columns
Oracle XML Schema Annotations
Common Uses of XML Schema Annotations
XML Schema Annotation Example
Available Oracle XML DB XML Schema Annotations
Querying a Registered XML Schema to Obtain Annotations
Mapping XML Schema Data Types to Oracle XML DB Storage
Mapping XML Schema Data Types to SQL Data Types
Example of Mapping XML Schema Data Types to SQL
Mapping XML Schema Attribute Data Types to SQL
Overriding the SQLType Value in an XML Schema When Declaring Attributes
Mapping XML Schema Element Data Types to SQL
Overriding the SQLType Value in an XML Schema When Declaring Elements
Mapping simpleType to SQL
NCHAR, NVARCHAR, and NCLOB SQLType Values are Not Supported
simpleType: Mapping XML Strings to SQL VARCHAR2 Versus CLOB
Working with Time Zones
Mapping complexType to SQL
Specifying Attributes in a complexType XML Schema Declaration
Mapping XML Schema Data Types To Binary XML Encoding Types
7
XPath Rewrite
Overview of XPath Rewrite
Where Does XPath Rewrite Occur?
Which XPath Expressions Are Rewritten?
Common XML Schema Constructs Supported in XPath Rewrite
Unsupported XML Schema Constructs in XPath Rewrite
Common Storage Constructs Supported in XPath Rewrite
Unsupported Storage Constructs in XPath Rewrite
XPath Rewrite Can Change Comparison Semantics
How Are XPath Expressions Rewritten?
Rewriting XPath Expressions: Mapping Data Types and Path Expressions
Mapping for a Simple XPath Expression
Mapping for simpleType Elements
Mapping of Predicates
Document Ordering with Collection Traversals
Schema-Based: Collection Position
XPath Expressions That Cannot Be Satisfied
Namespace Handling
Date Format Conversions
Existential Checks for Attributes and Elements with Scalar Values
Diagnosing XPath Rewrite
Using EXPLAIN PLAN with XPath Rewrite
Using Events with XPath Rewrite
Turning Off Functional Evaluation (Event 19021)
Tracing Reasons that Rewrite Does Not Occur
XPath Rewrite of Individual SQL Functions
XPath Rewrite for EXISTSNODE
EXISTSNODE Mapping with Document Order Preserved
EXISTSNODE Mapping Without Document Order Preserved
XPath Rewrite for EXTRACTVALUE
XPath Rewrite for EXTRACT
EXTRACT Mapping with Document Order Maintained
EXTRACT Mapping Without Maintaining Document Order
XPath Rewrite for XMLSEQUENCE
XPath Rewrite for UPDATEXML
XPath Rewrite for INSERTCHILDXML and DELETEXML
8
XML Schema Storage and Query: Advanced
Generating XML Schemas with DBMS_XMLSCHEMA.GENERATESCHEMA
Adding Unique Constraints to the Parent Element of an Attribute
Setting Attribute SQLInline to false for Out-Of-Line Storage
XPath Rewrite for Out-Of-Line Tables
Storing Collections in Out-Of-Line Tables
Fully Qualified XML Schema URLs
Mapping XML Fragments to Large Objects (LOBs)
complexType Extensions and Restrictions in Oracle XML DB
complexType Declarations in XML Schema: Handling Inheritance
Mapping complexType: simpleContent to Object Types
Mapping complexType: any and anyAttribute
Oracle XPath Extension Functions to Examine Type Information
ora:instanceof-only XPath Function
ora:instanceof XPath Function
XML Schema: Working With Circular and Cyclical Dependencies
For Circular XML Schema Dependencies Set Parameter GENTABLES to TRUE
Handling Cycling Between complexTypes in XML Schema
How a complexType Can Reference Itself
Cyclical References Between XML Schemas
Support for Recursive Schemas
Sharing defaultTable Among Common Out-of-line Elements
Query Rewrite When DOCID is Present
Disabling DOCID Column Creation
Guidelines for Using XML Schema with Oracle XML DB
Using Bind Variables in XPath Expressions
Loading and Retrieving Large Documents with Collections
Guidelines for Setting xdbcore Parameters
9
XML Schema Evolution
Overview of XML Schema Evolution
Using Copy-Based Schema Evolution
Scenario for Copy-Based Evolution
copyEvolve Parameters and Errors
Limitations When Using copyEvolve
Guidelines for Using copyEvolve
Top-Level Element Name Changes
User-Created Virtual Columns of Nondefault Tables
Ensure that the XML Schema and Dependents Are Not Used by Concurrent Sessions
Rollback When Procedure DBMS_XMLSCHEMA.COPYEVOLVE Raises an Error
Failed Rollback From Insufficient Privileges
Privileges Needed for XML Schema Evolution
Using a Style Sheet to Update Existing Instance Documents
Examples of Using Procedure copyEvolve
Using In-Place XML Schema Evolution
Restrictions for In-Place XML Schema Evolution
Backward-Compatibility Restrictions
Other Restrictions on In-Place Evolution
Supported Operations for In-Place XML Schema Evolution
Guidelines for Using In-Place XML Schema Evolution
inPlaceEvolve Parameters
Creating the Document for the diffXML Parameter
diffXML Operations and Examples
10
Transforming and Validating XMLType Data
Transforming XMLType Instances
SQL Function XMLTRANSFORM and XMLType Method transform()
XMLTRANSFORM and XMLType.transform(): Examples
Validating XMLType Instances
XMLIsValid
schemaValidate
isSchemaValidated
setSchemaValidated
isSchemaValid
Validating XML Data Stored as XMLType: Examples
11
Full-Text Search Over XML Data
Overview of Full-Text Search for XML
Comparison of Full-Text Search and Other Search Types
Searching XML Data
Searching Documents Using Full-Text Search and XML Structure
About the Full-Text Search Examples
Roles and Privileges
Schema and Data for Full-Text Search Examples
Overview of CONTAINS and ora:contains
Overview of SQL Function CONTAINS
Overview of XPath Function ora:contains
Comparison of CONTAINS and ora:contains
CONTAINS SQL Function
Full-Text Search Using SQL Function CONTAINS
Full-Text Boolean Operators AND, OR, and NOT
Full-Text Stemming: $
Combining Boolean and Stemming Operators
SCORE SQL Function
Restricting the Scope of a CONTAINS Search
WITHIN Structure Operator
INPATH Structure Operator
HASPATH Structure Operator
Projecting the CONTAINS Result
Indexing With a CONTEXT Index
Introduction to CONTEXT Indexes
Effect of a CONTEXT Index on CONTAINS
CONTEXT Index Preferences
Introduction to Section Groups
ora:contains XPath Function
Full-Text Search Using XPath Function ora:contains
Restricting the Scope of an ora:contains Query
Projecting the ora:contains Result
Policies for ora:contains Queries
Introduction to Policies for ora:contains Queries
Effect of Policies on ora:contains
Policy Defaults
Performance of ora:contains
Use a Primary Filter in the Query
XPath Rewrite and CONTEXT Indexes
Text Path BNF Specification
Support for Full-Text XML Examples
Purchase-Order XML Document, po001.xml
CREATE TABLE Statements
Purchase-Order XML Schema for Full-Text Search Examples
Part III Using XMLType APIs
12
PL/SQL APIs for XMLType
Overview of PL/SQL APIs for XMLType
API Features
Lazy Loading of XML Data (Lazy Manifestation)
XMLType Data Type Supports XML Schema
XMLType Supports Data in Different Character Sets
PL/SQL DOM API for XMLType (DBMS_XMLDOM)
Overview of the W3C Document Object Model (DOM) Recommendation
Oracle XDK Extensions to the W3C DOM Standard
Supported W3C DOM Recommendations
Difference Between DOM and SAX
PL/SQL DOM API for XMLType (DBMS_XMLDOM): Features
Enhanced Performance
Designing End-to-End Applications Using Oracle XDK and Oracle XML DB
Using PL/SQL DOM API for XMLType: Preparing XML Data
Defining an XML Schema Mapping to SQL Object Types
DOM Fidelity for XML Schema Mapping
Wrapping Existing Data into XML with XMLType Views
DBMS_XMLDOM Methods Supported
PL/SQL DOM API for XMLType: Node Types
Working with XML Schema-Based Data
DOM NodeList and NamedNodeMap Objects
Using PL/SQL DOM API for XMLType (DBMS_XMLDOM)
PL/SQL DOM API for XMLType – Examples
Large Node Handling Using DBMS_XMLDOM
Get-Push Model
Get-Pull Model
Set-Pull Model
Set-Push Model
Determining Binary Stream or Character Stream
PL/SQL Parser API for XMLType (DBMS_XMLPARSER)
PL/SQL Parser API for XMLType: Features
Using PL/SQL Parser API for XMLType (DBMS_XMLPARSER)
PL/SQL XSLT Processor for XMLType (DBMS_XSLPROCESSOR)
Enabling Transformations and Conversions with XSLT
PL/SQL XSLT Processor for XMLType: Features
Using PL/SQL XSLT Processor API for XMLType (DBMS_XSLPROCESSOR)
PL/SQL Translation API for XMLType (DBMS_XMLTRANSLATIONS)
DBMS_XMLTRANSLATIONS Methods
13
Package DBMS_XMLSTORE
Overview of PL/SQL Package DBMS_XMLSTORE
Using Package DBMS_XMLSTORE
Inserting with DBMS_XMLSTORE
Updating with DBMS_XMLSTORE
Deleting with DBMS_XMLSTORE
14
Java DOM API for XMLType
Overview of Java DOM API for XMLType
Java DOM API for XMLType
Using JDBC to Access XMLType Data
How Java Applications Use JDBC to Access XML Documents in Oracle XML DB
Using JDBC to Manipulate XML Documents Stored in a Database
Loading a Large XML Document into the Database with JDBC
Java DOM API for XMLType Features
Creating XML Schema-Based Documents
JDBC or SQLJ
Java DOM API for XMLType Classes
Java Methods That Are Deprecated or Not Supported
Using Java DOM API for XMLType
Handling Large Nodes Using Java
Stream Extensions to Java DOM
Get-Pull Model
Get-Push Model
Set-Pull Model
Set-Push Model
Using the Java DOM API and JDBC With Binary XML
15
Using the C API for XML
Overview of the C API for XML (Oracle XDK and Oracle XML DB)
Using OCI and the C API for XML with Oracle XML DB
Accessing XMLType Data Stored in the Database
Creating XMLType Instances on the Client
XML Context Parameter for C DOM API Functions
OCIXmlDbInitXmlCtx() Syntax
OCIXmlDbFreeXmlCtx() Syntax
Initializing and Terminating an XML Context
Using the C API for XML With Binary XML
Using the Oracle XDK Pull Parser With Oracle XML DB
Common XMLType Operations in C
16
Using Oracle Data Provider for .NET with Oracle XML DB
ODP.NET XML Support and Oracle XML DB
ODP.NET Sample Code
Part IV Viewing Existing Data as XML
17
Generating XML Data from the Database
Overview of Generating XML Data From Oracle Database
Overview of Generating XML Using Standard SQL/XML Functions
Overview of Generating XML Using Oracle Database SQL Functions
Overview of Generating XML Using DBMS_XMLGEN
Overview of Generating XML with XSQL Pages Publishing Framework
Overview of Generating XML Using XML SQL Utility (XSU)
Overview of Generating XML Using DBURIType
Generating XML Using SQL Functions
XMLELEMENT and XMLATTRIBUTES SQL Functions
Escaping Characters in Generated XML Data
Formatting of XML Dates and Timestamps
XMLElement Examples
XMLFOREST SQL Function
XMLSEQUENCE SQL Function
XMLCONCAT SQL Function
XMLAGG SQL Function
XMLPI SQL Function
XMLCOMMENT SQL Function
XMLROOT SQL Function
XMLSERIALIZE SQL Function
XMLPARSE SQL Function
XMLCOLATTVAL SQL Function
XMLCDATA SQL Function
Generating XML Using DBMS_XMLGEN
Using DBMS_XMLGEN
Functions and Procedures of Package DBMS_XMLGEN
DBMS_XMLGEN Examples
Generating XML Using SQL Function SYS_XMLGEN
Using XMLFormat Object Type
Generating XML Using SQL Function SYS_XMLAGG
Generating XML Using XSQL Pages Publishing Framework
Generating XML Using XML SQL Utility (XSU)
Guidelines for Generating XML With Oracle XML DB
Using XMLAGG ORDER BY Clause to Order Query Results Before Aggregation
Using XMLTABLE to Return a Rowset
18
Using XQuery with Oracle XML DB
Overview of XQuery in Oracle XML DB
Overview of the XQuery Language
Functional Language Based on Sequences
XQuery Expressions
FLWOR Expressions
SQL Functions XMLQUERY and XMLTABLE
XMLQUERY SQL Function in Oracle XML DB
XMLTABLE SQL Function in Oracle XML DB
When To Use XQuery
Predefined Namespaces and Prefixes
Oracle XQuery Extension Functions
ora:contains XQuery Function
ora:matches XQuery Function
ora:replace XQuery Function
ora:sqrt XQuery Function
ora:view XQuery Function
XMLQUERY and XMLTABLE Examples
XQuery Is About Sequences
Using XQuery to Query XML Data in Oracle XML DB Repository
Using ora:view to Query Relational Data in XQuery Expressions
Using XQuery with XMLType Data
Using Namespaces with XQuery
Performance Tuning for XQuery
XQuery Optimization over a SQL/XML View Created by ora:view
XQuery Optimization over XML Schema-Based XMLType Data
XQuery Static Type-Checking in Oracle XML DB
SQL*Plus XQUERY Command
Using XQuery with PL/SQL, JDBC, and ODP.NET
Oracle XML DB Support for XQuery
Support for XQuery and SQL
Implementation Choices Specified in the XQuery Standard
XQuery Features Not Supported by Oracle XML DB
XQuery Optional Features
Support for XQuery Functions and Operators
XQuery Functions fn:doc, fn:collection, and fn:doc-available
19
XMLType Views
What Are XMLType Views?
Creating XMLType Views: Syntax
Creating Non-Schema-Based XMLType Views
Using SQL/XML Generation Functions to Create Non-Schema-Based XMLType Views
Using Object Types with SYS_XMLGEN to Create Non-Schema-Based XMLType Views
Creating XML Schema-Based XMLType Views
Using SQL/XML Generation Functions to Create XML Schema-Based XMLType Views
Using Namespaces With SQL/XML Functions
Using Object Types and Views to Create XML Schema-Based XMLType Views
Creating Schema-Based XMLType Views Over Object Views
Wrapping Relational Department Data with Nested Employee Data as XML
Creating XMLType Views From XMLType Tables
Referencing XMLType View Objects Using SQL Function REF
DML (Data Manipulation Language) on XMLType Views
XPath Rewrite on XMLType Views
Views Constructed With SQL/XML Generation Functions
XPath Rewrite on Non-Schema-Based Views Constructed With SQL/XML
XPath Rewrite on Schema-Based Views Constructed With SQL/XML
Views Using Object Types, Object Views, and SYS_XMLGEN
Non-Schema-Based XMLType Views Using Object Types or Object Views
XML-Schema-Based Views Using Object Types or Object Views
XPath Rewrite Event Trace
Generating XML Schema-Based XML Without Creating Views
20
Accessing Data Through URIs
Overview of Oracle XML DB URL Features
URIs and URLs
URIType and its Subtypes
DBUris and XDBUris – What For?
URIType Methods
HTTPURIType Method getContentType()
DBURIType Method getContentType()
DBURIType Method getCLOB()
DBURIType Method getBLOB()
Accessing Data Using URIType Instances
XDBUris: Pointers to Repository Resources
XDBUri URI Syntax
XDBUri Examples
DBUris: Pointers to Database Data
Viewing the Database as XML Data
DBUri URI Syntax
DBUris are Scoped to a Database and Session
DBUri Examples
Targeting a Table
Targeting a Row in a Table
Targeting a Column
Retrieving the Text Value of a Column
Targeting a Collection
Creating New Subtypes of URIType using Package URIFACTORY
Registering New URIType Subtypes with Package URIFACTORY
SYS_DBURIGEN SQL Function
Rules for Passing Columns or Object Attributes to SYS_DBURIGEN
SYS_DBURIGEN SQL Function: Examples
DBUriServlet
Customizing DBUriServlet
DBUriServlet Security
Configuring Package URIFACTORY to Handle DBUris
Part V Oracle XML DB Repository
21
Accessing Oracle XML DB Repository Data
Overview of Oracle XML DB Foldering
Repository Terminology and Supplied Resources
Repository Terminology
Supplied Files and Folders
Oracle XML DB Resources
Where Is Repository Data Stored?
Names of Generated Tables
Defining Structured Storage for Resources
ASM Virtual Folder
Path-Name Resolution
Managing and Controlling Access to Resources
Link Types
Repository and Document Links
Hard Links and Weak Links
Creating a Weak Link Without Knowledge of Folder Hierarchy
Restricting Multiple Hard Links
Accessing Oracle XML DB Repository Resources
Navigational or Path Access
Accessing Oracle XML DB Resources Using Internet Protocols
Where You Can Use Oracle XML DB Protocol Access
Using Protocol Access
Retrieving Oracle XML DB Resources
Storing Oracle XML DB Resources
Using Internet Protocols and XMLType: XMLType Direct Stream Write
Accessing ASM Files Using Protocols and Resource APIs – For DBAs
Query-Based Access
Accessing Repository Data Using Servlets
Accessing Data Stored in Repository Resources
Managing and Controlling Access to Resources
22
Configuring Oracle XML DB Repository
Resource Configuration Files Configure a Resource
Configuring a Resource
Common Configuration Parameters
Configuration Element ResConfig
Configuration Element defaultChildConfig
Configuration Element applicationData
23
Using XLink and XInclude With Oracle XML DB
Overview of XLink and XInclude
XLink and Include Link Types
XLink and XInclude Links Model Document Relationships
XLink and XInclude Link Types
XInclude: Compound Documents
Using XLink With Oracle XML DB
Using XInclude With Oracle XML DB
Expanding Compound-Document Inclusions
Validating Compound Documents
Updating Compound Documents
Versioning, Locking, and Controlling Access to Compound Documents
Using DOCUMENT_LINKS View to Examine XLink and XInclude Links
Querying DOCUMENT_LINKS for XLink Information
Querying DOCUMENT_LINKS for XInclude Information
Configuring Resources for XLink and XInclude
Configuring Treatment of Unresolved Links: UnresolvedLink Attribute
Configuring the Document Links to Create: LinkType Element
Configuring the Path Format for Retrieval: PathFormat Element
Configuring Conflict-Resolution for XInclude: ConflictRule Element
Configuring Decomposition of Documents Using XInclude: SectionConfig Element
XLink and XInclude Configuration Examples
Using DBMS_XDB.processLinks to Manage XLink and XInclude Links
24
Managing Resource Versions
Overview of Oracle XML DB Versioning
Oracle XML DB Versioning Features
Oracle XML DB Versioning Terms Used in This Chapter
Oracle XML DB Resource ID and Path Name
Creating a Version-Controlled Resource (VCR)
Version Resource ID or VCR Version
Resource ID of a New Version
Accessing a Version-Controlled Resource (VCR)
Updating a Version-Controlled Resource (VCR)
Procedure DBMS_XDB_VERSION.checkOut
Procedure DBMS_XDB_VERSION.checkIn
Procedure DBMS_XDB_VERSION.unCheckOut
Update Contents and Properties
Access Control and Security of a VCR
Guidelines for Using Oracle XML DB Versioning
25
SQL Access Using RESOURCE_VIEW and PATH_VIEW
Overview of Oracle XML DB RESOURCE_VIEW and PATH_VIEW
RESOURCE_VIEW Definition and Structure
PATH_VIEW Definition and Structure
Understanding the Difference Between RESOURCE_VIEW and PATH_VIEW
Operations You Can Perform Using UNDER_PATH and EQUALS_PATH
RESOURCE_VIEW and PATH_VIEW SQL Functions
UNDER_PATH SQL Function
EQUALS_PATH SQL Function
PATH SQL Function
DEPTH SQL Function
Using RESOURCE_VIEW and PATH_VIEW SQL Functions
Accessing Repository Data Paths, Resources and Links: Examples
Deleting Repository Resources: Examples
Deleting Nonempty Folder Resources
Updating Repository Resources: Examples
Working with Multiple Oracle XML DB Resources
Performance Tuning of Oracle XML DB Resource Queries
Searching for Resources Using Oracle Text
26
Using PL/SQL to Access the Repository
Overview of PL/SQL Package DBMS_XDB
DBMS_XDB: Resource Management
DBMS_XDB: ACL-Based Security Management
DBMS_XDB: Configuration Management
27
Repository Resource Security
Overview of Oracle XML DB Resource Security and ACLs
How the ACL-Based Security Mechanism Works
Access Control List Concepts
Principal
Privilege
Access Control Entry (ACE)
Access Control List (ACL)
Default ACL
ACL File-Naming Conventions
ACL Evaluation Rules
Access Privileges
Atomic Privileges
Aggregate Privileges
Interaction with Database Table Security
Working with Oracle XML DB ACLs
Creating an ACL Using DBMS_XDB.createResource
Retrieving an ACL Document, Given its Repository Path
Setting the ACL of a Resource
Deleting an ACL
Updating an ACL
Retrieving the ACL Document that Protects a Given Resource
Retrieving Privileges Granted to the Current User for a Particular Resource
Checking if the Current User Has Privileges on a Resource
Checking if the Current User Has Privileges With the ACL and Resource Owner
Retrieving the Path of the ACL that Protects a Given Resource
Retrieving the Paths of All Resources Protected by a Given ACL
Managing Fine-Grained Access Control to External Network Services from the Database
Finding Information about Access Control Lists
Checking Privilege Assignments
Integrating Oracle XML DB with LDAP
Performance Issues for Using ACLs
28
Using Protocols to Access the Repository
Overview of Oracle XML DB Protocol Server
Session Pooling
Oracle XML DB Protocol Server Configuration Management
Configuring Protocol Server Parameters
Configuring Secure HTTP (HTTPS)
Enable the HTTP Listener to Use SSL
Enable TCPS Dispatcher
Interaction with Oracle XML DB File-System Resources
Protocol Server Handles XML Schema-Based or Non-Schema-Based XML Documents
Event-Based Logging
Using FTP and Oracle XML DB Protocol Server
Oracle XML DB Protocol Server: FTP Features
FTP Features That Are Not Supported
FTP Client Methods That Are Supported
FTP Quote Methods
Using FTP with ASM Files
Using FTP on the Standard Port Instead of the Oracle XML DB Default Port
FTP Server Session Management
Handling Error 421. Modifying the Default Timeout Value of an FTP Session
FTP Client Failure in Passive Mode
Using HTTP(S) and Oracle XML DB Protocol Server
Oracle XML DB Protocol Server: HTTP(S) Features
HTTP(S) Features That Are Not Supported
HTTP(S) Client Methods That Are Supported
Using HTTP(S) on a Standard Port Instead of an Oracle XML DB Default Port
HTTPS: Support for Secure HTTP
Anonymous Access to Oracle XML DB Repository using HTTP
Using Java Servlets with HTTP(S)
Embedded PL/SQL Gateway
Sending Multibyte Data From a Client
Characters That Are Not ASCII In URLs
Controlling Character Sets for HTTP(S)
Using WebDAV and Oracle XML DB
Oracle XML DB WebDAV Features
WebDAV Features That Are Not Supported
Supported WebDAV Client Methods
Using WebDAV with Microsoft Windows XP SP2
Using Oracle XML DB and WebDAV: Creating a WebFolder in Windows 2000
29
User-Defined Repository Metadata
Overview of Metadata and XML
Kinds of Metadata – Uses of the Term
User-Defined Resource Metadata
Scenario: Metadata for a Photo Collection
XML Schemas to Define Resource Metadata
Adding, Updating, and Deleting Resource Metadata
Using APPENDRESOURCEMETADATA to Add Metadata
Using DELETERESOURCEMETADATA to Delete Metadata
Using SQL DML to Add Metadata
Using WebDAV PROPPATCH to Add Metadata
Querying Schema-Based Resource Metadata
XML Image Metadata from Binary Image Metadata
Adding Non-Schema-Based Resource Metadata
PL/SQL Procedures Affecting Resource Metadata
30
Oracle XML DB Repository Events
Overview of Repository Events
Repository Events: Use Cases
Repository Events and Database Triggers
Repository Event Listeners and Event Handlers
Repository Event Configuration
Possible Repository Events
Repository Operations and Events
Repository Event Handler Considerations
Configuring Repository Events
Configuration Element event-listeners
Configuration Element listener
Repository Events Configuration Examples
31
Using Oracle XML DB Content Connector
Overview of JCR and Oracle XML DB Content Connector
About the Content Repository API for Java (JCR)
About Oracle XML DB Content Connector
How Oracle XML DB Repository Is Exposed in JCR
An Example of How Files and Folders are Exposed in JCR
Oracle Extensions to JCR Node Types
Binary and XML Content
System-Defined Metadata
User-Defined Metadata
Hard Links and Weak Links
How to Use Oracle XML DB Content Connector
Setting CLASSPATH
Obtaining the JCR Repository Object
Sample Code to Upload File
Additional Code Samples
Logging API for Oracle XML DB Content Connector
Supported JCR Compliance Levels
Oracle XML DB Content Connector Restrictions
Default Workspace Name
Operations Restricted to Specific Node Types
Determining the State of Files or Folders
Interaction Between Binary and XML Content
Order in Which Changes Are Saved
Undefined Properties
Node Type nt:base Is Abstract
Node jcr:content Is Created Automatically
Saving Normalizes Node jcr:xmltext
Node Type mix:referenceable
Full-Text Indexing
Using XML Schemas with JCR
Why Register XML Schemas for Use with JCR?
How to Register an XML Schema with JCR
How JCR Node Types are Generated from XML Schemas
Built-In Simple Types
XML Schema-Defined Simple Types
Complex Types
Global Element Declarations
32
Writing Oracle XML DB Applications in Java
Overview of Oracle XML DB Java Applications
Which Oracle XML DB APIs Are Available Inside and Outside the Database?
Design Guidelines: Java Inside or Outside the Database?
HTTP(S): Accessing Java Servlets or Directly Accessing XMLType Resources
Accessing Many XMLType Object Elements: Use JDBC XMLType Support
Use the Servlets to Manipulate and Write Out Data Quickly as XML
Writing Oracle XML DB HTTP Servlets in Java
Configuring Oracle XML DB Servlets
HTTP Request Processing for Oracle XML DB Servlets
Session Pool and Oracle XML DB Servlets
Native XML Stream Support
Oracle XML DB Servlet APIs
Oracle XML DB Servlet Example
Installing the Oracle XML DB Example Servlet
Configuring the Oracle XML DB Example Servlet
Testing the Example Servlet
33
Using Native Oracle XML DB Web Services
Overview of Native Oracle XML DB Web Services
Configuring and Enabling Web Services for Oracle XML DB
Configuring Web Services for Oracle XML DB
Enabling Web Services for Specific Users
Querying Oracle XML DB Using a Web Service
Accessing PL/SQL Stored Procedures Using a Web Service
Example of Using a PL/SQL Function With a Web Service
Part VI Oracle Tools that Support Oracle XML DB
34
Administering Oracle XML DB
Installing and Reinstalling Oracle XML DB
Installing or Reinstalling Oracle XML DB From Scratch
Installing a New Oracle XML DB With Database Configuration Assistant
Dynamic Protocol Registration of FTP and HTTP(S) Services with Local Listener
Installing Oracle XML DB Manually Without DBCA
Post-Installation
Reinstalling Oracle XML DB
Upgrading an Existing Oracle XML DB Installation
Validation of ACL Documents and Configuration File
Using Oracle Enterprise Manager to Administer Oracle XML DB
Configuring Oracle XML DB Using xdbconfig.xml
Oracle XML DB Configuration File, xdbconfig.xml
<xdbconfig> (Top-Level Element)
<sysconfig> (Child of <xdbconfig>)
<userconfig> (Child of <xdbconfig>)
<protocolconfig> (Child of <sysconfig>)
<httpconfig> (Child of <protocolconfig>)
<servlet> (Descendant of <httpconfig>)
Oracle XML DB Configuration File Example
Oracle XML DB Configuration API
Configuring Default Namespace to Schema Location Mappings
Configuring XML File Extensions
35
Loading XML Data Using SQL*Loader
Overview of Loading XMLType Data Into Oracle Database
Using SQL*Loader to Load XMLType Data
Using SQL*Loader to Load XMLType Data in LOBs
Loading LOB Data in Predetermined Size Fields
Loading LOB Data in Delimited Fields
Loading XML Columns Containing LOB Data from LOBFILEs
Specifying LOBFILEs
Using SQL*Loader to Load XMLType Data Directly From the Control File
Loading Very Large XML Documents into Oracle Database
36
Exporting and Importing XMLType Tables
Overview of Oracle Data Pump
EXPORT/IMPORT Support in Oracle XML DB
Exporting XML Schema-Based XMLType Tables
Exporting Hierarchy-Enabled (Repository) Tables
Exporting and Importing Transportable Tablespaces
Repository Resources and Foldering Support
Full Database Export
Exporting and Importing with Different Character Sets
Export/Import Syntax and Examples
Performing a Table-Mode Export /Import
Performing a Schema-Mode Export/Import
37
Exchanging XML Data with Oracle Streams AQ
How Do AQ and XML Complement Each Other?
AQ and XML Message Payloads
AQ Enables Hub-and-Spoke Architecture for Application Integration
Messages Can Be Retained for Auditing, Tracking, and Mining
Advantages of Using AQ
Oracle Streams and AQ
Streams Message Queuing
XMLType Attributes in Object Types
Internet Data Access Presentation (iDAP)
iDAP Architecture
XMLType Queue Payloads
Guidelines for Using XML and Oracle Streams Advanced Queuing
Storing Oracle Streams AQ XML Messages with Many PDFs as One Record?
Adding New Recipients After Messages Are Enqueued
Enqueuing and Dequeuing XML Messages?
Parsing Messages with XML Content from Oracle Streams AQ Queues
Preventing the Listener from Stopping Until the XML Document Is Processed
Using HTTPS with AQ
Storing XML in Oracle Streams AQ Message Payloads
Comparing iDAP and SOAP
Part VII Appendixes
A
Oracle-Supplied XML Schemas and Examples
XDBResource.xsd: XML Schema for Oracle XML DB Resources
XDBResource.xsd
XDBResConfig.xsd: XML Schema for Resource Configuration
XDBResConfig.xsd
acl.xsd: XML Schema for Oracle XML DB ACLs
ACL Representation XML Schema, acl.xsd
acl.xsd
xdbconfig.xsd: XML Schema for Configuring Oracle XML DB
xdbconfig.xsd
xdiff.xsd: XML Schema for Comparing Schemas for In-Place Evolution
xdiff.xsd
Purchase-Order XML Schemas
XSL Style Sheet Example, PurchaseOrder.xsl
Loading XML Using C (OCI)
Initializing and Terminating an XML Context (OCI)
B
Oracle XML DB Restrictions
Index