[
Lists Home |
Date Index |
Thread Index
]
> 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/
|