RE: [greenstone-devel] testing metadata values in a format string

From Gregory S. Williamson
DateMon, 18 Aug 2003 21:05:37 -0700
Subject RE: [greenstone-devel] testing metadata values in a format string
This variant does in fact work:

format DocumentText '<img src="/gsdl/collect/gamssf/images/aframer_top2.jpg">
<img src="/gsdl/collect/gamssf/images/rulclas_top2.jpg">)
<p><p>[Text]'

If the [Subject] is neither of the above I get no image, which is more-or-less what I want. Otherwise the desired one appears.

Thanks for the tips !

Greg W.

-----Original Message-----
From:John R. McPherson [mailto:jrm21@cs.waikato.ac.nz]
Sent:Sun 8/17/2003 4:43 PM
To:Gregory S. Williamson
Cc:greenstone-devel@list.scms.waikato.ac.nz
Subject:Re: [greenstone-devel] testing metadata values in a format string

Gregory S. Williamson wrote:
> I am tinkering with some ways of showing a banner based on a metadata
> tag ("Subject") ... if it is "Labor" I want to show one image, if it is
> "Haight Ashbury" another image, and so on.
>
> I have been able to test for the presence of a metadata element, but
> not for its content:
>
> format DocumentText "{If [Subject] } { <p><img src =
> "/gsdl/collect/gamssf/images/labor_top2.jpg" border =
> 0></a>,<p><p> } <p> [Text]"
>
> This seems to work for testing for the presence of the metadata tag (as
> advertised) -- other than a trailing "}" after the image and before
> the text, which puzzles me.

> Is there a way to test for the value of a metadata tag in such a format
> statement ?

Greenstone has two different way of checking metadata values...

{If}{test, value-if-true, value-if-false}
is supposed to be the "simple" way of testing whether a string is empty
or not-empty from within format strings, so
{If}{[Metadata], Metadata value: [Metadata], No Metadata Value}
would print different things depending on whether that document has
a "Metadata" field. It only tests empty or non-empty - you can't check its
value.

Now, the macros in the macro files use different semantics...
value-if-true
but the difference is that these tests can also check the value.

Now, the confusing part (for me) is that this syntax does not (or at
least did not) work from within a format string in the collect.cfg file,
but I have just tried it and it works (even though I thought it wasn't
supposed to).

You can do
metadata is some value
(the quote marks are important).

So, in your collect.cfg, you could try something like
format DocumentText '
<img src="labour.jpg">
<img src="something.jpg">
...
'
You can also use "ne" for not equal.

If you use single quotes (') around the whole format string then you can
use the double quotes unescaped, otherwise you have to do
format DocumentText " xxx.... "ccc" .... "..." .... "
etc.

Let us know if this works!

John McPherson