Oracle UTL_XML
Version 11.2.0.3
 
General Information
Purpose PL/SQL wrapper over COREs C-based XML/XSL processor. 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
Source {ORACLE_HOME}/rdbms/admin/utlcxml.sql
First Available 9.0.1
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
Dependencies
DBMS_METADATA DBMS_SYS_ERROR KU$_STRMTABLE_VIEW
DBMS_METADATA_INT KU$_10_2_STRMTABLE_VIEW UTL_XML_LIB
DBMS_METADATA_UTIL    
Data Types Data Type (Opaque Handles)

SUBTYPE xmlCtx IS PLS_INTEGER;
Security Model Owned by SYS with no privileges granted
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(100);
SELECT utl_xml.getFdo FROM dual;
 
GETHASHCODE (new 11.1.0.7, new parameter in 11.2)
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
 
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 (new 11.2.0.2)
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
 
XMLGETTABLEFROMDOC
Undocumented utl_xml.xmlgettablefromdoc(
ctx      IN  xmlCtx,
more     OUT BINARY_INTEGER,
tabName  OUT VARCHAR2,
tabOwner OUT VARCHAR2,
objOwner OUT VARCHAR2);
TBD
 
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
 
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
 
XMLTERM
Deletes all memory associated with the DOM XML Parser utl_xml.xmlterm(ctx IN xmlCtx);
DECLARE
 handle utl_xml.xmlCtx;
BEGIN
  handle := utl_xml.xmlInit;
  utl_xml.xmlTerm(handle);
END;
/
 
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.xslresetparam((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
 
XSLSETSTYLESHEET
Sets the top-level style sheet for the upcoming transform and establishes the base URI for any included or imported stylesheets utl_xml.xslsetstylesheet(
xslCtx   IN xmlCtx,
uri      IN VARCHAR2,
encoding IN VARCHAR2 DEFAULT NULL);
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
 
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-2013 Daniel A. Morgan All Rights Reserved