[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Globbing versus Regular Expressions (was: Regular Associations)


globbing regular expressions
> Sounds like you've invented a more verbose version of XPath 1.0. 

Almost so. With a few notes:

- it is not me who invented it, Relax NG is an international standard;

- it is not necessarily more verbose, there are cases when it is significantly
  more concise (or when it does not have an XPath equivalent);

- it does a different thing: XPath is a language for addressing parts of 
  a document, Relax NG, and the way it is used in ARX, the utility we are discussing,
  assesses that a document matches a regular pattern. 

The difference is almost the same as between filename globbing and regular
expressions for character strings. Globs is a subset of regular expressions,
they are not closed and cannot be freely combined. While globs can be shorter in 
a limited number of cases (and it only makes sense when amount of typing is important --
like filename globbing in a shell), their use for anything non-trivial is problematic.
Many Unix shell programmers routinely use sed to manipulate filenames in command's arguments.

  wc -l `ls *.*|grep -v "_(test|check)\.(c|cpp|sc)"`

will count lines in every file with dot in the name in the current directory (globbing), 
except those which name ends with _test or _check and which suffix is (.c, .cpp, or, .sc).

The same is true for XPath. It is good for XSLT (and several other applications), where
its use is constraineed and/or where the length of an expression is crucial (for clarity
or typing speed); however, in many other cases, a regular syntax is preferrable.

Note 1. However, I would find an XSLT-like language  that provides XML regular expressions
(similar to Relax NG) for matching and selection more useful and convenient, if occasionally
less verbose, than XSLT; if string regular expressions (which are peripheral to the area of XSLT)
were added, why XML regular expressions were not?

Note 2. Actually, I mentioned in the original message that my first thought had been to
use XSLT for this purpose (and I meant XPath, of course), and that I had realized later
that Relax NG is more appropriate. However, it was written at the very end of the message.

David Tolpin
http://davidashen.net/

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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.