From | Axel schild |
Date | Wed, 31 Aug 2005 14:09:43 +0200 |
Subject | Re: [greenstone-users] Displaying multiple metadata values individually? |
In-Reply-To | (Pine-LNX-4-44-0508311100330-29128-100000-fornax-it-iitb-ac-in) |
Hi Chaitra, indeed it might be a problem with Unicode characters that are encoded correctly. As you can see from the HTML source code line, there is no quotation mark " ' " before the closing bracket ")" (That is why the string is unterminated!). That is a problem in the format string of the collect.cfg file (sorry for that, I forgot it in the code I posted). The correct code should be _JavaScriptBeginMacro_(ExtractCommNames) \'_httpquery_;[cgisafe:sibling(All:\\' | \\'):agr.CommodityName];[sibling(All:\\'_\\'):agr.CommodityName]\'_JavaScriptEndMacro_ Sorry for that! However there are a number of question marks in the source code you copied and pasted (at least in the mail). I guess those question marks are placeholders for your metadata values. I am not sure whether these might become a problem or not. All I know from my experience, the metadata values in my collection, which contain Unicode characters (I think Greenstone handles them in UTF8 encoding, but I am not sure) do not cause problems. But before discussing this issue, lets go step by step. What is the behavior of the collection after you applied the above mentioned correction to the format string? Greetings, Axel Chaitra Rao schrieb: Hi Axel, I tried out the solution u suggested for Mozilla and other browsers.(I haven't tested it on Mozilla since most of us use IE, here in our lab). The Javascript debugger on IE (the yellow ballon like thing that appears on the left corner of the browser:)...I'm not sure if that can be called a debugger :)) shows an "unterminated string constant" error at the following lines in the source of the page: <script type="text/javascript"> ExtractCommNames ( '/gsdl/cgi-bin/library.exe?e=d-000-00---0cropsample--00-0-0--0prompt-10---4------0-1l--1-en-50---20-about---00031-001-1-0utfZz-8-00&a=q;%e0%a4%a6%e0%a5%8d%e0%a4%b0%e0%a4%be%e0%a4%95%e0%a5%8d%e0%a4%b7;??????? ); </script></a> <br><br>??? :?????????????<br></td></td> Could the error occur 'coz of the unicode chararcters that are passed as is without any encoding? Or is the "unterminated string"error a serious one? It'll be great if I can get this running! Thanks and regards, Chaitra On Tue, 23 Aug 2005, Axel schild wrote:Hi Chaitra, have you tried the solution I posted and got it to work yet? Reagrds, Axel Chaitra Rao schrieb:Hi Axel, Thanks for the quick response. I use webserver version of GS. I use Apache. Regards, Chaitra On Thu, 18 Aug 2005, schild wrote:Hi Chaitra okay you are using MSIE... Are you running a local library installation or a server based installation? When I changed from local to server setup, I remember I experienced similar problems that you seem to have, that is why I adapted the scripts the first place. Chaitra Rao wrote:I use IE...Do I need to do the same for IE too? Does this solution work for all browsers?I won't claim that it works for all browsers. All I know is, that it works for mozilla, IE and opera (at least from a colleague that uses it). As I do not have my old files with the first solution that you quoted available, It would be easier for the debugging, if you apply the changes that I mentioned in the last mail. You may want to save the corresponding files though before applying the changes just for backup. I do not know whether, there exists something like the javascript console for MSIE. Especially for debugging javascript code it would be handy, to have some more information where exactly the error occurs when you open the html page with the links... regards, Axel SchildRegards, Chaitra On Thu, 18 Aug 2005, schild wrote:Hi Chaitra,>from the html source code, you can see that the javascript has not beenexecuted at all. If you are using mozilla browser, it helps to open the javascript console in the "web development menu" under tools. Then you can check whether an error occurred in the execution of a javascript. Try that before you apply the changes I suggest below and see what the error message is. Anyway I think Jens comment is correct, that is you are not using MSIE but another browser. As mentioned before in the posting to the list, I changed the scripts a little to now work with mozilla (in my case I must say, it is still an ad hoc solution...) Try the following: Instead of using <label name=CommName id=CommName>_httpquery_;[cgisafe:sibling(All:\\' ; \\'):agr.CommodityName];[sibling(All:\\'_\\'):agr.CommodityName]</label> in your format statement of the cfg file use _JavaScriptBeginMacro_(ExtractCommNames) \'_httpquery_;[cgisafe:sibling(All:\\' | \\'):agr.CommodityName];[sibling(All:\\'_\\'):agr.CommodityName]_JavaScriptEndMacro_. In your extra.dm file add the two macros under package style: package Style _JavaScriptBeginMacro_ [c=hyconexa] { <script type="text/javascript"> _1_ (} _JavaScriptEndMacro_ [c=hyconexa] { ); </script>} Then change your old javascript function function ExtractCommNames() \{ var res; a = CommName.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=daa&t=1>" + c[i] + "&w=utf-8" +"</a><br/>"; \} CommName.outerHTML = res; \} to this new definition function ExtractCommNames(CommNamesString) \{ if (CommNamesString != "") \{ stringArray = CommNamesString.split(";"); resolver_PlainQueryField = stringArray[0]+ "&q="; linkString = stringArray[1].split(" | "); textString = stringArray[2].split("_"); hrefString = \'<ul>\'; for (i = 0; i < linkString.length ;i++) \{ linkString_without_highlight = linkString[i].split('<span style="background: #FFFF77">').join(''); linkString_without_highlight = linkString_without_highlight.split('</span>').join(''); hrefString = hrefString + "<li><a href=" + resolver_PlainQueryField + linkString_without_highlight + "&h=daa&t=1>" + textString[i] + "&w=utf-8" + "</a><br/>"; \} hrefString = hrefString + "</ul>"; document.write(hrefString); \} \} This should do it, at least I hope (if not let me know). Take out the second javascript function for the beginning such that you can be sure that now error is int he syntax of the javascript functions themselves. regards, axel Chaitra Rao wrote:Hi Axel, Thanks for the quick response. I've attached the collect.cfg, extra.dm, main.cfg and the html source files (.zip) along with this e-mail. The hyperlink text seems to be okay. I think javascript is not able to process the html variables or may be something is missing somewhere. Thanks once again :-) Regards, Chaitra On Wed, 17 Aug 2005, schild wrote:Hi Chaitra, for making this debugging effort a little easier, can you please send me your collect.cfg file (predominantely the format statement) the main.cfg file, the extra.dm file, as well as the source code of the html page which includes the hyperlink addresses. Thanks, Axel Chaitra Rao wrote:Hi Axel, I tried out your solution. It doesn't seem to be working fine for me. I think there's something I've missed out. First, I used the format stattement options wit the relevant metadata names (I've created my own metadata set). Next, I edited the document.dm file and inserted the following lines("cropsample" is the coll name): _textheader_ [c=cropsample] {_cgihead_ _htmlhead_(onLoad="ExtractCommNames();") <center> <table width=_pagewidth_><tr><td align=right> _icontab__javalinks_</td></tr></table> </center> } After that I placed the above lines in extra.dm and also the foll javascript: ### Self-made Javascript functions _pagescriptextra_{ function ExtractCommNames() \{ var res; a = CommName.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=daa&t=1>" + c[i] + "&w=utf-8" +"</a><br/>"; \} CommName.outerHTML = res; \} After I built the collection, I can see the long url but no hyperlink, which I guess the javascript is supposed to generate. I think there's some mistake somewhere. It'll be nice if you can help me :) Let me know if you want more details about the collection. Thanks and Regards, Chaitra On Thu, 27 Jan 2005, schild wrote: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) {If}{[dc.Creator], <tr> <td align=right valign=top><b>Authors:</b></td> <td align=left valign=bottom><label name=AuthorField id=AuthorField> _httpquery_;[cgisafe:sibling(All:\' ; \'):dc.Creator];[sibling(All:\'_\'):dc.Creator]</label></td> </tr>} 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 extra.dm 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_ _htmlhead_(onload="ExtractSubjects();ExtractAuthors();") <center> <table width=_pagewidth_><tr><td align=right> _icontab__javalinks_</td></tr></table> </center> } 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 extra.dm file. Make the neccessary modification which is in my case ### Self-made Javascript functions _pagescriptextra_{ 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] + "</a><br/>"; \} 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 E-mail: schild@atp.rub.de _______________________________________________ greenstone-users mailing list greenstone-users@list.scms.waikato.ac.nz https://list.scms.waikato.ac.nz/mailman/listinfo/greenstone-users-- ---------------------------------------------- Dipl.-Ing. Axel Schild Automatisierungstechnik und Prozessinformatik Ruhr-Universitaet Bochum IC-3/140 D-44780 Bochum, Germany Tel: +49 234 32 25203 Fax: +49 234 32 14101 E-mail: schild@atp.rub.de-- ---------------------------------------------- Dipl.-Ing. Axel Schild Automatisierungstechnik und Prozessinformatik Ruhr-Universitaet Bochum IC-3/140 D-44780 Bochum, Germany Tel: +49 234 32 25203 Fax: +49 234 32 14101 E-mail: schild@atp.rub.de-- ---------------------------------------------- Dipl.-Ing. Axel Schild Automatisierungstechnik und Prozessinformatik Ruhr-Universitaet Bochum IC-3/140 D-44780 Bochum, Germany Tel: +49 234 32 25203 Fax: +49 234 32 14101 E-mail: schild@atp.rub.de-- ---------------------------------------------- Dipl.-Ing. Axel Schild Automatisierungstechnik und Prozessinformatik Ruhr-Universitaet Bochum IC-3/140 D-44780 Bochum, Germany Tel: +49 234 32 25203 Fax: +49 234 32 14101 E-mail: schild@atp.rub.de -- ---------------------------------------------- Dipl.-Ing. Axel Schild Automatisierungstechnik und Prozessinformatik Ruhr-Universitaet Bochum IC-3/140 D-44780 Bochum, Germany Tel: +49 234 32 25203 Fax: +49 234 32 14101 E-mail: schild@atp.rub.de <<attachment>> Type: text/x-vcard Filename: schild.vcf
begin:vcard
|