Oracle9i XML Reference Release 1 (9.0.1) Part Number A88899-01 |
|
This chapter contains reference document on the types and functions related to XML support in the server including:
The DBMS_XMLGEN is a package to convert the results of SQL queries to a canonical XML format. The package takes in any arbitrary SQL query and converts them into the XML format and returns the result as a CLOB.
The package is similar to the DBMS_XMLQuery package, except that it is written in C and compiled into the kernel. This package may only be run on the database.
The package uses a canonical XML conversion. It does not support DTD or XMLSchema generation for now and these may be provided in later releases.
An example conversion is shown below:-
Assume an employee table with the following structure,
CREATE TABLE address_t AS OBJECT ( street VARCHAR2(20), state VARCHAR2(20), city VARCHAR2(20), zip VARCHAR2(20) ); / CREATE TABLE employee ( empno NUMBER, ename VARCHAR2(200), address address_t ); insert into employee values (100,'John', address_t('100, Main Street','Jacksonville','FL','32607')); insert into employee values (200,'Jack', address_t('200 Front Road','San Francisco','CA','94011')); declare ctx dbms_xmlgen.ctxhandle; result clob; begin -- create a new context with the SQL query ctx := dbms_xmlgen.newContext('select * from employee'); -- generate the CLOB as a result. res := dbms_xmlgen.getXML(ctx); -- print out the result of the CLOB printClobOut(result); -- see the lob manual for examples on printing.. -- close the context dbms_xmlgen.closeContext(ctx); end; /
produces a document like,
<?xml version="1.0"?> <ROWSET> <ROW> <EMPNO>100</EMPNO> <ENAME>John</ENAME> <ADDRESS> <STREET>100 Main Street</STREET> <CITY>Jacksonville</CITY> <STATE>FL</STATE> <ZIP>32607</ZIP> </ADDRESS> </ROW> <ROW> <EMPNO>200</EMPNO> <ENAME>Jack</ENAME> <ADDRESS> <STREET>200 Front Street</STREET> <CITY>San Francisco</CITY> <STATE>CA</STATE> <ZIP>94011</ZIP> </ADDRESS> </ROW> </ROWSET>
As you can see from the example, each row of the result gets translated to a ROW element which contains all the columns. The columns themeselves are converted to nested elements with the column name as the element tag name. The object columns (such as address) retain their structure with the object type attributes becoming nested elements of the column.
Thus, deep structuring of the XML can be achieved easily using the object-relational views and tables.
The DBMS_XMLGEN package contains a variety of funtions to generate XML and to set the properties of the result.
The order of calling procedures are as follows
Creates a new context handle from a passed in SQL query. The context handle can be used for the rest of the functions.
Sets the name of the element enclosing each row of the result. The default tag is "ROW"
Sets the name of the element enclosing the entire result. The default tag is "ROWSET"
This appends the XML to the CLOB passed in. Use the getNumRowsProcessed function to figure out if any rows were appended.
This returns the XML as a CLOB.
This returns the XML as an XMLType.
This gets the number of SQL rows that were processed in the last call to getXML. You can call this to find out if the end of the result set has been reached.
This sets the maximum number of rows to be fetched each time.
This sets the number of rows to skip everytime before generating the XML. The default is 0.
This sets whether special characters such as $ etc.. which are non-XML characters should be converted or not to their escaped representation. The default is to perform the conversion.
This forces the use of the collection column name appended with the tag "_ITEM" for collection elements. The default is to set the underlying object type name for the base element of the collection.
Restart the query to start fetching from the begining.
Close the context and release all resources.
SUBTYPE ctxHandle IS NUMBER
This is the context handle that is used by all functions.
These constants may be used in the getXML function to specify whether to generate a DTD or a schema or none. Note that only the NONE specification is supported in the getXML functions for this release.
Given a query string, generate a new context handle to be used in subsequent functions.
FUNCTION newContext(queryString IN VARCHAR2) RETURN ctxHandle;
queryString (IN)- the query string, the result of which needs to be converted to XML
The context handle
You need to call this function first to obtain a handle that you can use in the getXML() and other functions to get the XML back from the result.
Set the name of the element separating all the rows. The default name is ROW.
PROCEDURE setRowTag(ctx IN ctxHandle, rowTag IN VARCHAR2);
ctx (IN) - the context handle obtained from the newContext call rowTag (IN) - the name of the ROW element. NULL indicates that you do not want the ROW element to be present.
You can call this function to set the name of the ROW element, if you do not want the default "ROW" name to show up. You can also set this to NULL to supress the ROW element itself. However, this is an error if both the row and the rowset are null and there is more than one column or row in the output.
Set the name of the document's root element. The default name is "ROWSET"
PROCEDURE setRowSetTag(ctx IN ctxHandle, rowSetTag IN VARCHAR2);
ctx (IN) - the context handle obtained from the newContext call rowsetTag (IN) - the name of the document element. NULL indicates that you do not want the ROW element to be present.
You can call this function to set the name of the document root element, if you do not want the default "ROWSET" name in the output. You can also set this to NULL to supress the printing of this element. However, this is an error if both the row and the rowset are null and there is more than one column or row in the output.
Get the XML document by fetching the maximum number of rows specified. It appends the XML document to the CLOB passed in.
PROCEDURE getXML(ctx IN ctxHandle, clobval IN OUT NCOPY clob, dtdOrSchema IN number := NONE)
ctx (IN) - The context handle obtained from the newContext() call. clobval (IN/OUT) - the clob to which the XML document is to be appended. dtdOrSchema (IN) - whether we should generate the Dtd or Schema or neither (NONE). NONE is the only option currently supported.
Use this version of the getXML function, if you want to avoid any extra CLOB copies and you want to reuse the same CLOB for subsequent calls. The user must create the lob locator, but this is a one-time cost, and so it is recommended that users use this procedure whenever possible.
When generating the XML, the number of rows indicated by the setSkipRows call are skipped, then the maximum number of rows as specified by the setMaxRows call (or the entire result if not specified) is fetched and converted to XML.
Use the getNumRowsProcessed function to check if any rows were retrieved or not.
Generate the XML document and return that as a CLOB.
FUNCTION getXML(ctx IN ctxHandle, dtdOrSchema IN number := NONE) RETURN clob
ctx (IN) - The context handle obtained from the newContext() call. dtdOrSchema (IN) - whether we should generate the Dtd or Schema or neither (NONE). NONE is the only option currently supported.
A temporary CLOB containing the document.
You need to free the temporary CLOB that is obtained from this function using the dbms_lob.freetemporary call.
Generate the XML document and return it as sys.XMLType.
FUNCTION getXMLType(ctx IN ctxHandle, dtdOrSchema IN number := NONE) RETURN sys.XMLType
ctx (IN) - The context handle obtained from the newContext() call. dtdOrSchema (IN) - whether we should generate the Dtd or Schema or neither (NONE). NONE is the only option supported currently.
XML document as an XMLType
Further XMLType operations can be done on the result, such as ExistsNode and Extract. This also provides a way to get the result back as string using getStringVal(), if the result size is known to be less than 4K.
Get the number of SQL rows processed when generating the XML using the getXML call. This count does not include the number of rows skipped before generating the XML.
FUNCTION getNumRowsProcessed(ctx IN ctxHandle) RETURN number
queryString (IN)- the query string, the result of which needs to be converted to XML
The number of rows processed in the last call to getXML. This does not include the number of rows skipped.
Use this function to determine the teminating condition if you are calling getXML in a loop. Note that getXML would always generate a XML document even if there are no rows present.
Set the maximum number of rows to fetch from the SQL query result for every invokation of the getXML call.
PROCEDURE setMaxRows(ctx IN ctxHandle, maxRows IN NUMBER);
ctx (IN) - the context handle corresponding to the query executed maxRows (IN) - the maximum number of rows to get per call to getXML
The maxRows paramter can be used when generating paginated results using this utility. For instance when generating a page of XML or HTML data, you can restrict the number of rows converted to XML and then in subsequent calls, you can get the next set of rows and so on.
This also can provide for faster reponse times.
Skip a given number of rows before generating the XML output for every call to the getXML routine.
PROCEDURE setSkipRows(ctx IN ctxHandle, skipRows IN NUMBER);
ctx (IN) - the context handle corresponding to the query executed skipRows (IN) - the number of rows to skip per call to getXML
The skipRows paramter can be used when generating paginated results for stateless web pages using this utility. For instance when generating the first page of XML or HTML data, you can set skipRows to zero. For the next set, you can set the skipRows to the number of rows that you got in the first case.
Set whether special characters in the XML data need to be converted into their escaped XML equivalent or not. For example, the "<" sign is converted to <. The default is to perform conversions.
PROCEDURE setConvertSpecialChars(ctx IN ctxHandle, conv IN boolean);
ctx (IN) - the context handle to use conv (IN) - true indicates that conversion is needed.
You can use this function to speed up the XML processing whenever you are sure that the input data cannot contain any special characters such as <, >, ", ' etc. which need to be escaped. Note that it is expensive to actually scan the character data to replace the special characters, particularly if it involves a lot of data. So in cases when the data is XML-safe, then this function can be called to improve performance.
Set the name of the collection elements. The default name for collection elements it he type name itself. You can override that to use the name of the column with the "_ITEM" tag appended to it using this function.
PROCEDURE useItemTagsForColl(ctx IN ctxHandle);
ctx (IN) - the context handle
If you have a collection of NUMBER, say, the default tag name for the collection elements is NUMBER. You can override this behavior and generate the collection column name with the _ITEM tag appended to it, by calling this procedure.
Restart the query and generate the XML from the first row again.
PROCEDURE restartQuery(ctx IN ctxHandle);
ctx (IN) - the context handle corresponding to the current query
You can call this to start executing the query again, without having to create a new context.
Closes a given context and releases all resources associated with that context, including the SQL cursor and bind and define buffers etc.
PROCEDURE closeContext(ctx IN ctxHandle);
ctx (IN) - the context handle to close
Closes all resources associated with this handle. After this you cannot use the handle for any other DBMS_XMLGEN function call.
Oracle9i supports the UriType family of types which can be used to store and query Uri-refs inside the database. The UriType itself is an abstract object type and the HttpUriType and DBUriType are subtypes of it.
You can create a UriType column and store instances of the DBUriType or the HttpUriType inside of it.
You can also define your own subtypes of the UriType to handle different URL protocols.
Oracle9i also provides a UriFactory package which can be used as a factory method to generate various instances of these UriTypes automatically by scanning the prefix (e.g.http:// or ftp:// etc..). You can also register your subtype and give the prefix that you support. For instance if you have written a subtype to handle the gopher protocol, you can register that the prefix "gopher://" be handled by your subtype. With that, the UriFactory will generate your subtype instance for any URL starting with that prefix.
The UriType is the abstract super type. It provides a standard set of functions to get the value pointed to by the Uri. The actual implementation of the protocol must be defined by the subtypes of this type.
You cannot create instances of this type directly. However, you can create columns of this type and store subtype instances in it.
For example,
create table uri_tab ( url sys.uritype); insert into uri_tab values (sys.httpuritype.createHttpuri('http://www.oracle.com')); insert into uri_tab values ( sys.dburitype.createdburi('/SCOTT/EMPLOYEE/ROW[ENAME="Jack"]')); -- Now you can select from the column without having to know -- what instance of the URL is actually stored. select e.url.getclob() from uri_tab e; -- would retrieve both the HTTP URL and the DBUri-ref.
This member function returns a CLOB by following the URL and getting the document.
Get the url stored in the external form, i.e. the non-Url characters such as spaces are escaped, using the standard escape sequence, %xx where xx is the hexadecimal value of the UTF-8 encoding of the character.
Returns the URL stored in the type without any escaping. This function must be used instead of directly referencing the url attribute in the type.
Get the document pointed to by the URL as a CLOB. This function can be overridden in the subtype instances.
MEMBER FUNCTION getClob() RETURN clob
A temporary or permanent lob containing the document pointed to by the URL
You need to free the clob if it is a temporary CLOB.
Get the URL stored inside the instance after escaping the non-URL characters as specified in the Uri-ref specification.
MEMBER FUNCTION getExternalUrl() RETURN varchar2
Generates the escaped URL that can be used in HTML web pages. The subtype instances override this member function to provide additional semantics. For instance, the HttpUriType does not store the prefix http:// in the Url itself. When generating the external Url, it appends the prefix and generates it. This is the reason that you should use the getExternalUrl or getUrl to get to the URL value instead of using the attribute present in the UriType.
Get the URL stored inside the instance without escaping the non-URL characters.
MEMBER FUNCTION getUrl() RETURN varchar2
Generates the URL that is present in the UriType instance. The subtype instances override this member function to provide additional semantics. For instance, the HttpUriType does not store the prefix http:// in the Url itself. When generating the external Url, it appends the prefix and generates it. This is the reason that you should use the getExternalUrl or getUrl to get to the URL value instead of using the attribute present in the UriType.
The HttpUriType is a subtype of the UriType that provides support for the HTTP protocol. This uses the UTL_HTTP package underneath to access the HTTP urls. This does not support the proxy or secure wallets for this release.
For example,
-- create a uri table to store the Http instances create table uri_tab ( url sys.httpuritype); -- insert the Http instance. insert into uri_tab values (sys.httpuritype.createUri('http://www.oracle.com')); -- generate the HTML select e.url.getclob() from uri_tab e;
This member function returns a CLOB by following the HTTPURL and getting the document.
Get the HTTP url stored in the external form, i.e. the non-Url characters such as spaces are escaped, using the standard escape sequence, %xx where xx is the hexadecimal value of the UTF-8 encoding of the character.
Returns the URL stored in the type without any escaping. This function must be used instead of directly referencing the url attribute in the type.
Static function to construct a HTTPUri instance.
Get the document pointed to by the HTTP URL as a CLOB.
MEMBER FUNCTION getClob() RETURN clob
A temporary lob containing the document pointed to by the URL
You need to free the temporary clob.
Get the URL stored inside the instance after escaping the non-URL characters as specified in the Uri-ref specification.
MEMBER FUNCTION getExternalUrl() RETURN varchar2
Generates the escaped URL that can be used in HTML web pages. The subtype instances override this member function to provide additional semantics. The HttpUriType does not store the prefix http:// in the Url itself. When generating the external Url, it appends the prefix and generates it.
Get the URL stored inside the instance without escaping the non-URL characters.
MEMBER FUNCTION getUrl() RETURN varchar2
Generates the URL that is present in the HttpUri instance.
Static function to construct a Http URL instance.
STATIC FUNCTION createUri(url IN varchar2) RETURN HttpUriType
url (IN) - the url string containing a valid HTTP URL. The url string is assumed to be in the escaped form. i.e. non-url characters are represented as %xx where xx is the hexadecimal value for the UTF-8 encoding of the character.
Parses the Http URL supplied and generates a HttpUri instance. Note that this instance does not contain the prefix "http://" in the url stored.
The DbUriType is a subtype of the UriType that provides support for of DBUri-refs. A DBUri-ref is a intra-database URL that can be used to reference any row or row-column data in the database.
The URL is specified as an XPath expression over a XML visualization of the database. The schemas become elements which contain tables and views. These tables and view further contain the rows and columns inside them.
For example, the virtual document that a user scott can see can be something like this,
<?xml version="1.0"?> <DATABASE> <SCOTT> <EMPLOYEE> <ROWSET> <ROW> <EMPNO>100</EMPNO> <ENAME>John</ENAME> <ADDRESS> <STREET>100 Main Street</STREET> <CITY>Jacksonville</CITY> <STATE>FL</STATE> <ZIP>32607</ZIP> </ADDRESS> </ROW> <ROW> <EMPNO>200</EMPNO> <ENAME>Jack</ENAME> <ADDRESS> <STREET>200 Front Street</STREET> <CITY>San Francisco</CITY> <STATE>CA</STATE> <ZIP>94011</ZIP> </ADDRESS> </ROW> </ROWSET> </EMPLOYEE> </SCOTT> </DATABASE>
Hence to reference the State attribute inside the employee table, you can formulate a DBUri-ref as shown below:-
/SCOTT/EMPLOYEE/ROW[ENAME="Jack"]/ADDRESS/STATE
You can use the DBUriType to create instances of these and store them in columns.
-- create a table create table dburi_tab (dburl sys.dburitype); -- insert values..! insert into dburi_tab values ( sys.dburitype.createdUri('/SCOTT/EMPLOYEE/ROW[ENAME="Jack"]/ADDRESS/STATE')); select e.dburl.getclob() from dburi_tab e; -- will return, <?xml version="1.0"?> <STATE>CA</STATE>
You can also generate the DBUri-ref dynamically using the SYS_DBURIGEN SQL function.
For example you can generate a DBuri-ref to the state attribute as shown below:-
select sys_dburigen(e.ename,e.address.state) AS urlcol from scott.employee e;
This member function returns a CLOB by following the DBUriType and getting the document.
Get the DbUri-ref stored in the external form, i.e. the non-Url characters such as spaces are escaped, using the standard escape sequence, %xx where xx is the hexadecimal value of the UTF-8 encoding of the character.
Returns the URL stored in the type without any escaping. This function must be used instead of directly referencing the url attribute in the type.
Static function to construct a DbUri instance.
Get the document pointed to by the DBUri-ref
MEMBER FUNCTION getClob() RETURN clob
A temporary lob containing the document pointed to by the URL
You need to free the temporary clob.
The document obtained may be a XML document or a text document. When the DBUri-ref identifies an element in the XPath, the result is a well-formed XML document. On the other hand, if it identifies a text node (using the text() function), then we get back only the text contents of the column or attribute.
Get the URL stored inside the instance after escaping the non-URL characters as specified in the Uri-ref specification.
MEMBER FUNCTION getExternalUrl() RETURN varchar2
Generates the escaped URL that can be used in HTML web pages. You would still have to append the DBUri servlet that can process the DBUri-ref before using it in web pages.
Get the URL stored inside the instance without escaping the non-URL characters.
MEMBER FUNCTION getUrl() RETURN varchar2
Generates the URL that is present in the HttpUri instance.
Static function to construct a DbUri-ref instance.
STATIC FUNCTION createUri(url IN varchar2) RETURN DbUriType
url (IN) - the url string containing a valid HTTP URL. The url string is assumed to be in the escaped form. i.e. non-url characters are represented as %xx where xx is the hexadecimal value for the UTF-8 encoding of the character.
Parses the URL given and creates a Uri-ref type instance.
The UriFactory package contains factory methods that can be used to generate the appropriate instance of the Uri types without having to hard code the implementation in the program.
The UriFactory package also provides the ability to register new subtypes of the UriType to handle various other protocols not supported by Oracle9i. For example, one can invent a new protocol "ecom://" and define a subtype of the UriType to handle that protocol and register it with UriFactory. After that any factory method would generate the new subtype instance if it sees the ecom prefix.
For example,
create table url_tab (urlcol varchar2(20)); -- insert a Http reference insert into url_tab values ('http://www.oracle.com'); -- insert a DBuri-ref reference insert into url_tab values ('/SCOTT/EMPLOYEE/ROW[ENAME="Jack"]'); -- create a new type to handle a new protocol called ecom:// create type EComUriType under UriType ( overriding member function getClob() return clob, overriding member function getBlob() return blob, -- not supported overriding member function getExternalUrl() return varchar2, overriding member function getUrl() return varchar2, -- MUST NEED THIS for registering with the url handler static member function createUri(url in varchar2) return EcomUriType ); / -- register a new protocol handler. begin -- register a new handler for ecom:// prefixes. The handler -- type name is ECOMURITYPE, schema is SCOTT -- Ignore the prefix case, when comparing and also strip the prefix -- before calling the createUri function urifactory.registerHandler('ecom://','SCOTT','ECOMURITYPE', true,true); end; / insert into url_tab values ('ECOM://company1/company2=22/comp'); -- now use the factory to generate the instances.! select urifactory.getUri(urlcol) from url_tab; -- would now generate HttpUriType('www.oracle.com'); -- a Http uri type instance DBUriType('/SCOTT/EMPLOYEE/ROW[ENAME="Jack"],null); -- a DBUriType EComUriType('company1/company2=22/comp'); -- a EComUriType instance
This function takes in the Url string and generates the appropriate handler instance.
Escape the given URL in to the external form, i.e. the non-Url characters such as spaces are escaped, using the standard escape sequence, %xx where xx is the hexadecimal value of the UTF-8 encoding of the character.
Un-escape a URL. i.e. convert the %xx escape sequence into the corresponding characters.
This procedure registers a Url handler given the prefix to scan for and the schema and type name that handles the given URL.
This function deletes a handler for a particular prefix.
Factory method to get the correct Url handler for the given URL string. Returns a subtype instance of the UriType.
FUNCTION getUrl(url IN Varchar2) RETURN UriType
url (IN) - the url string containing a valid HTTP URL. The url string is assumed to be in the escaped form. i.e. non-url characters are represented as %xx where xx is the hexadecimal value for the UTF-8 encoding of the character.
A subtype instance of the UriType which can handle the protocol. By default it always creates a DBuri-ref instance, if it cannot resolve the URL.
The user can register a URL handler for a particular prefix using the registerUrlHandler and the getUrl would use that subtype if the prefix matches.
Escape the url string by replacing the non-URL characters as specified in the Uri-ref specification by their equivalent escape sequence.
MEMBER FUNCTION escapeUri() RETURN varchar2
url (IN) - the url string containing a valid URL.
Generates the escaped URL that can be used in HTML web pages. The subtype instances override this member function to provide additional semantics. For instance, the HttpUriType does not store the prefix http:// in the Url itself. When generating the external Url, it appends the prefix and generates it. This is the reason that you should use the getExternalUrl or getUrl to get to the URL value instead of using the attribute present in the UriType.
Un-escape a given url.
FUNCTION unescapeUri() RETURN varchar2
url (IN) - the url string that needs to be un-escaped
Reverse of the escapeUri. Scans the string and converts any %xx into the equivalent UTF-8 character. Since the return type is a VARCHAR2, the character would be converted into the equivalent character as defined by the database character set.
Register a particular type name for handling a particular URL.
PROCEDURE registerUrlHandler(prefix IN varchar2, schemaName in varchar2, typename in varchar2, ignoreCase in boolean := true, stripprefix in boolean := true)
prefix (IN) - the prefix to handle (e.g. http://) schemaName (IN) - the name of the schema in which the type resides typename (IN) - the name of the type to handle the URL Both the typename and schemaname are case sensitive. ignorecase (IN) - should the case be ignored when matching prefixes? stripprefix (IN) - should the prefix be stripped before generating the instance of the type?
Register a URL handler. The type specified must be valid and MUST be a subtype of the UriType or one of it's subtypes. The type MUST also implement the following static member function
STATIC FUNCTION createUri(url IN varchar2) RETURN <typename>;
This function is called by the getUrl() to generate an instance of the type. The stripprefix indicates that the prefix must be stripped off before calling this function.
Un-register a Url handler.
PROCEDURE unregisterUrlHandler(prefix in varchar2)
prefix (IN) - the prefix that should be unregistered.
Un-registers a particular prefix. Note that this would only un-register user registered handler prefixes and not the sytem predefined prefixes such as http://
Oracle9i has introduced a new datatype for handling XML data. This datatype is a system defined object type that has predefined member function on it to extract XML nodes and fragments.
You can create columns of XMLType and insert XML documents into it. You can also generate XML documents as XMLType instances dynamically using the SYS_XMLGEN and SYS_XMLAGG SQL functions.
For example,
create table xml_tab ( xmlval sys.xmltype); insert into xml_tab values ( sys.xmltype.createxml('<?xml version="1.0"?> <EMP> <EMPNO>221</EMPNO> <ENAME>John</ENAME> </EMP>')); insert into xml_tab values ( sys.xmltype.createxml('<?xml version="1.0"?> <PO> <PONO>331</PONO> <PONAME>PO_1</PONAME> </PO>')); -- now extract the numerical values for the employee numbers select e.xmlval.extract('//EMPNO/text()').getNumVal() as empno from xml_tab where e.xmlval.existsnode('/EMP/EMPNO') = 1;
This static function creates an XMLType instance from a string.
This static function creates an XMLType instance from a CLOB.
Checks if the given XPath expression returns any result nodes. Returns 1 for true.
Applies the XPath expression over the XML data to return a XMLType instance containing the resultant fragment.
Returns 1 or 0 indicating if the XMLType instance contains a fragment or a well-formed document.
Returns the document as a CLOB.
Returns the fragment or text value in the XMLType to a number.
Returns the document as a string.
Static function to create the XMLType instance from a string.
STATIC FUNCTION createXML(xmlval IN varchar2) RETURN sys.XMLType deterministic
xmlval (IN) - string containing the XML document
An XMLType instance.
The string must contain a well-formed and valid XML document.
Static function to create the XMLType instance from a CLOB.
STATIC FUNCTION createXML(xmlval IN clob) RETURN sys.XMLType deterministic
xmlval (IN) - CLOB containing the XML document
An XMLType instance.
The CLOB must contain a well-formed and valid XML document.
Given an XPath expression, checks if the XPath applied over the document can return any valid nodes.
MEMBER FUNCTION existsNode(xpath IN varchar2) RETURN number deterministic
xpath (IN) - the XPath expression to test
0 if the XPath expression does not return any nodes else 1.
If the XPath string is null or the document is empty, then a value of 0 is returned.
Given an XPath expression, applies the XPath to the document and returns the fragment as an XMLType
MEMBER FUNCTION extract(xpath IN varchar2) RETURN sys.XMLType deterministic
xpath (IN) - the XPath expression to apply
An XMLType instance containing the result node(s).
If the XPath does not result in any nodes, then the result is NULL.
Determine if the XMLType instance corresponds to a well-formed document, or a fragment.
MEMBER FUNCTION isFragment() RETURN boolean deterministic
Returns 1 or 0 indicating if the XMLType instance contains a fragment or a well-formed document.
Gets the document as a CLOB
MEMBER FUNCTION getClobVal() RETURN clob deterministic
An CLOB containing the seralized XML representation.
You need to free the temporary CLOB after use.
Gets the numeric value pointed to by the XMLType as a number
MEMBER FUNCTION getNumVal() RETURN number deterministic
An number formatted from the text value pointed to by the XMLType instance.
The XMLType must point to a valid text node that contains a numerical value.
Gets the document as a string.
MEMBER FUNCTION getStringVal() RETURN varchar2 deterministic
A string containing the seralized XML representation, or in case of text nodes, the text itself.
If the XML document is bigger than the maximum size of the varchar2, which is 4000, then an error is raised at run time.
|
Copyright © 1996-2001, Oracle Corporation. All Rights Reserved. |
|