Support for CQL transformations involving wildcard patterns, which
authorMike Taylor <mike@indexdata.com>
Fri, 19 Dec 2003 12:16:19 +0000 (12:16 +0000)
committerMike Taylor <mike@indexdata.com>
Fri, 19 Dec 2003 12:16:19 +0000 (12:16 +0000)
commit30580efb58e1e71dfd4743db723a79a01206bac4
tree9e92948b8ddd6b072b19dbc927e65a3372ca9383
parentce3481bda4af7147e61cb88f7e628e57c4c443c2
Support for CQL transformations involving wildcard patterns, which
were previously passed through untouched.  We now make an effort to
emit the most primitive (i.e. Bath-friendly) truncation attributes we
can, based on what's in the configuration file, falling back on
Z59.58-like wildcarding when necessary.

The logic turns out to be non-trival (sigh ... so unlike an OpenURL
resolver.)  Although the code, once I'd finally arrived at it, turned
out to be gratifying short and clear:

If a term begins and ends with * and has no other WC
characters in it AND we have a truncation.both element in the
configuration file, strip the *s and use truncation.both.

Otherwise, if it begins with * and has no other WC characters
in it AND truncation.left is configured, use that.

Otherwise, if it ends with * and has no other WC characters
in it AND truncation.right is configured, use that.

Otherwise, if it has any WCs anywhere in the string,
transliterate * to ? and ? to # and use truncation.z3958,
generating error 28 "Masking character not supported" if it's
not configured.

Otherwise it must be the case that it has no WCs.  Use
truncation.none, generating error 30 "Too many masking
characters in term" if it's not configured.

This arrangement allows some flexibility in the configuration file,
e.g. you can omit the special-case left-, right- and both-truncation
elements if you always want Z39.58-style truncation.

I also fixed a small and harmless bug of Adam's, which I am pretty
sure could _never_ have any effect, but which offended me anyway.
This change is far too trivial to be worth mentioning in the CVS log,
but I'm expecting Adam to read this, and probably go and see what the
bug was :-)
src/cqltransform.c