Download Stylus Studio - The World's Best XML Development Environment!


com.ddtek.jxtr
Class JXTRResultSetWrapper

java.lang.Object
  |
  +--com.ddtek.jxtr.JXTRBase
        |
        +--com.ddtek.jxtr.JXTRQueryBase
              |
              +--com.ddtek.jxtr.JXTRResultSetWrapper

public class JXTRResultSetWrapper
extends JXTRQueryBase

JXTRResultSetWrapper implements the methods required to execute a SQL query (instead of a SQL/XML query or jXTransformer query) and generate an XML document. The JXTRResultSetWrapper class wraps XML elements or attributes around the row and column data that is retrieved from the RDBMS.

The JXTRResultSetWrapper class allows you to generate XML documents based on any type of result set generating statement that the RDBMS supports. Statements that generate multiple result sets (typically stored procedures) are also supported; however, stored procedures with output parameters are not supported.

Because an RDBMS statement does not allow you to specify an XML structure, Connect for SQL/XML supports two XML document structures: flat-attribute and element-centric XML documents.

For flat-attribute (attribute-centric) XML documents, all data retrieved from the database is structured inside attributes (one attribute for each column). One element is created for each row retrieved and the column values are defined as its attributes. Attribute names are derived from the database column names.

For element-centric XML documents, all data retrieved from the database is structured inside elements. One element is created for each row retrieved and the column values are defined as its subelements. Element names are derived from the database column names.

Because column names in a database may not always be valid XML element or attribute names (for example, column names can contain spaces, but XML names cannot) an element/attribute name is generated for those columns: 'Column-nnn', where nnn is the index of the column in the result set.


Field Summary
static int ATTRIBUTE_CENTRIC
          Constant value used to generate flat-attribute XML documents.
static int ELEMENT_CENTRIC
          Constant value used to generate element-centric XML documents.
 
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
JXTRResultSetWrapper(java.sql.Connection con, java.lang.String stat, int mode)
          Constructs a JXTRResultSetWrapper object.
 
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.
 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.
 java.lang.String getRowElementTag()
          Gets the XML name for the row tags.
 void setRowElementTag(java.lang.String rowElementTag)
          Sets the XML name for the row tags.
 
Methods inherited from class com.ddtek.jxtr.JXTRQueryBase
addDocumentComment, addDocumentPI, addRootAttribute, addRootNameSpace, addRootNameSpace, getBinaryEncoding, getDatabaseExtension, getJDBCStatType, getPreferredJDBCStatType, getTimestampEncoding, setBigDecimal, setBinaryEncoding, setBoolean, setByte, setBytes, setDatabaseExtension, setDate, setDouble, setExternalDTD, setExternalDTD, setFloat, setInt, setLong, setNull, setNullReplacementValue, setObject, setObject, setObject, setPreferredJDBCStatType, setRootTag, setShort, setString, setTime, setTimestamp, setTimestampEncoding
 
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

ATTRIBUTE_CENTRIC

public static final int ATTRIBUTE_CENTRIC
Constant value used to generate flat-attribute XML documents.

See Also:
Constant Field Values

ELEMENT_CENTRIC

public static final int ELEMENT_CENTRIC
Constant value used to generate element-centric XML documents.

See Also:
Constant Field Values
Constructor Detail

JXTRResultSetWrapper

public JXTRResultSetWrapper(java.sql.Connection con,
                            java.lang.String stat,
                            int mode)
                     throws JXTRException
Constructs a JXTRResultSetWrapper object.

Parameters:
con - Reference to an open JDBC connection. The connection must be kept open until the last 'execute' has been invoked.
stat - RDBMS statement for which XML will be generated.
mode - XML structure (either ATTRIBUTE_CENTRIC or ELEMENT_CENTRIC).
Throws:
JXTRException - Refer to the JXTRException class for more information about possible error conditions.
See Also:
JXTRException
Method Detail

close

public void close()
           throws JXTRException
Description copied from class: JXTRBase
Closes database prepared statement(s).

Specified by:
close in class JXTRBase
Throws:
JXTRException - if an error occured during closing of resources or database statement(s).

setRowElementTag

public void setRowElementTag(java.lang.String rowElementTag)
                      throws JXTRException
Sets the XML name for the row tags. The default value is 'row'.

Parameters:
rowElementTag - The element name for the row tag.
Throws:
JXTRException - Refer to the JXTRException class for more information about possible error conditions.
See Also:
JXTRException

getRowElementTag

public java.lang.String getRowElementTag()
Gets the XML name for the row tags.

Returns:
The element name for the row tag.

executeDOM

public org.w3c.dom.Document executeDOM()
                                throws JXTRException
Description copied from class: JXTRQueryBase
Executes the jXTransformer query and returns the XML result as a DOM level 2 document object.

To 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.

Specified by:
executeDOM in class JXTRQueryBase
Throws:
JXTRException - Refer to the JXTRException class for more information about possible error conditions.
See Also:
JXTRException

executeDOM

public void executeDOM(org.w3c.dom.Node domNode)
                throws JXTRException
Description copied from class: JXTRQueryBase
Executes the jXTransformer query and creates the XML result under the specified DOM level 2 node.

Specified by:
executeDOM in class JXTRQueryBase
Parameters:
domNode - DOM level 2 node under which the XML result will be created.
Throws:
JXTRException - Refer to the JXTRException class for more information about possible error conditions.
See Also:
JXTRException

executeWriter

public void executeWriter(java.io.Writer xmlWriter,
                          boolean outputDocHeader)
                   throws JXTRException
Description copied from class: JXTRQueryBase
Executes the jXTransformer query and writes the XML as a character stream to the specified writer, which should use UTF-8 encoding.

Specified by:
executeWriter in class JXTRQueryBase
Parameters:
xmlWriter - 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)).
Throws:
JXTRException - Refer to the JXTRException class for more information about possible error conditions.
See Also:
JXTRException

executeWriter

public void executeWriter(java.io.Writer xmlWriter,
                          boolean outputDocHeader,
                          int indentLevel)
                   throws JXTRException
Description copied from class: JXTRQueryBase
Executes the jXTransformer query and writes the XML result as a character stream to the specified writer, which should use UTF-8 encoding. Each element level in the XML result is indented by the specified number of spaces.

Specified by:
executeWriter in class JXTRQueryBase
Parameters:
xmlWriter - 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.
Throws:
JXTRException - Refer to the JXTRException class for more information about possible error conditions.
See Also:
JXTRException

executeWriter

public void executeWriter(java.io.Writer xmlWriter,
                          boolean outputDocHeader,
                          java.lang.String encoding)
                   throws JXTRException
Description copied from class: JXTRQueryBase
Executes the jXTransformer query and writes the XML result as a character stream to the specified writer, which should use the specified encoding.

Specified by:
executeWriter in class JXTRQueryBase
Parameters:
xmlWriter - 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.
Throws:
JXTRException - Refer to the JXTRException class for more information about possible error conditions.
See Also:
JXTRException

executeWriter

public void executeWriter(java.io.Writer xmlWriter,
                          boolean outputDocHeader,
                          java.lang.String encoding,
                          int indentLevel)
                   throws JXTRException
Description copied from class: JXTRQueryBase
Executes the jXTransformer query and writes the XML as a character stream to the specified writer, which should use the specified encoding. Each element level in the resulting XML is indented the specified number of spaces.

Specified by:
executeWriter in class JXTRQueryBase
Parameters:
xmlWriter - 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.
Throws:
JXTRException - Refer to the JXTRException class for more information about possible error conditions.
See Also:
JXTRException

executeJDOM

public org.jdom.Document executeJDOM()
                              throws JXTRException
Description copied from class: JXTRQueryBase
Executes the jXTransformer query and returns a JDOM document.

Specified by:
executeJDOM in class JXTRQueryBase
Returns:
Generated JDOM document.
Throws:
JXTRException - Refer to the JXTRException class for more information about possible error conditions.
See Also:
JXTRException, org.jdom.Document

executeJDOM

public void executeJDOM(org.jdom.Element domElement)
                 throws JXTRException
Description copied from class: JXTRQueryBase
Executes the jXTransformer query and creates the XML result under the specified JDOM element node.

Specified by:
executeJDOM in class JXTRQueryBase
Parameters:
domElement - JDOM element node under which the resulting XML will be created.
Throws:
JXTRException - Refer to the JXTRException class for more information about possible error conditions.
See Also:
JXTRException

executeSAX

public void executeSAX(org.xml.sax.XMLReader xmlReader)
                throws JXTRException
Description copied from class: JXTRQueryBase
Executes the jXTransformer query and invokes SAX2 callbacks registered with the specified XMLReader.

The xmlReader must be an object of type JXTRSaxReader or the xmlReader features must be set as supported by JXTRSaxReader.

Specified by:
executeSAX in class JXTRQueryBase
Parameters:
xmlReader - SAX2 XML Reader whose registered handlers will receive the SAX2 events.
Throws:
JXTRException - Refer to the JXTRException class for more information about possible error conditions.
See Also:
JXTRException

dump

public void dump(java.io.Writer dumpTo)
          throws JXTRException
Description copied from class: JXTRQueryBase
Dumps the JXTRQuery internal structure. Only used for troubleshooting purposes.

Specified by:
dump in class JXTRQueryBase
Parameters:
dumpTo - Writer to which the information will be dumped.
Throws:
JXTRException - Refer to the JXTRException class for more information about possible error conditions.
See Also:
JXTRException

generateDTD

public void generateDTD(java.io.Writer dtdWriter)
                 throws JXTRException
Description copied from class: JXTRQueryBase
Generates a DTD describing the structure of the jXTransformer query result and writes the DTD to the specified Writer.

Specified by:
generateDTD in class JXTRQueryBase
Parameters:
dtdWriter - Writer to which the DTD will be written.
Throws:
JXTRException - Refer to the JXTRException class for more information about possible error conditions.
See Also:
JXTRException

generateXMLSchema

public void generateXMLSchema(java.io.Writer schemaWriter)
                       throws JXTRException
Description copied from class: JXTRQueryBase
Generates an XML Schema describing the structure of the jXTransformer query result and writes the XML Schema to the specified Writer. The generated XML Schema is compliant with the W3C Recommendation, 2 May 2001.

Specified by:
generateXMLSchema in class JXTRQueryBase
Parameters:
schemaWriter - Writer to which the XML Schema will be written.
Throws:
JXTRException - Refer to the JXTRException class for more information about possible error conditions.
See Also:
JXTRException, XML Schema Part 0: Primer, XML Schema Part 1: Structures, XML Schema Part 2: Datatypes

generateXMLSchema

public void generateXMLSchema(java.io.Writer schemaWriter,
                              java.lang.String targetNamespace)
                       throws JXTRException
Description copied from class: JXTRQueryBase
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. An XML Schema is generated for the specified namespace. The generated XML Schema is compliant with the W3C Recommendation, 2 May 2001.

Specified by:
generateXMLSchema in class JXTRQueryBase
Parameters:
schemaWriter - 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.
Throws:
JXTRException - Refer to the JXTRException class for more information about possible error conditions.
See Also:
JXTRException, XML Schema Part 0: Primer, XML Schema Part 1: Structures, XML Schema Part 2: Datatypes

generateXMLSchema

public void generateXMLSchema(java.io.Writer schemaWriter,
                              java.lang.String targetNamespace,
                              java.lang.String encoding)
                       throws JXTRException
Description copied from class: JXTRQueryBase
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. An XML Schema is generated for the specified namespace. The generated XML Schema is compliant with the W3C Recommendation, 2 May 2001.

Specified by:
generateXMLSchema in class JXTRQueryBase
Parameters:
schemaWriter - 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.
Throws:
JXTRException - Refer to the JXTRException class for more information about possible error conditions.
See Also:
JXTRException, XML Schema Part 0: Primer, XML Schema Part 1: Structures, XML Schema Part 2: Datatypes

generateXMLSchema

public void generateXMLSchema(java.io.Writer schemaWriter,
                              java.lang.String targetNamespace,
                              int indentLevel)
                       throws JXTRException
Description copied from class: JXTRQueryBase
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. The element levels in the generated XML Schema are indented by the specified number of spaces. The generated XML Schema is compliant with the W3C Recommendation, 2 May 2001.

Specified by:
generateXMLSchema in class JXTRQueryBase
Parameters:
schemaWriter - 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.
Throws:
JXTRException - Refer to the JXTRException class for more information about possible error conditions.
See Also:
JXTRException, XML Schema Part 0: Primer, XML Schema Part 1: Structures, XML Schema Part 2: Datatypes

generateXMLSchema

public void generateXMLSchema(java.io.Writer schemaWriter,
                              java.lang.String targetNamespace,
                              java.lang.String encoding,
                              int indentLevel)
                       throws JXTRException
Description copied from class: JXTRQueryBase
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. An XML Schema is generated for the specified namespace. The element levels in the generated XML Schema are indented by the specified number of spaces. The generated XML Schema is compliant with the W3C Recommendation, 2 May 2001.

Specified by:
generateXMLSchema in class JXTRQueryBase
Parameters:
schemaWriter - 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.
Throws:
JXTRException - Refer to the JXTRException class for more information about possible error conditions.
See Also:
JXTRException, XML Schema Part 0: Primer, XML Schema Part 1: Structures, XML Schema Part 2: Datatypes

generateXMLSchema

public void generateXMLSchema(java.util.Map targetNamespaceSchemaFileMap)
                       throws JXTRException
Description copied from class: JXTRQueryBase
Generates multiple XML Schemas describing the structure of the jXTransformer query result. The specified HashMap maps namespace URIs to filenames. As a result, one XML Schema is generated for each specified namespace. Each XML Schema is written using UTF-8 encoding in the specified file associated with the namespace. The generated XML Schemas are compliant with the W3C Recommendation, 2 May 2001.

Specified by:
generateXMLSchema in class JXTRQueryBase
Parameters:
targetNamespaceSchemaFileMap - 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.
Throws:
JXTRException - Refer to the JXTRException class for more information about possible error conditions.
See Also:
JXTRException, XML Schema Part 0: Primer, XML Schema Part 1: Structures, XML Schema Part 2: Datatypes

generateXMLSchema

public void generateXMLSchema(java.util.Map targetNamespaceSchemaFileMap,
                              java.lang.String encoding)
                       throws JXTRException
Description copied from class: JXTRQueryBase
Generates multiple XML Schemas describing the structure of the jXTransformer query result. The specified HashMap maps namespace URIs to filenames. As a result, one XML Schema is generated for each specified namespace. Each XML Schema is written using the specified encoding in the specified file associated with the namespace. The generated XML Schemas are compliant with the W3C Recommendation, 2 May 2001.

Specified by:
generateXMLSchema in class JXTRQueryBase
Parameters:
targetNamespaceSchemaFileMap - 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.
Throws:
JXTRException - Refer to the JXTRException class for more information about possible error conditions.
See Also:
JXTRException, XML Schema Part 0: Primer, XML Schema Part 1: Structures, XML Schema Part 2: Datatypes

generateXMLSchema

public void generateXMLSchema(java.util.Map targetNamespaceSchemaFileMap,
                              int indentLevel)
                       throws JXTRException
Description copied from class: JXTRQueryBase
Generates multiple XML Schemas describing the structure of the jXTransformer query result. The specified HashMap maps namespace URIs to filenames. As a result, one XML Schema is generated for each specified namespace. Each XML Schema is written using UTF-8 encoding in the file associated with the specified namespace. Element levels in the generated XML Schemas are indented by the specified number of spaces. The generated XML Schemas are compliant with the W3C Recommendation, 2 May 2001.

Specified by:
generateXMLSchema in class JXTRQueryBase
Parameters:
targetNamespaceSchemaFileMap - 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.
Throws:
JXTRException - Refer to the JXTRException class for more information about possible error conditions.
See Also:
JXTRException, XML Schema Part 0: Primer, XML Schema Part 1: Structures, XML Schema Part 2: Datatypes

generateXMLSchema

public void generateXMLSchema(java.util.Map targetNamespaceSchemaFileMap,
                              java.lang.String encoding,
                              int indentLevel)
                       throws JXTRException
Description copied from class: JXTRQueryBase
Generates multiple XML Schemas describing the structure of the jXTransformer query result. The specified HashMap maps namespace URIs to filenames. As a result, one XML Schema is generated for each specified namespace. The XML Schemas are written using the specified encoding in the file associated with the specified namespace. Element levels in the generated XML Schemas are indented by the specified number of spaces. The generated XML Schemas are compliant with the W3C Recommendation, 2 May 2001.

Specified by:
generateXMLSchema in class JXTRQueryBase
Parameters:
targetNamespaceSchemaFileMap - 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.
Throws:
JXTRException - Refer to the JXTRException class for more information about possible error conditions.
See Also:
JXTRException, XML Schema Part 0: Primer, XML Schema Part 1: Structures, XML Schema Part 2: Datatypes


Stylus Studio features SQL/XML tools for building XML views of relational data.