com.ibm.xml.xapi
Class XFactory
- java.lang.Object
com.ibm.xml.xapi.XFactory
- public abstract class XFactory
- extends java.lang.Object
The XFactory
class is the main factory class for
creating executables for XPath, XQuery, and XSLT. It is also
the means for creating instances of other classes and factories
such as the XStaticContext
, XDynamicContext
,
XItemFactory
, and XSequenceTypeFactory
classes.
Use the newInstance
method to get a concrete
XFactory
object.
An instance of XFactory
maintains a set of registered
schemas and can be validating or non-validating. A validating
factory produces schema-aware executables and ensures that source
documents get validated against the set of registered schemas
before they are processed. If a source document includes a
schema location and that schema is not already registered
then it will be registered automatically when the source document
is processed. If different sets of stylesheets, queries or
expressions need different sets of schemas, these can be kept
separate by using more than one XFactory instance.
An instance of XFactory
is thread safe as long as
the settings remain stable.
Field Summary
Modifier and Type | Field and Description |
---|---|
|
FULL_VALIDATION
Constant indicating that executables should be schema aware
and input documents will be validated.
|
|
NO_VALIDATION
Constant indicating that executables should not be schema
aware and input documents will not be validated.
|
Constructor Summary
Constructor and Description |
---|
XFactory()
|
Method Summary
Modifier and Type | Method and Description |
---|---|
|
getCompilationFactory()
Get the compilation factory.
|
|
getItemFactory()
Get the item factory.
|
|
getMessageHandler()
Get the message handler.
|
|
getSchemaResolver()
Get the currently registered schema resolver.
|
|
getSequenceTypeFactory()
Get the sequence type factory.
|
|
getValidatedDOM(org.w3c.dom.Document document)
Get a validated DOM.
|
|
getValidatedDOM(javax.xml.transform.stream.StreamSource source)
Get a validated DOM.
|
|
getValidating()
Get the validation setting.
|
|
getVersion()
Get the version of the
XFactory .
|
|
newDynamicContext()
Create a new
XDynamicContext .
|
|
newInstance()
Create the default
XFactory instance.
|
|
newOutputParameters()
Create a new
XOutputParameters .
|
|
newStaticContext()
Create a new
XStaticContext .
|
|
prepareXPath(javax.xml.transform.stream.StreamSource expression)
Create an
XPathExecutable for an XPath expression which can then
be used to apply that expression to input documents.
|
|
prepareXPath(javax.xml.transform.stream.StreamSource expression,XStaticContext context)
Create an
XPathExecutable for an XPath expression which can then
be used to apply that expression to input documents.
|
|
prepareXPath(java.lang.String expression)
Create an
XPathExecutable for an XPath expression which can then
be used to apply that expression to input documents.
|
|
prepareXPath(java.lang.String expression,XStaticContext context)
Create an
XPathExecutable for an XPath expression which can then
be used to apply that expression to input documents.
|
|
prepareXQuery(javax.xml.transform.stream.StreamSource query)
Create an
XQueryExecutable for an XQuery expression which can then
be used to apply that expression to input documents.
|
|
prepareXQuery(javax.xml.transform.stream.StreamSource query,XStaticContext context)
Create an
XQueryExecutable for an XQuery expression which can then
be used to apply that expression to input documents.
|
|
prepareXQuery(java.lang.String query)
Create an
XQueryExecutable for an XQuery expression which can then
be used to apply that expression to input documents.
|
|
prepareXQuery(java.lang.String query,XStaticContext context)
Create an
XQueryExecutable for an XQuery expression which can then
be used to apply that expression to input documents.
|
|
prepareXSLT(javax.xml.transform.Source stylesheet)
Create an
XSLTransformExecutable for an XSL stylesheet which can then
be used to apply that stylesheet to input documents.
|
|
prepareXSLT(javax.xml.transform.Source stylesheet,XStaticContext context)
Create an
XSLTransformExecutable for an XSL stylesheet which can then
be used to apply that stylesheet to input documents.
|
|
registerSchema(javax.xml.transform.Source source)
Register a schema.
|
|
registerSchemas(java.util.List<? extends javax.xml.transform.Source> schemas)
Register a list of schemas.
|
|
setMessageHandler(XMessageHandler handler)
Set the message handler to be used when registering schemas, creating
new items and sequences, and preparing and executing expressions,
queries and stylesheets.
|
|
setSchemaResolver(XSchemaResolver resolver)
Set the schema resolver to be used for imports in schemas
registered using the
registerSchema method or
for schemas imported in XSLT using the xsl:import-schema
declaration.
|
|
setValidating(int value)
When full validation is enabled the factory will create validating executables
and the input document will be validated on execution.
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail
NO_VALIDATION
- public static final int NO_VALIDATION
FULL_VALIDATION
- public static final int FULL_VALIDATION
Constructor Detail
XFactory
- public XFactory()
Method Detail
newInstance
- public static XFactory newInstance( )
- throws java.lang.ClassNotFoundException
- java.lang.IllegalAccessException
- java.lang.InstantiationException
XFactory
instance.
XFactory
instance. java.lang.ClassNotFoundException
- if the class cannot be found. java.lang.IllegalAccessException
- if the class is not accessible. java.lang.InstantiationException
- if the class cannot be instantiated. getVersion
- public static java.lang.String getVersion( )
XFactory
. Use this method to
determine what features are available.
prepareXPath
- public abstract XPathExecutable prepareXPath( java.lang.String expression)
XPathExecutable
for an XPath expression which can then
be used to apply that expression to input documents. The default static context
settings are used.
expression
- The XPath expression as a String
. java.lang.NullPointerException
- if the expression is null. XProcessException
- if the prepare fails because of errors in the expression. prepareXPath
- public abstract XPathExecutable prepareXPath( java.lang.String expression,
- XStaticContext context)
XPathExecutable
for an XPath expression which can then
be used to apply that expression to input documents.
expression
- The XPath expression as a String
. context
- The static context. java.lang.NullPointerException
- if the expression is null. XProcessException
- if the prepare fails because of errors in the expression. prepareXPath
- public abstract XPathExecutable prepareXPath( javax.xml.transform.stream.StreamSource expression)
XPathExecutable
for an XPath expression which can then
be used to apply that expression to input documents. The default static context
settings are used.
expression
- The XPath expression as a StreamSource
. java.lang.NullPointerException
- if the expression is null. XProcessException
- if the prepare fails because of errors in the expression. prepareXPath
- public abstract XPathExecutable prepareXPath( javax.xml.transform.stream.StreamSource expression,
- XStaticContext context)
XPathExecutable
for an XPath expression which can then
be used to apply that expression to input documents.
expression
- The XPath expression as a StreamSource
. context
- The static context. java.lang.NullPointerException
- if the expression is null. XProcessException
- if the prepare fails because of errors in the expression. prepareXQuery
- public abstract XQueryExecutable prepareXQuery( java.lang.String query)
XQueryExecutable
for an XQuery expression which can then
be used to apply that expression to input documents. The default static context
settings are used.
query
- The XQuery expression as an String
. java.lang.NullPointerException
- if the query is null. XProcessException
- if the prepare fails because of errors in the query. prepareXQuery
- public abstract XQueryExecutable prepareXQuery( java.lang.String query,
- XStaticContext context)
XQueryExecutable
for an XQuery expression which can then
be used to apply that expression to input documents.
query
- The XQuery expression as a String
. context
- The static context. java.lang.NullPointerException
- if the query is null. XProcessException
- if the prepare fails because of errors in the query. prepareXQuery
- public abstract XQueryExecutable prepareXQuery( javax.xml.transform.stream.StreamSource query)
XQueryExecutable
for an XQuery expression which can then
be used to apply that expression to input documents. The default static context
settings are used.
query
- The XQuery expression as a StreamSource
. java.lang.NullPointerException
- if the query is null. XProcessException
- if the prepare fails because of errors in the query. prepareXQuery
- public abstract XQueryExecutable prepareXQuery( javax.xml.transform.stream.StreamSource query,
- XStaticContext context)
XQueryExecutable
for an XQuery expression which can then
be used to apply that expression to input documents.
query
- The XQuery expression as a StreamSource
. context
- The static context. java.lang.NullPointerException
- if the query is null. XProcessException
- if the prepare fails because of errors in the query. prepareXSLT
- public abstract XSLTExecutable prepareXSLT( javax.xml.transform.Source stylesheet)
XSLTransformExecutable
for an XSL stylesheet which can then
be used to apply that stylesheet to input documents. The default static context
settings are used.
stylesheet
- The XSL stylesheet as a Source
object. java.lang.NullPointerException
- if the stylesheet is null. XProcessException
- if the prepare fails because of errors in the stylesheet. prepareXSLT
- public abstract XSLTExecutable prepareXSLT( javax.xml.transform.Source stylesheet,
- XStaticContext context)
XSLTransformExecutable
for an XSL stylesheet which can then
be used to apply that stylesheet to input documents.
stylesheet
- The XSL stylesheet as a Source
object. context
- The static context. java.lang.NullPointerException
- if the stylesheet is null. XProcessException
- if the prepare fails because of errors in the stylesheet. newStaticContext
- public abstract XStaticContext newStaticContext( )
XStaticContext
.
XStaticContext
object. newDynamicContext
- public abstract XDynamicContext newDynamicContext( )
XDynamicContext
.
XDynamicContext
object. setValidating
- public abstract void setValidating( int value)
NO_VALIDATION
.
value
- Set to FULL_VALIDATION
for full schema
validation, NO_VALIDATION
for no schema validation. getValidating
- public abstract int getValidating( )
registerSchema
- public abstract void registerSchema( javax.xml.transform.Source source)
Source
types are:
StreamSource
SAXSource
DOMSource
StAXSource
source
- The schema to register. java.lang.NullPointerException
- if the source is null. registerSchemas
- public abstract void registerSchemas( java.util.List<? extends javax.xml.transform.Source> schemas)
Source
types are:
StreamSource
SAXSource
DOMSource
StAXSource
schemas
- A list of schemas to register. java.lang.NullPointerException
- if the list is null. setSchemaResolver
- public abstract void setSchemaResolver( XSchemaResolver resolver)
Set the schema resolver to be used for imports in schemas
registered using the registerSchema
method or
for schemas imported in XSLT using the xsl:import-schema
declaration.
The default behaviour for resolving imports within a schema is to use the
base URI of the schema to resolve the imported schema's location. The default
behaviour for XSLT schema imports is to use the base URI of the xsl:import-schema
declaration to resolve the location specified in the declaration.
resolver
- The schema resolver implementation or null
to revert to the default schema resolution behaviour. getSchemaResolver
- public abstract XSchemaResolver getSchemaResolver( )
getItemFactory
- public abstract XItemFactory getItemFactory( )
There is a direct association between an item factory
and an XFactory
instance since the item
factory depends on the registered schemas and whether
validating is enabled when processing
Source
objects. New schemas registered
using the registerSchema
method will
be visible by the item factory.
getSequenceTypeFactory
- public abstract XSequenceTypeFactory getSequenceTypeFactory( )
There is a direct association between a sequence type factory
and an XFactory
instance since the sequence type
factory depends on the registered schemas. New schemas
registered using the registerSchema
method will
be visible by the sequence type factory.
getCompilationFactory
- public abstract XCompilationFactory getCompilationFactory( )
There is a direct association between a compilation factory
and an XFactory
instance since the compilation
factory depends on the registered schemas and whether
validating is enabled when generating compiled executables.
New schemas registered
using the registerSchema
method will
be visible by the compilation factory.
newOutputParameters
- public abstract XOutputParameters newOutputParameters( )
XOutputParameters
.
XOutputParameters
object. getValidatedDOM
- public abstract org.w3c.dom.Document getValidatedDOM( javax.xml.transform.stream.StreamSource source)
registerSchema
method prior to calling this
method.
getValidatedDOM
- public abstract org.w3c.dom.Document getValidatedDOM( org.w3c.dom.Document document)
registerSchema
method prior to calling this
method.
document
- The document. Document
. setMessageHandler
- public abstract void setMessageHandler( XMessageHandler handler)
handler
- The message handler. Pass in null
to
restore the default message handling behaviour. getMessageHandler
- public abstract XMessageHandler getMessageHandler( )
null
if not set.