Skip Headers

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

# 3
Oracle XML Developer Kits (XDKs) and Components: Overview and General FAQs

This chapter contains the following sections:

- Oracle XML Components: Overview

- Development Tools and Other XML-Enabled Features

- XML Parsers

- XSL Transformation (XSLT) Processor

- XML Class Generator

- XML Transviewer Java Beans

- Oracle XSQL Page Processor and Servlet

- Oracle XML SQL Utility (XSU)

- Oracle Text

- Oracle XML Components: Generating XML Documents

- Using Oracle XML Components to Generate XML Documents: Java

- Using Oracle XML Components to Generate XML Documents: C

- Using Oracle XML Components to Generate XML Documents: C++

- Using Oracle XML Components to Generate XML Documents: PL/SQL

- Frequently Asked Questions (FAQs): Oracle XML-Enabled Technology

## Oracle XML Components: Overview

This chapter provides an overview of Oracle's XML components.

Oracle provides several components, utilities, and interfaces you can use to take advantage of XML technology in building your Web-based database applications. Which components you use depends on your application requirements, programming preferences, development, and deployment environments.

The following XML components are provided with Oracle and Oracle Application Server:

- XML Developer's Kits (XDKs). There are Oracle XDKs for Java, C, C++, and PL/SQL. These development kits contain building blocks for reading, manipulating, transforming, and viewing XML documents. Oracle XDKs are fully supported and come with a commercial redistribution license. Table 3-1 lists the XDK components.

- XML SQL Utility (XSU). This utility, for Java and PL/SQL: Generates and stores XML data to and from the database from SQL queries or result sets or tables. It achieves data transformation, by mapping canonically any SQL query result to XML and vice versa.

The following figures schematically illustrate how the XDK components can be used to generate XML:

- Figure 3-7, "Generating XML Documents Using XDK for Java"

- Figure 3-8, "Generating XML Documents Using XDK for C"

- Figure 3-9, "Generating XML Documents Using XDK for C++"

- Figure 3-10, "Generating XML Documents Using XDK for PL/SQL"

  ##### Table 3-1 XDK Component Descriptions

  XDK Component | Languages | Description
  --- | --- | ---
  XML Parser | Java, C, C++, PL/SQL | Creates and parses XML using industry standard DOM and SAX interfaces.
  XSLT Processor | Java, C, C++, PL/SQL | Transforms or renders XML into other text-based formats such as HTML and WML
  XML Schema Processor | Java, C, C++ | Allows the use of XML simple and complex datatypes by means of your XML Schema definitions.
  XML Class Generator | Java, C++ | Automatically generates Java and C++ classes from DTDs and XML Schemas to send XML data from Web forms or applications.
  XML Transviewer Java Bean | Java | View and transform XML documents and data via Java components.
  XML SQL Utility (XSU) | Java, PL/SQL | Generates XML documents, DTDs, and XML Schemas from SQL queries.
  XSQL Servlet | Java | Combines XML, SQL, and XSLT in the server to deliver dynamic Web content.

## Development Tools and Other XML-Enabled Features

The following list includes Oracle's XML-enabled development tools:

- Oracle Text (interMedia Text/Context): A querying, search and retrieval tool, described in Chapter 8, "Searching XML Data with Oracle Text".

- Oracle JDeveloper9i and BC4J: JDeveloper9i is an integrated development tool for building Java web-based applications. Oracle Business Components for Java (BC4J) is a Java, XML-powered framework that enables productive development, portable deployment, and flexible customization of multitier, database-savvy applications from reusable business components. These applications can be deployed as CORBA Server Objects or EJB Session Beans on enterprise-scale server platforms supporting Java technology.

  See Also: Chapter 11, "Using JDeveloper to Build Oracle XML Applications" Chapter 12, "Building BC4J and XML Applications"

- Oracle Internet File System (iFS): An application interface in which data can be viewed as documents and the documents can be treated as data.iFS is a simple way for developers to work with XML, where iFS serves as the repository for XML. iFS can perform the following tasks on XML documents:

  - Automatically parse XML and store content in tables and columns

  - Render the XML file's content

    See Also: Oracle9i Case Studies - XML Applications, the chapter, "Using Internet File System (iFS) to Build XML Applications".

- Oracle Reports. Oracle Reports Developer and Reports Server enable you to build and publish high-quality, dynamically generated Web reports. Each major task is expedited by the use of a wizard, while the use of report templates and a live data preview allows for easy customization of the report structure. Reports can be published throughout the enterprise via a standard Web browser, in any chosen format, including HTML, HTML Cascading Style Sheets (HTML CSS), Adobe's Portable Document Format (PDF), delimited text, Rich Text Format (RTF), PostScript, PCL, or XML. Reports can be integrated with Oracle Portal (webDB).

  - You can schedule reports to run periodically and update the information in an Oracle Portal site. Reports can also be personalized for a user.

  - Oracle Reports Developer is part of Oracle's e-business intelligence solution, and integrates with Oracle Discoverer and Oracle Express.

    See Also: Chapter 14, "OracleAS Reports Services and XML"

### XDK for Java

XDK for Java is composed of the following components:

- XML Parser for Java. Creates and parses XML using industry standard DOM and SAX interfaces. Includes an XSL Transformation (XSLT) Processor that transforms XML to XML or other text-based formats, such as HTML.

- XML Schema Processor for Java. Supports simple and complex types and is built on the Oracle XML Parser for Java v2.

- XML Class Generator for Java. Creates source files from an XML DTD or XML Schema definition.

- XSQL Servlet. Processes SQL queries embedded in an XSQL file, xxxx.xsql. Returns results in XML format. Uses XML SQL Utility and XML Parser for Java.

- XML SQL Utility (XSU) for Java. Enables you to transform data retrieved from object-relational database tables or views into XML, extract data from an XML document and:

  - Use canonical mapping to insert data into appropriate columns or attributes of a table or a view

  - Apply this data to update or delete values of the appropriate columns or attributes

### XDK for Java Beans

XDK for Java Beans is composed of the following component:

- XML Transviewer Java Beans. View and transform XML documents and data through Java

### XDK for C

XDK for C is composed of the following component:

- XML Parser for C: Creates and parses XML using industry standard DOM and SAX interfaces. Includes an XSL Transformation (XSLT) Processor that transforms XML to XML or other text-based formats, such as HTML.

### XDK for C++

XDK for C++ is composed of the following:

- XML Parser for C++. Creates and parses XML using industry standard DOM and SAX interfaces. Includes an XSL Transformation (XSLT) Processor that transforms XML to XML or other text-based formats, such as HTML.

- XML Schema Processor for C++. A companion component to XML Parser for C++. It allows support for simple and complex datatypes in XML applications with Oracle Database. The Schema Processor supports the XML Schema Working Draft.

- XML C++ Class Generator: Creates source files from an XML DTD or XML Schema definition.

### XDK for PL/SQL

XDK for PL/SQL is composed of the following:

- XML Parser for PL/SQL: Creates and parses XML using industry standard DOM and SAX interfaces. Includes an XSL Transformation (XSLT) Processor that transforms XML to XML or other text-based formats, such as HTML.

- XML SQL Utility (XSU) for PL/SQL. Enables you to transform data retrieved from object-relational database tables or views into XML, extract data from an XML document and:

  - Use canonical mapping to insert data into appropriate columns or attributes of a table or a view

  - Apply this data to update or delete values of the appropriate columns or attributes

## XML Parsers

The Oracle XML parser includes implementations in C, C++, PL/SQL, and Java for the full range of platforms on which Oracle Database runs.

Based on conformance tests, `xml.com` ranked the Oracle parser in the top two validating parsers for its conformance to the XML 1.0 specification, including support for both SAX and DOM interfaces. The SAX and DOM interfaces conform to the W3C recommendations 2.0.

Version 2 (v2) of the Oracle XML parser provides integrated support for the following features:

- XPath. XPath is the W3C recommendation that specifies the data model and grammar for navigating an XML document utilized by XSLT, XLink and XML Query

- Incremental XSL transformation of document nodes. XSL transformations are compliant with version 1.0 of the W3C recommendations. This support enables the following:

  - Transformations of XML documents to another XML structure

  - Transformations of XML documents to other text-based formats

The parsers are available on all Oracle platforms.

Figure 3-1 illustrates the Oracle XML Parser for Java. Figure 3-2 illustrates the Oracle XML parsers' overall functionality.

See Also: Chapter 20, "Using XML Parser for Java" and Appendix C, "XDK for Java: Specifications and Cheat Sheets".

#### Figure 3-1 Oracle XML Parser for Java

Text description of the illustration adxml002.gif

#### Figure 3-2 The XML Parsers: Java, C, C++, PL/SQL

Text description of the illustration adxml001.gif

## XSL Transformation (XSLT) Processor

The Oracle XSLT engine fully supports the W3C 1.0 XSL Transformations recommendation. It has the following features:

- Enables standards-based transformation of XML information inside and outside the database on any platform.

- Supports Java extensibility and for additional performance comes natively compiled from Oracle8i Release 3 (8.1.7) and higher.

The Oracle XML Parsers, Version 2 include an integrated XSL Transformation (XSLT) Processor for transforming XML data using XSL stylesheets. Using the XSLT processor, you can transform XML documents from XML to XML, HTML, or virtually any other text-based format.

How to use the XSLT Processor is described in Chapter 20, "Using XML Parser for Java".

See Also: Appendix C, "XDK for Java: Specifications and Cheat Sheets".

## XML Class Generator

XML Class Generator creates a set of Java or C++ classes for creation of XML documents corresponding to an input DTD or XML Schema. Figure 3-3 shows Oracle XML Class Generator functionality.

How to use the XML Class Generators is described in the following chapters:

- Chapter 22, "XML Class Generator for Java"

- Chapter 28, "Using XML C++ Class Generator"

#### Figure 3-3 Oracle XML Java Class Generator

Text description of the illustration adxml003.gif

## XML Transviewer Java Beans

Oracle XML Transviewer Java Beans are a set of XML components that constitute XML for Java Beans. These are used for Java applications or applets to view and transform XML documents.

They are visual and non-visual Java components that are integrated into Oracle JDeveloper to enable the fast creation and deployment of XML-based database applications. In this release, the following four beans are available:

- DOM Builder Bean. This wraps the Java XML (DOM) parser with a bean interface, allowing multiple files to be parsed at once (asynchronous parsing). By registering a listener, Java applications can parse large or successive documents having control return immediately to the caller.

- XML Source Viewer Bean. This bean extends JPanel by enabling the viewing of XML documents. It improves the viewing of XML and XSL files by color-highlighting XML and XSL syntax. This is useful when modifying an XML document with an editing application. Easily integrated with the DOM Builder Bean, it allows for pre-parsing and post-parsing and validation against a specified DTD.

- XML Tree Viewer Bean. This bean extends JPanel by enabling viewing XML documents in tree form with the ability to expand and collapse XML parsers. It displays a visual DOM view of an XML document, enabling users to easily manipulate the tree with a mouse to hide or view selected branches.

- XSL Transformer Bean. This wraps the XSLT Processor with a bean interface and performs XSL transformations on an XML document based on an XSL stylesheet. It enables users to transform an XML document to almost any text-based format including XML, HTML and DDL, by applying an XSL stylesheet. When integrated with other beans, this bean enables an application or user to view the results of transformations immediately. This bean can also be used as the basis of a server-side application or servlet to render an XML document, such as an XML representation of a query result, into HTML for display in a browser.

- XML TransPanel Bean. This bean uses the other beans to create a sample application which can process XML files. This bean includes a file interface to load XML documents and XSL stylesheets. It uses the beans as follows:

  - Visual beans to view and edit files

  - Transformer bean to apply the stylesheet to the XML document and view the output

- DBAccess Bean.

- DBViewer Bean.

As standard Java Beans, they can be used in any graphical Java development environment, such as Oracle JDeveloper. The Oracle XML Transviewer Beans functionality is described in Chapter 23, "Using XML Transviewer Beans".

## Oracle XSQL Page Processor and Servlet

XSQL Servlet is a tool that processes SQL queries and outputs the result set as XML. This processor is implemented as a Java servlet and takes as its input an XML file containing embedded SQL queries. It uses XML Parser for Java, XML- SQL Utility, and Oracle XSL Transformation (XSLT) Engine to perform many of its operations.

You can use XSQL Servlet to perform the following tasks:

- Build dynamic XML datapages from the results of one or more SQL queries and serve the results over the Web as XML datagrams or HTML pages using server-side XSLT transformations.

- Receive XML posted to your web server and insert it into your database.

### Servlet Engines that Support XSQL Servlet

XSQL Servlet has been tested with the following servlet engines:

- Allaire JRun 2.3.3

- Apache 1.3.9 with JServ 1.0 and 1.1

- Apache 1.3.9 with Tomcat 3.1 Beta1 Servlet Engine

- Apache Tomcat 3.1 Beta1 Web Server + Servlet Engine

- Caucho Resin 1.1

- NewAtlanta ServletExec 2.2 for IIS/PWS 4.0

- Oracle9i Lite Web-to-Go Server

- Oracle Application Server 4.0.8.1 (with JSP Patch)

- Oracle8i 8.1.7 Beta Aurora and Oracle9i Servlet Engine and higher

- Sun JavaServer Web Development Kit (JSWDK) 1.0.1 Web Server

### JavaServer Pages Platforms that Support XSQL Servlet

JavaServer Pages can use `<jsp:forward>` or `<jsp:include>` to collaborate with XSQL Pages as part of an application. The following JSP platforms have been tested to support XSQL Servlet:

- Apache 1.3.9 with Tomcat 3.1 Beta1 Servlet Engine

- Apache Tomcat 3.1 Beta1 Web Server + Tomcat 3.1 Beta1 Servlet Engine

- Caucho Resin 1.1 (Built-in JSP 1.0 Support)

- NewAtlanta ServletExec 2.2 for IIS/PWS 4.0 (Built-in JSP 1.0 Support)

- Oracle9i Lite Web-to-Go Server with Oracle JSP 1.0

- Oracle8i 8.1.7 Beta Aurora and Oracle9i Servlet Engine with Oracle JSP 1.0 and higher

- Any Servlet Engine with Servlet API 2.1+ and Oracle JSP 1.0

In general, it should work with the following:

- Any servlet engine supporting the Servlet 2.1 specification or higher

- Oracle JSP 1.0 reference implementation or functional equivalent from another vendor

XSQL Servlet is a tool that processes SQL queries and outputs the result set as XML. This processor is implemented as a Java servlet and takes as its input an XML file containing embedded SQL queries. It uses XML Parser for Java and XML SQL Utility to perform many of its operations.

Figure 3-4 shows how data flows from a client, to the servlet, and back to the client. The sequence of events is as follows:

1. The user enters a URL through a browser, which is interpreted and passed to the XSQL Servlet through a Java Web Server. The URL contains the name of the target XSQL file (.xsql) and optionally, parameters, such as values and an XSL stylesheet name. Alternatively, the user can invoke the XSQL Servlet from the command line, bypassing the browser and Java web server.

2. The servlet passes the XSQL file to the XML Parser for Java, which parses the XML and creates an API for accessing the XML contents.

3. The page processor component of the servlet uses the API to pass XML parameters and SQL statements (found between `<query></query>` tags) to XML SQL Utility. The page processor also passes any XSL processing statements to the XSLT Processor.

4. XML SQL Utility sends the SQL queries to the underlying Oracle Database, which returns the query results to the utility.

5. XML SQL Utility returns the query results to the XSLT Processor as XML formatted text. Results are embedded in the XML file in the same location as the original `<query>` tags.

6. If desired, the query results and any other XML data are transformed by the XSLT processor using a specified XSL stylesheet. The data can be transformed to HTML or any other format defined by the stylesheet. The XSLT processor can selectively apply different stylesheets based on the type of client that made the original URL request. This `HTTP_USER_AGENT` information is obtained from the client through an HTTP request.

7. The XSLT Processor passes the completed document back to the client browser for presentation to the user.

   See Also: Chapter 10, "XSQL Pages Publishing Framework"

#### Figure 3-4 Oracle XSQL Page Processor and Servlet Functional Diagram

Text description of the illustration adxml017.gif

## Oracle XML SQL Utility (XSU)

Oracle XML SQL Utility (XSU) supports Java and PL/SQL.

- XML SQL Utility is comprised of core Java class libraries for automatically and dynamically rendering the results of arbitrary SQL queries into canonical XML. It includes the following features:

  - Supports queries over richly-structured user-defined object types and object views.

  - Supports automatic XML Insert of canonically-structured XML into any existing table, view, object table, or object view. By combining with XSLT transformations, virtually any XML document can be automatically inserted into the database.

  XML SQL Utility Java classes can be used for the following tasks:

  - Generate from an SQL query or Result set object a text or XML document, a Document Object Model (DOM), Document Type Definition (DTD), or XML Schema.

  - Load data from an XML document into an existing database schema or view.

- XML SQL Utility for PL/SQL is comprised of a PL/SQL package that wraps the XML SQL Utility for Java.

Figure 3-5 shows the Oracle XML SQL Utility overall functionality.

#### Figure 3-5 Oracle XML SQL Utility Functional Diagram

Text description of the illustration adxml012.gif

XML SQL Utility for Java consists of a set of Java classes that perform the following tasks:

- Pass a query to the database and generate an XML document (text or DOM) from the results or the DTD which can be used for validation.

  - Write XML data to a database table

    See Also: Chapter 7, "XML SQL Utility (XSU)"

### Generating XML from Query Results

Figure 3-6 shows how XML SQL Utility processes SQL queries and returns the results as an XML document.

#### Figure 3-6 XMl-SQL Utility Processes SQL Queries and Returns the Result as an XML Document

Text description of the illustration adxml004.gif

### XML Document Structure: Columns Are Mapped to Elements

The structure of the resulting XML document is based on the internal structure of the database schema that returns the query results:

- Columns are mapped to top level elements

- Scalar values are mapped to elements with text-only content

- Object types are mapped to elements with attributes appearing as sub-elements

- Collections are mapped to lists of elements

#### XSU Generates the XML Document as a String or DOM Element Tree

The XML SQL Utility (XSU) generates either of the following:

- A string representation of the XML document. Use this representation if you are returning the XML document to a requester.

- An in-memory XML DOM tree of elements. Use this representation if you are operating on the XML programmatically, for example, transforming it using the XSLT Processor using DOM methods to search or modify the XML in some way.

#### XSU Generates a DTD Based on Queried Table's Schema

You can also use the XML SQL Utility (XSU) to generate a DTD based on the schema of the underlying table or view being queried. You can use the generated DTD as input to the XML Class Generator for Java or C++. This generates a set of classes based on the DTD elements. You can then write code that uses these classes to generate the infrastructure behind a Web-based form. See also "XML Class Generator".

Based on this infrastructure, the Web form can capture user data and create an XML document compatible with the database schema. This data can then be written directly to the corresponding database table or object view without further processing.

See Also: Chapter 7, "XML SQL Utility (XSU)" and Oracle9i Case Studies - XML Applications, the chapter, "B2B XML Application: Step by Step", for more information about this approach.

Note: To write an XML document to a database table, where the XML data does not match the underlying table structure, transform the XML document before writing it to the database. For techniques on doing this, see Chapter 7, "XML SQL Utility (XSU)".

## Oracle Text

Oracle Text (interMedia Text) extends Oracle Database by indexing any text or documents stored in Oracle. Use Oracle Text to perform searches on XML documents stored in Oracle by indexing the XML as plain text, or as document sections for more precise searches, such as find `Oracle WITHIN title` where `title` is a section of the document.

JDeveloper

See Also: Chapter 8, "Searching XML Data with Oracle Text", for more information on using Oracle Text and XML.

## Oracle XML Components: Generating XML Documents

Figure 3-7 through Figure 3-10 illustrate the relationship of the Oracle XML components and how they work together to generate XML documents from Oracle via a SQL query. The options are depicted according to language used:

- Java

- C

- C++

- PL/SQL

## Using Oracle XML Components to Generate XML Documents: Java

Figure 3-7 shows the Oracle XML Java components and how they can be used to generate an XML document. Available XML Java components are:

- XDK for Java:

  - XML Parser for Java, Version 2 including the XSLT

  - XMl Schema Processor for Java

  - XML Class Generator for Java

  - XSQL Servlet

  - XML Transviewer Beans

- XML SQL Utility (XSU) for Java

In the Java environment, when a user or client or application sends a query (SQL), there are three possible ways of processing the query using the Oracle XML components:

- By the XSL Servlet (this includes using XSU and XML Parser)

- Directly by the XSU (this includes XML Parser)

- Directly by JDBC which then accesses XML Parser

Regardless of which way the stored XML data is generated from the database, the resulting XML document output from the XML Parser is further processed, depending on what you or your application needs it for.

The XML document is formatted and customized by applying stylesheets and processed by the XSLT.

#### Figure 3-7 Generating XML Documents Using XDK for Java

Text description of the illustration adxml006.gif

## Using Oracle XML Components to Generate XML Documents: C

Figure 3-8 shows the Oracle XML C language components used to generate an XML document. The XML components are:

- XML Parser/XSLT Processor for C

- XML Schema Processor for C

SQL queries can be sent to the database via OCI or as embedded statements in the Pro*C precompiler.

The resulting XML data can be processed in the following ways:

- With the XML Parser

- From the CLOB as an XML document

This XML data is optionally transformed by the XSLT processor, viewed directly by an XML-enabled browser, or sent for further processing to an application or AQ Broker.

#### Figure 3-8 Generating XML Documents Using XDK for C

Text description of the illustration adxml029.gif

## Using Oracle XML Components to Generate XML Documents: C++

Figure 3-9 shows the Oracle XML components used to generate an XML document. The XDK for C++ components used here are:

- XML Parser for C++, Version 2 including the XSLT

- XML Schema Processor for C++

- XML Class Generator for C++

In the C++ environment, when a user or client or application sends a SQL query, there are two possible ways of processing the query using the XDK for C++:

- Directly by JDBC which then accesses the XML Parser

- Through OCCI or Pro*C/C++ Precompiler

#### Figure 3-9 Generating XML Documents Using XDK for C++

Text description of the illustration adxml030.gif

## Using Oracle XML Components to Generate XML Documents: PL/SQL

Figure 3-10 shows the XDK for PL/SQL components used to generate an XML document:

- XML Parser for PL/SQL, Version 2 including XSLT

- XML SQL Utility (XSU) for PL/SQL

In the PL/SQL environment, when a user or client or application sends a SQL query, there are two possible ways of processing the query using the Oracle XML components:

- Directly by JDBC which then accesses the XML Parser

- Through XML SQL Utility (XSU)

#### Figure 3-10 Generating XML Documents Using XDK for PL/SQL

Text description of the illustration adxml028.gif

## Frequently Asked Questions (FAQs): Oracle XML-Enabled Technology

This section includes general questions about Oracle XML-enabled technology in the following categories:

- General XDK Questions

- Portability and XML Support in Older Oracle Releases

- Browsers that Support XML

- Standards

- XML, CLOBs, and BLOBs

- Maximum FileSizes

- Inserting XML Data Into Tables

- XML in the Database: Performance

- Using XML With Different Languages

- Further References

There are Frequently Asked Questions at the end of several other chapters in this manual.

## General XDK Questions

### What XML Components Do I Need to Install?

I am going to develop a small application using XML and Oracle. Here is the scenario: Company A has is a central purchasing system with Departments B, C, and D. Company A gets purchase orders in XML format from B, C, and D.

Company A needs to collect all purchase orders and store them in an Oracle database. Then, it has to create another Request for proposal for its preferred vendors in XML. I am writing queries to insert or update into the database. What XML components do I need to install in Oracle?

#### Answer

Assuming you are using Java, you need the XML Parser and XML SQL Utility. If you are using a Java-based front end to generate the purchase orders, then the XML Class Generator can provide you with the classes you need to populate your purchase orders. Finally, the XSQL Servlet can help you build a Web interface.

### Building an XML Application: What Software Is Needed?

I have a CGI-PERL-Oracle7 application on Solaris 2.6 and I want to convert it to XML/XSL-JAVA-Oracle. I know most parts of the technologies, for example, SGML, XML, and JAVA, but I don't know how to start it in Oracle. What software do I need from Oracle? Specifically,

1. Can I use Apache instead of the Oracle Web server? If so, how?

2. How far can I go with Oracle 7.3?

3. Do I still need an XML Parser if all XML was created by my programs?

4. What should be between the Web server and Oracle DB server? XSQL Servlet? Parser? JAVA VM? EJB? CORBA? SQLJ? JDBC? Oracle packages such as `UTL_HTTP`?

#### Answer

1. Yes you can. The Apache web server must now interact with Oracle through JDBC or other means. See the XSQL servlet. This is a servlet that can run on any servlet-enabled Web server. This runs on Apache and connects to the database through a JDBC driver to the Oracle database.

2. How far can you go with Oracle 7.3? You can go a long way. The only problem would be that you cannot run any of the Java programs inside the server, that is, you cannot load all the XML tools into the server. But you can connect to the database by downloading the Oracle JDBC utility for Oracle7 and run all the programs as client-side utilities.

3. Do you still need an XML Parser if all XML was created by your programs? That depends on what you intend to do with the generated XML. If your task is just to generate XML and send it out then you might not need it. But if you wanted to generate an XML DOM tree then you would need the parser. Also, you would need it if you have incoming XML documents and you want to parse and store them somewhere. See the XML SQL utility for some help on this issue.

4. What should be between the Web server and Oracle DB server? As explained before in Answer 1, you would need to have a servlet (or CGI) which interacts to Oracle through OCI or JDBC.

### DTD to Database Schema

Is there a tool that goes from a DTD to a database schema?

#### Answer

Currently we do not have a tool to go from a DTD to a database schema as there is no way to specify datatypes until we have XML Schema. With our XML- SQL Utility available on OTN with our other XML components you can generate a DTD from a database schema which can then be entered into the Class Generator. You should try an approach your solution from that angle since a database is involved. Check out our OTN resource including the XML Discussion Forum for further assistance at `http://otn.oracle.com/tech/xml`

### Schema Map to XML

My project requires converting master-details data to XML for clients.

1. Is there a best way to design tables and generate XML (flat tables, objects, or collections)?

2. Can I use XML SQL Utilities in Pro*C?

3. Is there a limiting size for generating XML documents from database? Can I use Pro*C to call XSU?

#### Answer

1. It really depends on what your application calls for. The generalized approach is to use object views and have the schema define the tag structure with database data as the element content.

2. I am not aware of any limits beyond those imposed by the object view and the underlying table structure.

### Are There XDK Utilities That Translate From Other Formats to XML?

Are there any utilities in the XDK that translate data from a given format to XML? I know that the XSLT will translate from XML to XML, HTML, or another text-based format. What about the other way around?

#### Answer

For HTML, you can use utilities like Tidy or JTidy to turn HTML into well-formed HTML that can be transformed using XSLT. For random text formats, you can try utilities like XFlat at `http://www.unidex.com/xflat.htm`.

### Can Oracle Generate a Database Schema From a Rational Rose Generated XML File?

It is possible to generate database schema in Oracle using a script with `CREATE TABLE`, from an XML file generated by a Rational Rose design tool?

#### Answer

All the parser/generator files (such as petal files, XML, and so on) are developed in our project. All the components are designed for reuse, but developed in the context of a lager framework. You have to follow some guidelines, such as modeling in UML, and you must use the base class to get any benefit from our work.

Oracle only generates object types and delivers full object-oriented features such as inheritance in the persistence layer. If you did not need this, the Rational Rose (Petal-File) parser and Oracle packages as the base of the various generators may interest you.

### Does Oracle Offer Any Tools to Create and Edit XML Documents?

Does Oracle have any tools for creation (based on DTDs or XML Schema Definition DOM) and editing of XML documents with DTD or Schema validation?

#### Answer

JDeveloper9i has an integrated XML Schema-driven code editor for working on XMLSchema-based documents such as XML Schemas and XSLT Stylesheets, with tag-insight to help you easily enter the correct elements and attributes as defined by the schema.

See Also: Chapter 11, "Using JDeveloper to Build Oracle XML Applications"

### How Can I Format XML Documents as PDF?

I have been asked to take stored XML docs in v816 and format them as PDF. We are using JDev 3112 as our development environment and the client wants to stick to OAS 4082 on NT if possible. Any suggestions or recommended resources?

#### Answer

Oracle XSQL Pages v1.0.2 supports integration with Apache FOP 0.14.0 for rendering PDF output from XML/SQL input.

It is possible to format XML into PDF using Formatting Object (FOP). See information on this at: `http://xml.apache.org/fop/` and `http://www.xml.com/pub/rg/75`)

### How Do I Load a Large XML Document Into the Database?

#### Question 1

I have a large (27 MB) data-centric XML document. I could not load it into the database when it was split into relational tables with XML SQL Utility, because the DOM parser failed (memory leak) during the XSLT processor execution. Do you have a workaround for this problem? Should I use SAX Parser? How do I use the XSLT processor and Sax Parser?

#### Answer 1a

If this is a one time load, or if the XML document you get always has the same tags, then you might consider using the SQL*Loader (direct path). All you have to do is compose a loader control file (see the Oracle9i Utilities manual, Chapter 3, for examples). You can use the `enclosed by` option to describe the fields. For example, in the files list you enter something like the following:

    (empno    number(10)    enclosed by "<empno>" and "</empno>",...)

Except for the data parsing which has to be done the same regardless of what you are using, the actual loading into the database will be fastest with SQL*Loader (as the direct path writes data straight to data blocks, bypassing the layers in between).

#### Answer 1b

If the document is 27 MB because it is a very large number of repeating sub-documents, then you can use the sample code that comes in Chapter 14 of the book "Building Oracle XML Applications" by Steve Muench (O'Reilly) to load XML of any size into any number of tables. In Chapter 14, "Advanced XML Loading Techniques", the example builds an XML Loader utility that does what you are looking for.

#### Question 2

Can SQL*Loader handle nesting? That is, what if you have:

    ...
         <something>
            <price>10.00</price>
         </something>
    ...
       ...
          ...
              <somethingelse>
                <price>55.00</price>
              </somethingelse>

Is there a way to uniquely identify the two `<price>` elements?

#### Answer 2

Not really. The field description in the control file can be nested which is part of the support for object relational columns. The data record to which this maps is of course flat but using all the data-field description features of the SQL*Loader one can get a lot done. For example:

sample.xml

    <resultset>
        <emp>
            <first>...</first>
            <last>...</last>
            <middle>....</middle>
        <emp>
        <friend>
            <first>...</first>
            <last>...</last>
            <middle>....</middle>
        </friend>
    </resultset>

`sample.ctl` -- field definition part of the SQL Loader control file

    field list ....
    (
     emp  COLUMN OBJECT ....
       (
            first      char(30)   enclosed by "<first>" and "</first>",
            last      char(30)   enclosed by "<last>" and "</last>",
            middle     char(30)   enclosed by "<middle>" and </middle>"
       )
        friend COLUMN OBJECT ....
      (
            first      char(30)   enclosed by "<first>" and "</first>",
            last      char(30)   enclosed by "<last>" and "</last>",
            middle     char(30)   enclosed by "<middle>" and </middle>"
      )

Keep in mind that the `COLUMN OBJECT` field names have to match the ADT column in the database. Also, you will have to use a custom record terminator, otherwise it defaults to `newline` (that is, at every new line it thinks that is has data for a complete database record).

If your XML is more complex and you are trying to extract only select fields, you can use `FILLER` fields to reposition the scanning cursor, which scans from where it has left off towards the end of the record (or for the first field, from the beginning of the record).

The SQL*Loader has a very powerful text parser so you can do a lot of neat tricks. For loading XML when the document is very big, but consistent in its tags, you should consider it.

See Also: Chapter 2, "Modeling and Design Issues for Oracle XML Applications", "Loading XML into a Database" , for guidelines on loading XML

## Portability and XML Support in Older Oracle Releases

### Can I Use Parsers from Different Vendors?

I am currently investigating SAX. I understand that both the Oracle and IBM parsers use DOM and SAX from W3C.

- What is the difference between the parsers from different vendors like Oracle and IBM?

- If I use the Oracle XML Parser now, and for some reason I decide to switch to parser by other vendor, will I have to change my code?

#### Answer

You will not have to change your code if you stick to SAX interfaces or DOM interfaces for your implementation. That is what the standard interfaces are in place to assist you with.

### Is There XML Support in Oracle 8.0.x?

We are currently architecting some of our future systems to run on XML-based interfaces. We are a large Wall Street institution. Our current systems are all running Oracle 8.0.6, and we would like to have some of our XML concepts implemented on the existing systems due to high demand. Are there current or future plans to support XML-based code within the database, or are there any adapters or cartridges that we can use to get by?

#### Answer

All of our XML Developer's Kit components, including the XML Parser, XSLT Processor, XSQL Servlet, and utilities like the XML SQL Utility all work outside the database against Oracle 8.0.6. However, you will not be able to run XML components inside the database or use Oracle Text (interMedia) XML searching, which are both features in Oracle 8i and higher.

### Oracle 7.3.4: Data Transfers to Other Vendors Using XML

#### Question

My company has Oracle release 7.3.4 and my group is thinking of using XML for some data transfers between us and our vendors. From what I could see from this Web site, it looks like we would need to move to Oracle8i or higher in order to do so. Is there any way of leveraging Oracle release 7 to do XML?

#### Answer

As long as you have the appropriate JDBC 1.1 drivers for 7.3.4 you should be able to use the XML SQL Utility to extract data in XML.

For JDBC drivers, refer to `http://otn.oracle.com/tech/java/sqlj_jdbc/` for information about Oracle7 JDBC OCI and JDBC Thin Drivers.

### If I Use Versions Prior to Oracle8i Can I use Oracle XML Tools?

1. If I am using an Oracle version lower than Oracle8i, can I supply XML based applications using Oracle XML tools? If yes, then what are the licensing terms in that case?

2. Is Oracle XML technology suitable for creating magtape files where the file is just a string of characters like '`abcdefg........`' in a particular format? Is it is possible to create a stylesheet that will create these kind of files?

#### Answer

1. XDKs for Java, C, and C++ can work outside the database, including the XML SQL Utility and XSQL Pages framework. Licensing is the same, free runtime. See OTN for the latest licenses.

2. Yes. Just use `<xsl:output method="text"/>` to output plain text.

## Browsers that Support XML

### Which Browsers Support XML?

Is there a list of browsers that support XML?

#### Answer

The following browsers support the display of XML:

- Opera. XML, in version 4.0 and higher

- Citec Doczilla. XML and SGML browser

- Indelv. Will display XML documents only using XSL

- Mozilla Gecko. Supports XML, CSS1, and DOM1

- HP ChaiFarer. Embedded environment that supports XML and CSS1

- ICESoft embedded browser. Supports XML, DOM1, CSS1, and MathML

- Microsoft IE5. Has a full XML parser, IE5.x or higher

- Netscape 5.x or higher

## Standards

### Are there Advantages of XML Over EDI?

We are considering implementing EDI to communicate requirements with our vendors and customers. I understand that XML is a cheaper alternative for smaller companies. Do you have any information on the advantages of XML over EDI?

#### Answer

Here are some thoughts on the subject:

- EDI is a difficult technology: EDI allows machine-to-machine communication in a format that developers cannot easily read and understand.

- EDI messages are very difficult to debug. XML documents are readable and easier to edit.

- EDI is not flexible: it is very hard to add a new trading partner as part of an existing system, each new trading partner requires its own mapping. XML is extremely flexible with the ability to add new tags on demand and to transform an XML document into another XML document, for example, to map two different formats of purchase order numbers.

- EDI is expensive: developer training costs are high, and deployment of EDI requires very powerful servers that need a specialized network. (EDI runs on VANs, which are expensive). XML works with inexpensive Web servers over existing internet connections.

The next question then becomes: is XML going to replace EDI? Probably not. The technologies will likely coexist, at least for a while. Large companies with an existing investment in EDI will probably use XML as a way to extend their EDI implementation, which raises a new question of XML and EDI integration.

XML is a compelling approach for smaller organizations, and for applications where EDI is inflexible.

### What B2B Standards and Development Tools Does Oracle Support?

What B2B XML standards (such as ebXML, cxml, and BizTalk) does Oracle support? What tools does Oracle offer to create B2B exchanges?

#### Answer

Oracle participates in several B2B standards organizations:

- OBI (Open Buying on the Internet)

- ebXML (Electronic Business XML)

- RosettaNet (E-Commerce for Supply Chain in IT Industry)

- OFX (Open Financial Exchange for Electronic Bill Presentment and Payment)

For B2B exchanges, Oracle provides several alternatives depending on customer needs, such as the following:

- Oracle Exchange delivers an out-of-the-box solution for implementing electronic marketplaces

- Oracle Integration Server (and primarily Message Broker) for in-house implementations

- Oracle Gateways for exchanges at data level

- Oracle XML Gateway to transfer XML-based messages from our e-business suite.

Oracle Internet Platform provides an integrated and solid platform for B2B exchanges.

### What is Oracle Corporation's Direction Regarding XML?

What is Oracle Corporation's direction regarding XML?

#### Answer

Oracle Corporation's XML strategy is to use XML in ways that exploit all of the benefits of the current Oracle technology stack. Today you can combine Oracle XML components with the Oracle8i (or higher) database and Advanced Queueing (AQ) to achieve conflict resolution, transaction verification, and so on. Oracle is working to make future releases more seamless for these functions, as well as for functions such as distributed two phase commit transactions.

XML data is stored either object-relational tables or views, or as CLOBs. XML transactions are transactions with one of these datatypes and are handled using the standard Oracle mechanisms, including rollback segments, locking, and logging.

From Oracle, Oracle supports sending XML payloads using AQ. This involves making XML queriable from SQL.

Oracle is active in all XML standards initiatives, including W3C XML Working Groups, Java Extensions for XML, Open Applications Group, and `XML.org` for developing and registering specific XML schemas.

#### XML Query

Oracle is participating in the W3C Working Group for XML Query. Oracle is considering plans to implement a language that allows querying XML data, such as in the XQL proposal. While XSLT provides static XML transformation features, a query language will add data query flexibility similar to what SQL does for relational data.

Oracle has representatives participating actively in the following 3C Working Groups related to XML/XSL: XML Schema, XML Query, XSL, XLink/XPointer, XML Infoset, DOM, and XML Core.

### Are There Standard DTDs that We Can Use for Orders, Shipments, and So On?

We have implemented Oracle8i and the XDK. Where can we find basic, standard DTDs to build on for orders, shipments, and acknowledgements?

#### Answer

A good place to start would be this Web site: `http://www.xml.org` which is being set up for that purpose.

## XML, CLOBs, and BLOBs

### Is There Support for XML Messages in BLOBs?

Is there any support for XML messages enclosing BLOBs, or I should do it on an application level by encoding my binary objects in a suitable text format such as UUENCODE with a MIME wrapper?

#### Answer

XML requires all characters to be interpreted, therefore there is no provision for including raw binary data in an XML document. That being said, you could UUENCODE the data and include it in a CDATA section. The limitation on the encoding technique is to be sure it only produces legal characters for a CDATA section.

## Maximum FileSizes

### What is the Maximum XML File Size When Stored in CLOBs?

If we store XML files as CLOBs in the Oracle database, what is the maximum file size?

#### Answer

The maximum file size is 2 GB. See the Oracle9i Application Developer's Guide - Large Objects (LOBs) for more information on LOBs and CLOBs.

### XML File Size Limitations

Are there any limitations in the size of an XML file?

#### Answer

There are no XML limitations to an XML file size.

### Maximum Size for an XML Document

1. Is there a maximum size for an XML document to provide data for PL/SQL (or SQL) across tables, provided that no CLOBs are used?

2. What is the maximum size of XML document generated from Oracle to an XML document?

#### Answer

1. The size limit should be what can be inserted into an object view.

2. The size limit should be what can be retrieved from an object view.

## Inserting XML Data Into Tables

### What Do I Need to Insert Data Into Tables Using XML?

To select data for display and insert data to tables by XML what software do I need? We are using Oracle8i on Solaris.

#### Answer

You need the following software:

- XML SQL Utility

- XML Parser for Java,V2

- JDBC driver

- JDK

The first three can be obtained from Oracle. The fourth can be obtained from Sun Microsystems. If you want to perform the tasks from a browser, you will also need the following:

- A Java compliant Web server

- XSQL Servlet

## XML in the Database: Performance

### Where Can I Find Information about the Performance of XML and Oracle?

Is there a whitepaper that discusses the performance of XML and Oracle?

#### Answer

Currently, we do not have any official performance analyses due to the lack of a performance standard or benchmark for XML products.

### How Can I Speed Up the Record Retrieval in XML Documents?

I have a database with millions of records. I give a query based on some 4/5 parameters, and retrieve the records corresponding to that, I have added indexes in the database for faster retrieval of the same, but since the number of records returned is quite high and I planned to put a previous and next link to show only 10 records at a time, I had to get the `count(*)` of the number of records that match.

Since there are so many records, and `count(*)` does not consider index, it takes nearly 20-30 seconds for the retrieved list to be seen on the browser window. If I remove that `count(*)`, the retrieval is quite fast, but then there is no previous and next as I had linked them to `count(*)`.

#### Answer

I presume you are referring on a faster way to retrieve XML documents. The solution is to use SAX interface instead of DOM.

Make sure to select the `COUNT(*)` of an indexed column (the more selective the index the better), this way the optimizer can satisfy the count query with a few I/Os of the index blocks instead of a full-table scan.

## Using XML With Different Languages

My application requires communication with outside entities that may have a totally different language system. If I need to put information in other languages (for instance, Chinese) into XML, do I need to treat and process them differently? For example, do I need to care which encoding they use, or would the parser be able to recognize it? Would there be any problems when dealing with the database?

#### Answer

XML inherently supports multiple languages in a single document. Each entity can use a different encoding from the others; that is, you could add a Chinese entity encoded in a Chinese encoding to the rest of the document. You could also treat all portions uniformly, regardless of the language used, by encoding in Unicode. Using the former, you must have an encoding declaration in the XML text declaration.

Oracle XML Parsers are designed to be able to handle most external entities and recognizes a wide range of encodings, including most widely used ones from all over the world.

The database should support all the languages you are going to use on XML. Chinese character sets like ZHS16GBK and ZHT16BIG5 are a superset of ASCII so you may be able to do with one of them to serve for English and Chinese, but you may want to use Unicode to use more languages.

## Further References

### Other XML Frequently Asked Questions

Here is another XML Frequently Asked Question site of interest:

- `http://www.ucc.ie/xml/`

### Recommended XML and XSL Books

Can you recommend a good XML or XSL book?

#### Answer

- A publisher group by the name of WROX has a number of helpful books. One of these, XML Design and Implementation by Paul Spencer covers XML, XSL and development well.

- Building Oracle XML Applications by Steve Muench (published by O'Reilly) See `http://www.oreilly.com/catalog/orxmlapp/`

- The XML Bible. Although I do not have this book, my impression that it is good one on XML and XSL. I read the updated chapter 14 from: `http://metalab.unc.edu/xml/books/bible/` and it gave me a good understanding of XSLT. Downloading this chapter is free so you can get a good impression.

- Oracle XML Handbook by the Oracle XML Product Development Team http://www.osborne.com/oracle/

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