[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Need XML grep-like tool for Linux that uses XPath
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|