From: André K. <ak...@la...> - 2010-11-30 00:19:20
|
>>> >>> Is it worth adding all these options? Your example shell commands >>> look >>> like XSL with shorter tags (<tagname></tagname> becomes --tagname or >>> -t). >> >> Well that's what I wanted to discuss about! >> I think some switches are definitely worth adding: var, key, choose/ >> when/otherwise, import, include. >> Some are less worth it and as you say could be added with extra >> switches or extended --elem and --attr (say --xelem and --xattr) >> which >> would write xslt elements. >> >> Some switches could be shortcuts to longer xslt constructs (like >> currently --template, --match): function and/or function call >> switches. >> >> In the end the command line will look like an XSLT stylesheet but >> less >> verbose and hopefully human-readable. >> But I also see xmlstarlet as a command-line xslt stylesheet designer. >> > > Hmm, well I see it more as a little tool for when you have just a > small > XML manipulation task that isn't worth the bother of writing a > stylesheet: little one-liners. It would be interesting to hear others > people's opinion on this. I felt a bit let down when I was trying to go over the one-liner since things are rarely as simple as they look like. This is why I added options to support other xsl elements. First of I didn't much like the idea of writing: xml sel -t -i 'condition' -o 'yes' -b -i 'not(condition) -o 'no' -b -b for an if/then/else so I added support for choose/when/otherwise: xml sel -t --choose --when 'condition' -o 'yes' -b --otherwise -o 'no' -b -b -b Sure it's longer to write but it also opens new horizons. Then things leading to another I added support to var, key. Anyway, adding other switches won't prevent you from using xmlstarlet for one-liners if that's how you use it. I also use it for one-liners. I just don't want to be stopped at the first hurdle. I'd be interested in other people's opinion as well. > If we do go in the "less verbose stylesheet direction", I think there > should be some kind of syntax defined instead of using options for > everything. I don't find the dashes very pretty, and single letter > options aren't all that human-readable. Well sure that's a matter of taste. I don't mind too much the dashes, but I rarely write long xml commands directly in the terminal, I directly integrate them in longer shell scripts. As for the the syntax I don't quite understand. If that's a full language, then XQuery is already there. If that's some shortcuts or syntactic sugar to avoid typing dashes then OK. For instance I'd prefer to write -a name=value to set an attribute rather than the current -a name -o value -b. But the second syntax remains useful for more complex logic. There's a learning curve as for any command-line or any tool, and if I don't want to have to remember what a short option means, I use the long one. More typing but less head scratching three months later. Regards, André |