|
Oracle® Application Server XML Java API Reference 10g Release 3 (10.1.3) B28238-01 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
oracle.xml.sql.query.OracleXMLQuery
This generates XML from a SQL query. A typical sequence might look like this:
import java.sql.*; import oracle.xml.sql.query.*; import oracle.jdbc.*; public class sample { public static void main(String args[]) throws Exception { DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); Connection conn = DriverManager.getConnection("jdbc:oracle:oci8:scott/tiger@"); OracleXMLQuery qry = new OracleXMLQuery(conn, "select * from emp"); System.out.println(qry.getXMLString()); conn.close(); } }
Field Summary | |
static int |
DTD Specifies that a DTD is to be generated |
static java.lang.String |
ERROR_TAG Specifies the default tag name for the ERROR document |
static int |
MAXROWS_ALL Specifies that all rows should be included in the result |
static int |
MAXROWS_DEFAULT Deprecated. since v2.0; Use MAXROWS_ALL instead |
static int |
MAXROWS_NONE Deprecated. since v2.0; Use 0 instead |
static int |
NONE Specifies that a DTD is not to be generated. |
static java.lang.String |
ROW_TAG Specifies the default tag name for ROW elements. |
static java.lang.String |
ROWIDATTR_TAG Specifies the default tag name for the ROWIDATTR . |
static java.lang.String |
ROWSET_TAG Specifies the default tag name for the document. |
static int |
SCHEMA Specifies that an XML schema is not to be generated. |
static int |
SKIPROWS_ALL Specifies that all rows be skipped in the result. |
static int |
SKIPROWS_DEFAULT Deprecated. since v2.0; Use 0 instead |
static int |
SKIPROWS_NONE Deprecated. since v2.0; Use 0 instead |
Constructor Summary | |
OracleXMLQuery(java.sql.Connection conn, java.sql.ResultSet rset) Constructor for the OracleXMLQueryObject. |
|
OracleXMLQuery(java.sql.Connection conn, java.lang.String query) Constructor for the OracleXMLQuery object. |
|
OracleXMLQuery(oracle.xml.sql.dataset.OracleXMLDataSet dset) Constructor for the OracleXMLQueryObject. |
Method Summary | |
void |
bindValue(java.lang.String bindName, java.lang.String bindValue) Sets a bind name/value pair. |
void |
close() Closes open resources created by the OracleXML engine. |
long |
getNumRowsProcessed() Returns the number of rows processed. |
void |
getXML(oracle.xml.sql.docgen.OracleXMLDocGen doc, int metaType) NOTE: THIS IS AN INTERNAL CALL Transforms the object-relational data, specified in the constructor, into an XML document which is returned via the doc argument. |
Document |
getXMLDOM() Transforms the object-relational data, specified in the constructor, into an XML document. |
Document |
getXMLDOM(boolean withDTD) Deprecated. since 1.2.1; please use getXMLDOM(int) instead |
Document |
getXMLDOM(int metaType) Transforms the object-relational data, specified in the constructor, into an XML document. |
Document |
getXMLDOM(Node root) Transforms the object-relational data, specified in the constructor, into an XML document. |
Document |
getXMLDOM(Node root, int metaType) Transforms the object-relational data, specified in the constructor, into XML. |
java.lang.String |
getXMLMetaData(int metaType, boolean withVer) Returns either the DTD or the XMLSchema for the XML document generated by getXML calls. |
void |
getXMLSAX(ContentHandler sax) Transforms the object-relational data, specified in the constructor, into an XML document in SAX form. |
Document[] |
getXMLSchema() Generates XML Schema(s) corresponding to the query. |
void |
getXMLStream(Node root, int metaType, java.io.Writer out) Transforms the object-relational data, specified in the constructor, into XML. |
java.lang.String |
getXMLString() Transforms the object-relational data, specified in the constructor, into an XML document. |
java.lang.String |
getXMLString(boolean withDTD) Deprecated. since 1.2.1; please use getXMLString(int) instead |
java.lang.String |
getXMLString(int metaType) Transforms the object-relational data, specified in the constructor, into an XML document. |
java.lang.String |
getXMLString(Node root) Transforms the object-relational data, specified in the constructor, into an XML document. |
java.lang.String |
getXMLString(Node root, int metaType) Transforms the object-relational data, specified in the constructor, into an XML document. |
void |
keepCursorState(boolean alive) Deprecated. since 1.2.1; use keepObjectOpen instead. |
void |
keepObjectOpen(boolean alive) Specifies whether to keep the input object open after a getXML()/code> call. |
void |
removeXSLTParam(java.lang.String name) Removes the value of a top-level stylesheet parameter. |
void |
resetResultSet() Resets the result set to start XML generation from the from the first row of the resultset. |
void |
setCollIdAttr(java.lang.String collIdAttr) Deprecated. since 1.2.1; please use setCollIdAttrName instead. |
void |
setCollIdAttrName(java.lang.String attrName) Sets the name of the collection element separator tag id attribute. |
void |
setDataHeader(java.io.Reader header, java.lang.String docTag) Sets the XML data header. |
void |
setDateFormat(java.lang.String mask) Specifies the format of dates used in the XML document. |
void |
setEncoding(java.lang.String enc) Sets the processing instruction for encoding, the PI, in the XML document. |
void |
setErrorTag(java.lang.String tag) Sets the tag used to enclose the XML error documents. |
void |
setException(java.lang.Exception e) Allows the user to pass in an exception, and have the XSU handle it. |
void |
setMaxRows(int rows) Sets the maximum number of rows to be converted to XML. |
void |
setMetaHeader(java.io.Reader header) Sets the XML meta header. |
void |
setRaiseException(boolean flag) Specifies whether to throw the raised exceptions. |
void |
setRaiseNoRowsException(boolean flag) Specifies whether to throw an OracleXMLNoRowsException if the generated XML document is empty. |
void |
setRowIdAttrName(java.lang.String attrName) Sets the name of the row enclosing tag id attribute. |
void |
setRowIdAttrValue(java.lang.String colName) Specifies the scalar column whose value is assigned to the row id attribute. |
void |
setRowIdColumn(java.lang.String colName) Deprecated. since 1.2.1 -- please use setRowIdAttrValue instead. |
void |
setRowsetTag(java.lang.String tag) Sets the tag used to enclose the XML dataset. |
void |
setRowTag(java.lang.String tag) Sets the tag to be used to enclose the XML element corresponding to a db. record. |
void |
setSkipRows(int rows) Sets the number of rows to skip. |
void |
setSQLToXMLNameEscaping(boolean flag) Specifies whether to turn on XML tag escaping for SQL object names, to ensure conversion to valid XML identifiers. |
void |
setStrictLegalXMLCharCheck(boolean flag) Tells XSU whether it should do strict checking on the input data (as generated by the query) before generating the XML document. |
void |
setStyleSheet(java.lang.String uri) Deprecated. since XSU2.0 -- please use setStylesheetHeader instead. |
void |
setStyleSheet(java.lang.String uri, java.lang.String type) Deprecated. since XSU2.0 -- please use setStylesheetHeader instead. |
void |
setStylesheetHeader(java.lang.String uri) Sets the stylesheet header processing instructions in the generated XML document. |
void |
setStylesheetHeader(java.lang.String uri, java.lang.String type) Sets the stylesheet header processing instructions in the generated XML document. |
void |
setXSLT(java.io.Reader stylesheet, java.lang.String ref) Sets the XSL transformation to be applied to generated XML. |
void |
setXSLT(java.lang.String stylesheet, java.lang.String ref) Sets the XSL transformation to be applied to generated XML. |
void |
setXSLTParam(java.lang.String name, java.lang.String value) Sets the value for top-level stylesheet parameter. |
void |
useLowerCaseTagNames() Specifies use of lower case for all tag names. |
void |
useNullAttributeIndicator(boolean flag) Specifies whether to use an XML attribute to indicate NULLness, or by omitting the entity from the XML document. |
void |
useTypeForCollElemTag(boolean flag) Specifies the use of collection element's type name as the collection element tag name when called with a TRUE value for the flag parameter. |
void |
useUpperCaseTagNames() Specifies use of upper case for all tag names. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int MAXROWS_NONE
0
instead
public static final int MAXROWS_ALL
public static final int MAXROWS_DEFAULT
MAXROWS_ALL
instead
public static final int SKIPROWS_NONE
0
instead
public static final int SKIPROWS_ALL
public static final int SKIPROWS_DEFAULT
0
instead
public static final int NONE
public static final int DTD
public static final int SCHEMA
public static final java.lang.String ROWSET_TAG
public static final java.lang.String ROW_TAG
ROW
elements.
public static final java.lang.String ERROR_TAG
ERROR
document
public static final java.lang.String ROWIDATTR_TAG
ROWIDATTR
.
Constructor Detail |
public OracleXMLQuery(java.sql.Connection conn, java.lang.String query)
OracleXMLQuery
object.conn
- database connectionquery
- the SQL query stringpublic OracleXMLQuery(java.sql.Connection conn, java.sql.ResultSet rset)
conn
- database connectionrset
- jdbc result set objectpublic OracleXMLQuery(oracle.xml.sql.dataset.OracleXMLDataSet dset)
dset
- datasetMethod Detail |
public void bindValue(java.lang.String bindName, java.lang.String bindValue)
bindName
- bind namebindValue
- bind valuepublic void resetResultSet()
public java.lang.String getXMLString()
public java.lang.String getXMLString(int metaType)
metaType
argument specifies the type of XML metadata generated with the XML; valid values are NONE
. and DTD
, or SCHEMA
(static fields of this class).metaType
- type of XML metadata: NONE
, DTD
, or SCHEMA
public java.lang.String getXMLString(boolean withDTD)
public java.lang.String getXMLString(Node root)
root
argument is considered the "root" element of the XML document if its value is not null
.root
- root node to which to append the new XMLpublic java.lang.String getXMLString(Node root, int metaType)
root
argument is considered the "root" element of the XML document if its value is not null
. The metaType
argument specifies the type of XML metadata generate with the XML; valid values are NONE
and DTD
, static fields of this class. If the root argument is not null
, the DTD is not generated, even if requested.root
- root node to which to append the new XMLmetaType
- type of XML metadata: NONE
, DTD
, or SCHEMA
public Document getXMLDOM()
public Document getXMLDOM(Node root)
root
argument is considered the "root" element of the XML document if its value is not null
.root
- root node to which to append the new XMLpublic Document getXMLDOM(int metaType)
metaType
argument specifies the type of XML metadata generate with the XML; valid values are NONE
and SCHEMA
, static fields of this class.metaType
- type of XML metadata: NONE
or SCHEMA
public Document getXMLDOM(boolean withDTD)
public Document getXMLDOM(Node root, int metaType)
root
argument is considered the "root" element of the XML doc. The metaType
argument is used to specify the type of XML metadata the XSU is to generate along with the XML. Currently this value is ignored, and no XML metadata is generated.root
- root node to which to append the new XMLmetaType
- the type of XML metadata (NONE, SCHEMA)public void getXMLStream(Node root, int metaType, java.io.Writer out)
root
argument is considered the "root" element of the XML doc. The metaType
argument is used to specify the type of XML metadata the XSU is to generate along with the XML. The output is written to the stream passed in.root
- root node to which to append the new XMLmetaType
- the type of XML metadata (NONE, SCHEMA)out
- the stream to write the output topublic void getXMLSAX(ContentHandler sax)
sax
- ContentHandler object to be registeredpublic void getXML(oracle.xml.sql.docgen.OracleXMLDocGen doc, int metaType)
doc
argument.doc
- object containing the generated XML documentmetaType
- type of XML metadata to generate (NONE or DTD)public long getNumRowsProcessed()
public java.lang.String getXMLMetaData(int metaType, boolean withVer)
getXML
calls. The metaType
parameter specifies the type of XML metadata to be generated. The withVer
parameter specifies whether to generate the version header.metaType
- type of XML metadata: NONE
or DTD
withVer
- TRUE
to generate the version headerpublic Document[] getXMLSchema()
public void setMetaHeader(java.io.Reader header)
null
value for the header
parameter unsets the meta header.header
- headerpublic void setDataHeader(java.io.Reader header, java.lang.String docTag)
docTag
tag encloses the header and the rowset. The most recently specified data header is used; a null
value for the header
parameter unsets the data header.header
- headerdocTag
- tag used to enclose the data header and the rowsetpublic void setEncoding(java.lang.String enc)
enc
parameter is null
or an empty string.enc
- IANA name for encoding of the XML documentpublic void setStrictLegalXMLCharCheck(boolean flag)
flag
- do strict checking?public void setDateFormat(java.lang.String mask)
java.text.SimpleDateFormat
class. Setting the mask
parameter to null</null> or empty string sets the default mask
OracleXMLCore.DATE_FORMAT.mask
- the date maskpublic void setRowsetTag(java.lang.String tag)
tag
- tag namepublic void setRowTag(java.lang.String tag)
tag
- tag namepublic void setErrorTag(java.lang.String tag)
tag
- tag namepublic void setRowIdAttrName(java.lang.String attrName)
null
or empty string value in the attrName
omits the row id attribute.attrName
- attribute namepublic void setRowIdAttrValue(java.lang.String colName)
null
or empty string value in the colName
parameter assigns the row count value to the id attribute, 0
, 1
, 2
, and so on.colName
- column namepublic void setRowIdColumn(java.lang.String colName)
public void setCollIdAttrName(java.lang.String attrName)
null
or empty string value in the attrName
omits the separator tag id attribute.attrName
- attribute namepublic void setCollIdAttr(java.lang.String collIdAttr)
public void useTypeForCollElemTag(boolean flag)
TRUE
value for the flag
parameter. By default, the tag name is a concatenation of the tag name and "_item".flag
- TRUE
to use the element's type name as the tag namepublic void useNullAttributeIndicator(boolean flag)
flag
- TRUE
to use attribute to indicate null
public void setStylesheetHeader(java.lang.String uri)
null
value for uri
unsets the stylesheet header and type.uri
- stylesheet URIpublic void setStyleSheet(java.lang.String uri)
setStylesheetHeader
instead.public void setStylesheetHeader(java.lang.String uri, java.lang.String type)
null
value for uri
unsets the stylesheet header and type.uri
- stylesheet URItype
- stylesheet type; default value is text/xsl
public void setStyleSheet(java.lang.String uri, java.lang.String type)
setStylesheetHeader
instead.public void setXSLT(java.lang.String stylesheet, java.lang.String ref)
null
in the stylesheet
parameter.stylesheet
- the stylesheet URIref
- URL for include, import and external entitiespublic void setXSLT(java.io.Reader stylesheet, java.lang.String ref)
null
in the stylesheet
parameter.stylesheet
- the stylesheetref
- URL for include, import and external entitiespublic void setXSLTParam(java.lang.String name, java.lang.String value)
value
parameter is expected to be a valid XPath expression; literal String
values have to be explicitly quoted. This method is a no-op if no stylesheet is registered.name
- parameter namevalue
- parameter value as an XPATH expressionpublic void removeXSLTParam(java.lang.String name)
name
- parameter namepublic void setSQLToXMLNameEscaping(boolean flag)
flag
- TRUE
to turn on SQL to XML escapingpublic void useLowerCaseTagNames()
public void useUpperCaseTagNames()
public void setException(java.lang.Exception e)
e
- the exception to be processed by the XSU.public void setRaiseException(boolean flag)
flag
parameter is FALSE
, the SQL exceptions are caught and used to generate an XML exception message document.flag
- TRUE
to throw raised exceptionpublic void setRaiseNoRowsException(boolean flag)
OracleXMLNoRowsException
if the generated XML document is empty. By default, the exception is not thrown.flag
- TRUE
to throw OracleXMLNoRowsException
public void setMaxRows(int rows)
MAXROWS_ALL
field to explicitly specify the maximum number of rows.rows
- maximum number of rows to generatepublic void setSkipRows(int rows)
SKIPROWS_ALL
to skip all the rows.rows
- number of rows to skippublic void close()
OracleXML
engine. This call will not effect result sets supplied by the user.public void keepObjectOpen(boolean alive)
getXML()/code> call. If the input object remains open, successive calls to
getXML return successive sets of rows. By default, getXML()
calls that do not use a ResultSet
object close both the ResultSet
and Statement
objects. The close()
function explicitly closes the cursor state.alive
- TRUE
to keep the object openpublic void keepCursorState(boolean alive)
|
Oracle® Application Server XML Java API Reference 10g Release 3 (10.1.3) B28238-01 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |