Command import


import imports a module or package into the default namespace or a named namespace.


import module [prefix=]module
import package [prefix=]package [ [prefix=]package ...]
import commands [prefix=]command-subpackage [ [prefix=]command-subpackage ...]
import java url [url ...]

Description Modules

The import command imports a module into the default namespace or a named namespace.
See the Modules section for a description of Extension Modules.
If prefix is omited then the module is imported into the default namespace.
If prefix is specified then the module is imported into the named prefix and commands are accessed by using the prefix.

"module" is either the name of an extension module or the path to the module.xml file.
For named modules, the XMODPATH variable is searched. For each directory in XMODPATH, a child directory is searched with the name of the module, and if found the file "module.xml" is searched for in that directory. If found then that module.xml file is used for the module configuration.

If a URL is specified for "module" it is assumed to be the module configuration file (typically named "module.xml" but could be any name.
When located, the fully expanded URL for the module configuration file is used as the base URI for any dependant files (e.g jar files in the class path). Both the module.xml and its Dependant jars can be local files or on the network.

Commands are found by looking in that package for classes that extend the XCommand abstract class.
Commands may also be xmlsh scripts as resources within the specified package (and end with the .xsh extension).


Load module calabash from /usr/local/xmlsh/calabash
import module xp=calabsh
xp:xproc xprocfile.xpl

Load module marklogic from /usr/local/markogic/module.xml
import module ml=/usr/local/marklogic/module.xml

Load module marklogic from a remote host at
where all jar files are located remotely
import module ml=

Description Packages

Commands that are already in the CLASSPATH may be imported by specifying just the package name using the "import package" command. A namespace prefix may be provided and optionally a symbolic name may be specified.

To reference xmlsh internal commands not imported by default use the "import commands" statement so that your script is not dependant on knowing the specific package name of internal commands.

Example, to import commands from com.mycompany.commands package already in the class path

import package mycommands=com.mycompany.commands

Description Commands

To simplify importing sets of commands internal to xmlsh but not imported by default, the "import commands" command may be used.
This is equivalent to using "import package" using the full package name, but does not depend on version changes which may rename internal packages.

Example, to import the posix commands using the full package name and specifying the posix prefix

import commands posix=posix

Example to import the experimental commands into the global namespace

import commands experimental

You can group commands together to include multiple command sets

import commands posix experimental

Description Java

The shell's classpath can be extended by using the "import java" command. With no further arguments it prints the current classpath. Arguments are added to the classpath. They can be any URI, but typically will be paths to jar files. Relative paths are resolved against the current directory.

The classpath of the current shell is used as the base classpath for any commands which dynamically load java classes.
For example, xsql, jset, jcall, jnew.

Print the current classpath
import java

Add myfile.jar to the classpath
import java myfile.jar


There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki