Executing using the command-line tools
We can use the ExecuteXSLT tool to execute a stylesheet, use the ExecuteXPath tool to execute an XPath expression, and use the ExecuteXQuery tool to execute an XQuery expression.
Tasks
- Execute XSLT
- Location
- The product includes the following script that sets up the environment and invokes the tool.
- (Windows) app_server_root\bin\ExecuteXSLT.bat
- app_server_root/bin/ExecuteXSLT.sh
- Syntax
- (Windows)
ExecuteXSLT.bat -outputfile file -baseURI URI -useCompiler -bindVar name=varName value=varValue -baseOutputURI URI -XSLTinitMode mode -XSLTinitTemplate template -v -h -input file stylesheet./ExecuteXSLT.sh -outputfile file -baseURI URI -useCompiler -bindVar name=varName value=varValue -baseOutputURI URI -XSLTinitMode mode -XSLTinitTemplate template -v -h -input file stylesheet
- Parameters
- -outputfile file
- Specifies that output should go to the specified file
By default, the output is sent to standard out.
- -baseURI URI
- Base URI of the containing element
- -useCompiler
- Specifies compiler modes
If not specified, the default behavior is to use interpreted mode.
- -bindVar name=varName value=varValue
- Bind an atomic value to a variable (XPath, XQuery) or a param (XSLT)
The value must be valid for the type that was specified in the static context (XPath), in the query (XQuery), or in the stylesheet (XSLT) for the same name.
The -bindVar option can be used multiple times.
- varName
- Name of the variable (expressed localPart,namespaceURI)
- If the variable is in no namespace, the namespace URI should be omitted.
- If the value of any option contains a blank space, enclose it in quotation marks.
- Localpart is a required value.
- varValue
- Variable value
For example:
-bindVar name=la,"http://www.ibm.com/Los Angeles" value="some value"
- -baseOutputURI URI
- Base URI to use when resolving result documents
The default is either the base URI for the main result document or the current working directory.
This option only applies when working with XSLT.
- -XSLTinitMode mode
- Specifies a mode to use as the initial mode in an XSLT transformation (expressed localPart,namespaceURI)
This option only applies when working with XSLT.
For example:
-XSLTinitMode la,"http://www.ibm.com/Los Angeles"
- -XSLTinitTemplate template
- Named template to use as the initial template in an XSLT transformation (expressed localPart,namespaceURI)
If a named template is not set, the initial template is determined by the initial mode, context node, and template matching rules.
This option only applies when working with XSLT.
For example:
-XSLTinitTemplate la,"http://www.ibm.com/Los Angeles"
- -v
- Prints the version of the tool
- -h
- Prints the usage statement
- -input file
- Full path to a file containing an XML artifact against which the stylesheet will be executed
- stylesheet
- Full path to a file containing the XSL stylesheet
The following is a basic example of executing a stylesheet using the ExecuteXSLT tool:
- (Windows) ExecuteXSLT.bat -input C:\sampledata\sample.xml C:\stylesheets\simple.xsl
This executes the C:\stylesheets\simple.xsl stylesheet and places the resulting output on standard out.
- ./ExecuteXSLT.sh -input /var/sampledata/sample.xml /var/stylesheets/simple.xsl
This executes the /var/stylesheets/simple.xsl stylesheet and places the resulting output on standard out.
- Execute an XPath expression
- Location
- The product includes the following script that sets up the environment and invokes the tool.
- (Windows) app_server_root\bin\ExecuteXPath.bat
- app_server_root/bin/ExecuteXPath.sh
- Syntax
- (Windows)
ExecuteXPath.bat -outputfile file -cpm mode -ns prefix=URI -schema URI [-var name=varName type=varType] ... -baseURI URI -dnet URI -useCompiler -bindVar name=varName value=varValue -v -h -input file xpathfile./ExecuteXPath.sh -outputfile file -cpm mode -ns prefix=URI -schema URI [-var name=varName type=varType] ... -baseURI URI -dnet URI -useCompiler -bindVar name=varName value=varValue -v -h -input file xpathfile
- Parameters
- -outputfile file
- Specifies that output should go to the specified file
By default, the output is sent to standard out.
- -cpm mode
- Specifies an alternate XPath compatibility mode
Valid values are Latest, 1.0, and 2.0.
The default is 2.0.
- -ns prefix=URI
- Namespace for use during static processing
If the value of any option contains a blank space, enclose it in quotation marks.
This option can be used multiple times.
- -schema URI
- Specifies any schema document used to populate the in-scope schema definitions
This option can be used multiple times.
- -var name=varName type=varType
- Adds a variable binding to the static context for a single item
This simply declares the variable, and a value also must be bound to the XDynamicContext.
- varName
- Indicates the name of the variable (expressed localPart,namespaceURI)
If the variable is in no namespace, the namespace URI should be omitted.
Localpart is a required value.
- varType
- Indicates the type of the variable (expressed localPart[, namespaceURI])
If the value of any option contains a blank space, enclose it in quotation marks.
This option can be used multiple times.
For example:
-var name=la,"http://www.ibm.com/Los Angeles" type=boolean,http://www.w3.org/2001/XMLSchema
- -baseURI URI
- Base URI of the containing element
- -dnet URI
- 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.
- -useCompiler
- Specifies compiler modes
If not specified, the default behavior is to use interpreted mode.
- -bindVar name=varName value=varValue
- Bind an atomic value to a variable (XPath, XQuery) or a param (XSLT)
The value must be valid for the type that was specified in the static context (XPath), in the query (XQuery), or in the stylesheet (XSLT) for the same name.
The -bindVar option can be used multiple times.
- varName
- Name of the variable (expressed localPart,namespaceURI)
- If the variable is in no namespace, the namespace URI should be omitted.
- If the value of any option contains a blank space, enclose it in quotation marks.
- Localpart is a required value.
- varValue
- Variable value
For example:
-bindVar name=la,"http://www.ibm.com/Los Angeles" value="some value"
- -v
- Prints the version of the tool
- -h
- Prints the usage statement
- -input file
- Full path to a file containing an XML artifact against which the XPath expression will be executed
- xpathfile
- Full path to a file containing the XPath expression
The following is a basic example of executing an XPath expression using the ExecuteXPath tool:
- (Windows) ExecuteXPath.bat -input C:\sampledata\sample.xml C:\XPath\simpleXPath.txt
This executes the XPath expression provided in C:\XPath\simpleXPath.txt and places the resulting output on standard out.
- ./ExecuteXPath.sh -input /var/sampledata/sample.xml /var/XPath/simpleXPath.txt
This executes the XPath expression provided in /var/XPath/simpleXPath.txt and places the resulting output on standard out.
- Execute an XQuery expression
- Location
- The product includes the following script that sets up the environment and invokes the tool.
- (Windows) app_server_root\bin\ExecuteXQuery.bat
- app_server_root/bin/ExecuteXQuery.sh
- Syntax
- (Windows)
ExecuteXQuery.bat -outputfile file -baseURI URI -dnet URI -useCompiler -bindVar name=varName value=varValue -v -h -input file xqueryfile./ExecuteXQuery.sh -outputfile file -baseURI URI -dnet URI -useCompiler -bindVar name=varName value=varValue -v -h -input file xqueryfile
- Parameters
- -outputfile file
- Specifies that output should go to the specified file
By default, the output is sent to standard out.
- -baseURI URI
- Base URI of the containing element
- -dnet URI
- 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.
- -useCompiler
- Specifies compiler modes
If not specified, the default behavior is to use interpreted mode.
- -bindVar name=varName value=varValue
- Bind an atomic value to a variable (XPath, XQuery) or a param (XSLT)
The value must be valid for the type that was specified in the static context (XPath), in the query (XQuery), or in the stylesheet (XSLT) for the same name.
The -bindVar option can be used multiple times.
- varName
- Name of the variable (expressed localPart,namespaceURI)
- If the variable is in no namespace, the namespace URI should be omitted.
- If the value of any option contains a blank space, enclose it in quotation marks.
- Localpart is a required value.
- varValue
- Variable value
For example:
-bindVar name=la,"http://www.ibm.com/Los Angeles" value="some value"
- -v
- Prints the version of the tool
- -h
- Prints the usage statement
- -input file
- Full path to a file containing an XML artifact against which the XQuery expression will be executed
- xqueryfile
- Full path to a file containing the XQuery expression
The following is a basic example of executing an XQuery expression using the ExecuteXQuery tool:
- (Windows) ExecuteXQuery.bat -input C:\sampledata\sample.xml C:\XQuery\simpleXQuery.txt
This executes the XQuery expression provided in C:\XQuery\simpleXQuery.txt and places the resulting output on standard out.
- ./ExecuteXQuery.sh -input /var/sampledata/sample.xml /var/XQuery/simpleXQuery.txt
This executes the XQuery expression provided in /var/XQuery/simpleXQuery.txt and places the resulting output on standard out.
Loading a precompiled executable Precompiling using ANT tasks Precompiling using the command-line tools