Skip Headers

Oracle® Application Developer's Guide - XML 10g (9.0.4) Part Number B12099-01 |
Home | Contents | Index

# 1
Oracle XML-Enabled Technology

This chapter describes the following sections:

- What is XML?

- Storing and Retrieving XML Data from Oracle

- XML Support in the Database

- Oracle-Based XML Applications

- Oracle XML-Enabled Technology Components and Features

- The Oracle Suite of Integrated Tools and Components

- Oracle XML Samples and Demos

- What Is Needed to Run Oracle XML Components

- XML Technical Support

## What is XML?

Appendix A, "An XML Primer", provides some introductory information about XML, the W3C XML recommendations, differences between HTML and XML, and other XML syntax topics. It also discusses reasons why XML, the internet standard for information exchange is such an appropriate and necessary language to use in database applications.

### What are Oracle XML-Enabled Technologies?

XML models structured and semi-structured data. Oracle supports structured and semi-structured data, as well as complex and unstructured data. Oracle Database is XML-enabled in that it natively handles the storage, query, presentation, and manipulation of XML data.

### Oracle XML Components

Figure 1-1 shows the Oracle XML components in the "XML application" box. Oracle XML components are comprised of the following:

- Database XML support

  - `XMLType` - a new datatype to store, query, and retrieve XML documents

  - `SYS_XMLGEN` - SQL function to create XML documents

  - `SYS_XMLAGG` - SQL function to aggregate multiple XML documents

  - `DBMS_XMLGEN` - a built-in package to create XML from SQL queries

  - URI support - store and retrieve global and intra-database references

  - Text support - Supports XPath on `XMLType` and text columns

- XML Developer's Kit (XDK) for Java

  - XML Parser for Java and XSLT Processor

  - XML Schema Processor for Java

  - XML Class Generator for Java

  - XSQL Servlet

  - XML SQL Utility (XSU) for Java

- XDK for Java Beans

  - XML Transviewer Beans

    - DOMBuilder Bean

    - XSLTransformer Bean

    - DBAccessBean

    - TreeViewer Bean

    - SourceViewer Bean

    - XMLTransformPanel Bean

    - DBViewer Bean

- XDK for C

  - XML Parser for C

  - XML Schema Processor for C

- XDK for C++

  - XML Parser for C++

  - XML Schema Processor for C++

  - XML Class Generator for C++

- XDK for PL/SQL

  - XML Parser for PL/SQL

  - XML SQL Utility (XSU) for PL/SQL

Figure 1-1 also lists some typical XML-based business solutions:

- Business Data Exchanges with XML

  - Buyer-Supplier Transparent Trading Automation

  - Seamless integration of partners and HTTP-based data exchange

  - Database inventory access and integration of commercial transactions and flow

  - Self-service procurement, such as using Oracle iProcurement

  - Data mining and reporting with Oracle Discoverer 3i Viewer

  - Oracle Exchange and Applications

  - Phone number portability

- Content and Document Management with XML

  - Personalized publishing and portals

  - Customized presentation. Dynamic News case study, Portal-to-Go, and Flight Finder

#### Figure 1-1 Oracle XML Components and E-Business Solutions: What's Involved

Text description of the illustration adxml033.gif

Figure 1-1 also shows the following:

#### Oracle Development Tools and Frameworks

XSQL Servlet and Pages, Oracle Internet File System (iFS), JDeveloper, Business Components for Java (BC4J), Oracle Portal (WebDB), Oracle Application Server Reports Services, and Oracle Dynamic Services can all be used to build XML applications.

Note: XSQL Servlet and Pages are part of the Oracle XDK for Java.

#### Database and Middle Tier

XML applications, such as Oracle Application Server, Apache Server, or other Java-enabled Web servers can either reside on the database or on a middle tier.

#### Data Stored in the Database

Data is stored as relational tables utilizing object views or as XML documents in `XMLType` columns and CLOBs. Oracle Text (interMedia Text) can be used to efficiently search XML documents stored in `XMLType` or CLOB columns.

## Storing and Retrieving XML Data from Oracle

XML has emerged as the standard for data interchange on the Web and Oracle is XML-enabled to natively store, search, and retrieve XML in the following formats:

- As decomposed XML documents. That is, when the XML documents are stored in their constituent fragments. Here the XML data is stored in object relational form and you can use XML SQL Utility (XSU) or SQL functions and packages to generate the whole (composed) XML documents from these object relational instances.

  You can also use XSU or SQL functions, such as `Extract()`, and `TABLE` functions, to convert the XML back to its object relational (decomposed) form.

- As composed, or "whole" XML documents. Store XML data in `XMLType` or CLOB/BLOB columns and use `XMLType` functions such as `Extract()` and `ExistsNode()` or Oracle Text indexing to search these documents.

## XML Support in the Database

Oracle Database provides the following XML support:

- Generation of XML Documents. Oracle supports the generation of XML on the client or server, where existing object-relational data can be used to generate the corresponding XML. XML can be generated from query results or as part of the SQL query itself using the XSU (XML SQL Utility) Java or PL/SQL API.

  In this release, Oracle extends the XML support in the server:

  - By providing new SQL functions for XML generation and aggregation

  - By providing a C version of the XML SQL Utility, linked to the server

- Storage, Querying, and Retrieval of XML documents. Before this release you could use, for example, XSU to store, query, and retrieve XML documents. Now, with this release you can use the new datatype, XMLType.

  `XMLType` stores XML documents as Character Large Objects (CLOBs). Oracle Text (interMedia Text) indexing can then be used to index the `XMLType` columns and query them using the `CONTAINS` operator and an XPath-like syntax. XMLType also supports member functions that can be used to extract fragments from the XML document.

  See Also: Chapter 5, "Database Support for XML", "Indexing XMLType columns" .

### XML and URI Data Types

Oracle provides new types to handle XML and URI data. The Extensible Markup Language (XML) is a standard format developed by the World Wide Web Consortium (W3C) for representing structured and un-structured data on the Web.

URIs or Universal Resource Identifiers are used to identify resources such as web pages anywhere on the web. Oracle provides a new class of URIs to access data stored in the database itself, called DBUri-refs. It also provides a new set of types to store and access both external and internal URIs from the database.

#### XMLType

The Oracle supplied type, `XMLType`, can be used to store and query XML data in the database.`XMLType` provides member functions to access, extract and query the XML data using XPath expressions. XPath is another standard developed by the W3C committee to traverse XML documents. `XMLType` functions only support a limited subset of the XPath expressions. Oracle also provides a set of SQL functions such as `SYS_XMLGEN,SYS_XMLAGG,` and other PL/SQL packages (`DBMS_XMLGEN`) to create these `XMLType` values from existing relational or object relational data.

`XMLType`, a system defined type, can be used as arguments to functions or as table or view columns. When you create a `XMLType` column in a table Oracle internally uses a CLOB to actually store the XML data associated with this column. You can create Oracle Text indexing on the `XMLType` column and other functional indexes. In Oracle Database, since the `XMLType` is stored as a CLOB, updates can only be made to the entire document.

See Also: Chapter 5, "Database Support for XML" Chapter 8, "Searching XML Data with Oracle Text" Chapter 9, "Exchanging XML Data Using Oracle AQ" Oracle9i Application Developer's Guide - Advanced Queuing, or information about using XMLType with Oracle Advanced Queuing

#### URI Data Types

Oracle supplies the following family of Uri types:

- `UriType`

- `DBUriType`

- `HttpUriType`

These are related by an inheritance hierarchy. `UriType` is an abstract type and the`DBUriType` and `HttpUriType` are subtypes of this type.

- `HttpUriType` can be used to store URLs to external web pages or files. It accesses these files using the HTTP protocol (Hyper Text Transfer Protocol).

- `DBUriType` can be used to store DBUri-refs which reference data inside the database.

Since `UriType` is the super type, you can create columns of this type and store `DBUriType` or `HttpUriType` instances in this column. This allows you to reference data stored inside or outside the database and access them consistently.

DBUri-ref uses an XPath like representation to reference data inside the database. If you imagine the database as a XML tree, then you would see the tables, rows and columns as elements in the XML document. For instance, user `scott` would see a tree such as:

      <SCOTT>
        <EMP>
          <ROW>
            <EMPNO>2100</EMPNO>
            <ENAME>John</ENAME>
            <SALARY>10000</SALARY>
            .. <!-- other columns -->
          </ROW>
          ... <!-- other rows -->
        </EMP>
        <!-- other tables..-->
      </SCOTT>
      <!-- other user schemas on which you have some privilege on..-->

DBUri-ref is simply an XPath expression over this virtual XML document. So to reference the `SALARY` value in the `EMP` table for the employee with employee number `2100`, you can write a DBUri-ref as:

    /SCOTT/EMP/ROW[EMPNO=2100]/SALARY

Using this, you can reference data stored in CLOBs or other columns and expose them as URLs to the external world. Oracle provides a standard servlet than can be installed and run under the Oracle Servlet engine which can interpret such URLs.

See Also: Chapter 6, "Database Uri-references"

### Extensibility and XML

Oracle's extensibility enables special indexing on XML, including Oracle Text indexes for section searching, special operators to process XML, aggregation of XML, and special optimization of queries involving XML.

### Oracle Text Searching

XML text stored in LOBs can be indexed using the extensibility indexing interface. Oracle provides operators such as `CONTAINS` and `WITHIN` that you can use to search within the XML text for substring matches.

See Also: Chapter 2, "Modeling and Design Issues for Oracle XML Applications". Chapter 8, "Searching XML Data with Oracle Text"

## Oracle-Based XML Applications

There are many potential uses of XML in Internet applications. This manual focuses on the following two database-centric application areas where Oracle's XML components are well suited.

#### Content and Document Management

Content and document management includes customizing data presentation. These applications typically process mostly authored XML documents. Several case studies are described in the manual.

See: "Customizing Content with XML: Dynamic News Application" "OracleAS Wireless Edition and XML" "Customizing Presentation with XML and XSQL: Flight Finder"

#### Business-to-Business (B2B) or Business-to-Consumer (B2C) Messaging

B2B and B2C messaging involves exchanging data between business applications. These applications typically process generated XML documents or a combination of generated and composed XML documents.

See: These B2B Chapters: Chapter 9, "Exchanging XML Data Using Oracle AQ"

### When to Use Oracle XML Components: How They Work Together

For descriptions of the Oracle XML components and how they work together see Chapter 2, "Modeling and Design Issues for Oracle XML Applications" and Chapter 3, "Oracle XML Developer Kits (XDKs) and Components: Overview and General FAQs".

The remaining sections of this manual, describe how to use the Oracle XML components, Oracle development tools, and how to build Web-based, database applications with these tools.

## Oracle XML-Enabled Technology Components and Features

Oracle Database is well-suited for building XML database applications. Oracle XML-enabled technology has the following features:

- Indexing and Searching XML Documents with Oracle Text (interMedia Text)

- Messaging Hubs and Middle Tier Components

- Back-End to Database to Front-End Integration Issues

- Oracle XDKs Provide the Two Most Common APIs: DOM and SAX

- The Oracle Suite of Integrated Tools and Components

- Oracle XML Samples and Demos

### Indexing and Searching XML Documents with Oracle Text (interMedia Text)

Oracle Text (interMedia Text) provides powerful search and retrieval options for XML stored in CLOBs and other documents. It can index and search XML documents and document sections as large as 4 Gigabytes each stored in a column in a table.

Oracle Text XML document searches include hierarchical element containership, doctype discrimination, and searching on XML attributes. These XML document searches can be used in combination with standard SQL query predicates or with other powerful lexical and full-text searching options.

XML documents or document sections saved into text CLOBs in the database can be enabled for indexing by Oracle Text's text-search engine. Developers can pinpoint searches to data within a specific XML hierarchy as well as locate name-value pairs in attributes of XML elements.

Since Oracle Text is seamlessly integrated into the database and the SQL language, developers can easily use SQL to perform queries that involve both structured data and indexed document sections.

See Also: Chapter 8, "Searching XML Data with Oracle Text" Oracle9i Text Reference

### Messaging Hubs and Middle Tier Components

Also included in Oracle XML are the following components:

- XML-Enabled Messaging Hubs. These hubs are vital in business-to-business applications that interface with non-Oracle systems. See also Chapter 9, "Exchanging XML Data Using Oracle AQ".

- Middle Tier Systems: XML-enabled application, web, or integrated servers, such as Oracle Integration Server (OIS) and Oracle Application Server.

#### Oracle JVM (Java Virtual Machine)

Built from the ground up on Oracle Multi-threaded Server (MTS) architecture, Oracle JVM (Jserver) is a Java 1.2 compliant virtual machine that data server shares memory address space. This allows the following:

- Java and XML-processing code to run with in-memory data access speeds using standard JDBC interfaces.

- Natively compile Java byte codes to improve performance of server-side Java, with linear scalability to thousands of concurrent users. Oracle XDK components are pre-loaded and natively compiled.

Oracle JVM supports native CORBA and EJB standards as well as Java Stored Procedures for easy integration of Java with SQL and PL/SQL.

#### Oracle Application Server

Oracle Application Server (OracleAS), offers services for both intranet and internet Web applications. It is integrated with Oracle and offers advanced services such as data caching and Oracle Portal. OracleAS also provides other services including Oracle Advanced Queueing, Oracle Message Broker, Oracle Workflow, Oracle Reports Services, Dynamic Services, and more.

See Also: http://otn.oracle.com/products/

### Back-End to Database to Front-End Integration Issues

A key development challenge is integrating back-end ERP and CRM systems from multiple vendors, with systems from partners in their supply chain, and with customized data warehouses.

Such data exchange between different vendors' relational and object-relational databases is simpler using XML.

Oracle XML Technology and Oracle XML-enabled tools, interfaces, and servers provide building blocks for most data and application integration challenges.

#### Higher Performance Implications

Not only are these building blocks available, but their use results in higher performance implementations for the following reasons:

- Processing database data and XML together on the same server helps eliminate network traffic for data access.

- Exploiting the speed of the Oracle query engine and Oracle JVM, Oracle Application Server, or OIS further enhances data access speed.

- XDK for C components can be used for their native XML capabilities and higher performance

Hence developers can build XML-based Web solutions that integrate Java and database data and facilities in many ways.

### Oracle XDKs Provide the Two Most Common APIs: DOM and SAX

Oracle XDKs are implemented in four languages, Java, C, C++, and PL/SQL. The Java version runs directly on Oracle JVM (Java virtual machine). It supports the XML 1.0 specification and is used as a validating or non-validating parser.

The parser provides the two most common APIs that developers need for processing XML documents:

- DOM 1.0 and 2.0: W3C-recommended Document Object Model (DOM) interface. This provides a standard way to access and edit a parsed document's element contents.

- SAX 1.0 and 2.0: Simple API for XML interface.

For more information, see Chapter 20, "Using XML Parser for Java"". See Appendix B, "Comparing Oracle XML Parsers and Class Generators by Language", for a comparison of the Oracle XML parsers and generators.

### Writing Custom XML Applications

Writing custom applications that process XML documents can be simpler in an Oracle environment. This enables you to write portable standards-based applications and components in your language of choice that can be deployed on any tier.

The XML parser is part of the Oracle Database platform on every operating system where Oracle Database is ported.

Oracle XML Parser is also implemented in PL/SQL. Existing PL/SQL applications can be extended to take advantage of Oracle XML technology.

## The Oracle Suite of Integrated Tools and Components

Oracle provides an integrated suite of tools and components for building e-business applications:

- Oracle JDeveloper and Oracle Business Components for Java (BC4J)

- Oracle Internet File System

- Oracle Portal

- Oracle Exchange

This suite of tools ensure that exchanging data and document objects is simplified for application development and that multiple serializations is eliminated.

### Oracle JDeveloper and Oracle Business Components for Java (BC4J)

Oracle JDeveloper is an integrated environment for building, deploying, and debugging applications leveraging Java and XML on Oracle. It facilitates working in Java 1.1 or 1.2 with CORBA, EJB, and Java Stored Procedures. With it you can do the following:

- Directly access Oracle XML components to build multitier applications

- Quickly create and debug Java Servlets that serve XML information

- Build portable application logic with JDeveloper and BC4J components

Examples of applications built using Oracle JDeveloper include:

- iProcurement (Self Service Applications) including Self-Service Web-Expensing.

- Online Marketplaces

See Chapter 11, "Using JDeveloper to Build Oracle XML Applications" for more information on JDeveloper and XML applications.

##### Oracle Business Components for Java (BC4J)

Business Components for Java (BC4J) is an Oracle application framework for encapsulating business logic into reusable libraries of Java components and reusing the business logic through flexible, SQL-based views of information.

Note: Oracle JDeveloper and BC4J are not included with Oracle. Only the BC4J runtime is included. You can download JDeveloper from OTN.

### Oracle Internet File System

Access to Oracle Internet File System (iFS) facilitates organizing and accessing documents and data using a file- and folder-based model through standard Windows and Internet protocols such as SMB, HTTP, FTP, SMTP, and IMAP4.

iFS facilitates building and administering Web-based applications. It is an application interface for Java and can load a document, such as a Powerpoint file, into Oracle and display the document from a Web server, such as Oracle Application Server or Apache Web Server.

iFS is a simple way for developers to work with XML, where iFS serves as the repository for XML. iFS automatically parses XML and stores content in tables and columns. iFS renders the content when a file is requested delivering select information, for example, on the Web.

For more information see `http://otn.oracle.com/products/ifs/`

### Oracle Portal

Oracle Portal can, for example, input XML-based Rich Site Summary (RSS) format documents, and merge the information with an XSL stylesheet. The result can be rendered in a browser. This design efficiently separates the rendition of information from the information itself and allows for easy customization of the look and feel without risk to data integrity.

Oracle Portal is software for building and deploying enterprise portals, the Web sites that power an e-business. The browser interface delivers an organized, personalized view of business information, Web content, and applications needed by each user. It includes site-building and self-service Web publishing functionality of WebDB 2.2 and adds new enterprise portal features such as single sign-on, personalization, and content classification. Oracle Portal uses Oracle Database and is deployed on and packaged with Oracle Application Server.

##### Portlets:

Portlets are reusable interface components that provide access to Web-based resources. Any Web page, application, business intelligence report, syndicated content feed, hosted software service or other resource can be accessed through a portlet, allowing it to be personalized and managed as a service of Oracle Portal. Companies can create their own portlets and select portlets from third-party portlet providers. Oracle provides a Portal Developer's Kit (PDK) for developers to easily create portlets using PL/SQL, Java, HTML, or XML.

See Also: Chapter 15, "Using the PDK for Visualizing XML Data in Oracle Portal" for an introduction to Oracle Portal's PDF and URL Services.

### Oracle Exchange

The Oracle Exchange platform is based on Oracle Database. It offers all necessary business transactions to support an entire industry's or a company's supply chain. Oracle Exchange is based on Oracle's e-Business Suite, which supports a supply chain from the initial contact with the prospect, to manufacturing planning and execution, to post-sales ongoing service and support.

Oracle Exchange uses XML as its data exchange format and message payload, and Advanced Queueing.

See Also: Chapter 16, "How Oracle Exchange Uses XML"

### XML Gateway

XML Gateway is a set of services that allow you to easily integrate with the Oracle e-Business Suite, to create and consume XML messages triggered by business events. It also integrates with Oracle Advanced Queuing to enqueue/dequeue messages which are then transmitted to/from business partners through any message transport service, including Oracle Message Broker.

See Also: Chapter 17, "Introducing Oracle XML Gateway"

### Metadata API

Metadata API provides a centralized, simple, and flexible means for performing the following tasks:

- Extracting complete definitions of database objects (metadata) as either XML or creation DDL

- Transforming metadata via industry-standard XML Stylesheet Transformation language (XSLT).

- Generating SQL DDL to recreate the database objects

Metadata API is available on Oracle Database whenever the instance is operational. It is not available on Oracle Lite.

See Also: Chapter 13, "Using Metadata API"

### Other XML Initiatives

Besides these tools, the following initiatives are underway.

#### XML Metadata Interchange (XMI): Managing and Sharing Tools and Data Warehouse Metadata

Support for XML Metadata Interchange (XMI) specification proposed by Oracle, IBM, and Unisys. This enables application development tools and data warehousing tools from Oracle and others to exchange common metadata, ensuring that you can choose any tool without having to modify your application and warehouse design.

#### Advanced Queueing XML Support: Using the Internet for Reliable, Asynchronous Messaging

Oracle Advanced Queueing (AQ) now allows reliable propagation of asynchronous messages, including messages with XML documents, document sections, or even fragments as their payload, over secure HTTP. This enables dynamic trading and eliminates delays and startup costs to establish inter-company or inter-agency links.

See Also: Chapter 9, "Exchanging XML Data Using Oracle AQ"

## Oracle XML Samples and Demos

This manual contains examples that illustrate the use of Oracle XML components. The examples do not conform to one schema. Where examples are available for download or supplied with the `$ORACLE_HOME/rdbms/demo` or `$ORACLE_HOME/xdk/.../sample`, this is indicated.

## What Is Needed to Run Oracle XML Components

Oracle8i and higher includes native support for internet standards, including Java and XML. You can run Oracle XML components and applications built with them inside the database itself using Oracle JServer, a built-in Java Virtual Machine.

Use Oracle Lite to store and retrieve XML data, for devices and applications that require a smaller database footprint.

Oracle XML components can be downloaded for free from `http://otn.oracle.com/tech/xml`

### Requirements for XDK

The following are requirements for XDK for Java and XDK for PL/SQL:

- XDK for Java requires JDK/JRE 1.1 or high VM for Java

- XDK for PL/SQL requires Oracle8x or higher, or PL/SQL cartridge

Requirements are also discussed in the XDK chapters, chapters 19 through 29, and Appendixes C though G.

### Which XML Components are Included with Oracle Database and Oracle Application Server?

Table 1-1 lists the XDK component versions included with Oracle Database and Oracle Application Server (OracleAS):

##### Table 1-1 Oracle Database and OracleAS XDK Component Supplied Versions

XDK Component | Oracle Database Rel. 10g (9.0.4) | OracleAS Rel.--prellimary version nos. only
--- | --- | ---
XDK for Java | - | -
XML Parser for Java and XSLT Processor | 9.0.1.0.0 | 9.0.1.0.0
XML Schema Processor for Java | 9.0.1.0.0 | 9.0.1.0.0
XML Class Generator for Java | 9.0.1.0.0 | 9.0.1.0.0
XSQL Servlet | 9.0.1.0.0 | 9.0.1.0.0
XML SQL Utility (XSU) for Java | 9.0.1.0.0 | 9.0.1.0.0
XDK for Java Beans | - | -
XML Transviewer Beans | 9.0.1.0.0 | 9.0.1.0.0
XDK for C | - | -
XML Parser for C and XSLT Processor | 9.0.1.0.0 | 9.0.1.0.0
XML Schema Processor for C | 9.0.1.0.0 | 9.0.1.0.0
XDK for C++ | - | -
XML Parser for C++ and XSLT Processor | 9.0.1.0.0 | 9.0.1.0.0
XML Schema Processor for C++ | 9.0.1.0.0 | 9.0.1.0.0
XML Class Generator for C++ | 9.0.1.0.0 | 9.0.1.0.0
XDK for PL/SQL | - | -
XML Parser for PL/SQL and XSLT Processor | 9.0.1.0.0 | 9.0.1.0.0
XML SQL Utility (XSU) for PL/SQL | 9.0.1.0.0 | 9.0.1.0.0

## XML Technical Support

Besides your regular channels of support through your customer representative or consultant, technical support for Oracle XML-enabled technologies is available free through the Discussions option on Oracle Technology Network (OTN):

`http://otn.oracle.com/tech/xml`

You do not need to be a registered user of OTN to post or reply to XML-related questions on the OTN technical discussion forum. To use the OTN technical forum follow these steps:

1. In the left-hand navigation bar, of the OTN site select Support > Discussions.

2. Click on Enter a Technical Forum.

3. Scroll down to the Technologies section. Select XML.

4. Post any questions, comments, requests, or bug reports there.

#### Download the Latest Software From OTN

You will find the latest information about the Oracle XML components and can download them from OTN:

`http://otn.oracle.com/software/`

At the top, under Download Oracle Products, Drivers, and Utilities, in the Select a Utility or Driver pull down menu, scroll down and select any of the XML utilities listed. For the latest XML Parser for Java and C++, select v2.

| Copyright © 2001, 2003 Oracle Corporation. All Rights Reserved. |
Home | Contents | Index