[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

Subject: Re: 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
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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.