Skip navigation links

Oracle® Database XML Java API Reference
12c Release 1 (12.1)

E15981-09


oracle.xdb
Class XMLType

java.lang.Object
  extended by oracle.sql.OPAQUE
      extended by oracle.xdb.XMLType

Direct Known Subclasses:
SQLXMLType

public class XMLType
extends oracle.sql.OPAQUE

Class that deals with XMLType objects.


Field Summary
static int _SQL_TYPECODE
          A constant set to OPAQUE oracle type.
static int CONNTYPE_KPRB
          KPRB connection type.
static int CONNTYPE_OCI8
          OCI8 connection type.
static int CONNTYPE_THIN
          Thin connection type.
static int DEF_INDENT
          Default indentation and print flags
static int MAX_INDENT
           
static int MAX_PFLAG
           
static int PRINT_DEFAULT_PROPERTY
           
static int PRINT_NOPRETTY
           
static int PRINT_PRETTY
           
static int XMLTYPE_PICKLE_AS_BINXML
           
static int XMLTYPE_PICKLE_AS_TEXT
          Flags to specify pickle preference, used in setPicklePreference

 

Constructor Summary
XMLType(java.sql.Connection conn, oracle.sql.BLOB xmlval, int csid)
          Construct an XMLType given a BLOB containing the XML data
XMLType(java.sql.Connection conn, oracle.sql.CLOB xmlval)
          Construct an XMLType given a CLOB containing the XML data
XMLType(java.sql.Connection conn, oracle.sql.CLOB xmlval, java.lang.String schemaURL, boolean wellformed, boolean valid)
          Construct an XMLType given a CLOB containing the XML data
XMLType(java.sql.Connection conn, java.lang.String xmlval)
          Construct an XMLType given the string containing the XML data
XMLType(java.sql.Connection conn, java.lang.String xmlval, java.lang.String schemaURL, boolean wellformed, boolean valid)
          Construct an XMLType given the string containing the XML data
XMLType(OpaqueDescriptor type, java.sql.Connection conn, java.lang.Object value)
          Create an XMLType given an opaque descriptor, connection and a pickled image.

 

Method Summary
static void cleanupCache(boolean forcemode)
          Clean-up method for an internal cache used for Binary XML decoding.
 void close()
          Function to free/close the XMLType.
 XMLType createSchemaBasedXML(java.lang.String schemaURL)
          Create a schema-based XML
static XMLType createXML(java.sql.Connection conn, oracle.sql.CLOB xmlval)
          Create an XMLType given a CLOB containing the XML data
static XMLType createXML(java.sql.Connection conn, oracle.sql.CLOB xmlval, java.lang.String schemaURL, boolean wellformed, boolean valid)
          Create an XMLType given a CLOB containing the XML data
static XMLType createXML(java.sql.Connection conn, java.lang.String xmlval, java.lang.String schemaURL, boolean wellformed, boolean valid)
          Create an XMLType given the string containing the XML data
static XMLType createXML(oracle.sql.OPAQUE opq)
          Create an XMLType given the opaque type containing the XMLType bytes
 boolean existsNode(java.lang.String xpath, java.lang.String nsmap)
          Function to check for the existence of the given set of nodes in the XMLType.
 XMLType extract(java.lang.String xpath, java.lang.String nsmap)
          Function to extract the given set of nodes from the XMLType.
 void free()
           
 java.io.InputStream getBinaryStream()
           
 oracle.sql.BLOB getBlobVal(int csid)
          Get the BLOB value containing the XML data from the XMLType.
 oracle.sql.BLOB getBlobVal(int csid, int pflag, int indent)
          Get the BLOB value containing the XML data from the XMLType.
 java.io.ByteArrayOutputStream getBytesVal()
           
 java.io.Reader getCharacterStream()
           
 oracle.sql.CLOB getClobVal()
          Get the CLOB value containing the XML data from the XMLType.
 oracle.sql.CLOB getClobVal(int pflag, int indent)
          Get the CLOB value containing the XML data from the XMLType.
static int getConnType(java.sql.Connection conn)
          Get the connection type of the given connection.
 int getCSid()
           
 Document getDocument()
          Gets the DOM document associated with the XMLType.
 XDBDocFragment getDocumentFragment()
          Function to return XDBDocFragment if XMLType instance is a fragment
 Document getDOM()
          Deprecated. use getDocument
static long getErrorHandle(java.sql.Connection conn, int conntype)
          Get the error handle given the connection and the connection type.
 java.io.InputStream getInputStream()
          Get an InputStream from the XMLType, applications can read XML data from the stream
 java.io.InputStream getInputStream(int pflag, int indent)
          Get an InputStream from the XMLType, applications can read XML data from the stream
 boolean getisReadonly()
           
 Document getmDom()
           
 java.lang.String getNamespace()
          return the default namespace of the XMLType document
 NUMBER getNumberVal()
          Return the numeric value of the XML document
 java.lang.String getRootElement()
          Return the root element name
 java.lang.String getSchemaURL()
          Return the schema URL (i.e. location of the schema to which this XMLType conforms)
static long getServiceHandle(java.sql.Connection conn, int conntype)
          Get the service handle given the connection and the connection type.
<T extends Source>
T
getSource(java.lang.Class<T> sourceClass)
           
 java.lang.String getString()
           
 java.lang.String getStringVal()
          Get the string value containing the XML data from the XMLType.
 java.lang.String getStringVal(int pflag, int indent)
          Get the string value containing the XML data from the XMLType.
 boolean isFragment()
          Function to check if the XMLType is a regular document or a document fragment.
 boolean isSchemaBased()
          Function to check if the XMLType is schema based.
 boolean isSchemaValid(java.lang.String schurl, java.lang.String elname)
          Function to check if the XMLType is schema based.
 boolean isSchemaValidated()
          Return TRUE if the document has been validated against its schema
 void schemaValidate()
          Validate the schema-based document against its own schema.
 java.io.OutputStream setBinaryStream()
           
 void setBinaryXML()
          Function to mark the XML type as Binary XML
 void setBinaryXMLEncoding(java.lang.String encoding)
          Sets the client requested encoding for retrieving Binary XML.
 java.io.Writer setCharacterStream()
           
 void setMetadataConn(java.lang.Object metaconn)
          Function to set the metadata connection to be used for getting Binary XML token data
 void setPicklePreference(int pref)
          Function to set how the XMLType will be sent across the wire.
<T extends Result>
T
setResult(java.lang.Class<T> resultClass)
           
 void setSchemaValidated(boolean validateFlag)
          This function sets the VALIDATED flag to indicate that the XMLType has been validated or not.
 void setString(java.lang.String str)
           
 XMLType transform(XMLType xsldoc, java.lang.String parammap)
          Function to transform the XMLType using the given XSL document.
 void writeToOutputStream(java.io.OutputStream os)
          Write the contents of the XMLType to an OutputStream
 void writeToOutputStream(java.io.OutputStream os, int pflag, int indent)
          Write the contents of the XMLType to an OutputStream

 

Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

_SQL_TYPECODE

public static final int _SQL_TYPECODE
A constant set to OPAQUE oracle type. Required for the ORADATA interface.

CONNTYPE_THIN

public static final int CONNTYPE_THIN
Thin connection type.
See Also:
Constant Field Values

CONNTYPE_OCI8

public static final int CONNTYPE_OCI8
OCI8 connection type.
See Also:
Constant Field Values

CONNTYPE_KPRB

public static final int CONNTYPE_KPRB
KPRB connection type.
See Also:
Constant Field Values

DEF_INDENT

public static final int DEF_INDENT
Default indentation and print flags
See Also:
Constant Field Values

MAX_INDENT

public static final int MAX_INDENT
See Also:
Constant Field Values

MAX_PFLAG

public static final int MAX_PFLAG
See Also:
Constant Field Values

PRINT_DEFAULT_PROPERTY

public static final int PRINT_DEFAULT_PROPERTY
See Also:
Constant Field Values

PRINT_PRETTY

public static final int PRINT_PRETTY
See Also:
Constant Field Values

PRINT_NOPRETTY

public static final int PRINT_NOPRETTY
See Also:
Constant Field Values

XMLTYPE_PICKLE_AS_TEXT

public static final int XMLTYPE_PICKLE_AS_TEXT
Flags to specify pickle preference, used in setPicklePreference
See Also:
Constant Field Values

XMLTYPE_PICKLE_AS_BINXML

public static final int XMLTYPE_PICKLE_AS_BINXML
See Also:
Constant Field Values

Constructor Detail

XMLType

public XMLType(java.sql.Connection conn,
               java.lang.String xmlval)
        throws java.sql.SQLException
Construct an XMLType given the string containing the XML data
Parameters:
conn - the connection object to be used.
xmlval - the string containing the XML data
Throws:
java.sql.SQLException

XMLType

public XMLType(java.sql.Connection conn,
               java.lang.String xmlval,
               java.lang.String schemaURL,
               boolean wellformed,
               boolean valid)
        throws java.sql.SQLException
Construct an XMLType given the string containing the XML data
Parameters:
conn - the connection object to be used.
xmlval - the string containing the XML data
schemaURL - the schema URL for the XMLType
wellformed - XML document is well-formed
valid - XML document is valid
Throws:
java.sql.SQLException

XMLType

public XMLType(java.sql.Connection conn,
               oracle.sql.CLOB xmlval)
        throws java.sql.SQLException
Construct an XMLType given a CLOB containing the XML data
Parameters:
conn - the connection object to be used.
xmlval - the CLOB containing the XML data
Throws:
java.sql.SQLException

XMLType

public XMLType(java.sql.Connection conn,
               oracle.sql.CLOB xmlval,
               java.lang.String schemaURL,
               boolean wellformed,
               boolean valid)
        throws java.sql.SQLException
Construct an XMLType given a CLOB containing the XML data
Parameters:
conn - the connection object to be used.
xmlval - the CLOB containing the XML data
schemaURL - the schema URL for the XMLType
wellformed - XML document is well-formed
valid - XML document is valid
Throws:
java.sql.SQLException

XMLType

public XMLType(java.sql.Connection conn,
               oracle.sql.BLOB xmlval,
               int csid)
        throws java.sql.SQLException
Construct an XMLType given a BLOB containing the XML data
Parameters:
conn - the connection object to be used.
xmlval - the BLOB containing the XML data
csid - the charset id.
Throws:
java.sql.SQLException

XMLType

public XMLType(OpaqueDescriptor type,
               java.sql.Connection conn,
               java.lang.Object value)
        throws java.sql.SQLException
Create an XMLType given an opaque descriptor, connection and a pickled image.
Parameters:
type - the opaque type descriptor to be used.
conn - the connection object to be used.
value - the pickled image bytes.
Throws:
java.sql.SQLException

Method Detail

setPicklePreference

public void setPicklePreference(int pref)
                         throws java.sql.SQLException
Function to set how the XMLType will be sent across the wire. i.e. as Binary XML or text
Parameters:
pref - XMLTYPE_PICKLE_AS_TEXT or XMLTYPE_PICKLE_AS_BINXML
Throws:
java.sql.SQLException

setMetadataConn

public void setMetadataConn(java.lang.Object metaconn)
                     throws java.sql.SQLException
Function to set the metadata connection to be used for getting Binary XML token data
Parameters:
metaconn - Metadata connection of type Connection
Throws:
java.sql.SQLException

setBinaryXML

public void setBinaryXML()
                  throws java.sql.SQLException
Function to mark the XML type as Binary XML
Throws:
java.sql.SQLException

createXML

public static XMLType createXML(oracle.sql.OPAQUE opq)
                         throws java.sql.SQLException
Create an XMLType given the opaque type containing the XMLType bytes
Parameters:
opq - the opaque data object from which the XMLType is to be generated
Returns:
the created XMLType
Throws:
java.sql.SQLException

createXML

public static XMLType createXML(java.sql.Connection conn,
                                java.lang.String xmlval,
                                java.lang.String schemaURL,
                                boolean wellformed,
                                boolean valid)
                         throws java.sql.SQLException
Create an XMLType given the string containing the XML data
Parameters:
conn - the connection object to be used.
xmlval - the string containing the XML data
schemaURL - the schema URL for the XMLType
wellformed - XML document is well-formed
valid - XML document is valid
Returns:
the created XMLType
Throws:
java.sql.SQLException

createXML

public static XMLType createXML(java.sql.Connection conn,
                                oracle.sql.CLOB xmlval)
                         throws java.sql.SQLException
Create an XMLType given a CLOB containing the XML data
Parameters:
conn - the connection object to be used.
xmlval - the CLOB containing the XML data
Returns:
the created XMLType
Throws:
java.sql.SQLException

createXML

public static XMLType createXML(java.sql.Connection conn,
                                oracle.sql.CLOB xmlval,
                                java.lang.String schemaURL,
                                boolean wellformed,
                                boolean valid)
                         throws java.sql.SQLException
Create an XMLType given a CLOB containing the XML data
Parameters:
conn - the connection object to be used.
xmlval - the CLOB containing the XML data
schemaURL - the schema URL for the XMLType
wellformed - XML document is well-formed
valid - XML document is valid
Returns:
the created XMLType
Throws:
java.sql.SQLException

getStringVal

public java.lang.String getStringVal()
                              throws java.sql.SQLException
Get the string value containing the XML data from the XMLType.
Returns:
the string containing the XML data bytes.
Throws:
java.sql.SQLException

getStringVal

public java.lang.String getStringVal(int pflag,
                                     int indent)
                              throws java.sql.SQLException
Get the string value containing the XML data from the XMLType.
Parameters:
pflag - flags to control print
indent - indent output by "indent" characters
Returns:
the string containing the XML data bytes.
Throws:
java.sql.SQLException

getClobVal

public oracle.sql.CLOB getClobVal()
                           throws java.sql.SQLException
Get the CLOB value containing the XML data from the XMLType.
Returns:
the CLOB containing the XML data bytes.
Throws:
java.sql.SQLException

getClobVal

public oracle.sql.CLOB getClobVal(int pflag,
                                  int indent)
                           throws java.sql.SQLException
Get the CLOB value containing the XML data from the XMLType.
Parameters:
pflag - flags to control print
indent - indent output by "indent" characters
Returns:
the CLOB containing the XML data bytes.
Throws:
java.sql.SQLException

getBlobVal

public oracle.sql.BLOB getBlobVal(int csid)
                           throws java.sql.SQLException
Get the BLOB value containing the XML data from the XMLType.
Parameters:
csid - The character set ID.
Returns:
the BLOB containing the XML data bytes.
Throws:
java.sql.SQLException

getBlobVal

public oracle.sql.BLOB getBlobVal(int csid,
                                  int pflag,
                                  int indent)
                           throws java.sql.SQLException
Get the BLOB value containing the XML data from the XMLType.
Parameters:
csid - The character set ID.
pflag - flags to control print
indent - indent output by "indent" characters
Returns:
the BLOB containing the XML data bytes.
Throws:
java.sql.SQLException

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.sql.SQLException
Get an InputStream from the XMLType, applications can read XML data from the stream
Returns:
the InputStream for the XMLType
Throws:
java.sql.SQLException

getInputStream

public java.io.InputStream getInputStream(int pflag,
                                          int indent)
                                   throws java.sql.SQLException
Get an InputStream from the XMLType, applications can read XML data from the stream
Parameters:
pflag - flags to control print
indent - indent output by "indent" characters
Returns:
the InputStream for the XMLType
Throws:
java.sql.SQLException

writeToOutputStream

public void writeToOutputStream(java.io.OutputStream os)
                         throws java.sql.SQLException
Write the contents of the XMLType to an OutputStream
Parameters:
os - The OutputStream to which the contents are written.
Throws:
java.sql.SQLException

writeToOutputStream

public void writeToOutputStream(java.io.OutputStream os,
                                int pflag,
                                int indent)
                         throws java.sql.SQLException
Write the contents of the XMLType to an OutputStream
Parameters:
os - The OutputStream to which the contents are written.
pflag - flags to control print
indent - indent output by "indent" characters
Throws:
java.sql.SQLException

extract

public XMLType extract(java.lang.String xpath,
                       java.lang.String nsmap)
                throws java.sql.SQLException
Function to extract the given set of nodes from the XMLType. This set of nodes is specified by the xpath expression. The original XMLType remains unchanged. Works only in the thick case
Parameters:
xpath - the xpath expression which specifies the nodes to search for.
nsmap - the map of namespaces which resolves the prefixes in the xpath expression. format is "xmlns=a.com xmlns:b=b.com"
Returns:
XMLType which contains the extracted nodes. null if no nodes match the specified expression.
Throws:
java.sql.SQLException

existsNode

public boolean existsNode(java.lang.String xpath,
                          java.lang.String nsmap)
                   throws java.sql.SQLException
Function to check for the existence of the given set of nodes in the XMLType. This set of nodes is specified by the xpath expression.
Parameters:
xpath - the xpath expression which specifies the nodes to search for.
nsmap - the map of namespaces which resolves the prefixes in the xpath expression. format is "xmlns=a.com xmlns:b=b.com"
Returns:
TRUE if specified nodes exist in the XMLType else FALSE
Throws:
java.sql.SQLException

transform

public XMLType transform(XMLType xsldoc,
                         java.lang.String parammap)
                  throws java.sql.SQLException
Function to transform the XMLType using the given XSL document. The new (transformed) XML document is returned.
Parameters:
xsldoc - the XSL document to be applied to the XMLType
parammap - the top level parameters to be passed to the XSL transformation. This should be of the format "a=b c=d e=f". This can be null.
Returns:
the transformed XMLType
Throws:
java.sql.SQLException

isFragment

public boolean isFragment()
                   throws java.sql.SQLException
Function to check if the XMLType is a regular document or a document fragment.
Returns:
TRUE if doc is a fragment else FALSE
Throws:
java.sql.SQLException

getDocumentFragment

public XDBDocFragment getDocumentFragment()
                                   throws java.sql.SQLException
Function to return XDBDocFragment if XMLType instance is a fragment
Returns:
XDDBDocFragment if XMLType instance is a fragment, else null
Throws:
java.sql.SQLException

isSchemaValid

public boolean isSchemaValid(java.lang.String schurl,
                             java.lang.String elname)
                      throws java.sql.SQLException
Function to check if the XMLType is schema based.
Parameters:
schurl - the URL of the schema to be validated against; if this is null then the documents own schema URL is used (if one exists).
elname - the name of the root element of the schema
Returns:
TRUE if doc is schema based else FALSE
Throws:
java.sql.SQLException

createSchemaBasedXML

public XMLType createSchemaBasedXML(java.lang.String schemaURL)
                             throws java.sql.SQLException
Create a schema-based XML
Parameters:
schemaURL - The schema URL
Returns:
an XMLType object based on the given schema
Throws:
java.sql.SQLException

getRootElement

public java.lang.String getRootElement()
                                throws java.sql.SQLException
Return the root element name
Returns:
the root element name
Throws:
java.sql.SQLException

getSchemaURL

public java.lang.String getSchemaURL()
                              throws java.sql.SQLException
Return the schema URL (i.e. location of the schema to which this XMLType conforms)
Returns:
the schema URL
Throws:
java.sql.SQLException

isSchemaBased

public boolean isSchemaBased()
                      throws java.sql.SQLException
Function to check if the XMLType is schema based.
Returns:
TRUE if doc is schema based else FALSE
Throws:
java.sql.SQLException

getNamespace

public java.lang.String getNamespace()
                              throws java.sql.SQLException
return the default namespace of the XMLType document
Returns:
the namespace of the XMLType document
Throws:
java.sql.SQLException

schemaValidate

public void schemaValidate()
                    throws java.sql.SQLException
Validate the schema-based document against its own schema.
Throws:
java.sql.SQLException

isSchemaValidated

public boolean isSchemaValidated()
                          throws java.sql.SQLException
Return TRUE if the document has been validated against its schema
Returns:
TRUE if the document has been validated against its schema
Throws:
java.sql.SQLException

setSchemaValidated

public void setSchemaValidated(boolean validateFlag)
                        throws java.sql.SQLException
This function sets the VALIDATED flag to indicate that the XMLType has been validated or not.
Parameters:
validateFlag - True indicates that the XMLType has been validated. False indicates that the XMLType has not been validated.
Throws:
java.sql.SQLException

getNumberVal

public NUMBER getNumberVal()
                    throws java.sql.SQLException
Return the numeric value of the XML document
Returns:
the numeric value of the XML document
Throws:
java.sql.SQLException

getDOM

public Document getDOM()
                throws java.sql.SQLException
Deprecated. use getDocument
Gets the DOM document associated with the XMLType. This document is the org.w3c.dom.Document. The caller can perform all the DOM operations on the Document. If the document is a binary document the getDOM function will return null. NOTE: This function is for the old java APIs. Use getDocument() for the unified APIs
Returns:
the DOM Document object associated with the XMLType
Throws:
java.sql.SQLException
See Also:
Document

getDocument

public Document getDocument()
                     throws java.sql.SQLException
Gets the DOM document associated with the XMLType. This document is the org.w3c.dom.Document. The caller can perform all the DOM operations on the Document. If the document is a binary document the getDOM function will return null.
Returns:
the DOM Document object associated with the XMLType
Throws:
java.sql.SQLException
See Also:
Document

getErrorHandle

public static long getErrorHandle(java.sql.Connection conn,
                                  int conntype)
                           throws java.sql.SQLException
Get the error handle given the connection and the connection type.
Parameters:
conn - The connection
conntype - The connection type.
Returns:
the long describing the error handle.
Throws:
java.sql.SQLException

getServiceHandle

public static long getServiceHandle(java.sql.Connection conn,
                                    int conntype)
                             throws java.sql.SQLException
Get the service handle given the connection and the connection type.
Parameters:
conn - The connection
conntype - The connection type.
Returns:
the long describing the service handle.
Throws:
java.sql.SQLException

close

public void close()
Function to free/close the XMLType. Any operation after this will result in a SQLException. Applications need to call close else a memory leak will result.

getConnType

public static int getConnType(java.sql.Connection conn)
                       throws java.sql.SQLException
Get the connection type of the given connection.
Parameters:
conn - The connection.
Returns:
The connection type.
Throws:
java.sql.SQLException

setBinaryXMLEncoding

public void setBinaryXMLEncoding(java.lang.String encoding)
                          throws java.sql.SQLException
Sets the client requested encoding for retrieving Binary XML.
Parameters:
encoding - The encoding.
Throws:
java.sql.SQLException

cleanupCache

public static void cleanupCache(boolean forcemode)
Clean-up method for an internal cache used for Binary XML decoding.
Parameters:
forcemode - If true, purges the entire cache; otherwise only mappings with values already garbage collected are removed from the cache.

getString

public java.lang.String getString()
                           throws java.sql.SQLException
Throws:
java.sql.SQLException

getBinaryStream

public java.io.InputStream getBinaryStream()
                                    throws java.sql.SQLException
Throws:
java.sql.SQLException

getCharacterStream

public java.io.Reader getCharacterStream()
                                  throws java.sql.SQLException
Throws:
java.sql.SQLException

getSource

public <T extends Source> T getSource(java.lang.Class<T> sourceClass)
                           throws java.sql.SQLException
Throws:
java.sql.SQLException

getBytesVal

public java.io.ByteArrayOutputStream getBytesVal()
                                          throws java.sql.SQLException
Throws:
java.sql.SQLException

getCSid

public int getCSid()
            throws java.sql.SQLException
Throws:
java.sql.SQLException

getisReadonly

public boolean getisReadonly()
                      throws java.sql.SQLException
Throws:
java.sql.SQLException

getmDom

public Document getmDom()
                 throws java.sql.SQLException
Throws:
java.sql.SQLException

free

public void free()
          throws java.sql.SQLException
Throws:
java.sql.SQLException

setBinaryStream

public java.io.OutputStream setBinaryStream()
                                     throws java.sql.SQLException
Throws:
java.sql.SQLException

setResult

public <T extends Result> T setResult(java.lang.Class<T> resultClass)
                           throws java.sql.SQLException
Throws:
java.sql.SQLException

setCharacterStream

public java.io.Writer setCharacterStream()
                                  throws java.sql.SQLException
Throws:
java.sql.SQLException

setString

public void setString(java.lang.String str)
               throws java.sql.SQLException
Throws:
java.sql.SQLException

Skip navigation links

Oracle® Database XML Java API Reference
12c Release 1 (12.1)

E15981-09


Copyright © 2003, 2014, Oracle and/or its affiliates. All rights reserved.