Tool of the Moment: XSH-Shell Environment for XML Manipulation
Today we discovered XSH, an open source, interactive command line environment for querying and manipulating XML documents. Given its XML orientation it’s primarily of interest to XML users, and thus users of Structured Framemaker, but those who fall into that category and who have a little Unix shell programming experience should find ways to put it to good use.
The “About XSH” page describes it as follows:
XSH is a powerfull command-line tool for querying, processing and editing XML documents. It features a shell-like interface with auto-completion for comfortable interactive work, but can be as well used for off-line (batch) processing of XML data. XSH makes extensive use of the XPath language, but system shell and the Perl programming language are both accessible from XSH as well, in a very natural way. XSH itself is written in Perl and uses XML::LibXML bindings of libxml2 library as the XML-backend.
Features include:
- Based on excellent libxml2 library
- Work with multiple DOM trees at once
- Filesystem-like navigation within the DOM tree using XPath
- XPath-based copy/move nodes within a DOM tree or between two DOM trees (with automatic node-type conversion, so that you may e.g. move text nodes into attributes or comments)
- Deleting nodes, creating nodes of any type (elements, attributes, text, cdata, comments, well-balanced XML chunks, and (experimentally) even entity reference)
- XPath-based search and XML listing
- Arbitrary XPath and Perl expression evaluation
- Conditional statements, while loop, Perl-like foreach loop
- Command outupt redirection using a unix pipe; for example, use
xsh> list //word | grep [A-Z] | lessto read a list all word elements containing letters A to Z letters in less
- XML and HTML supported on both input and output
- XSLT transformation
- Validaton against DTD, RelaxNG and W3C Schemas
- XInclude support for both reading/writing
- XUpdate support
- Transparent conversion between XPath and Perl objects
- Global, local and lexical variables (as in Perl)
- User-defined procedures
- XML Namespace support in XPath expressions
- Lots of handy XPath extension functions
- Support for user-definable XPath extension functions, implemented in Perl
- Easy access to Perl and system calls
- Fully featured interactive shell with history and TAB-completion (for XSH commands, XPath expressions, variables, filenames, etc).
Frankly, this looks too convenient to pass up, just based on the XSH examples provided on the Web site. We’ll be downloading this right now and putting it in the toolbox.

























Post a Comment
You must be logged in to post a comment.