Oracle® Application Developer's Guide - XML 10g (9.0.4) Part Number B12099-01 |
|
This appendix contains the following sections:
Table H-1 lists XML SQL Utility (XSU) distribution archive (zip file) contents.
To install XML SQL Utility (XSU) follow these steps:
Download the correct XSU distribution archive from the Oracle Technology Network web-site (http://otn.oracle.com). Expand the downloaded archive. Depending on the usage scenario, perform the following install tasks:
To use the XSU's client side front-end or its java API, you need to:
To use XSU's PL/SQL API, or write java stored procedures on top of XSU's java API, you need to:
xsulload.xxx
names the desired schema into which the XSU is to be loaded (default "scott/tiger").
xsuload.xxx
that loads the parser.
dbmsxsu.sql
PL/SQL script)
There are two versions of the utility, xsu111.jar and xsu12.jar, one compatible for JDK 1.1.x and the other with JDK1.2 respectively.
XML SQL Utility (XSU) is packaged with Oracle8i (8.1.7 and later) and Oracle. XSU is made up of three files:
dbmsxsu.sql
is executed.
By default the Oracle installer installs XSU on your hard drive in the locations specified above. It also loads it into the database.
If during initial installation you choose to not install XSU, you can install it later, but the installation becomes less simple. To install XSU later, first install XSU and its dependent components on your system. You can accomplish this using Oracle Installer. Next perform the following steps:
$ORACLE_HOME/admin
and execute catxsu.sql
XML SQL Utility (XSU) is also available on OTN at: http://otn.oracle.com/tech/xml Check here for XSU updates.
Note:
Before installing the utility make sure that you choose the right version of the utility depending on your particular needs. For example, if you can only use the JDK1.1.x version, then download the xsu111.jar file. Ensure that you have the JDK and the JDBC drivers correctly downloaded and installed, if not already available.
After downloading the zip file, simply extract the contents to a directory of your choice, say C:\xml. The files will get expanded in to a subdirectory called xsu111 or xsu112 depending on the version of the utility.
The following tables summarize XSU Java API classes and members:
Table H-2 XSU Java API: Class OracleXMLQuery
Methods, Parameters, Returns, Constructors, ... | Description |
---|---|
public class OracleXMLSave extends java.lang.Object where java.lang.Object is oracle.xml.sql.dml.OracleXMLSave |
Supports canonical mapping from XML to object-relational tables or views. It supports inserts, updates and deletes. You first create the class by passing in the table name on which the DML operations need to be done. After that, the user is free to use the insert/update/delete on this table. The useful functions provided in this class help identify the key columns for update or delete and restrict the columns being updated. |
Fields |
- |
DATE_FORMAT public static final java.lang.String DATE_FORMAT |
The date format for use in setDateFormat |
DEFAULT_BATCH_SIZE public static int DEFAULT_BATCH_SIZE |
default insert batch size is 17 |
Constructors |
- |
OracleXMLSave(Connection, String) public OracleXMLSave(java.sql.Connection oconn, java.lang.String tabName) |
The public constructor for the Save class. |
Parameters |
oconn - Connection object (connection to the database), tableName - The name of the table that should be updated |
Methods |
- |
cleanLobList() public void cleanLobList() |
- |
close() public void close() |
Closes/deallocates all the context associated with this object. |
createURL(String) public java.net.URL createURL(java.lang.String fileName) |
Deprecated since XSU2.0. Use the static version of this method instead. |
deleteXML(Document) public int deleteXML(org.w3c.dom.Document doc) |
Deletes the rows in the table based on the XML document. |
Parameters |
xmlDoc - The XML document in DOM form |
Returns |
The number of XML ROW elements processed. See Also: deleteXML(URL) |
deleteXML(InputStream) public int deleteXML(java.io.InputStream xmlStream) |
Deletes the rows in the table based on the XML document. |
Parameters |
xmlDoc - The XML document in Stream form |
Returns |
The number of XML ROW elements processed. See Also: deleteXML(URL) |
deleteXML(Reader) public int deleteXML(java.io.Reader xmlStream) |
Deletes the rows in the table based on the XML document. |
Parameters |
xmlDoc - The XML document in Stream form |
Returns |
The number of XML ROW elements processed.See Also: deleteXML(URL) |
deleteXML(String) public int deleteXML(java.lang.String xmlDoc) |
Deletes the rows in the table based on the XML document. |
Parameters |
xmlDoc - The XML document in String form |
Returns |
The number of XML ROW elements processed.See Also: deleteXML(URL) |
deleteXML(URL) public int deleteXML(java.net.URL url) |
Deletes rows from a specified table based on the element values in the supplied XML document. By default, the delete processing matches all the element values with the corresponding column names. Each ROW element in the input document is taken as a separate delete statement on the table. |
Parameters |
url - The URL to the document to use to delete the rows in the table |
Returns |
Number of XML row elements processed. This may or may not be equal to the number of database rows deleted based on whether the rows selected through the XML document uniquely identified the rows in the table. |
finalize() protected void finalize() |
Overrides: java.lang.Object.finalize() in class java.lang.Object |
getURL(String) public static java.net.URL getURL(java.lang.String target) |
Given a file name or a URL it return a URL object. If the argument passed is not in the valid URL format (e.g. http://.. or file://) then this method tried to fix the argument by pre-pending "file://" to the argument. If a null or an empty string are passed to it, null is returned. |
Parameters |
target - file name or URL string |
Returns |
the URL object identifiying the target entity |
insertXML(Document) public int insertXML(org.w3c.dom.Document doc) |
- |
insertXML(InputStream) public int insertXML(java.io.InputStream xmlStream) |
- |
insertXML(Reader) public int insertXML(java.io.Reader xmlStream) |
- |
insertXML(String) public int insertXML(java.lang.String xmlDoc) |
- |
insertXML(URL) public int insertXML(java.net.URL url) |
Inserts an XML document from a specified URL into the specified table. By default, the insert routine inserts values into the table by matching the element name with the column name and inserts a null value for all elements missing in the input document. By setting the list of columns to insert using the setUpdateColumnList() you can restrict the insert to only insert values into those columns and let the default values for other columns to be inserted. For more details see Chapter 7, "XML SQL Utility (XSU)" and Oracle9i XML Reference |
Parameters |
url - The URL to the document to use to insert rows into the table |
Returns |
The number of rows inserted. |
removeXSLTParam(String) public void removeXSLTParam(java.lang.String name) |
Removes the value of a top-level stylesheet parameter. If no stylesheet is registered, this method is non operational. |
Parameters |
name - parameter name |
setBatchSize(int) public void setBatchSize(int size) |
Changes the batch size used during DML operations. When inserting, updating, or deleting, it is better to batch the operations so that the database can execute it once rather than as separate statements. However, more memory is needed to hold all the bind values before the operation is done. Note when batching is used, the commits occur only in terms of batches. So if one of the statement inside a batch fails, the whole batch is rolled back. If this behaviour is unaccepatable, set the batch size to 1. The default batch size is DEFAULT_BATCH_SIZE; |
Parameters |
size - The batch size to use for all DML |
setCommitBatch(int) public void setCommitBatch(int size) |
Sets the commit batch size. The commit batch size refers to the number or records inserted after which a commit should follow. If commitBatch is < 1 or the session is in "auto-commit" mode then XSU does not make any explicit commit's. By default the commit-batch size is 0. |
Parameters |
size - commit batch size |
setDateFormat(String) public void setDateFormat(java.lang.String mask) |
Describes to XSU the format of the dates in the XML document. By default, |
Parameters |
mask - the date mask |
setIgnoreCase(boolean) public void setIgnoreCase(boolean ignore) |
XSU maps XML elements to database columns/attributes based on element names (XML tags). This function tells XSU to do this match case insensitively. This resetting of case may affect metadata caching done when creating the Save object. |
Parameters |
flag - ignore tag case in the XML doc? 0-false 1-true |
setKeyColumnList(String[]) public void setKeyColumnList(java.lang.String[] keyColNames) |
Sets the list of columns to be used for identifying a particular row in the database table during update or delete. This call is ignored for the inserts. Key columns must be set before updates can be done. It is optional for deletes. When this key columns is set, then the values from these tags in the XML document is used to identify the database row for update or delete. Currently, there is no way to update the values of the key columns themselves, since there is no way in the XML document to specify that case. |
Parameters |
keyColNames - The names of the list of columns that are used as keys |
setRowTag(String) public void setRowTag(java.lang.String rowTag) |
Names the tag used in the XML doc., to enclose the XML elements corresponding to each row value. Setting the value of this to null implies that there is no row tag present and the top level elements of the document correspond to the rows themselves. |
Parameters |
tag - tag name |
setUpdateColumnList(String[]) public void setUpdateColumnList(java.lang.String[] updColNames) |
Sets column values to be updated. Only valid for inserts and updates. Ignored for deletes. For inserts, the default is to insert values to all the columns in the table. For updates, the default is to only update the columns corresponding to the tags present in the ROW element of the XML document. When specified, these columns alone are updated in the UPDATE or INSERT statement. All other elements in the document are ignored. |
Parameters |
updColNames - The string list of columns to be updated |
setXSLT(Reader, String) public void setXSLT(java.io.Reader stylesheet, java.lang.String ref) |
Registers an XSL transform to be applied to generated XML. If a stylesheet was already registered, it gets replaced by the new one. To un-register the stylesheet pass in a null for the stylesheet argument. |
Parameters |
stylesheet - the stylesheet, ref - URL for include, import and external entities |
setXSLT(String, String) public void setXSLT(java.lang.String stylesheet, java.lang.String ref) |
Registers a XSL transform to be applied to generated XML. If a stylesheet was already registered, it gets replaced by the new one. To un-register the stylesheet pass in a null for the stylesheet argument. |
Parameters |
stylesheet - the stylesheet URI, ref - URL for include, import and external entities |
setXSLTParam(String, String) public void setXSLTParam(java.lang.String name, java.lang.String value) |
Sets the value of a top-level stylesheet parameter. The parameter value is expected to be a valid XPath expression (note that string literal values would therefore have to be explicitly quoted). If no stylesheet is registered, this method is a no op. |
Parameters |
name - parameter name, value - parameter value as an XPATH expression |
updateXML(Document) public int updateXML(org.w3c.dom.Document doc) |
Updates the table given the XML document in a DOM tree form. |
Parameters |
xmlDoc - The DOM tree form of the XML document |
Returns |
The number of XML elements processed. See Also: updateXML(URL) |
updateXML(InputStream) public int updateXML(java.io.InputStream xmlStream) |
Updates the table given the XML document in a stream form. |
Parameters |
xmlDoc - The stream form of the XML document |
Returns |
The number of XML elements processed. See Also: updateXML(URL) |
updateXML(Reader) public int updateXML(java.io.Reader xmlStream) |
Updates the table given the XML document in a stream form. |
Parameters |
xmlDoc - The stream form of the XML document |
Returns |
The number of XML elements processed. See Also: updateXML(URL) |
updateXML(String) public int updateXML(java.lang.String xmlDoc) |
Updates the table given the XML document in a string form. |
Parameters |
xmlDoc - The string form of the XML document |
Returns |
The number of XML elements processed. See Also: updateXML(URL) |
updateXML(URL) public int updateXML(java.net.URL url) |
Updates the columns in a database table, based on the element values in the supplied XML document. The update requires a list of key columns which are used to uniquely identify a row to update in the given table. By default, the update uses the list of key columns and matches the values of the corresponding elements in the XML document to identify a particular row and then updates all the columns in the table for which there is an equivalent element present in the XML document. |
Parameters |
url - The URL to the document to use to update the table |
Returns |
The number of XML row elements processed. This may or may not be equal to the number of database rows modified based on whether the rows selected through the XML document uniquely identified the rows in the table. |
XML SQL Utility (XSU) for PL/SQL offers the following PL/SQL packages:
Table H-6 lists DBMS_XMLQuery
procedures, functions, and constants.
Table H-7 lists DBMS_XMLSave
procedures, functions, types, and constants.
|
Copyright © 2001, 2003 Oracle Corporation. All Rights Reserved. |
|