News

This release is only available through CPAN.
It contains several important bug and compatibility fixes and a three new XPath functions:

xsh:lineno()

returns the line-number of the current node (the function was present
before but was not documented)

xsh:span($start-node,$end-node)

returns a node-set which forms a span of sibling nodes
starting at $start-node and ending at $end-node
(these two must be siblings).

xsh:context($node,$before,$after?)

returns a node-set of sibling nodes surrounding $node. The span
consists of (up to) $before-many nodes immediately preceding
$node, the $node itself, and (up to) $after-many nodes
immediately following $node. If the $after is not given,
the value of $before is assumed.

Note: the project repository was migrated from CVS to SVN.

XSH2 2.1.0 ReleasedWed Jan 3 13:57:36 2007

This release contains several feature enhancements and many bug fixes.

If you, like me, use Emacs PSGML mode for
editing XML documents and you are familiar with XSH2, you might
find useful this tip:

The following lisp code allows you to apply an arbitrary
XSH2 one-liner to any element of an XML document. Just add the code
to your
~/.emacs file, open an XML file in Emacs (in
psgml-mode), move the cursor inside some element, run
M-x xsh-edit-element and type in a XSH2 command.

The commands 'map' and 'rename' are going to changeMon Sep 25 20:40:38 2006

While working on a new release, some syntax polishing took place
in the CVS version.
There were two commands with which I was so unsatisfied
that I decided to change them in a way that
may break some of the existing scripts.
Let me summarize the changes:

the mapping expression can also be XPath,
or any other XSH2 argument expression, not just
Perl

if Perl is used, it must be enclosed in braces,
as customary in XSH2.

$_ is read-only and
the result is collected from the expression value
just like in Perl map.

However, --in-place (:i) flag
was introduced to preserve the old behavior,
when the result is taken from $_.
This is useful for s///-like substitutions
with Perl code.

map does not rename elements anymore,
rename is used for that.
Instead, map operates on element's content
and the mapping expression may produce arbitrary nodes,
not just text.

Here is how the old syntax translates to the new one:

Old syntax

New syntax

map { $_=uc } //text();

map { uc } //text();

map $_=uc //text();

map { uc } //text();

map s/foo/bar/ //text();

map :i { s/foo/bar/ } //text();

map { $_='link' } //ref

rename link //ref;

And here are some funny examples from the documentation
demonstrating the gained features: