Source Code for the XML Helper Packages

The xml, xmldoc, xpath, and xslt packages depend on having the Oracle XML Parser for PL/SQL installed. (See Chapter 5 for installation details). In addition, since the Oracle XML Parser for PL/SQL wraps the Oracle XML Parser for Java, one of the following must be true before you can successfully compile and run these packages:

  • You must have already:

    • Installed the Oracle XML Parser for Java in your schema

    • Installed the Oracle XML Parser for PL/SQL packages in your schema, and

    • Been granted the JAVAUSERPRIV privilege to execute Java code inside Oracle8i

  • Alternatively, you must have been granted EXECUTE permission on the Oracle XML Parser for PL/SQL packages installed in another schema.

The xml Package

The xml package provides key functionality for parsing XML documents from VARCHAR2, CLOB, BFILE, and URL sources. It uses the Oracle XML Parser for PL/SQL’s xmlparser package. To use these routines, perform these steps:

  1. Call one of the xml.parse functions to parse your XML document

  2. Work with the returned xmldom.DOMDocument

  3. Call xml.freeDocument( yourDoc ) to free the memory used by the parsed representation of your XML document

It is safe to cache the instances of xmldom.DOMDocument in PL/SQL package-level variables for parsed XML documents you need to use over and over during the same database session, but remember that the memory they occupy is not freed until you explicitly call xml.freeDocument.

Note that if you need to parse an XML document from a ...

Get Building Oracle XML Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.