1.1.1

Table Of Contents
Examples
In the x_table table, to determine if the xcol XML column for each row has an element called student
with an age attribute equal to 20, use this statement:
SELECT id, XMLEXISTS('//student[@age=20]' PASSING BY REF xcol)
FROM x_table
In the x_table table, to return the ID for every row whose xcol XML column is non-null and contains the
element /roster/student, use this statement:
SELECT id FROM x_table WHERE XMLEXISTS('/roster/student' PASSING BY REF
xcol)
You can create the x_table table with a check constraint that limits which XML values can be inserted into
the xcol XML column. In this example, the constraint is that the column has at least one student element
with an age attribute with a value that is less than 25. To create the table, use this statement:
CREATE TABLE x_table ( id INT, xcol XML CHECK (XMLEXISTS ('//student[@age
< 25]' PASSING BY REF xcol)) )
Usage note
SQLFire requires that a JAXP parser (such as Apache Xerces) and Apache Xalan are listed in the Java classpath
for the XML functions to work. If either the JAXP parser or Xalan is missing from the classpath, attempts to
use the XMLEXISTS operator will result in an error. In some situations, you may need to take steps to place the
parser and Xalan in your classpath. See "XML data types and operators" in the SQLFire for details.
XMLPARSE operator
XMLPARSE is a SQL/XML operator that you use to parse a character string expression into a SQLFire XML
value.
You can use the result of this operator temporarily or you can store the result permanently in SQLFire XML
columns. Whether temporary or permanent, you can use the XML value as an input to the other SQLFire XML
operators, such as XMLEXISTS operator on page 589 and XMLQUERY operator on page 591.
Syntax
XMLPARSE (DOCUMENT string-value-expression PRESERVE WHITESPACE)
Required keyword that describes the type of XML input that SQLFire can
parse. SQLFire can only parse string expressions that constitute well-formed
DOCUMENT
XML documents. This is because SQLFire uses a JAXP parser to parse all
string values. The JAXP parser expects the string-value-expression to
constitute a well-formed XML document. If the string does not constitute a
well-formed document, JAXP throws an error. SQLFire catches the error
and throws the error as a SQLException.
Any expression that evaluates to a SQL character type, such as CHAR,
VARCHAR, LONG VARCHAR, or CLOB. The
string-value-expression
string-value-expression argument can also be a parameter. You
must use the CAST function when you specify the parameter to indicate the
type of value that is bound into the parameter. SQLFire must verify that the
parameter is the correct data type before the value is parsed as an XML
document. If a parameter is specied without the CAST function, or if the
CAST is to a non-character datatype, SQLFire throws an error.
Required keywords that describe how SQLFire handles whitespace between
consecutive XML nodes. When the PRESERVE WHITESPACE keywords
PRESERVE WHITESPACE
vFabric SQLFire User's Guide590
vFabric SQLFire Reference