Oracle8i Application Developer's Guide - XML Release 3 (8.1.7) Part Number A86030-01 |
Library | Service | Contents | Index

Using XML Parser for PL/SQL, 4 of 7

## Using XML Parser for PL/SQL (DOM Interface)

The XML Parser for PL/SQL makes developing XML applications with Oracle8i a simplified and standardized process. With the PL/SQL interface, Oracle shops familiar with PL/SQL can extend existing applications to take advantage of XML as needed.

Since the XML Parser for PL/SQL is implemented in PL/SQL and Java, it can run "out of the box" on the Oracle8i Java Virtual Machine.

XML Parser for PL/SQL supports the W3C XML 1.0 specification. The goal is to be 100% conformant.. It can be used both as a validating or non-validating parser.

In addition, XML Parser for PL/SQL provides the two most common API's developers need for processing XML documents:

- W3C-recommended Document Object Model (DOM)

- XSL-T and XPath recommendations

This makes writing custom applications that process XML documents straightforward in the Oracle8i environment, and means that a standards-compliant XML parser is part of the Oracle8i platform on every operating system where Oracle8i is ported.

Figure 24-1 shows the XML Parser for PL/SQL usage and parsing process diagram.

1. Make a newParser declaration to begin the parsing process for the XML document and DTD, if applicable.

   Table 24-1 lists available properties for the newParser procedure:

   ##### Table 24-1 XML Parser for PL/SQL: newParser() Properties

   Property | Description
   --- | ---
   setValidationMode | Default = Not
   setPreserveWhiteSpace | Default = Not
   setDocType | Use if input type is a DTD
   setBaseURL | Refers to other locations to the base locations, if reading from an outside source
   showWarnings | Turns warnings on or off.

2. The XML and DTD can be input as a file, varchar buffer, or CLOB. The XML input is called by the following procedures:

   - parse() if the XML input is a file

   - parseBuffer() if the XML input is an varchar buffer

   - `parserClob()` if the XML input is a CLOB

   If a DTD is also input, it is called by the following procedures:

   - `parseDTD()` if the input is an DTD file

   - `parseDTDBuffer()` if the DTD input is an varchar buffer

   - `parserDTDClob()` if the DTD input is a CLOB

For the XML Input: For an XML input, the parsed result from `Parse(), ParserBuffer()`, or `ParserClob()` procedures is sent to `GetDocument().`

1. `getDocument()` procedure performs the following:

   - Outputs the parsed XML document as a DOM document typically to be used in a PL/SQL application, or

   - Applies other DOM functions, if applicable. See Oracle8i XML Reference for a list of available optional DOM functions.

2. Use `freeDocument()` function to free up the parser and parse the next XML input

3. Use `freeParser()` to free up any temporary document structures created during the parsing process

For the DTD input: The parsed result from `parseDTD()`, `parseDTDBuffer()`, or p`arseDTDClob()` is used by `getDocType()` function.

1. `getDocType()` then uses `setDocType()` to generate a DTD object.

2. The DTD object can be fed into the parser using `setDocType()` to override the associated DTD.

#### Figure 24-1 XML Parser for PL/SQL Functionality (DOM Interface)

### XML Parser for PL/SQL: Default Behavior

The following is the default behavior for XML Parser for PLSQL XML:

- A parse tree which can be accessed by DOM APIs is built

- The parser is validating if a DTD is found, otherwise it is non-validating

- Errors are not recorded unless an error log is specified; however, an application error will be raised if parsing fails

The types and methods described in this manual are supplied with the PLSQL package xmlparser().

| Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
Library | Service | Contents | Index