|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--oracle.xml.sql.query.OracleXMLQuery
The OracleXMLQuery
class does the generation of XML given a
SQL query. Following is a very simple example:
import java.sql.*; import oracle.xml.sql.query.*; import oracle.jdbc.driver.*; 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 |
Type | Field |
---|---|
static int |
DTD
The DTD is used to specified that the DTD is to be generated |
static java.lang.String |
ERROR_TAG
The ERROR_TAG specifies the default tag name for the ERROR document |
static int |
MAXROWS_ALL
The MAXROWS_ALL specifies that all rows 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
The NONE is used to specified that no DTD is to be generated |
static java.lang.String |
ROW_TAG
The ROW_TAG specifies the default tag name for the ROW elements |
static java.lang.String |
ROWIDATTR_TAG
The ROWIDATTR_TAG specifies the default tag name for the ROW elements |
static java.lang.String |
ROWSET_TAG
The ROWSET_TAG specifies the default tag name for the document |
static int |
SCHEMA
The SCHEMA is used to specified that no XML schema is to be generated |
static int |
SKIPROWS_ALL
The 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 OracleXMLQueryObject. |
OracleXMLQuery(oracle.xml.sql.query.OracleXMLDataSet dset)
Constructor for the OracleXMLQueryObject. |
Method Summary |
Type | Method |
---|---|
void |
close()
Close any open resource, created by the OracleXML engine. |
java.lang.Object |
getInternalObj()
This is an internal API. |
long |
getNumRowsProcessed()
Returns the number of rows processed. |
void |
getXML(oracle.xml.sql.query.OracleXMLDocGen doc)
NOTE: THIS IS AN INTERNAL CALL Transforms the object-relational data, specified in the constructor, into a XML document which is returned via the doc argument. |
void |
getXML(oracle.xml.sql.query.OracleXMLDocGen doc,
boolean withDTD)
Deprecated. since v2.0 |
void |
getXML(oracle.xml.sql.query.OracleXMLDocGen doc,
int metaType)
NOTE: THIS IS AN INTERNAL CALL Transforms the object-relational data, specified in the constructor, into a XML document which is returned via the doc argument. |
Document |
getXMLDOM()
Transforms the object-relational data, specified in the constructor, into a 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 a XML document. |
Document |
getXMLDOM(Node root)
Transforms the object-relational data, specified in the constructor, into XML. |
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)
This functions returns the DTD or the XMLSchema for the XML document which would have been generated by a getXML call. |
void |
getXMLMetaData(int metaType,
boolean withVer,
oracle.xml.sql.query.OracleXMLDocGen doc)
NOTE: THIS IS AN INTERNAL CALL This functions returns the DTD or the XMLSchema for the XML document which would have been generated by a getXML call. |
void |
getXMLSAX(ContentHandler sax)
Transforms the object-relational data, specified in the constructor, into a XML document. |
Document[] |
getXMLSchema()
This methods generated the XML Schema(s) corresponding to the specified query. |
java.lang.String |
getXMLString()
Transforms the object-relational data, specified in the constructor, into a 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 a XML document. |
java.lang.String |
getXMLString(Node root)
Transforms the object-relational data, specified in the constructor, into XML. |
java.lang.String |
getXMLString(Node root,
int metaType)
Transforms the object-relational data, specified in the constructor, into XML. |
void |
keepCursorState(boolean alive)
Deprecated. since 1.2.1; use keepObjectOpen instead. |
void |
keepObjectOpen(boolean alive)
The default behavior for all the getXML functions which DO NOT TAKE in a ResultSet object is to close the ResultSet object and Statement objects at the end of the call. |
void |
removeXSLTParam(java.lang.String name)
Removes the value of a top-level stylesheet parameter. |
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 id attribute of the collection element's separator tag. |
void |
setDataHeader(java.io.Reader header,
java.lang.String docTag)
Sets the xml data header. |
void |
setDateFormat(java.lang.String mask)
Sets the format of the generated dates in the XML doc. |
void |
setEncoding(java.lang.String enc)
Sets the encoding PI (processing instruction) in the XML doc. |
void |
setErrorTag(java.lang.String tag)
Sets the tag to be used to enclose the xml error docs. |
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 max number of rows to be converted to XML. |
void |
setMetaHeader(java.io.Reader header)
Sets the XML meta header. |
void |
setRaiseException(boolean flag)
Tells the XSU to throw the raised exceptions. |
void |
setRaiseNoRowsException(boolean flag)
Tells the XSU to throw or not to throw an OracleXMLNoRowsException in the case when for one reason or another, the XML doc generated is empty. |
void |
setRowIdAttrName(java.lang.String attrName)
Sets the name of the id attribute of the row enclosing tag. |
void |
setRowIdAttrValue(java.lang.String colName)
Specifies the scalar column whose value is to be assigned to the id attribute of the row enclosing tag. |
void |
setRowIdColumn(java.lang.String colName)
Deprecated. since 1.2.1 -- please use setRowIdAttrValue instead. |
void |
setRowsetTag(java.lang.String tag)
Sets the tag to be 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. |
void |
setSkipRows(int rows)
Sets the number of rows to skip. |
void |
setSQLToXMLNameEscaping(boolean flag)
This turns on or off escaping of XML tags in the case that the SQL object name, which is mapped to a XML identifier, is not a valid XML identifier. |
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 (i.e. |
void |
setStylesheetHeader(java.lang.String uri,
java.lang.String type)
Sets the stylesheet header (i.e. |
void |
setXSLT(java.io.Reader stylesheet,
java.lang.String ref)
Registers a XSL transform to be applied to generated XML. |
void |
setXSLT(java.lang.String stylesheet,
java.lang.String ref)
Registers a XSL transform to be applied to generated XML. |
void |
setXSLTParam(java.lang.String name,
java.lang.String value)
Sets the value of a top-level stylesheet parameter. |
void |
useLowerCaseTagNames()
This will set the case to be lower for all tag names. |
void |
useNullAttributeIndicator(boolean flag)
Specified weather to use an XML attribute to indicate NULLness, or to do it by omitting the inclusion of the particular entity in the XML document. |
void |
useTypeForCollElemTag(boolean flag)
By default the tag name for elements of a collection is the collection's tag name followed by "_item". |
void |
useUpperCaseTagNames()
This will set the case to be upper 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
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
public static final java.lang.String ERROR_TAG
public static final java.lang.String ROWIDATTR_TAG
Constructor Detail |
public OracleXMLQuery(java.sql.Connection conn, java.lang.String query)
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.query.OracleXMLDataSet dset)
conn
- database connectiondset
- datasetMethod Detail |
public java.lang.String getXMLString()
public java.lang.String getXMLString(int metaType)
metaType
argument is used to
specify the type of XML metadata the XSU is to generate along with the
XML. Valid values for the metaType
argument are
NONE
and DTD
(static fields of this class).metaType
- the 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 doc.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 doc. The metaType
argument is
used to specify the type of XML metadata the XSU is to generate along
with the XML. Valid values for the metaType
argument are
NONE
and DTD
(static fields of this class).
Note that if the root
argument is non-null,
no DTD is generated even if requested.root
- root node to which to append the new XMLmetaType
- the 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 doc.root
- root node to which to append the new XMLpublic Document getXMLDOM(int metaType)
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.metaType
- the type of XML metadata (NONE, 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 getXMLSAX(ContentHandler sax)
sax
- ContentHandler object to be registeredpublic void getXML(oracle.xml.sql.query.OracleXMLDocGen doc)
doc
argument.doc
- object containing the generated XML documentpublic void getXML(oracle.xml.sql.query.OracleXMLDocGen doc, boolean withDTD)
public void getXML(oracle.xml.sql.query.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)
withVer
parameter specifies if version header is to be
generated or not.metaType
- XML meta data type to generate (NONE or DTD)withVer
- generate the version PI ?public void getXMLMetaData(int metaType, boolean withVer, oracle.xml.sql.query.OracleXMLDocGen doc)
withVer
parameter specifies if version header is to be
generated or not.metaType
- XML meta data type to generate (NONE or DTD)withVer
- generate the version PI ?doc
- object into which to write the metadatapublic Document[] getXMLSchema()
public void setMetaHeader(java.io.Reader header)
null
for the header
,
parameter unsets the meta header.header
- headerpublic void setDataHeader(java.io.Reader header, java.lang.String docTag)
docTag
argument.
Note that the last data header specified is the one that is used;
furthermore, passing in null
for the header
,
parameter unsets the data header.header
- headertag
- tag used to enclose the data header and the rowsetpublic void setEncoding(java.lang.String enc)
null
or an empty string are specified as the encoding,
then the default characterset is specified in the encoding PI.enc
- characterset encoding of the XML docpublic void setDateFormat(java.lang.String mask)
null
or an empty string, unsets
the date mask.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 an empty string for the tag
results the row id attribute to be omitted.attrName
- attribute namepublic void setRowIdAttrValue(java.lang.String colName)
null
or an empty string for the colName
results the row
id attribute being assigned the row count value (i.e. 0, 1, 2 and so on).colName
- column whose value is to be assigned to the row id attrpublic void setRowIdColumn(java.lang.String colName)
public void setCollIdAttrName(java.lang.String attrName)
null
or an empty string for the tag
results the row id attribute to be omitted.attrName
- attribute namepublic void setCollIdAttr(java.lang.String collIdAttr)
public void useTypeForCollElemTag(boolean flag)
true
, tells the XSU to use the collection element's type
name as the collection element tag name.flag
- use the coll. elem. type as its tag name?public void useNullAttributeIndicator(boolean flag)
flag
- use attribute to indicate null?public void setStylesheetHeader(java.lang.String uri)
null
for the uri
argument
will unset the stylesheet header and the stylesheet type.uri
- stylesheet URIpublic void setStyleSheet(java.lang.String uri)
setStylesheetHeader
instead.
public void setStylesheetHeader(java.lang.String uri, java.lang.String type)
null
for the uri
argument
will unset the stylesheet header and the stylesheet type.uri
- stylesheet URItype
- stylesheet type; defaults to '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
for the stylesheet
argument.stylesheet
- the stylesheet URIref
- URL for include, import and external entitiespublic void setXSLT(java.io.Reader stylesheet, java.lang.String ref)
null
for the stylesheet
argument.stylesheet
- the stylesheetref
- URL for include, import and external entitiespublic void setXSLTParam(java.lang.String name, java.lang.String value)
name
- parameter namevalue
- parameter value as an XPATH expressionpublic void removeXSLTParam(java.lang.String name)
name
- parameter namepublic void setSQLToXMLNameEscaping(boolean flag)
flag
- turn on SQL to XML identifier escaping.public 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)
false
is passed to the flag
argument,
the XSU catches the SQL exceptions and generates an XML doc out of
the exception's message.flag
- throw raised exceptions?public void setRaiseNoRowsException(boolean flag)
flag
- throw OracleXMLNoRowsException if no data found?public void setMaxRows(int rows)
rows
- max number of rows to generatepublic void setSkipRows(int rows)
rows
- number of rows to skippublic void close()
public void keepObjectOpen(boolean alive)
alive
- keep object open ?public void keepCursorState(boolean alive)
public java.lang.Object getInternalObj()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |