|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--com.ddtek.jxtr.JXTRBase
|
+--com.ddtek.jxtr.JXTRQueryBase
|
+--com.ddtek.jxtr.JXTRQuery
JXTRQuery implements all processing required to generate an XML document from a jXTransformer query.
A JXTRQuery object is created by passing a JDBC connection object
and a valid jXTransformer query (as a string) to the constructor
JXTRQuery(Connection,String).
Once the JXTRQuery object has been created, the following methods support further customizing of the resulting XML.
JXTRQueryBase.setExternalDTD(String) or
JXTRQueryBase.setExternalDTD(String,String).JXTRQueryBase.addDocumentPI(String,String).JXTRQueryBase.addDocumentComment(String).JXTRQueryBase.setRootTag(String).JXTRQueryBase.setNullReplacementValue(String).setXXX methods. Optionally, see the JDBC
documentation.
JXTRQueryBase.setNull(int,int) and the equivalent method
in the JDBC documentation.JXTRQueryBase.addRootAttribute(String,String).JXTRQueryBase.addRootNameSpace(String,String).Once the JXTRQuery object is created and customized, the method used to execute the jXTransformer query depends on the target format of the XML document.
executeWriter(Writer,boolean),
executeWriter(Writer,boolean,int),
executeWriter(Writer,boolean,String),
executeWriter(Writer,boolean,String,int).executeDOM().executeDOM(Node).executeJDOM().executeJDOM(org.jdom.Element).executeSAX(XMLReader).Alternatively one can request a resultset type of view on the created
XML. When invoking executeQuery(), an object of type JXTRResultSet
is returned.
XML meta information that describes the XML result for the jXTransformer can be generated through the following methods.
generateDTD(Writer).generateXMLSchema(Writer) and related methods.For more information, see the following available resources:
To support the preceding features, Connect for SQL/XML is installed with:
| Field Summary | |
static int |
EMPTY_ELEMENT_CREATED
"Empty element" create behavior. |
static int |
EMPTY_ELEMENT_NOT_CREATED
"Empty element" create behavior. |
static int |
EMPTY_ELEMENT_NOTSET
"Empty element" create behavior. |
static int |
NESTED_LOOP
Constant for nested loop rewrite algorithm. |
static int |
NOT_SET
Constant to indicate when rewrite algorithm information is not available. |
static int |
ORDER_BY_ORDINAL_EXPR_IN_XML
Semantics of 'order by |
static int |
ORDER_BY_ORDINAL_EXPR_NOT_IN_XML
Semantics of 'order by |
static int |
ORDER_BY_ORDINAL_NOTSET
Semantics of 'order by |
static int |
OUTER_UNION
Constant for outer union rewrite algorithm. |
static int |
SORTED_OUTER_UNION
Constant for sorted outer union rewrite algorithm. |
static int |
XML_EXPLICIT
Constant for XML explicit rewrite algorithm. |
static int |
XMLTYPE
Constant to be considered an extension to java.sql.types. |
| Fields inherited from class com.ddtek.jxtr.JXTRQueryBase |
JDBC_PREPARED_STAT, JDBC_STAT, JDBC_STATTYPE_NOTSET |
| Fields inherited from class com.ddtek.jxtr.JXTRBase |
BINARY_AS_BASE64, BINARY_AS_HEX, TIMESTAMP_AS_ISO8601, TIMESTAMP_AS_ODBC |
| Constructor Summary | |
JXTRQuery(java.sql.Connection con,
java.lang.String jxtrStat)
Constructs a JXTRQuery object based on the provided JDBC connection and jXTransformer query text. |
|
JXTRQuery(java.sql.Connection con,
java.lang.String jxtrStat,
int rewriteAlgorithm)
Constructs a JXTRQuery object based on the provided JDBC connection, jXTransformer query, and rewrite algorithm. |
|
| Method Summary | |
void |
close()
Closes database prepared statement(s). |
void |
dump(java.io.Writer dumpTo)
Dumps the JXTRQuery internal structure. |
org.w3c.dom.Document |
executeDOM()
Executes the jXTransformer query and returns the XML result as a DOM level 2 document object. |
void |
executeDOM(org.w3c.dom.Node domNode)
Executes the jXTransformer query and creates the XML result under the specified DOM level 2 node. |
org.jdom.Document |
executeJDOM()
Executes the jXTransformer query and returns a JDOM document. |
void |
executeJDOM(org.jdom.Element domElement)
Executes the jXTransformer query and creates the XML result under the specified JDOM element node. |
JXTRResultSet |
executeQuery()
Executes a jXTransformer query and returns XML values in a result set. |
void |
executeSAX(org.xml.sax.XMLReader xmlReader)
Executes the jXTransformer query and invokes SAX2 callbacks registered with the specified XMLReader. |
void |
executeWriter(java.io.Writer xmlWriter,
boolean outputDocHeader)
Executes the jXTransformer query and writes the XML as a character stream to the specified writer, which should use UTF-8 encoding. |
void |
executeWriter(java.io.Writer xmlWriter,
boolean outputDocHeader,
int indentLevel)
Executes the jXTransformer query and writes the XML result as a character stream to the specified writer, which should use UTF-8 encoding. |
void |
executeWriter(java.io.Writer xmlWriter,
boolean outputDocHeader,
java.lang.String encoding)
Executes the jXTransformer query and writes the XML result as a character stream to the specified writer, which should use the specified encoding. |
void |
executeWriter(java.io.Writer xmlWriter,
boolean outputDocHeader,
java.lang.String encoding,
int indentLevel)
Executes the jXTransformer query and writes the XML as a character stream to the specified writer, which should use the specified encoding. |
void |
generateDTD(java.io.Writer dtdWriter)
Generates a DTD describing the structure of the jXTransformer query result and writes the DTD to the specified Writer. |
void |
generateXMLSchema(java.util.Map targetNamespaceSchemaFileMap)
Generates multiple XML Schemas describing the structure of the jXTransformer query result. |
void |
generateXMLSchema(java.util.Map targetNamespaceSchemaFileMap,
int indentLevel)
Generates multiple XML Schemas describing the structure of the jXTransformer query result. |
void |
generateXMLSchema(java.util.Map targetNamespaceSchemaFileMap,
java.lang.String encoding)
Generates multiple XML Schemas describing the structure of the jXTransformer query result. |
void |
generateXMLSchema(java.util.Map targetNamespaceSchemaFileMap,
java.lang.String encoding,
int indentLevel)
Generates multiple XML Schemas describing the structure of the jXTransformer query result. |
void |
generateXMLSchema(java.io.Writer schemaWriter)
Generates an XML Schema describing the structure of the jXTransformer query result and writes the XML Schema to the specified Writer. |
void |
generateXMLSchema(java.io.Writer schemaWriter,
java.lang.String targetNamespace)
Generates an XML Schema describing the structure of the jXTransformer query result and writes the XML Schema to the specified Writer, which should use UTF-8 encoding. |
void |
generateXMLSchema(java.io.Writer schemaWriter,
java.lang.String targetNamespace,
int indentLevel)
Generates an XML Schema describing the structure of the jXTransformer query result and writes the XML Schema to the specified Writer, which should use UTF-8 encoding. |
void |
generateXMLSchema(java.io.Writer schemaWriter,
java.lang.String targetNamespace,
java.lang.String encoding)
Generates an XML Schema describing the structure of the jXTransformer query result and writes the result to the specified Writer, which should use the specified encoding. |
void |
generateXMLSchema(java.io.Writer schemaWriter,
java.lang.String targetNamespace,
java.lang.String encoding,
int indentLevel)
Generates an XML Schema describing the structure of the jXTransformer query result and writes the XML Schema to the specified Writer, which should use the specified encoding. |
int |
getAlgorithm()
Returns the rewrite algorithm used to process the query. |
int |
getEmptyElementCreateBehavior()
Returns create behavior for empty elements for this jXTransformer query. |
int |
getOrderByOrdinalBehavior()
Returns order by ordinal behavior for this jXTransformer query. |
void |
setEmptyElementCreateBehavior(int emptyElementCreateBehavior)
Sets behavior for empty elements. |
void |
setOrderByOrdinalBehavior(int orderByOrdinalBehavior)
Sets behavior of order by expressions.
|
| Methods inherited from class com.ddtek.jxtr.JXTRBase |
clearWarnings, getPreparedStatementCloseBehaviour, getWarnings, setPreparedStatementCloseBehaviour, unlock |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int NOT_SET
getAlgorithm() before the
jXTransformer query is executed.
public static final int NESTED_LOOP
JXTRQuery(java.sql.Connection, java.lang.String, int)
and getAlgorithm().
public static final int OUTER_UNION
JXTRQuery(java.sql.Connection, java.lang.String, int)
and getAlgorithm().
public static final int SORTED_OUTER_UNION
JXTRQuery(java.sql.Connection, java.lang.String, int)
and getAlgorithm().
public static final int XML_EXPLICIT
JXTRQuery(java.sql.Connection, java.lang.String, int)
and getAlgorithm().
public static final int XMLTYPE
public static final int ORDER_BY_ORDINAL_NOTSET
setOrderByOrdinalBehavior(int)
public static final int ORDER_BY_ORDINAL_EXPR_IN_XML
setOrderByOrdinalBehavior(int)
public static final int ORDER_BY_ORDINAL_EXPR_NOT_IN_XML
setOrderByOrdinalBehavior(int)
public static final int EMPTY_ELEMENT_NOT_CREATED
setEmptyElementCreateBehavior(int)
public static final int EMPTY_ELEMENT_CREATED
setEmptyElementCreateBehavior(int)
public static final int EMPTY_ELEMENT_NOTSET
setEmptyElementCreateBehavior(int)
| Constructor Detail |
public JXTRQuery(java.sql.Connection con,
java.lang.String jxtrStat)
throws JXTRException
con - Reference to an open JDBC connection. The connection must
remain open until the last 'execute' has been invoked.jxtrStat - jXTransformer query to execute.
JXTRException - Refer to the JXTRException class
for more information about error conditions.JXTRException
public JXTRQuery(java.sql.Connection con,
java.lang.String jxtrStat,
int rewriteAlgorithm)
throws JXTRException
con - Reference to an open JDBC connection. The connection must
be kept open until the last 'execute' has been invoked.jxtrStat - jXTransformer query to execute.rewriteAlgorithm - A supported rewrite algorithm (either
NESTED_LOOP, OUTER_UNION, SORTED_OUTER_UNION, or XML_EXPLICIT).
JXTRException - Refer to the JXTRException class
for more information about possible error conditions.JXTRException| Method Detail |
public void close()
throws JXTRException
JXTRBase
close in class JXTRBaseJXTRException - if an error occured during closing of
resources or database statement(s).
public org.w3c.dom.Document executeDOM()
throws JXTRException
JXTRQueryBaseTo create the DOM level 2 object, Connect for SQL/XML uses JAXP 1.1. Any DOM level 2 implementation that supports JAXP 1.1 can be used.
executeDOM in class JXTRQueryBaseJXTRException - Refer to the JXTRException class
for more information about possible error conditions.JXTRException
public void executeDOM(org.w3c.dom.Node domNode)
throws JXTRException
JXTRQueryBase
executeDOM in class JXTRQueryBasedomNode - DOM level 2 node under which the XML result will
be created.
JXTRException - Refer to the JXTRException class
for more information about possible error conditions.JXTRException
public void executeWriter(java.io.Writer xmlWriter,
boolean outputDocHeader)
throws JXTRException
JXTRQueryBase
executeWriter in class JXTRQueryBasexmlWriter - Writer to which the XML result will be streamed.outputDocHeader - When set to false, no XML
document header or root element will be created. When set to
true, a complete XML document will be created with
a document header and root element. If a root element is not
specified, a default root element of jxtr-result will be used
(see JXTRQueryBase.setRootTag(String)).
JXTRException - Refer to the JXTRException class
for more information about possible error conditions.JXTRException
public void executeWriter(java.io.Writer xmlWriter,
boolean outputDocHeader,
int indentLevel)
throws JXTRException
JXTRQueryBase
executeWriter in class JXTRQueryBasexmlWriter - Writer to which the XML document will be streamed.outputDocHeader - When set to false, no XML
document header or root element will be created. When set to
true, a complete XML document will be created with
a document header and root element. If a root element is not
specified, a default root element of jxtr-result will be used
(see JXTRQueryBase.setRootTag(String)).indentLevel - Number of spaces each element level will be indented.
JXTRException - Refer to the JXTRException class
for more information about possible error conditions.JXTRException
public void executeWriter(java.io.Writer xmlWriter,
boolean outputDocHeader,
java.lang.String encoding)
throws JXTRException
JXTRQueryBase
executeWriter in class JXTRQueryBasexmlWriter - Writer to which the XML result will be streamed.outputDocHeader - When set to false, no XML
document header or root element will be created. When set to
true, a complete XML document will be created with
a document header and root element. If a root element is not
specified, a default root element of jxtr-result will be used
(see JXTRQueryBase.setRootTag(String)).encoding - Encoding the specified writer will use.
JXTRException - Refer to the JXTRException class
for more information about possible error conditions.JXTRException
public void executeWriter(java.io.Writer xmlWriter,
boolean outputDocHeader,
java.lang.String encoding,
int indentLevel)
throws JXTRException
JXTRQueryBase
executeWriter in class JXTRQueryBasexmlWriter - Writer to which the XML document will be streamed.outputDocHeader - When set to false, no XML
document header or root element is created. When set to
true, a complete XML document is created with
a document header and root element. If a root element is not
specified, a default root element of jxtr-result will be used
(see JXTRQueryBase.setRootTag(String)).encoding - Encoding the specified writer will use.indentLevel - Number of spaces each element level will be indented.
JXTRException - Refer to the JXTRException class
for more information about possible error conditions.JXTRException
public org.jdom.Document executeJDOM()
throws JXTRException
JXTRQueryBase
executeJDOM in class JXTRQueryBaseJXTRException - Refer to the JXTRException class
for more information about possible error conditions.JXTRException,
org.jdom.Document
public void executeJDOM(org.jdom.Element domElement)
throws JXTRException
JXTRQueryBase
executeJDOM in class JXTRQueryBasedomElement - JDOM element node under which the resulting XML
will be created.
JXTRException - Refer to the JXTRException class
for more information about possible error conditions.JXTRException
public void executeSAX(org.xml.sax.XMLReader xmlReader)
throws JXTRException
JXTRQueryBaseThe xmlReader must be an object of type JXTRSaxReader
or the xmlReader features must be set as supported by
JXTRSaxReader.
executeSAX in class JXTRQueryBasexmlReader - SAX2 XML Reader whose registered handlers
will receive the SAX2 events.
JXTRException - Refer to the JXTRException class
for more information about possible error conditions.JXTRException
public JXTRResultSet executeQuery()
throws JXTRException
Instead of returning one merged XML result, as is the case with all other execute methods, JXTRResultSet allows you to scroll through the resulting XML on a row by row basis.
JXTRExceptionJXTRResultSet
public void dump(java.io.Writer dumpTo)
throws JXTRException
JXTRQueryBase
dump in class JXTRQueryBasedumpTo - Writer to which the information will be dumped.
JXTRException - Refer to the JXTRException class
for more information about possible error conditions.JXTRException
public int getAlgorithm()
throws JXTRException
JXTRException - Refer to the JXTRException class
for more information about possible error conditions.
JXTRExceptionJXTRException
public void generateDTD(java.io.Writer dtdWriter)
throws JXTRException
JXTRQueryBase
generateDTD in class JXTRQueryBasedtdWriter - Writer to which the DTD will be written.
JXTRException - Refer to the JXTRException class
for more information about possible error conditions.JXTRException
public void generateXMLSchema(java.io.Writer schemaWriter)
throws JXTRException
JXTRQueryBase
generateXMLSchema in class JXTRQueryBaseschemaWriter - Writer to which the XML Schema will be written.
JXTRException - Refer to the JXTRException class
for more information about possible error conditions.JXTRException,
XML Schema Part 0: Primer,
XML Schema Part 1: Structures,
XML Schema Part 2: Datatypes
public void generateXMLSchema(java.io.Writer schemaWriter,
java.lang.String targetNamespace)
throws JXTRException
JXTRQueryBase
generateXMLSchema in class JXTRQueryBaseschemaWriter - Writer to which the XML Schema will be written.targetNamespace - Namespace for which the XML Schema will be
generated or null to generate an XML Schema for those
elements/attributes that do not have a namespace.
JXTRException - Refer to the JXTRException class
for more information about possible error conditions.JXTRException,
XML Schema Part 0: Primer,
XML Schema Part 1: Structures,
XML Schema Part 2: Datatypes
public void generateXMLSchema(java.io.Writer schemaWriter,
java.lang.String targetNamespace,
java.lang.String encoding)
throws JXTRException
JXTRQueryBase
generateXMLSchema in class JXTRQueryBaseschemaWriter - Writer to which the XML Schema will be written.targetNamespace - Namespace for which the XML Schema will be
generated or null to generate an XML Schema for those
elements/attributes that do not have a namespace.encoding - Encoding the specified writer will use.
JXTRException - Refer to the JXTRException class
for more information about possible error conditions.JXTRException,
XML Schema Part 0: Primer,
XML Schema Part 1: Structures,
XML Schema Part 2: Datatypes
public void generateXMLSchema(java.io.Writer schemaWriter,
java.lang.String targetNamespace,
int indentLevel)
throws JXTRException
JXTRQueryBase
generateXMLSchema in class JXTRQueryBaseschemaWriter - Writer to which the XML Schema will be written.targetNamespace - Namespace for which the XML Schema will be
generated or null to generate an XML Schema for those
elements/attributes that do not have a namespace.indentLevel - Number of spaces to indent each element level.
JXTRException - Refer to the JXTRException class
for more information about possible error conditions.JXTRException,
XML Schema Part 0: Primer,
XML Schema Part 1: Structures,
XML Schema Part 2: Datatypes
public void generateXMLSchema(java.io.Writer schemaWriter,
java.lang.String targetNamespace,
java.lang.String encoding,
int indentLevel)
throws JXTRException
JXTRQueryBase
generateXMLSchema in class JXTRQueryBaseschemaWriter - Writer to which the XML Schema is written.targetNamespace - Namespace for which the XML Schema will be
generated or null to generate an XML Schema for those
elements/attributes that do not have a namespace.encoding - Encoding the specified writer will use.indentLevel - Number of spaces to indent each element level.
JXTRException - Refer to the JXTRException class
for more information about possible error conditions.JXTRException,
XML Schema Part 0: Primer,
XML Schema Part 1: Structures,
XML Schema Part 2: Datatypes
public void generateXMLSchema(java.util.Map targetNamespaceSchemaFileMap)
throws JXTRException
JXTRQueryBase
generateXMLSchema in class JXTRQueryBasetargetNamespaceSchemaFileMap - Map containing the
namespaces (keys) and their associated output XML Schema
filenames (values). A null key is used to generate XML
Schemas for elements/attributes that do not have a namespace.
JXTRException - Refer to the JXTRException class
for more information about possible error conditions.JXTRException,
XML Schema Part 0: Primer,
XML Schema Part 1: Structures,
XML Schema Part 2: Datatypes
public void generateXMLSchema(java.util.Map targetNamespaceSchemaFileMap,
java.lang.String encoding)
throws JXTRException
JXTRQueryBase
generateXMLSchema in class JXTRQueryBasetargetNamespaceSchemaFileMap - Map containing the
namespaces (keys) and their associated output XML Schema
filenames (values). A null key is used to generate XML
Schemas for elements/attributes that do not have a namespace.encoding - Encoding the specified writer will use.
JXTRException - Refer to the JXTRException class
for more information about possible error conditions.JXTRException,
XML Schema Part 0: Primer,
XML Schema Part 1: Structures,
XML Schema Part 2: Datatypes
public void generateXMLSchema(java.util.Map targetNamespaceSchemaFileMap,
int indentLevel)
throws JXTRException
JXTRQueryBase
generateXMLSchema in class JXTRQueryBasetargetNamespaceSchemaFileMap - Map containing the
namespaces (keys) and their associated output XML Schema
filenames (values). A null key is used to generate XML
Schemas for elements/attributes that do not have a namespace.
JXTRException - Refer to the JXTRException class
for more information about possible error conditions.JXTRException,
XML Schema Part 0: Primer,
XML Schema Part 1: Structures,
XML Schema Part 2: Datatypes
public void generateXMLSchema(java.util.Map targetNamespaceSchemaFileMap,
java.lang.String encoding,
int indentLevel)
throws JXTRException
JXTRQueryBase
generateXMLSchema in class JXTRQueryBasetargetNamespaceSchemaFileMap - Map containing the
namespaces (keys) and their associated output XML Schema
filenames (values). A null key is used to generate XML
Schemas for elements/attributes that do not have a namespace.encoding - Encoding the specified writer will use.
JXTRException - Refer to the JXTRException class
for more information about possible error conditions.JXTRException,
XML Schema Part 0: Primer,
XML Schema Part 1: Structures,
XML Schema Part 2: Datatypes
public void setOrderByOrdinalBehavior(int orderByOrdinalBehavior)
throws JXTRException
order by expressions.
order by When specifying ORDER_BY_ORDINAL_IN_XML, the ordinal number can refer to
expressions that can be located inside XML constructs. Each 'selected
expression' (inside or outside an XML construct) gets a unique sequence
number.
When specifying ORDER_BY_ORDINAL_NOT_IN_XML, the ordinal number cannot
refer to expressions inside XML constructs. The sequence numbers are
determined by counting the top-level expressions, including XML constructs.
Example
When using ORDER_BY_ORDINAL_IN_XML, the result is sorted on
e.FirstName, but when using ORDER_BY_ORDINAL_NOT_IN_XML the result is
sorted on e.StartDate.
select
e.Title,
xml_element('emp',
xml_attribute('id',e.EmpId),
xml_element('name',e.FirstName)),
e.StartDate
from Employees e
order by 3
orderByOrdinalBehavior - one of ORDER_BY_ORDINAL_IN_XML or
ORDER_BY_ORDINAL_NOT_IN_XML.
JXTRException
public int getOrderByOrdinalBehavior()
setOrderByOrdinalBehavior(int)
public void setEmptyElementCreateBehavior(int emptyElementCreateBehavior)
throws JXTRException
When using EMPTY_ELEMENT_CREATED, an empty element
will be created when a NULL value is fetched from the database.
This setting matches the SQL/XML semantics.
When using EMPTY_ELEMENT_NOT_CREATED, no element will
be created. This setting matches jXTransformer 1.1 behavior.
JXTRExceptionpublic int getEmptyElementCreateBehavior()
setEmptyElementCreateBehavior(int)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||