Subject: Re: [xsl] Need XML grep-like tool for Linux that uses XPath expressions From: Syd Bauman <Syd_Bauman@xxxxxxxxx> Date: Wed, 12 Oct 2011 04:14:03 -0400 |
In addition to all of the excellent suggestions so far, there is xmlstarlet, which I use for exactly this sort of thing every day. I typically wrap the command in a shell for loop. E.g., the following (all on one line, of course) asks for a list of all TEI files that have within their <text>s one or more naked <reg> elements not wrapped in <choice>, and for each file a count of such cases: for f in *.tei ; do echo -n "---------$f:" ; xmlstarlet sel -N t=http://www.tei-c.org/ns/1.0 -t -m "/t:TEI/t:text" -v "count( .//t:reg[not( parent::t:choice )] )" $f ; done | egrep -v ':0$' The `xmlstarlet sel` subcommand basically let's you execute a small XSLT 1.0 program from the commandline. The "-t" switch says "here starts my template", the "-m" switch is for the match= attribute, and the -v switch is for the select= of an <xsl:value>. There are other capabilities, too. xmlstarlet also can execute an XSLT stylesheet file on STDIN from the commandline, although I personally don't use that much. Also see the xpath++ utility at https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14488694#14488694
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Need XML grep-like tool f, steve.majewski@xxxxx | Thread | [xsl] "grouping" footnote numbers, Emma Burrows |
Re: [xsl] "grouping" footnote numbe, David Carlisle | Date | [xsl] superfluous xmlns, Merrilees, David |
Month |