Re: [greenstone-users] Displaying multiple metadata values individually?

From schild
DateThu, 27 Jan 2005 21:26:59 +0100
Subject Re: [greenstone-users] Displaying multiple metadata values individually?
In-Reply-To (41F13231-9040308-atp-rub-de)
Hi everyone again,

I figured out a way how to solve the problem myself by now. It is maybe
a quick and dirty solution, but it works by using simple Javascript
functions. For the ones that are interested and want to do the same
thing as me: here is how I did it:

The inital problem first again: Instead of displaying an html version of
the documents of my collection, I display a bibliographical record of
all the assigned metadata elements. The values of these metadata
elements are hyperlinked, such that clicking on a string starts a search
query for this value in the corresponding index across the whole
collection. An example to clarify the problem: all of my documetns have
authors assigned as metadata. When clicking on the display document
button the mentioned bibliographic record for that specific document
appears. Imagine this document has two authors, "A" and "B". Clicking on
the hyperlinked "A" string of the bib. record will execute a search
across the whole document collection for "A" in the "author" index. The
produced and displayed search results include all other documents
created by "A".
The problem with multiple assigned metadata values (e.g. multiple
authors) is that you can either access the complete string (all values)
or just the first one. If you use the statement [siblings(All";
")dc.creator], it will return a string off all values, with each value
separated by a semicolon (in the example this produces the string "A;
B"). On the contrary [dc.creator] only displays the first value (which
is "A"). For a hyperlink connect to each value individually you can do
the following (this is how I did it)

Use the format string below in the collect.cfg file (for my collection I
put this string in "format DocumentText" statement)

<td align=right valign=top><b>Authors:</b></td>
<td align=left valign=bottom><label name=AuthorField id=AuthorField>
_httpquery_;[cgisafe:sibling(All:\' ;

Notice, that statement includes a label definition with the name
"AuthorField". "_httpquery_" is a macro which resolves into the
http-address of query page of the collection. "[cgisafe:sibling(All:\' ;
\'):dc.Creator]" will be evaluated to the string as mentioned above with
the exception, that cgisafe is a cgiscript, which will replace all
special characters with UTF-8 encoding, such that it can be used within
a web address. [sibling(All:\'_\'):dc.Creator] produces a similar string
without replaced special characters. Notice the different separation
symbols, these are needed later on.

Additional changes have to be made in order to make this whole thing
work. You further need to change the _header_ or _textheader_ macro in
the package of the page, the format string will be displayed in (in my
case the document package). The change is that _htmlhead has to be
parametrized with

_htmlhead_(onload="ExtractAuthors();"), where ExtractAuthors(); is a
Javascipt function, which is called on loading the corresponding page
(the document display page). Since you do not want to mess in the
standard macro files, create your one file and override the
chosen macro with a collection specific macro. In my example this is
done by the code sequence

package document

###document display

###HTML-Page Header
_textheader_ [c=exacol] {_cgihead_
<table width=_pagewidth_><tr><td align=right>

Now all that is missing is the Javascript function which has to be
included into the _pagescriptextra_ macro of the same package. Copy this
macro out of the corresponding standard macro file and paste it into
your file. Make the neccessary modification which is in my case

### Self-made Javascript functions
function ExtractAuthors() \{
var res;
a = AuthorField.outerText.split(";");
resolver = a[0]+"&q=";
b = a[1].split("+%3b+");
c = a[2].split("_");
res = "";
for (i = 0; i < b.length ;i++)
res = res + "<a href=" + resolver + b[i]+ "&h=dd0&t=0>" + c[i] +
AuthorField.outerHTML = res;

You see the included Javascript function, which evaluates the string of
the defined label, splits it into serveral strings and composes a string
out of thoses values, which is then set to the "outerHTML" element of
the label. This will actually work (believe it or not!). As I said, it
is probably not the most efficient and the cleanest way of achieve this
functionality, but who cares.

Well, time to leave

Axel Schild

schild schrieb:

> Hi everyone,
> I am fairly new to the Greenstone community, so I do not know whether
> this question has been asked before... (although I did some extensive
> research on the postings in the mailing list). I am in the process of
> constructing my first Greenstone demo collection. At the moment I am
> trying to figure out some customizing features of the software and ran
> across the following problem:
> I assigned multiple values to various metadata fields, as for instance
> "dc.creator". Now I found out from the FAQ section that it is possible
> to display the first entry using just [dc.creator] or all of them
> using [(sibling(All):dc.creator]. I wonder whether it is possible to
> display all of them individually. The reason for me wanting to do this
> is the following:
> In my collection I would like to display a bibliographical record of
> each document first, in which metadata elements hyperlinked.
> It should be possible to initiate a search for other documents of a
> specific author, by just clicking on the authors name, that is
> displayed in the bibliographical record. An example is for this is
> given below
> *Creator:* E. Kerrigan
> A. Bemporad
> D. Mignone
> M. Morari
> J. Maciejowski
> <gsdl?e=d-0-00-hyconexa--00-0-0--0prompt-10---4------0-1l--1-en-50---20-about---00031-001-1-0utfZz-8-00&a=q&q=E%2e+KerriganA%2e+BemporadD%2e+MignoneM%2e+MorariJ%2e+Maciejowski&h=dd0&t=1>
> *Rights:* Public
> Does anyone know a solution to my problem (basically how to access
> metadata field individually)?
> Thanks in advance and keep up the outstanding development of
> Greenstone :-),
> Axel Schild


Dipl.-Ing. Axel Schild
Automatisierungstechnik und Prozessinformatik
Ruhr-Universitaet Bochum IC-3/151
D-44780 Bochum, Germany

Tel: +49 234 32 25203
Fax: +49 234 32 14101