You can use the TaskCompileXPath, TaskCompileXQuery, and
TaskCompileXSLT ANT tasks as alternatives to using the CompileXPath,
CompileXQuery, and CompileXSLT commands.
About this task
ANT task elements:
- argType
- This element indicates the types of the function arguments expressed
in terms of the localpart and namespaceURI.
Parameters specified
as nested elements:- localpart
- A nested localpart element must be specified to provide the local
part of the qualified name.
- namespaceURI
- A nested namespaceURI element can be specified to indicate the
namespaceURI.
Example:
<argType>
<localpart>boolean</localpart>
<namespaceURI>"http://www.w3.org/2001/XMLSchema"</namespaceURI>
</argType>
- baseURI
- This element specifies the base URI of the containing element.
Example:
<baseURI>"http://www.ibm.com/Los Angeles"</baseURI>
- bsp
- This element specifies the Boundary Space Policy.
Valid values
include:
- 1 = preserve white spaces
- 2 = strip white spaces
The default value is 2 (strip white spaces).
- cnmi
- This element specifies the inherit part of the copy-namespaces.
Valid
values include:
- 1 = inherit
Inherit mode should be used in namespace binding
assignment when an existing element node is copied by an element constructor.
- 2 = no inherit
No-inherit mode should be used in namespace binding
assignment when an existing element node is copied by an element constructor.
The default is 1 (inherit).
- cnmp
- This element specifies the preserve part of the copy-namespaces.
Valid
values include:
- 1 = preserve
Preserve mode should be used in namespace binding
assignment when an existing element node is copied by an element constructor.
- 2 = no preserve
No-preserve mode should be used in namespace
binding assignment when an existing element node is copied by an element
constructor.
The default is 1 (preserve).
- cpm
- This element specifies an alternate XPath Compatibility Mode.
Valid
values are:
For example: use 1.0 for compatibility with XPath Version 1.0.
The
default is 2.0.
- csm
- This element specifies the Construction Mode.
Valid values
include:
- 1 = preserve
The type of a constructed element node is xs:anyType,
and all attribute and element nodes copied during node construction
retain their original types.
- 2 = strip
The type of a constructed element node is xs:untyped,
all element nodes copied during node construction receive the type
xs:untyped, and all attribute nodes copied during node construction
receive the type xs:untypedAtomic.
The default value is 1 (preserve).
- dir
- This element specifies a destination directory for the executables.
The
default is the current working directory.
If the value contains
a blank space, enclose it in quotation marks.
Example:
<dir>C:/precompiledXSLT</dir>
- dnet
- This element specifies a default namespace URI for element and
type names.
The namespace URI, if present, is used for any unprefixed
QName appearing in a position where an element or type name is expected.
Example:
<dnet>http://example.org/ibm</dnet>
- dnf
- This element specifies a default namespace URI for function names.
The
namespace URI, if present, is used for any unprefixed QName appearing
in a position where a function name is expected.
Example:
<dnf>http://my.org</dnf>
- eso
- This element specifies the Empty Sequence Order.
Valid values
include:
The default value is 2 (empty sequences least).
- function
- For the CompileXSLT, CompileXPath, and CompileXQuery tasks, this
element defines and binds a function to the static context for a single
item. Note that this simply declares the function, and a Method object
for the function must also be bound to the dynamic context. Note:
this element can be specified multiple times.
Parameters specified
as nested elements:
- name
- A nested name element must be specified to indicate the name of
the function.
- type
- A nested type element must be specified to indicate the type of
the function.
- argType
- A nested argType element can be specified to indicate the types
of the function arguments.
This element is optional and can be
specified multiple times.
Example:
<function>
<name>
<localpart>la</localpart>
<namespaceURI>"http://www.ibm.com/Los Angeles"</namespaceURI>
</name>
<type>
<localpart>boolean</localpart>
<namespaceURI>http://www.w3.org/2001/XMLSchema</namespaceURI>
</type>
</function>
- imm
- This element sets the integer math mode, which is a constant representing
the level of precision required and whether overflow detection is
required when working with xs:integer values.
Valid values include:
- 1 = values need only support the minimum precision required for
a minimally conforming processor (18 digits)
- 2 = values should support an arbitrary number of digits of precision;
no overflow should occur
- 3 = values need only support the minimum precision required for
a minimally conforming processor (18 digits) but any overflow condition
should be detected and error FOAR0002 raised
- inputfile
- This element specifies the full path to a file containing an XSL,
XPath, or XQuery to be compiled.
Example:
<inputfile>C:/XSLT/simple.xsl</inputfile>
- localpart
- This element indicates the local part of a qualified name.
Example:
<localpart>la</localpart>
- name
- This element indicates the name of the function or variable (expressed
in terms of the localpart and namespaceURI).
In the case of a
variable that is in no namespace the namespace URI should be omitted.
Parameters
specified as nested elements:
- localpart
- A nested localpart element must be specified to provide the local
part of the qualified name.
- namespaceURI
- A nested namespaceURI element can be specified to indicate the
namespaceURI.
Example:
<name>
<localpart>la</localpart>
<namespaceURI>"http://www.ibm.com/Los Angeles"</namespaceURI>
</name>
- namespaceURI
- This element indicates the namespaceURI part of a qualified name.
If
the value contains a blank space. enclose it in quotation marks.
Example:
<namespaceURI>"http://www.ibm.com/Los Angeles"</namespaceURI>
- ns
- This element specifies a namespace for use during static processing.
The
value should be specified as prefix=URI.
If the value contains
a blank space, enclose it in quotation marks.
This element can
be used multiple times.
Example:
<ns>my=http://www.example.com/examples</ns>
- ordm
- This element specifies the Ordering Mode.
Valid values include:
- 1 = ordered results are to be returned by certain path expressions,
union, intersect, and except expressions, and FLWOR expressions that
have no order by clause
- 2 = unordered results are to be returned by certain path expressions,
union, intersect, and except expressions, and FLWOR expressions that
have no order by clause
The default value is 1 (ordered).
- out
- This element specifies the name of the generated executable.
The
default executable name is XSLTModule, XPathModule, or XQueryModule
depending on the corresponding task.
This option is ignored
if compiling multiple files.
Example:
<out>sample</out>
- dir
- This element specifies a destination directory for the executables.
Default is the current working directory.
If the value contains
a blank space, enclose it in quotation marks.
Example:
<pkg>com.mycompany.precompiled</pkg>
- schema
- This element specifies a schema document that will be used to
populate the in-scope schema definitions.
This element can be used
multiple times.
Example:
<schema>C:/samples/xpath/variousTypesNodeTest.xsd</schema>
- type
- This element indicates the type of the function or variable expressed
in terms of the localpart and namespaceURI.
Parameters
specified as nested elements:
- localpart
- A nested localpart element must be specified to provide the local
part of the qualified name.
- namespaceURI
- A nested namespaceURI element can be specified to indicate the
namespaceURI.
Example:
<type>
<localpart>boolean</localpart>
<namespaceURI>"http://www.w3.org/2001/XMLSchema"</namespaceURI>
</type>
- variable
- This element defines and binds a variable to the static context
for a single item.
This simply declares the variable, and a value
must be bound to the dynamic context.
This element can be specified
multiple times.
Parameters specified as nested elements:
- name
- A nested name element must be specified to indicate the name of
the variable.
- type
- A nested type element must be specified to indicate the type of
the variable.
Example:
<variable>
<name>
<localpart>booleanVar</localpart>
</name>
<type>
<localpart>boolean</localpart>
<namespaceURI>http://www.w3.org/2001/XMLSchema</namespaceURI>
</type>
</variable>
Procedure
- Use TaskCompileXPath
This task can
be used to precompile one or more XPath expressions. The output will
be a set of Java classes that
subsequently can be used to execute the expressions without the performance
overhead of dynamic compilation.
Parameters specified as nested
elements:
- out
- A nested out specifies the name of the generated executable.
The
default executable name is XPathModule.
- dir
- A nested dir specifies a destination directory for the
executables.
The default is the current working directory.
- pkg
- A nested pkg specifies a package name prefix for all generated
classes.
The default is the Java default
package.
- cpm
- A nested cpm specifies an alternate XPath Compatibility
Mode.
- ns
- A nested ns specifies a namespace for use during static
processing.
- schema
- A nested schema specifies a schema document that will be
used to populate the in-scope schema definitions.
- function
- A nested function definition can be specified.
This
will create a function binding to the static context for a single
item.
- variable
- A nested variable definition can be specified.
This
will add a variable binding to the static context for a single item.
- baseURI
- A nested baseURI specifies the base URI of the containing
element.
- dnet
- A nested dnet specifies a default namespace URI for element
and type names.
- dnf
- A nested dnf specifies a default namespace URI for function
names.
- imm
- A nested imm sets the integer math mode, which is a constant
representing the level of precision required and whether overflow
detection is required when working with xs:integer values.
- inputfile
- A nested inputfile specifies the full path to a file containing
XPath expression to be compiled.
Note: This element is required and
can be used multiple times.
Example:<target name="testXPath">
<taskdef name="compileXPath" classname="com.ibm.xml.xapi.ant.TaskCompileXPath"/>
<compileXPath>
<out>sample</out>
<dir>"C:/precompiledXPath"</dir>
<pkg>com.mycompany.precompiled</pkg>
<variable>
<name>
<localpart>booleanVar</localpart>
</name>
<type>
<localpart>boolean</localpart>
<namespaceURI>http://www.w3.org/2001/XMLSchema</namespaceURI>
</type>
</variable>
<inputfile>C:/XPath/xpath.txt</inputfile>
</compileXPath>
</target>
- Use TaskCompileXQuery
This task can
be used to precompile one or more XQuery expressions. The output will
be a set of Java classes that
subsequently can be used to execute the expressions without the performance
overhead of dynamic compilation.
Parameters specified as nested
elements:
- out
- A nested out specifies the name of the generated executable.
The
default executable name is XQueryModule.
- dir
- A nested dir specifies a destination directory for the
executables.
The default is the current working directory.
- pkg
- A nested pkg specifies a package name prefix for all generated
classes.
The default is the Java default
package.
- function
- A nested function definition can be specified.
This
will create a function binding to the static context for a single
item.
- baseURI
- A nested baseURI specifies the base URI of the containing
element.
- dnet
- A nested dnet specifies a default namespace URI for element
and type names.
- dnf
- A nested dnf specifies a default namespace URI for function
names.
- imm
- A nested imm sets the integer math mode, which is a constant
representing the level of precision required and whether overflow
detection is required when working with xs:integer values.
- bsp
- A nested bsp specifies the Boundary Space Policy.
- csm
- A nested csm specifies the Construction Mode.
- cnmi
- A nested cnmi specifies the inherit part of the copy-namespaces.
- cnmp
- A nested cnmp specifies the preserve part of the copy-namespaces.
- eso
- A nested eso specifies the Empty Sequence Order.
- ordm
- A nested ordm specifies the Ordering Mode.
- inputfile
- A nested inputfile specifies the full path to a file containing
an XQuery expression to be compiled. Note: this element is required
and can be used multiple times.
Example:<target name="testXQuery">
<taskdef name="compileXQuery" classname="com.ibm.xml.xapi.ant.TaskCompileXQuery"/>
<compileXQuery>
<out>sample</out>
<dir>"C:/precompiledXQuery"</dir>
<pkg>com.mycompany.precompiled</pkg>
<inputfile>C:/XQuery/xquery.sq</inputfile>
</compileXQuery>
</target>
- Use TaskCompileXSLT
This task can
be used to precompile one or more stylesheets. The output will be
a set of Java classes that subsequently
can be used to execute transformations without the performance overhead
of dynamic compilation.
Parameters specified as nested elements:
- out
- A nested out specifies the name of the generated executable.
The
default executable name is XSLTModule.
This element is ignored
if compiling multiple stylesheets.
- dir
- A nested dir specifies a destination directory for the
executables.
The default is the current working directory.
- pkg
- A nested pkg specifies a package name prefix for all generated
classes.
The default is the Java default
package.
- function
- A nested function definition can be specified.
This
will create a function binding to the static context for a single
item.
- baseURI
- A nested baseURI specifies the base URI of the containing
element.
- imm
- A nested imm sets the integer math mode, which is a constant
representing the level of precision required and whether overflow
detection is required when working with xs:integer values.
- inputfile
- A nested inputfile specifies the full path to a file containing
an XSL stylesheet to be compiled.
Note: This element is required and
can be used multiple times.
Example:<target name="testXSLT">
<taskdef name="compileXSLT" classname="com.ibm.xml.xapi.ant.TaskCompileXSLT"/>
<compileXSLT>
<out>sample</out>
<dir>"C:/precompiledXSLT"</dir>
<pkg>com.mycompany.precompiled</pkg>
<function>
<name>
<localpart>la</localpart>
<namespaceURI>"http://www.ibm.com/Los Angeles"</namespaceURI>
</name>
<type>
<localpart>boolean</localpart>
<namespaceURI>http://www.w3.org/2001/XMLSchema</namespaceURI>
</type>
</function>
<inputfile>C:/XSLT/simple.xsl</inputfile>
</compileXSLT>
</target>