From: André K. <ak...@la...> - 2010-11-29 13:21:22
|
Hi Noam, >> I've put an "enhanced" xml select version in the 'enhanced_select' >> branch. >> >> The most useful switches to me currently are --var, --key and -- >> choose/--when/--otherwise. But --import might be useful also. >> The --function/--param/--call-template/--with-param needs some >> thinking since it's too verbose to my taste. >> >> I use variables mostly for clarity, and since they can hold nodesets, >> it makes it easier to collect data from several places in an xml >> document (or even several times from the same place). > > 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. >> >> Here's a little script which dumps the structure of an XML document >> and demonsrates the use of --var and --choose/--when/--otherwise >> switches. > > I couldn't get this one to work. I got a whole bunch of warnings like: > > warning: failed to load external entity "b" > warning: failed to load external entity "--when" I think that my mail client breaks lines longer than 70 characters. I added the contrib/xml_struct.sh script in the enhanced_select branch. Hopefully you'll be able to use it. Regards, André |