XSH2 is designed as an environment for querying and manipulating XML and HTML documents. Use open or create commands to load an XML or HTML document from a local file, external URL (such as http:// or ftp://), string or pipe. XSH2 can optionally validate the document during parse process (see validation and load-ext-dtd). Parsed documents are stored in memory as DOM trees, that can be navigated and manipulated with XSH2 commands and XPath language, whose names and syntax make working with the DOM tree a flavor of working in a UNIX filesystem.
A parsed document is usually stored in a variable.
XSH2 shares variables
with the XPath engine, so if e.g.
$doc is a XSH2
variable holding a document (or, more generally any node-set), then
$doc//section/title is an
XPath expression selecting all
subelements of all
section elements within the (sub)tree of $doc.
Although XSH2 is able to parse remote documents via
ftp://, it is only
able to save them locally. To upload a document to a remote server
(e.g. using FTP) or to store it into a database, use save command with a
parameter, in connection with an external program able to store
its standard input (XML) to the desired location.
You can also use similar
parameter with open in order to parse
documents from standard output of some external program.
Example 1. Store a XSH2 document on a remote machine using the Secure Shell
save --pipe "ssh my.remote.org 'cat > test.xml'" $doc
turn on backup file creation
use a catalog file during all parsing processes
set on/off changing current document to newly open/created files
clone a given document
close document (without saving)
make a new document from a given XML fragment
display a list of open documents
index a static document for faster XPath lookup
turn off backup file creation
specifying names of DOM nodes
load an XML, HTML, or Docbook SGML document from a file, pipe or URI
load and insert XInclude sections
save a document as XML or HTML
change filename or URL associated with a document
process selected elements from an XML stream (EXPERIMENTAL)
name of a sub-routine