Oracle UTL_XML
Version 12.1.0.1

General Information
Library Note Morgan's Library Page Footer
The Library is currently in the process of being upgraded from Oracle Database Version 11.2.0.3 to 12.1.0.1. Demos are being upgraded to reflect the new Container paradigm as well as EBR (Edition Based Redefinition) and may contain references to CDBs, PDBs, and other objects you may not be familiar with such as CDB_OBJECTS_AE: Welcome to 12c.
Purpose PL/SQL wrapper over COREs C-based XML/XSL processor.
Note This is the package header for the PL/SQL interface to CORE's C-based XML Parser and XSL Processor. It currently does not provide an interface to CORE's C-based DOM, SAX and Namespace APIs. You MUST call function XMLINIT before any others in this package. Pkg. body and trusted lib. implementations are in: /vobs/rdbms/src/server/datapump/ddl.
AUTHID DEFINER
Constants
Name Data Type Value
DISCARD_WHITESPACE BINARY_INTEGER 2
DTD_ONLY BINARY_INTEGER 4
STOP_ON_WARNING BINARY_INTEGER 8
VALIDATE BINARY_INTEGER 1
Data Types Data Type (Opaque Handles)

SUBTYPE xmlCtx IS PLS_INTEGER;
Dependencies
DBMS_METADATA DBMS_SYS_ERROR KU$_STRMTABLE_VIEW
DBMS_METADATA_INT KU$_10_2_STRMTABLE_VIEW UTL_XML_LIB
DBMS_METADATA_UTIL    
Documented No
First Available 9.0.1
Security Model Owned by SYS with no privileges granted
Source {ORACLE_HOME}/rdbms/admin/utlcxml.sql
Subprograms
 
COMPARE
Compares the DDL of 2 input objects and returns a diff document utl_xml.compare(
ctx    IN xmlCtx,
doc1   IN CLOB,
doc2   IN CLOB,
difDoc IN CLOB,
flags  IN OUT BINARY_INTEGER);
TBD
 
GETFDO
Return the format descriptor object for objects on this platform utl_xml.getFdo RETURN RAW;
SELECT utl_xml.getFdo FROM dual;
 
GETHASHCODE
Upgrading from 8.1.7 corrupts the hashcode in type$, so this functions calls kotgHashCode utl_xml.gethashcode(
schema   IN  VARCHAR2,       -- type schema
typename IN  VARCHAR2,       -- type name
flag     IN  BINARY_INTEGER, -- 1 = only return V1 hashcode, 0 = return any hashcode
hashcode OUT RAW);           -- returned hashcode
set serveroutput on

DECLARE
 hc RAW(32);
BEGIN
  utl_xml.gethashcode('SYSTEM', 'REPCAT$_OBJECT_NULL_VECTOR', 0, hc);
  dbms_output.put_line(hc);
END;
/
 
GETNEXTTYPEID
Given the current value of next_typeid for a type hierarchy and another typeid, see if next_typeid needs to be incremented, and, if so, what its new value should be utl_xml.getnexttypeid(
next_typeid     IN  RAW,
typeid          IN  RAW,
new_next_typeid OUT RAW);
TBD
 
HASTSTZ
Returns TRUE if the type have a TSTZ element or attribute utl_xml.HasTsTz(
schema   IN VARCHAR2,
typename IN VARCHAR2)
RETURN BOOLEAN;
TBD
 
ISNAMEOMF
Tests a file name to see if it is an OMF name

0 = not OMF
1 = OMF
utl_xml.isnameomf(fname IN VARCHAR2, isomf OUT BINARY_INTEGER);
set serveroutput on

DECLARE
 fn dba_data_files.file_name%TYPE;
 x  SIGNTYPE;
BEGIN
  SELECT file_name
  INTO fn
  FROM dba_data_files
  WHERE rownum = 1;

  utl_xml.isnameomf(fn, x);

  dbms_output.put_line(x);
END;
/
 
LONG2CLOB
Fetch a LONG as a CLOB

NOTE: the doc states that tab and col must belong to a short list of valid values, see prvtcxml.sql, but this file does not exist in the distribution
utl_xml.long2clob(
tab    IN            VARCHAR2,
col    IN            VARCHAR2,
row_id IN            ROWID,
lobloc IN OUT NOCOPY CLOB);
CREATE TABLE t1 (x INT, y LONG);

INSERT INTO t1 VALUES (1, RPAD('*',100,'*'));
INSERT INTO t1 VALUES (2, RPAD('*',100,'$'));
INSERT INTO t1 VALUES (3, RPAD('*',100,'#'));
COMMIT;

desc t1

SELECT * FROM t1;

set serveroutput on

DECLARE
 rid    ROWID;
 lob    CLOB;
 xmlctx PLS_INTEGER;
BEGIN
  SELECT rowid
  INTO rid
  FROM t1
  WHERE rownum = 1;

  xmlctx := sys.utl_xml.xmlInit;

  sys.utl_xml.long2clob('T1', 'Y', rid, lob);
  dbms_output.put_line(rid);
  dbms_output.put_line(lob);
END;
/
 
PARSEEXPR
Parse an expression (boolean or arithmetic) and return in a CLOB as XML utl_xml.parseexpr(
schema  IN VARCHAR2,
tab     IN VARCHAR2,
sqltext IN CLOB,
arith   IN BINARY_INTEGER,
lobloc  IN OUT NOCOPY CLOB);
TBD
 
PARSEQUERY
Parse a SQL query and return in a CLOB as XML utl_xml.parsequery(
user    IN            VARCHAR2,
sqltext IN            CLOB,
lobloc  IN OUT NOCOPY CLOB);
TBD
 
SSCFIND (new 12.1)
Find stylesheet by index or name or allocate it utl_xml.(
ss_index IN BINARY_INTEGER,
ss_name  IN VARCHAR2)
RETURN BINARY_INTEGER;
TBD
 
SSCGETCTX (new 12.1)
Get xml context identifier for the specified stylesheet utl_xml.sscGetCtx (ss_index IN BINARY_INTEGER) RETURN xmlctx;
TBD
 
SSCMINIMIZECACHE (new 12.1)
Minimize stylesheet cache LRU size (set to 1) utl_xml.sscMinimizeCache;
exec utl_xml.sscMinimizeCache;
 
SSCPARSE (new 12.1)
Sets the top-level style sheet for the upcoming transform and also establishes the base URI for any included or imported stylesheets utl_xml.sscParse (
ss_index IN BINARY_INTEGER,
uri      IN VARCHAR2,
encoding IN VARCHAR2 DEFAULT NULL);
TBD
 
SSCPURGE (new 12.1)
Purge the stylesheet cache utl_xml.sscPurge;
exec utl_xml.sscPurge;
 
SSCSETDEBUG (new 12.1)
Set stylesheet cache's debug level to match prvtmeti.sql utl_xml.sscSetDebug (value IN BOOLEAN);
exec utl_xml.sscSetDebug(FALSE);
 
TYPEHASHCODEEQ
Does the hashcode match the hc for the type? The type hashcode versions changed between 10.2 and 11g so a simple compare doesn't work. This is a wrapper around kottyphcequ utl_xml.typehashcodeeq(
schema   IN VARCHAR2, -- type schema
typename IN VARCHAR2, -- type name
hashcode IN RAW)      -- hashcode to check
RETURN BOOLEAN;
TBD
 
WINDOWS32
Determines if Oracle is running on a 32bit  Windows NT system utl_xml.windows32(flag OUT BINARY_INTEGER);
set serveroutput on

DECLARE
 i BINARY_INTEGER;
BEGIN
  utl_xml.windows32(i);
  dbms_output.put_line(i);
END;
/
 
XMLCLEAN
Cleans up memory from last doc. associated with this parser utl_xml.xmlclean(ctx IN xmlCtx);
TBD
 
XMLDUMPCTXS (new 12.1)
Dump info on the active XML contexts to the trace file utl_xml.xmlDumpCtxs;
exec utl_xml.xmlDumpCtxs;
 
XMLINIT
Initializes a DOM XML parser utl_xml.xmlInit RETURN xmlCtx;
DECLARE
 handle utl_xml.xmlCtx;
BEGIN
  handle := utl_xml.xmlInit;
END;
/
 
XMLPARSE
Parses target of a URI (file or DB column) into a DOM format

Overload 1
utl_xml.xmlparse(
ctx      IN xmlCtx,
uri      IN VARCHAR2,
encoding IN VARCHAR2 DEFAULT NULL);
TBD
Parses the CLOB source doc into a DOM format

Overload 2
utl_xml.xmlparse(
ctx    IN xmlCtx,
srcDoc IN CLOB);
TBD
 
XMLSETMEMDEBUG (new 12.1)
Sets kux's Lpx memory tracing utl_xml.xmlSetMemDebug (value IN BOOLEAN);
exec utl_xml.xmlSetMemDebug (FALSE);
 
XMLSETPARSEFLAG
Sets parsing options for this parser

These are sticky across parses using the same parser.
utl_xml.xmlsetparseflag(
ctx   IN xmlctx,
flag  IN BINARY_INTEGER,
value IN BOOLEAN);
TBD
 
XSLLOADFROMFILE
Load an XSL stylesheet from a BFILE into a CLOB utl_xml.xslloadfromfile(
destLob IN CLOB,
srcFile IN BFILE,
amount  IN BINARY_INTEGER);
TBD
 
XSLRESETPARAMS
Resets all parameters to their default values for the given XSL parser ctx utl_xml.xslresetparams(xslCtx IN xmlCtx);
TBD
 
XSLSETPARAM
set a parameter value for a stylesheet utl_xml.xslsetparam(
xslCtx    IN xmlCtx,
paramName IN VARCHAR2,
paramVal  IN VARCHAR2);
TBD
 
XSLTRANSFORM
Transforms srcdoc into resdoc using the XSL stylesheet associated with xslCtx utl_xml.xsltransform(
srcDoc IN            CLOB,
xslCtx IN            xmlCtx,
resDoc IN OUT NOCOPY CLOB);
TBD
 
XSLTRANSFORMCTOX
Transform a Clob to xmlCtx utl_xml.xxltransformctox(srcDoc IN CLOB, xslCtx IN xmlCtx)
RETURN xmlCtx;
TBD
 
XSLTRANSFORMXTOC
Perform an XSL transformation on a pre-parsed xmlctx returning a CLOBU utl_xml.xxltransformxtoc(
srcCtx IN            xmlCtx,
xslCtx IN            xmlCtx,
resDoc IN OUT NOCOPY CLOB);
TBD
 
XSLTRANSFORMXTOX
Transforms a pre-parsed xmlCtx returning another xmlCtx utl_xml.xsltransformxtox(srcCtx IN xmlCtx, xslCtx IN xmlCtx)
RETURN xmlCtx;
TBD

Related Topics
DBMS_LOB
LONG to CLOB
Packages

Morgan's Library Page Footer
This site is maintained by Dan Morgan. Last Updated: This site is protected by copyright and trademark laws under U.S. and International law. © 1998-2014 Daniel A. Morgan All Rights Reserved