CODE
Oracle Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
PSOUG Home Code Snippets Oracle Reference Oracle Functions PSOUG Forum Oracle Blogs Bookmark and Share
 
 Search the Reference Library pages:  

Free
Oracle Magazine
Subscriptions
and Oracle White Papers

Oracle UTL_XML
Version 11.1
 
General Information
Note: 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 Availability 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
Data Type (Opaque Handles) SUBTYPE xmlCtx IS PLS_INTEGER;
Dependencies
DBMS_METADATA KU$_10_2_STRMTABLE_VIEW
DBMS_METADATA_INT KU$_STRMTABLE_VIEW
DBMS_METADATA_UTIL UTL_XML_LIB
DBMS_SYS_ERROR  
Security Model No explicit grants
 
COMPARE (new in 11.1.0.6)

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 in 11.1.0.7)

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
hashcode OUT RAW);      -- returned hashcode
set serveroutput on

DECLARE
 hc RAW(32);
BEGIN
  utl_xml.gethashcode('SYSTEM', 'REPCAT$_OBJECT_NULL_VECTOR', 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
 
ISNAMEOMF (new in 11.1.0.6)

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: 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 11g.

utl_xml.long2clob(
tab    IN     VARCHAR2,
col    IN     VARCHAR2,
rowid  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 uwclass.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 (new in 11.1.0.6)

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 (new in 11g)

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 (new in 11.1.0.7)
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.gethashcode(
schema   IN VARCHAR2,  -- type schema
typename IN VARCHAR2,  -- type name
hashcode IN RAW)       -- hashcode to check
RETURN BOOLEAN;
TBD
 
XMLCLEAN
Cleans up memory from last doc. associated with this parser utl_xml.xmlclean(ctx IN xmlCtx);
TBD
 
XMLGETTABLEFROMDOC (new in 11.1.0.6)

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;
TBD
 
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
Runs this parser down: Deletes all memory associated with ctx utl_xml.xmlterm(ctx IN xmlCtx);
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.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 CLOB. 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 2 CLOB
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us [192 users online]    © 2010 psoug.org