I recently found xmlsh and decided to give it a try in spite of it not being available as a Debian package. I like the approach to make the whole thing look like a Unix shell. Here is an example what you can do with it: I run a system command, here echo -n "a+b" | p2x -bPLUS, and get the result in an XML variable, and then extract some subtree from it with XPath.

xmlsh <<EOF
x=$<(echo -n "a+b" | p2x -bPLUS)
declare namespace cx=http://johannes-willkomm.de/xml/code-xml/
xecho \$x | xpath "/*/cx:root"
EOF
$ x=$<(echo -n "a+b" | p2x -bPLUS)
$ declare namespace cx=http://johannes-willkomm.de/xml/code-xml/
$ xecho $x | xpath "/*/cx:root"
<root xmlns="http://johannes-willkomm.de/xml/code-xml/"
      line="0"
      col="0"
      code="27"
      type="ROOT">
      <null/>
      <op line="1" col="1" code="47" type="PLUS">
         <id line="1" col="0" code="31" repr="a" type="IDENTIFIER">
            <ca:text xmlns:ca="http://johannes-willkomm.de/xml/code-xml/attributes/">a</ca:text>
         </id>
         <ca:text xmlns:ca="http://johannes-willkomm.de/xml/code-xml/attributes/">+</ca:text>
         <id line="1" col="2" code="31" repr="b" type="IDENTIFIER">
            <ca:text xmlns:ca="http://johannes-willkomm.de/xml/code-xml/attributes/">b</ca:text>
         </id>
      </op>
   </root>
$

However, I miss many of my zsh hotkeys, so I will not make xmlsh my default command shell. But I will certainly use it for scripting XML pipelines.

blog comments powered by Disqus