Skip Headers
Oracle® Database PL/SQL Packages and Types Reference
11g Release 2 (11.2)

Part Number E25788-04
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub
ARPLS375

173 DBMS_XMLPARSER

Using DBMS_XMLPARSER, you can access the contents and structure of XML documents. XML describes a class of data XML document objects. It partially describes the behavior of computer programs which process them. By construction, XML documents are conforming SGML documents.

XML documents are made up of storage units called entities, which contain either parsed or unparsed data. Parsed data is made up of characters, some of which form character data, and some of which form markup. Markup encodes a description of the document's storage layout and logical structure. XML provides a mechanism to impose constraints on the storage layout and logical structure.

A software module called an XML processor is used to read XML documents and provide access to their content and structure. It is assumed that an XML processor is doing its work on behalf of another module, called the application. This PL/SQL implementation of the XML processor (or parser) follows the W3C XML specification REC-xml-19980210 and includes the required behavior of an XML processor in terms of how it must read XML data and the information it must provide to the application.

The default behavior for this PL/SQL XML parser is to build a parse tree that can be accessed by DOM APIs, validate it if a DTD is found (otherwise, it is non-validating), and record errors if an error log is specified. If parsing fails, an application error is raised.

This chapter contains the following topics:

See Also:

Oracle XML DB Developer's Guide
ARPLS73532

Using DBMS_XMLPARSER

ARPLS73533

Security Model

Owned by XDB, the DBMS_XDB_XMLPARSER package must be created by SYS or XDB. The EXECUTE privilege is granted to PUBLIC. Subprograms in this package are executed using the privileges of the current user.

ARPLS69897

Summary of DBMS_XMLPARSER Subprograms

ARPLS69898Table 173-1 DBMS_XMLPARSER Package Subprograms

Method Description

FREEPARSER

Frees a parser object.

GETDOCTYPE

Gets parsed DTD.

GETDOCUMENT

Gets DOM document.

GETRELEASEVERSION

Returns the release version of Oracle XML Parser for PL/SQL.

GETVALIDATIONMODE

Returns validation mode.

NEWPARSER

Returns a new parser instance

PARSE

Parses XML stored in the given url/file.

PARSEBUFFER

Parses XML stored in the given buffer

PARSECLOB

Parses XML stored in the given clob

PARSEDTD

Parses DTD stored in the given url/file

PARSEDTDBUFFER

Parses DTD stored in the given buffer

PARSEDTDCLOB

Parses DTD stored in the given clob

SETBASEDIR

Sets base directory used to resolve relative URLs.

SETDOCTYPE

Sets DTD.

SETERRORLOG

Sets errors to be sent to the specified file

SETPRESERVEWHITESPACE

Sets white space preserve mode

SETVALIDATIONMODE

Sets validation mode.

SHOWWARNINGS

Turns warnings on or off.


ARPLS69899

FREEPARSER

Frees a parser object.

ARPLS69900Syntax

PROCEDURE freeParser(
    p Parser); 
Parameter IN / OUT Description
p (IN) Parser instance.

ARPLS69901

GETDOCTYPE

Returns the parsed DTD; this function must be called only after a DTD is parsed.

ARPLS69902Syntax

FUNCTION getDoctype(
p Parser)
RETURN DOMDocumentType; 
Parameter IN / OUT Description
p (IN) Parser instance.


ARPLS69903

GETDOCUMENT

Returns the document node of a DOM tree document built by the parser; this function must be called only after a document is parsed.

ARPLS69904Syntax

FUNCTION GETDOCUMENT(
p Parser)
RETURN DOMDocument; 
Parameter IN / OUT Description
p (IN) Parser instance.

ARPLS69905

GETRELEASEVERSION

Returns the release version of the Oracle XML parser for PL/SQL.

ARPLS69906Syntax

FUNCTION getReleaseVersion
RETURN VARCHAR2;
ARPLS69907

GETVALIDATIONMODE

Retrieves validation mode; TRUE for validating, FALSE otherwise.

ARPLS69908Syntax

FUNCTION GETVALIDATIONMODE(
p Parser)
RETURN BOOLEAN; 
Parameter IN / OUT Description
p (IN) Parser instance.


ARPLS69909

NEWPARSER

Returns a new parser instance. This function must be called before the default behavior of Parser can be changed and if other parse methods need to be used.

ARPLS69910Syntax

FUNCTION newParser 
RETURN Parser; 
ARPLS69911

PARSE

Parses XML stored in the given URL or file. An application error is raised if parsing fails. There are several versions of this method.

Syntax Description
FUNCTION parse(

   url VARCHAR2)

RETURN DOMDocument;

Returns the built DOM Document. This is meant to be used when the default parser behavior is acceptable and just a url/file needs to be parsed.
PROCEDURE parse(

   p Parser,

   url VARCHAR2);

Any changes to the default parser behavior should be effected before calling this procedure.


Parameter IN / OUT Description
url (IN) Complete path of the url/file to be parsed.
p (IN) Parser instance.


ARPLS69912

PARSEBUFFER

Parses XML stored in the given buffer. Any changes to the default parser behavior should be effected before calling this procedure. An application error is raised if parsing fails.

ARPLS69913Syntax

PROCEDURE PARSEBUFFER(
p   Parser,
doc VARCHAR2); 
Parameter IN / OUT Description
p (IN) Parser instance.
doc (IN) XML document buffer to parse.


ARPLS69914

PARSECLOB

Parses XML stored in the given clob. Any changes to the default parser behavior should be effected before calling this procedure. An application error is raised if parsing fails.

ARPLS69915Syntax

PROCEDURE PARSECLOB(
p   Parser,
doc CLOB); 
Parameter IN / OUT Description
p (IN) Parser instance.
doc (IN) XML document buffer to parse.


ARPLS69916

PARSEDTD

Parses the DTD stored in the given URL or file. Any changes to the default parser behavior should be effected before calling this procedure. An application error is raised if parsing fails.

ARPLS69917Syntax

PROCEDURE PARSEDTD(
p     Parser,
url   VARCHAR2,
root  VARCHAR2); 
Parameter IN / OUT Description
p (IN) Parser instance.
url (IN) Complete path of the URL or file to be parsed.
root (IN) Name of the root element.


ARPLS69918

PARSEDTDBUFFER

Parses the DTD stored in the given buffer. Any changes to the default parser behavior should be effected before calling this procedure. An application error is raised if parsing fails.

ARPLS69919Syntax

PROCEDURE PARSEDTDBUFFER(
p    Parser,
dtd  VARCHAR2,
root VARCHAR2); 
Parameter IN / OUT Description
p (IN) Parser instance.
dtd (IN) DTD buffer to parse.
root (IN) Name of the root element.


ARPLS69920

PARSEDTDCLOB

Parses the DTD stored in the given clob. Any changes to the default parser behavior should be effected before calling this procedure. An application error is raised if parsing fails.

ARPLS69921Syntax

PROCEDURE PARSEDTDCLOB(
p    Parser,
dtd  CLOB,
root VARCHAR2);
Parameter IN / OUT Description
p (IN) Parser instance.
dtd (IN) DTD Clob to parse.
root (IN) Name of the root element.

ARPLS69922

SETBASEDIR

Sets base directory used to resolve relative URLs. An application error is raised if parsing fails.

ARPLS69923Syntax

PROCEDURE setBaseDir(
p   Parser,
dir VARCHAR2); 
Parameter IN / OUT Description
p (IN) Parser instance.
dir (IN) Directory used as a base directory.

ARPLS69924

SETDOCTYPE

Sets a DTD to be used by the parser for validation. This call should be made before the document is parsed.

ARPLS69925Syntax

PROCEDURE setDoctype(
p   Parser,
dtd DOMDocumentType); 
Parameter IN / OUT Description
p (IN) Parser instance.
dtd (IN) DTD to set.

ARPLS69926

SETERRORLOG

Sets errors to be sent to the specified file.

ARPLS69927Syntax

PROCEDURE setErrorLog(
p        Parser,
fileName VARCHAR2); 
Parameter IN / OUT Description
p (IN) Parser instance.
fileName (IN) Complete path of the file to use as the error log.

ARPLS69928

SETPRESERVEWHITESPACE

Sets whitespace preserving mode.

ARPLS69929Syntax

PROCEDURE setPreserveWhitespace(
p   Parser,
yes BOOLEAN); 
Parameter IN / OUT Description
p (IN) Parser instance.
yes (IN) Mode to set: TRUE - preserve, FALSE - don't preserve.

ARPLS69930

SETVALIDATIONMODE

Sets validation mode.

ARPLS69931Syntax

PROCEDURE setValidationMode(
p   Parser,
yes BOOLEAN); 
Parameter IN / OUT Description
p (IN) Parser instance.
yes (IN) Mode to set: TRUE - validate, FALSE - don't validate.


ARPLS69932

SHOWWARNINGS

Turns warnings on or off.

ARPLS69933Syntax

PROCEDURE showWarnings(
p   Parser,
yes BOOLEAN); 
Parameter IN / OUT Description
p (IN) Parser instance.
yes (IN) Mode to set: TRUE - show warnings, FALSE - don't show warnings.

Reader Comment

   

Comments, corrections, and suggestions are forwarded to authors every week. By submitting, you confirm you agree to the terms and conditions. Use the OTN forums for product questions. For support or consulting, file a service request through My Oracle Support.

Hide Navigation

Quick Lookup

Database Library · Master Index · Master Glossary · Book List · Data Dictionary · SQL Keywords · Initialization Parameters · Advanced Search · Error Messages

Main Categories

This Page

This Document

New and changed documents:
RSS Feed HTML RSS Feed PDF