From 09b200a563efc77be8bd8eceb05423772e261e18 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Wed, 8 Feb 2006 14:41:08 +0000 Subject: [PATCH] (Miguel Ferreira) - Controlled vocabulary patch to provide search on classification terms, and addition of terms during submission. SF Patch: #1244559 git-svn-id: http://scm.dspace.org/svn/repo/trunk@1414 9c30dcfa-912a-0410-8fc2-9e0234be79fd --- dspace/CHANGES | 9 + .../config/controlled-vocabularies/LICENCES | 14 + dspace/config/controlled-vocabularies/nsi.xml | 563 +++++ .../config/controlled-vocabularies/srsc.xml | 2251 +++++++++++++++++ dspace/config/dspace.cfg | 6 + dspace/config/input-forms.xml | 1 + .../config/language-packs/Messages.properties | 21 + dspace/docs/configure.html | 95 +- dspace/docs/controlledvocabulary.xsd | 63 + dspace/etc/dspace-web.xml | 23 + dspace/jsp/WEB-INF/dspace-tags.tld | 42 + .../controlledvocabulary.jsp | 177 ++ .../controlledvocabularyTag.jsp | 62 + dspace/jsp/controlledvocabulary/results.jsp | 230 ++ dspace/jsp/controlledvocabulary/search.jsp | 115 + .../controlledvocabulary/vocabulary2html.xsl | 75 + .../controlledvocabulary/vocabularyprune.xsl | 44 + dspace/jsp/help/index.html | 67 +- dspace/jsp/image/controlledvocabulary/f.gif | Bin 0 -> 162 bytes dspace/jsp/image/controlledvocabulary/m.gif | Bin 0 -> 104 bytes dspace/jsp/image/controlledvocabulary/p.gif | Bin 0 -> 106 bytes dspace/jsp/layout/navbar-default.jsp | 14 +- dspace/jsp/styles.css.jsp | 31 + dspace/jsp/utils.js | 115 + .../webui/jsptag/ControlledVocabularyTag.java | 402 +++ .../ControlledVocabularySearchServlet.java | 390 +++ .../servlet/ControlledVocabularyServlet.java | 86 + .../org/dspace/app/webui/util/DCInput.java | 311 ++- .../org/dspace/app/webui/util/XMLUtil.java | 217 ++ 29 files changed, 5291 insertions(+), 133 deletions(-) create mode 100644 dspace/config/controlled-vocabularies/LICENCES create mode 100644 dspace/config/controlled-vocabularies/nsi.xml create mode 100644 dspace/config/controlled-vocabularies/srsc.xml create mode 100644 dspace/docs/controlledvocabulary.xsd create mode 100644 dspace/jsp/controlledvocabulary/controlledvocabulary.jsp create mode 100644 dspace/jsp/controlledvocabulary/controlledvocabularyTag.jsp create mode 100644 dspace/jsp/controlledvocabulary/results.jsp create mode 100644 dspace/jsp/controlledvocabulary/search.jsp create mode 100644 dspace/jsp/controlledvocabulary/vocabulary2html.xsl create mode 100644 dspace/jsp/controlledvocabulary/vocabularyprune.xsl create mode 100644 dspace/jsp/image/controlledvocabulary/f.gif create mode 100644 dspace/jsp/image/controlledvocabulary/m.gif create mode 100644 dspace/jsp/image/controlledvocabulary/p.gif create mode 100644 dspace/src/org/dspace/app/webui/jsptag/ControlledVocabularyTag.java create mode 100644 dspace/src/org/dspace/app/webui/servlet/ControlledVocabularySearchServlet.java create mode 100644 dspace/src/org/dspace/app/webui/servlet/ControlledVocabularyServlet.java create mode 100644 dspace/src/org/dspace/app/webui/util/XMLUtil.java diff --git a/dspace/CHANGES b/dspace/CHANGES index f1c4146195..2878736997 100644 --- a/dspace/CHANGES +++ b/dspace/CHANGES @@ -1,5 +1,14 @@ 1.4 alpha 1 =========== +(Miguel Ferreira) +- Controlled vocabulary patch to provide search on classification terms, and + addition of terms during submission. + SF Patch: #1244559 + +(Richard Jones) +- Add 'visibility' element to input-forms.xml + SF Patch #1368160 + (Martin Hald) - Log4J enhancement to use XML configuration SF Patch #1224389 diff --git a/dspace/config/controlled-vocabularies/LICENCES b/dspace/config/controlled-vocabularies/LICENCES new file mode 100644 index 0000000000..71933fb65f --- /dev/null +++ b/dspace/config/controlled-vocabularies/LICENCES @@ -0,0 +1,14 @@ +nsi.xml +======= + +Norsk inndeling av vitenskapsdisipliner was created in 2003 for The Norwegian +Association of Higher Education Institutions. + +-------------------------------------------------------------------------------- + +srsc.xml +======== + +Thanks to the Swedish Royal Librarys Department for National Co-ordination and +Development, BIBSAM, and the participating members in the SVEP project for +the permission to use the Swedish Research Subject Categories. \ No newline at end of file diff --git a/dspace/config/controlled-vocabularies/nsi.xml b/dspace/config/controlled-vocabularies/nsi.xml new file mode 100644 index 0000000000..d299451ab6 --- /dev/null +++ b/dspace/config/controlled-vocabularies/nsi.xml @@ -0,0 +1,563 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dspace/config/controlled-vocabularies/srsc.xml b/dspace/config/controlled-vocabularies/srsc.xml new file mode 100644 index 0000000000..b6d6106d51 --- /dev/null +++ b/dspace/config/controlled-vocabularies/srsc.xml @@ -0,0 +1,2251 @@ + + + + + + + + + Religionshistoria + + + Kyrkovetenskap + + + Missionsvetenskap + + + Systematisk teologi + + + Islamologi + + + Tros- och livsåskådningsvetenskap + + + Religionssociologi + + + Religionspsykologi + + + Religionsfilosofi + + + Nya testamentets exegetik + + + Gamla testamentets exegetik + + + Dogmatik med symbolik + + + Religionsvetenskap/Teologi + + + + + + + Logik + + + Praktisk filosofi + + + Teoretisk filosofi + + + Vetenskapsteori + + + Filosofiämnen + + + + + Arkeologi + + + Arkeologi, klassisk + + + Arkeologi, medeltid + + + Arkeologi, nordeuropeisk + + + Arkeologi, utomeuropeisk + + + Afrikansk och jämförande arkeologi + + + Historisk osteologi + + + Arkeologiämnen + + + + + Historia + + + Idé- o lärdomshistoria + + + Ekonomisk historia + + + Kyrkohistoria + + + Teknikhistoria + + + Teknik och kultur + + + Teknik- och industrihistoria + + + Vetenskapshistoria + + + Rättshistoria + + + Medicinens historia + + + Agrarhistoria + + + Bok- och bibliotekshistoria + + + Historieämnen + + + + + Humanekologi + + + Kulturantropologi + + + Etnologi + + + + + Antikens kultur och samhälle + + + Bysantinologi + + + Historiska kulturer + + + Historisk-filosofiska ämnen + + + + + Estetik + + + Filmvetenskap + + + Konstvetenskap + + + Litteraturvetenskap + + + Musikvetenskap + + + Retorik + + + Teatervetenskap + + + Bebyggelseforskning + + + Estetiska ämnen + + + + + + + Svenska språket + + + Samiska + + + Norska språket + + + Danska språket + + + Nordiska språk + + + + + Germanistik + + + Engelska språket + + + Tyska språket + + + Nederländska + + + Övriga germanska språk + + + + + Franska språket + + + Italienska språket + + + Spanska språket + + + Portugisiska + + + Rumänska + + + Romanska språk + + + + + Finska språket + + + Estniska språket + + + Finsk-ugriska språk + + + + + Ryska språket + + + Polska språket + + + Slaviska språk + + + + + Latin + + + Klassisk grekiska + + + Nygrekiska + + + Klassiska språk + + + + + Sanskrit med indoeuropeisk språkforskning + + + Keltiska språk + + + Baltiska språk + + + Östasiatiska språk + + + Turkiska språk + + + Iranska språk + + + Arabiska + + + Kinesiska + + + Egyptologi + + + Indonesiska + + + Afrikanska språk + + + Bantuistik + + + Kaukasiska språk + + + Semitiska språk + + + Altaistik + + + Assyriologi + + + Indologi + + + Japanologi + + + Koreanologi + + + Övriga språk + + + Teckenspråk + + + + + Lingvistik + + + Fonetik + + + Barnspråk + + + Tvåspråkighet + + + Språkteknologi + + + Datorlingvistik + + + Lingvistikämnen + + + Språkvetenskap + + + Övrig humaniora och religionsvetenskap + + + HUMANIORA och RELIGIONSVETENSKAP + + + + + + + Förvaltningsrätt + + + Konstitutionell rätt + + + Socialrätt + + + Offentlig rätt + + + + + Civilprocess + + + Straffprocess + + + Förvaltningsprocess + + + Skiljemannarätt + + + Processrätt + + + Straffrätt + + + Finansrätt + + + + + Allmän avtalsrätt + + + Arbetsrätt + + + Affärsrätt + + + Bolagsrätt + + + Försäkringsrätt + + + Immaterialrätt + + + Sakrätt + + + Skadeståndsrätt + + + Speciell avtalsrätt + + + Civilrätt + + + + + Allmän rättslära + + + EU-rätt + + + Folkrätt + + + Internationell privat- och processrätt + + + Komparativ rätt + + + Marknads- och konkurrensrätt + + + Miljörätt + + + Övrig rätt + + + RÄTTSVETENSKAP/JURIDIK + + + + + + + + + Ämnesdidaktik + + + Vårdpedagogik + + + Musikpedagogik + + + Internationell pedagogik + + + Pedagogik + + + + + Tillämpad psykologi + + + Miljöpsykologi + + + Kognitionsforskning + + + Psykologi + + + + + Socialantropologi + + + Etnografi + + + Socialantrolopologi/etnografi + + + + + Familjeforskning + + + Ungdomsforskning + + + Handikappsforskning + + + Idrottsforskning + + + Socialt arbete + + + + + Kriminalvetenskap + + + Kriminologi + + + + + Rättssociologi + + + Sociologi + + + Demografi + + + + + Freds- och konfliktforskning + + + Freds- och utvecklingsforskning + + + Empirisk konfliktforskning + + + Forskning om Europa + + + Statsvetenskap + + + Pedagogiskt arbete + + + Socialvetenskap + + + + + Företagsekonomi + + + + + Kulturgeografi + + + Ekonomisk geografi + + + Kulturgeografi, ekonomisk geografi + + + + + Ekonometri + + + Nationalekonomi + + + Ekonomi + + + + + + + Informatik + + + Informatik och systemvetenskap + + + ADB + + + Data- och systemvetenskap + + + Databaser + + + Databehandling + + + Informations- och språkteknologi + + + Informationsbehandling + + + Informationsteknologi + + + Informatik, data- och systemvetenskap + + + + + Biostatistik + + + Statistik + + + Statistik, data- och systemvetenskap + + + + + Masskommunikation + + + Medie- och kommunikationsvetenskap + + + Biblioteks- och informationsvetenskap + + + Arbetsmarknadsforskning + + + Europeiskt forskningssamarbete + + + Forskning om offentlig sektor + + + Forskningspolitik + + + Militär underrättelse- och säkerhetstjänst + + + Övrig samhällsvetenskap + + + SAMHÄLLSVETENSKAP + + + + + + + Algebra och geometri + + + Analys + + + Matematisk logik + + + Diskret matematik + + + Algebra, geometri och analys + + + + + Numerisk analys + + + Matematisk statistik + + + Optimeringslära, systemteori + + + Teoretisk datalogi + + + Tillämpad matematik + + + Övrig matematik + + + MATEMATIK + + + + + + + + + Astropartikelfysik + + + Jonfysik + + + Elementarpartikelfysik + + + + + Tungjonsfysik + + + Mellanenergifysik + + + Lågenergifysik + + + Kärnfysik + + + + + Atomfysik + + + Molekylfysik + + + Kemisk fysik + + + Atom- och molekylfysik + + + + + Magnetism + + + Ytor och mellanytor + + + Halvledarfysik + + + Elektronstruktur + + + Supraledning + + + Defekter och diffusion + + + Struktur- och vibrationsfysik + + + Kritiska fenomen (fasövergångar) + + + Vätskefysik + + + Lågtemperaturfysik + + + Makromolekylfysik + + + Mesoskopisk fysik + + + Biologisk fysik + + + Kondenserade materiens fysik + + + + + Astronomi + + + Astropartikelfysik + + + Högenergiastrofysik + + + Solfysik + + + Planetsystemet + + + Galaktisk astronomi + + + Extragalaktisk astronomi + + + Stjärnors bildning och utveckling + + + Kosmologi + + + Astronomi och astrofysik + + + + + Rymdfysik + + + Plasmafysik + + + Fusion + + + Geokosmofysik och plasmafysik + + + + + Optik + + + Geofysik + + + Matematisk fysik + + + Beräkningsfysik + + + Relativitetsteori, gravitation + + + Statistisk fysik + + + Icke-linjär dynamik, kaos + + + Övrig fysik + + + Fysik + + + + + + + Kvantkemi + + + Statistisk mekanik + + + Bioinformatik + + + Teoretisk kemi + + + + + Biofysikalisk kemi + + + Kinetik + + + Spektroskopi + + + Yt- och kolloidkemi + + + Kemisk fysik + + + Fysikalisk kemi + + + + + Separationsmetoder + + + Elektrokemi + + + Spektroskopi + + + Analytisk kemi + + + Molekylär biofysik + + + + + Koordinationskemi + + + Lösningskemi + + + Fasta tillståndets kemi + + + Bio-oorganisk kemi + + + Oorganisk kemi + + + + + Organisk syntes + + + Fysikalisk organisk kemi + + + Bioorganisk kemi + + + Polymerkemi + + + Läkemedelskemi + + + Organisk kemi + + + + + Molekylärbiologi + + + Toxikologi + + + Strukturbiologi + + + Funktionsgenomik + + + Biokemi + + + + + Persistenta organiska föreningar + + + Tungmetaller och övriga metaller + + + Miljötoxikologi + + + Miljökemi + + + Övrig kemi + + + Kemi + + + + + + + Terrestisk ekologi + + + Limnisk ekologi + + + Marin ekologi + + + Etologi och beteendeekologi + + + Terrestisk, limnisk och marin ekologi + + + + + Mikrobiologi + + + Morfologi + + + Systematik och fylogeni + + + Växtfysiologi + + + Zoofysiologi + + + Utvecklingsbiologi + + + Organismbiologi + + + + + Cellbiologi + + + Molekylärbiologi + + + Immunologi + + + Toxikologi + + + Neurobiologi + + + Genetik + + + Cell- och molekylärbiologi + + + + + Bioinformatik + + + Funktionsgenomik + + + Övrig biologi + + + Biologi + + + + + + + Berggrundsgeologi och petrologi + + + Mineralvetenskap + + + Fasta jordens fysik + + + Endogen geovetenskap + + + + + Historisk geologi och paleontologi + + + Kvartärgeologi + + + Naturgeografi + + + Exogen geokemi + + + Sedimentologi + + + Exogen geovetenskap + + + + + Meteorologi + + + Hydrologi + + + Oceanografi + + + Klimatologi + + + Atmosfärs- och hydrosfärsvetenskap + + + Övrig geovetenskap + + + Geovetenskap + + + NATURVETENSKAP + + + + + + + + + Datalogi + + + Programvaruteknik + + + Kognitionsvetenskap + + + Datavetenskap + + + Reglerteknik + + + + + Telekommunikationsteori + + + Teletransmissionsteori + + + Teletrafiksystem + + + Datatransmission + + + Telekommunikation + + + Signalbehandling + + + Bildanalys + + + Datorteknik + + + Systemteknik + + + Övrig informationsteknik + + + Informationsteknik + + + + + Optisk fysik + + + Akustik + + + Materialfysik med ytfysik + + + Plasmafysik med fusion + + + Biofysik + + + Övrig teknisk fysik + + + Teknisk fysik + + + + + Elektroteknik + + + Elektronik + + + Elektrofysik + + + Fotonik + + + Elektronisk mät- och apparatteknik + + + Elkraftteknik + + + Övrig elektroteknik, elektronik och fotonik + + + Elektroteknik, elektronik och fotonik + + + + + + + Processkemi + + + Katalys + + + Molekylära transportprocesser i kemisk processteknik + + + Kemisk energiteknik + + + Cellulosa- och pappersteknik + + + Materialkemi + + + Elektrokemi + + + Yt- och kolloidkemi + + + Kärnkemi + + + Kemisk apparatteknik + + + Kemisk produktionsteknik + + + Kemisk process- och produktionsteknik + + + + + Metallurgisk processteknik + + + Metallurgisk produktionsteknik + + + Metallurgisk process- och produktionsteknik + + + Livsmedelsteknik + + + Övrig kemiteknik + + + Kemiteknik + + + + + Genteknik inkl. funktionsgenomik + + + Strukturbiokemi + + + Biokemisk och bioteknisk processteknik + + + Enzymteknik + + + Immunteknik + + + Bioteknisk separation + + + Bioanalytisk teknik + + + Bioorganisk syntes + + + Växtbioteknik + + + Bioinformatik + + + Övrig bioteknik + + + Bioteknik + + + + + Fastkroppsmekanik + + + Strömningsmekanik + + + Konstruktionsteknik + + + Mekanisk tillverkningsteknik + + + + + Mekanisk energiteknik + + + Termisk energiteknik + + + Mekanisk och termisk energiteknik + + + Farkostteknik + + + Övrig teknisk mekanik + + + Teknisk mekanik + + + + + Funktionella material + + + Konstruktionsmaterial + + + Ytbehandlingsteknik + + + Övrig bearbetning/sammanfogning + + + Övrig teknisk materialvetenskap + + + Teknisk materialvetenskap + + + + + + + Geoteknik + + + Gruvteknik + + + Geoteknik och gruvteknik + + + Byggnadsteknik + + + Byggproduktionsteknik + + + Vattenteknik + + + Lantmäteri + + + + + Arkitektur + + + Bebyggelsevård + + + Arkitektur och bebyggelsevård + + + Övrig samhällsbyggnadsteknik och arkitektur + + + Samhällsbyggnadsteknik och arkitektur + + + + + + + Produktionsteknik + + + Arbetsvetenskap och ergonomi + + + Produktion och arbetsvetenskap + + + Industriell organisation, administration och ekonomi + + + Fysisk planläggning + + + Övrig industriell teknik och ekonomi + + + Industriell teknik och ekonomi + + + + + Medicinsk teknik + + + Miljöteknik + + + Rymdteknik + + + Övriga teknikvetenskaper + + + TEKNIKVETENSKAP + + + + + + + Markfysik + + + Markkemi + + + Markbiologi + + + Jordmånslära + + + Markvetenskap + + + + + Växtförädling + + + Trädgårdsväxtodling + + + Jordbruksväxtodling + + + Skogsskötsel + + + Växt- och skogsskydd + + + Växtproduktion + + + + + Husdjursförädling + + + Husdjurens utfodring och vård + + + Vattenbruk + + + Fiske + + + Animalieproduktion + + + + + Livsmedelsvetenskap + + + Träfiber- och virkeslära + + + Fytokemi inklusive alger och industribioråvaror + + + Produktforskning + + + + + Landskapsarkitektur + + + Vegetationsbyggnad + + + Natur- och landskapsvård + + + Översiktlig planering + + + Landskapsplanering + + + + + Jordbruksteknik + + + Jordbrukets byggnadsteknik + + + Skogsteknik + + + Fjärranalys + + + Areell teknik + + + + + Jordbruksekonomi + + + Skogsekonomi + + + Skogsuppskattning och skogsindelning + + + Informationslära + + + Areell ekonomi + + + SKOGS- och JORDBRUKSVETENSKAP samt LANDSKAPSPLANERING + + + + + + + + + Anestesiologi + + + Intensivvård + + + Katastrofmedicin + + + Traumatologi + + + Anestesiologi och intensivvård + + + + + Endokrin kirurgi + + + Handkirurgi + + + Kirurgi + + + Kärlkirurgi + + + Neurokirurgi + + + Ortopedi + + + Otoneurologi + + + Pediatrisk kirurgi + + + Plastikkirurgi + + + Thoraxkirurgi + + + Transplantationskirurgi + + + Urologi och andrologi + + + Kirurgisk forskning + + + + + Obstetrik och gynekologi + + + Reproduktiv hälsa + + + Reproduktiv och perinatal omvårdnad + + + Obstetrik och kvinnosjukdomar + + + Onkologi + + + + + Audiologi + + + Logopedi och foniatrik + + + Otorhinolaryngologi + + + Kirurgi + + + + + + + Neurovetenskap + + + Neurobiologi + + + Medicinsk cellbiologi + + + Cellbiologi + + + + + Anatomi + + + Biomaterial + + + Histologi + + + Tumörbiologi + + + Morfologi + + + + + Rättsmedicin + + + Molekylär medicin + + + Patologi + + + Morfologi, cellbiologi, patologi + + + + + Dermatologi och venerologi + + + + + Medicinsk genetik + + + Rättsgenetik + + + Molekylärbiologi + + + Molekykär ekogenetik + + + Klinisk genetik + + + + + Barnkardiologi + + + Diabetologi + + + Endokrinologi + + + Gastroenterologi + + + Geriatrik och medicinsk gerontologi + + + Hematologi + + + Kardiologi + + + Kardiovaskulär medicin + + + Lungsjukdomar + + + Molekylär medicin (genetik och patologi) + + + Neurologi + + + Njursjukdomar + + + Palliativ medicin + + + Pediatrisk medicin + + + Prenatal- och perinatalforskning + + + Reumatologi + + + Transfusionsmedicin + + + Invärtesmedicin + + + Dermatologi och venerologi, klinisk genetik, invärtesmedicin + + + + + + + Farmakologi + + + Klinisk farmakologi + + + Toxikologi + + + Farmakologisk forskning + + + + + Experimentell hjärnforskning + + + Försöksdjursvetenskap + + + Klinisk fysiologi + + + Klinisk neurofysiologi + + + Medicinsk informatik + + + Medicinsk teknik + + + Molekylär neurobiologi + + + Neurobiologi + + + Neurofysiologi + + + Näringslära + + + Fysiologi + + + + + Oftalmiatrik + + + Optometri + + + Oftalmologi + + + + + Radiologi + + + Diagnostisk radiologi + + + Radiofysik + + + Strålningsbiologi + + + Radiologisk forskning + + + Fysiologi och farmakologi + + + + + + + Allmänmedicin + + + Arbetsfysiologi + + + Epidemiologi + + + Folkhälsovetenskap + + + Miljömedicin + + + Samhällsmedicin + + + Yrkesmedicin + + + Folkhälsomedicinska forskningsområden + + + Socialmedicin + + + + + + + Allergologi + + + Immungenetik + + + Immunbiologi + + + Klinisk immunologi + + + Tumörimmunologi + + + Immunologi + + + + + Bakteriologi + + + Klinisk bakteriologi + + + Klinisk virologi + + + Medicinsk mikrobiologi + + + Virologi + + + Mikrobiologi + + + Infektionssjukdomar + + + Mikrobiologi, immunologi, infektionssjukdomar + + + + + Biokemi + + + Klinisk kemi + + + Neurokemi + + + Rättskemi + + + Kemi + + + + + Barn- och ungdomspsykiatri + + + Beroendelära + + + Psykiatri + + + MEDICIN + + + + + Biokemi + + + Biomaterial + + + Cariologi + + + Cell- och molekylärbiologi + + + Endodonti + + + Farmakologisk forskning + + + Fysiologi + + + Gerodontologi + + + Kirurgisk forskning + + + Morfologi + + + Odontologisk beteendevetenskap + + + Oral mikrobiologi + + + Oral patologi och rättsodontologi + + + Oral protetik + + + Ortodonti + + + Parodontologi + + + Pedodonti + + + Radiologisk forskning + + + Övrig odontologi + + + ODONTOLOGI + + + + + Biofarmaci + + + Biologisk beroendeforskning + + + Farmaceutisk biokemi + + + Farmaceutisk farmakologi + + + Farmaceutisk kemi + + + Farmaceutisk mikrobiologi + + + Toxikologi + + + Farmakognosi + + + Galenisk farmaci + + + Samhällsfarmaci + + + Övrig farmaci + + + FARMACI + + + + + Biokemi och klinisk kemi + + + Cellbiologi och genomforskning + + + Husdjurens etologi + + + Farmakologisk forskning + + + Fysiologi och näringslära + + + Husdjurshygien + + + Kirurgi + + + Livsmedelshygien + + + Medicin + + + Mikrobiologi och immunologi + + + Morfologi + + + Obstetrik och gynekologi + + + Patologi + + + Radiologi + + + Veterinärmedicinsk epidemiologi + + + Övrig veterinärmedicin + + + VETERINÄRMEDICIN + + + + + Barn + + + Hushålls- och kostvetenskap + + + Hälso- och sjukvård i samhället + + + Kommunikation mellan människor + + + Teknik och social förändring + + + Vatten i natur och samhälle + + + + + Arbetsterapi + + + Medicinsk laboratorievetenskap + + + Omvårdnad + + + Sjukgymnastik/fysioterapi + + + Social omsorg/socialpedagogik + + + Vetenskapsteori med inriktning mot vård- och omsorgsområdet + + + Vårdvetenskap + + + Etnicitet + + + Genus + + + Kulturarv och kulturproduktion + + + Idrott + + + Äldre och åldrande + + + TVÄRVETENSKAPLIGA FORSKNINGSOMRÅDEN + + + Ämneskategorier för vetenskapliga publikationer + \ No newline at end of file diff --git a/dspace/config/dspace.cfg b/dspace/config/dspace.cfg index 23e8ec68a2..ff933d1a7c 100644 --- a/dspace/config/dspace.cfg +++ b/dspace/config/dspace.cfg @@ -507,6 +507,12 @@ webui.suggest.sender = A DSpace user webui.suggest.recipient = colleague +#### Controlled Vocabulary Settings ##### +# Enable or disable the controlled vocabulary add-on +# Warning: this feature is not compatible with WAI (it requires javascript to function) +# +# webui.controlledvocabulary.enable = true + #### Checksum Checker Settings #### # Default dispatcher in case none specified plugin.single.org.dspace.checker.BitstreamDispatcher=org.dspace.checker.SimpleDispatcher diff --git a/dspace/config/input-forms.xml b/dspace/config/input-forms.xml index 8ce42299d1..dc4288b41e 100644 --- a/dspace/config/input-forms.xml +++ b/dspace/config/input-forms.xml @@ -164,6 +164,7 @@ it, please enter the types and the actual numbers or codes below. twobox Enter appropriate subject keywords or phrases below. + srsc diff --git a/dspace/config/language-packs/Messages.properties b/dspace/config/language-packs/Messages.properties index 49f1e2da51..0ab5956cd7 100644 --- a/dspace/config/language-packs/Messages.properties +++ b/dspace/config/language-packs/Messages.properties @@ -125,6 +125,25 @@ jsp.components.ldap-form.username-or-email = Username
or Email address: jsp.components.ldap-form.password = Password: jsp.components.ldap-form.login.button = Log In +jsp.controlledvocabulary.controlledvocabulary.title = Subject Categories +jsp.controlledvocabulary.controlledvocabulary.trimbutton = Apply +jsp.controlledvocabulary.controlledvocabulary.clearbutton = Clear +jsp.controlledvocabulary.controlledvocabulary.closebutton = Close +jsp.controlledvocabulary.controlledvocabulary.trimmessage = Find a subject in the controlled vocabulary: +jsp.controlledvocabulary.controlledvocabularytag.noresults = No results +jsp.controlledvocabulary.controlledvocabulary.filter = Filter: +jsp.controlledvocabulary.controlledvocabulary.help-link = (Help on Subject Categories...) +jsp.controlledvocabulary.search.title = Subject Search +jsp.controlledvocabulary.search.heading = Subject Search +jsp.controlledvocabulary.search.on-page-help.para1 = Check the boxes next to the categories that you wish to search under, then hit "Search...". Categories can be expanded to refine the search terms, and as many categories can be selected as required. +jsp.controlledvocabulary.search.on-page-help.para2 = Filtering the list of categories will remove from the list below any categories that do not match the filter term. Expanding each category will show you which terms did match the filter. +jsp.controlledvocabulary.search.trimmessage = Find a subject in the controlled vocabulary: +jsp.controlledvocabulary.search.trimbutton = Apply +jsp.controlledvocabulary.search.clearbutton = Clear +jsp.controlledvocabulary.search.filter = Filter: +jsp.controlledvocabulary.search.searchbutton = Search... +jsp.controlledvocabulary.results.newsearch = Search other subject... + jsp.display-item.copyright = All items in DSpace are protected by copyright, with all rights reserved. jsp.display-item.identifier =Please use this identifier to cite or link to this item: jsp.display-item.license =Creative Commons License @@ -530,6 +549,7 @@ jsp.layout.navbar-default.subjects = Subjects jsp.layout.navbar-default.titles = Titles jsp.layout.navbar-default.users = My DSpace jsp.layout.navbar-default.users-authorized = authorized users +jsp.layout.navbar-default.subjectsearch = Subject Search jsp.login.chooser.heading = Choose a Login Method jsp.login.chooser.chooseyour = Choose one of these ways to login: @@ -846,6 +866,7 @@ jsp.submit.edit-metadata.day = Day: jsp.submit.edit-metadata.year = Year: jsp.submit.edit-metadata.seriesname = Series Name jsp.submit.edit-metadata.paperno = Report or Paper No. +jsp.submit.edit-metadata.controlledvocabulary = Subject Categories jsp.submit.get-file-format.choose.button =Choose automatically-recognized type jsp.submit.get-file-format.format =File Format: diff --git a/dspace/docs/configure.html b/dspace/docs/configure.html index 4615130f90..9831a2fe43 100644 --- a/dspace/docs/configure.html +++ b/dspace/docs/configure.html @@ -742,8 +742,100 @@ dstat-report-monthly

The wording and layout of the email message is governed by the template file [dspace]/config/emails/suggest. You may edit this file to alter the language, layout, type, or amount of information contained in the email, but note that the values passed to the template are limited to those enumerated at the top of the template file and represented in the body of the message with 'placeholders' {0}, {1}, etc. A general description of DSpace is included as - a footer to the email, which may be replaced with site-specific content. + a footer to the email, which may be replaced with site-specific content.

+ + +

Configuring Controlled Vocabularies

+

+ DSpace now supports controlled vocabularies to confine the set of keywords that users can use + while describing items.

+

+ The need for a limited set of keywords is important since it eliminates the + ambiguity of a free description system, consequently simplifying the task of finding specific + items of information. +

+

+ The controlled vocabulary add-on allows the user to choose from a defined set of keywords organised + in an tree (taxonomy) and then use these keywords to describe items while they are being submitted. +

+

+ We have also developed a small search engine that displays the classification tree (or taxonomy) + allowing the user to select the branches that best describe the information that he/she seeks. +

+

+ The taxonomies are described in XML following this (very simple) structure: +

+ + + +<node id="acmccs98" label="ACMCCS98">
+  <isComposedBy>
+   <node id="A." label="General Literature">
+    <isComposedBy>
+     <node id="A.0" label="GENERAL"/>
+     <node id="A.1" label="INTRODUCTORY AND SURVEY"/>
+     ...
+    </isComposedBy>
+   </node>
+   ...
+  </isComposedBy>
+</node>
+
+

+Your are free to use any application you want to create your controlled vocabularies. A simple +text editor should be enough for small projects. Bigger projects will require more complex +tools. You may use Protegé to create your taxonomies, save them as OWL and then use a +XML Stylesheet (XSLT) to transform your documents to the appropriate format. Future enhancements +to this add-on should make it compatible with standard schemas such as OWL or RDF. +

+

+In order to make DSpace compatible with WAI 2.0, the add-on is turned off by default +(the add-on relies strongly on Javascript to function). + It can be activated by setting the following property in dspace.cfg: +

+ + webui.controlledvocabulary.enable = true + +

+

+New vocabularies should be placed in [dspace]/config/controlled-vocabularies/ and must be +according to the structure described. A validation XML Schema can be downloaded here. +

+

+Vocabularies need to be associated with the correspondant DC metadata fields. +Edit the file [dspace]/config/input-forms.xml and place +a "vocabulary" tag under the "field" element that you +want to control. Set value of the "vocabulary" element to +the name of the file that contains the vocabulary, leaving out the extension +(the add-on will only load files with extension "*.xml"). +For example: +

+

+ + <field>
+     <dc-schema>dc</dc-schema>
+     <dc-element>subject</dc-element>
+     <dc-qualifier></dc-qualifier>
+     <!-- An input-type of twobox MUST be marked as repeatable -->
+     <repeatable>true</repeatable>
+     <label>Subject Keywords</label>
+     <input-type>twobox</input-type>
+     <hint> Enter appropriate subject keywords or phrases below. </hint>
+   <required></required>
+   <vocabulary>nsi</vocabulary>
+ </field>
+
+

+ +

+The following vocabularies are currently available by default: +

+

Checksum Checker

There are two main aspects of the checksum checker's operation that can be configured. Firstly the strategy and duration of the checker's duration can be @@ -848,6 +940,7 @@ bin/checker -L # Loops through the repository forever

By default, these properties should go in dspace.cfg. By passing an argument to the -p option you can pass another properties file to the checker instead, for example: -

bin/checker -lp temporaryRetentionPolicy.properties
+>>>>>>> 1.18
diff --git a/dspace/docs/controlledvocabulary.xsd b/dspace/docs/controlledvocabulary.xsd new file mode 100644 index 0000000000..30fbb7f8ad --- /dev/null +++ b/dspace/docs/controlledvocabulary.xsd @@ -0,0 +1,63 @@ + + + + + + + + Element that describes a concept + + + + + + Contains the children of this node. + + + + + + + + + + A list of related terms + + + + + + Link to an existing node + + + + + + + + + + + A note related to this term + + + + + + + + + + + + + + + diff --git a/dspace/etc/dspace-web.xml b/dspace/etc/dspace-web.xml index cb749e3cf0..b4339bfc8c 100644 --- a/dspace/etc/dspace-web.xml +++ b/dspace/etc/dspace-web.xml @@ -382,6 +382,18 @@ workspace org.dspace.app.webui.servlet.WorkspaceServlet + + + + controlledvocabulary + org.dspace.app.webui.servlet.ControlledVocabularyServlet + + + + subject-search + org.dspace.app.webui.servlet.ControlledVocabularySearchServlet + + @@ -614,6 +626,17 @@ workspace /workspace + + + + controlledvocabulary + /controlledvocabulary + + + + subject-search + /subject-search + diff --git a/dspace/jsp/WEB-INF/dspace-tags.tld b/dspace/jsp/WEB-INF/dspace-tags.tld index 387f6806d2..b0adc97e08 100644 --- a/dspace/jsp/WEB-INF/dspace-tags.tld +++ b/dspace/jsp/WEB-INF/dspace-tags.tld @@ -360,5 +360,47 @@ true + + + + + + controlledvocabulary + org.dspace.app.webui.jsptag.ControlledVocabularyTag + empty + + Lays out a html tree with a set of controlled vocabularies. + This tag receives 3 possible parameters: + - filter + A filter specification to prune branches of the loaded vocabularies + - allowMultipleSelection + Specifies if we want to be able the select multiple terms + from the taxonomy. This will diplay checkboxes close to the + vocabulary terms. + - vocabulary + The name of the vocabulary to be displayed. If no vocabulary + is provided, all existing taxonomies will be rendered and + displayed. + + + + filter + false + true + + + + allowMultipleSelection + no + true + + + + vocabulary + no + true + + + diff --git a/dspace/jsp/controlledvocabulary/controlledvocabulary.jsp b/dspace/jsp/controlledvocabulary/controlledvocabulary.jsp new file mode 100644 index 0000000000..9c259bdada --- /dev/null +++ b/dspace/jsp/controlledvocabulary/controlledvocabulary.jsp @@ -0,0 +1,177 @@ +<%-- + - controlledvocabulary.jsp + - + - Version: $Revision$ + - + - Date: $Date$ + - + - Copyright (c) 2002, Hewlett-Packard Company and Massachusetts + - Institute of Technology. All rights reserved. + - + - Redistribution and use in source and binary forms, with or without + - modification, are permitted provided that the following conditions are + - met: + - + - - Redistributions of source code must retain the above copyright + - notice, this list of conditions and the following disclaimer. + - + - - Redistributions in binary form must reproduce the above copyright + - notice, this list of conditions and the following disclaimer in the + - documentation and/or other materials provided with the distribution. + - + - - Neither the name of the Hewlett-Packard Company nor the name of the + - Massachusetts Institute of Technology nor the names of their + - contributors may be used to endorse or promote products derived from + - this software without specific prior written permission. + - + - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + - HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + - BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + - OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + - TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + - USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + - DAMAGE. + --%> + + +<%-- + -- This jsp is reponsible for displaying controlled vocabularies in a + -- popup window during the description phases of submitted items. + -- This jsp holds the content of that popup window. + --%> + + +<%@ page language="java" contentType="text/html;charset=iso-8859-1" %> +<%@ page import="javax.servlet.jsp.jstl.fmt.LocaleSupport" %> + +<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> +<%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %> + + + + + +<fmt:message key="jsp.controlledvocabulary.controlledvocabulary.title"/> + + + + + + + + + + + + + + + + + + + + + +<% + String filter = (String)session.getAttribute("controlledvocabulary.filter"); + filter = filter==null?"":filter; + String ID = (String)session.getAttribute("controlledvocabulary.ID"); + + if(request.getParameter("vocabulary")!=null) { + session.setAttribute("controlledvocabulary.vocabulary", request.getParameter("vocabulary")); + } + String vocabulary = (String)session.getAttribute("controlledvocabulary.vocabulary"); +%> + +
+ +
+ + + + + + + + + + + + +
+ + +
+ + + + + + +
+
+
+ + + + + +
+
+ + +
+ +
+ +

+ + + +
+
+ " > +
+ + diff --git a/dspace/jsp/controlledvocabulary/controlledvocabularyTag.jsp b/dspace/jsp/controlledvocabulary/controlledvocabularyTag.jsp new file mode 100644 index 0000000000..aca009d71d --- /dev/null +++ b/dspace/jsp/controlledvocabulary/controlledvocabularyTag.jsp @@ -0,0 +1,62 @@ +<%-- + - controlledvocabularyTag.jsp + - + - Version: $Revision$ + - + - Date: $Date$ + - + - Copyright (c) 2002, Hewlett-Packard Company and Massachusetts + - Institute of Technology. All rights reserved. + - + - Redistribution and use in source and binary forms, with or without + - modification, are permitted provided that the following conditions are + - met: + - + - - Redistributions of source code must retain the above copyright + - notice, this list of conditions and the following disclaimer. + - + - - Redistributions in binary form must reproduce the above copyright + - notice, this list of conditions and the following disclaimer in the + - documentation and/or other materials provided with the distribution. + - + - - Neither the name of the Hewlett-Packard Company nor the name of the + - Massachusetts Institute of Technology nor the names of their + - contributors may be used to endorse or promote products derived from + - this software without specific prior written permission. + - + - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + - HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + - BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + - OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + - TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + - USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + - DAMAGE. + --%> + + + +<%-- + -- This custom tag is used to display an HTML version of a + -- controlled vocabulary. + -- This jsp is called by ControlledVocabularyTag.java + --%> + +<%@ page language="java" errorPage="/internal-error" contentType="text/html;charset=UTF-8" %> +<%@ page import="javax.servlet.jsp.jstl.fmt.LocaleSupport" %> + +<% + String vocabulariesHTML = (String)session.getAttribute("controlledvocabulary.vocabularyHTML"); + vocabulariesHTML = (vocabulariesHTML == null || vocabulariesHTML.length() == 0)? + LocaleSupport.getLocalizedMessage(pageContext,"jsp.controlledvocabulary.controlledvocabularytag.noresults"): + vocabulariesHTML; +%> + +<%= vocabulariesHTML %> + + + diff --git a/dspace/jsp/controlledvocabulary/results.jsp b/dspace/jsp/controlledvocabulary/results.jsp new file mode 100644 index 0000000000..097d72f722 --- /dev/null +++ b/dspace/jsp/controlledvocabulary/results.jsp @@ -0,0 +1,230 @@ +<%-- + - results.jsp + - + - Version: $Revision$ + - + - Date: $Date$ + - + - Copyright (c) 2002, Hewlett-Packard Company and Massachusetts + - Institute of Technology. All rights reserved. + - + - Redistribution and use in source and binary forms, with or without + - modification, are permitted provided that the following conditions are + - met: + - + - - Redistributions of source code must retain the above copyright + - notice, this list of conditions and the following disclaimer. + - + - - Redistributions in binary form must reproduce the above copyright + - notice, this list of conditions and the following disclaimer in the + - documentation and/or other materials provided with the distribution. + - + - - Neither the name of the Hewlett-Packard Company nor the name of the + - Massachusetts Institute of Technology nor the names of their + - contributors may be used to endorse or promote products derived from + - this software without specific prior written permission. + - + - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + - HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + - BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + - OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + - TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + - USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + - DAMAGE. + --%> + + +<%-- + - Display the results of a subject search + - + - Attributes to pass in: + - + - community - pass in if the scope of the search was a community + - or a collection in this community + - collection - pass in if the scope of the search was a collection + - community.array - if the scope of the search was "all of DSpace", pass + - in all the communities in DSpace as an array to + - display in a drop-down box + - collection.array - if the scope of a search was a community, pass in an + - array of the collections in the community to put in + - the drop-down box + - items - the results. An array of Items, most relevant first + - communities - results, Community[] + - collections - results, Collection[] + - + - query - The original query + --%> + +<%@ page contentType="text/html;charset=UTF-8" %> + +<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" + prefix="fmt" %> + +<%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %> + +<%@ page import="java.net.URLEncoder" %> +<%@ page import="org.dspace.content.Community" %> +<%@ page import="org.dspace.content.Collection" %> +<%@ page import="org.dspace.content.Item" %> +<%@ page import="org.dspace.search.QueryResults" %> + +<% + // Get the attributes + Community community = (Community ) request.getAttribute("community" ); + Collection collection = (Collection ) request.getAttribute("collection"); + Community[] communityArray = (Community[] ) request.getAttribute("community.array"); + Collection[] collectionArray = (Collection[]) request.getAttribute("collection.array"); + + Item [] items = (Item[] )request.getAttribute("items"); + Community [] communities = (Community[] )request.getAttribute("communities"); + Collection[] collections = (Collection[])request.getAttribute("collections"); + + String query = (String) request.getAttribute("query"); + + QueryResults qResults = (QueryResults)request.getAttribute("queryresults"); + + int pageTotal = ((Integer)request.getAttribute("pagetotal" )).intValue(); + int pageCurrent = ((Integer)request.getAttribute("pagecurrent")).intValue(); + int pageLast = ((Integer)request.getAttribute("pagelast" )).intValue(); + int pageFirst = ((Integer)request.getAttribute("pagefirst" )).intValue(); +%> + + + + <%--

Search Results

--%> + +

+ + + +<% if( qResults.getErrorMsg()!=null ) +{ + %> +

<%= qResults.getErrorMsg() %>

+<% +} +else if( qResults.getHitCount() == 0 ) +{ + %> + <%--

Search produced no results.

--%> +

+<% +} +else +{ +%> + <%--

Results - of --%> +

+ <%=qResults.getStart()+1%> + <%=qResults.getStart()+qResults.getHitHandles().size()%> + <%=qResults.getHitCount()%> +

+ +<% } %> + +<% if (communities.length > 0 ) { %> + <%--

Community Hits:

--%> +

+ +<% } %> + +<% if (collections.length > 0 ) { %> +
+ <%--

Collection hits:

--%> +

+ +<% } %> + +<% if (items.length > 0) { %> +
+ <%--

Item hits:

--%> +

+ +<% } %> + +

+ +<% + // retain scope when navigating result sets + String searchScope = ""; + if (community == null && collection == null) { + searchScope = ""; + } else if (collection == null) { + searchScope = "/handle/" + community.getHandle(); + } else { + searchScope = "/handle/" + collection.getHandle(); + } + + // create the URLs accessing the previous and next search result pages + String prevURL = request.getContextPath() + + searchScope + + "/simple-search?query=" + + URLEncoder.encode(query) + + "&start="; + + String nextURL = prevURL; + + prevURL = prevURL + + (pageCurrent-2) * qResults.getPageSize(); + + nextURL = nextURL + + (pageCurrent) * qResults.getPageSize(); + + +if (pageFirst != pageCurrent) +{ + %><% +}; + + +for( int q = pageFirst; q <= pageLast; q++ ) +{ + String myLink = "" + + q + + ""; + } +%> + +<%= myLink %> + +<% +} + +if (pageTotal > pageCurrent) +{ + %><% +} +%> + + +

+ +

+ +
+ diff --git a/dspace/jsp/controlledvocabulary/search.jsp b/dspace/jsp/controlledvocabulary/search.jsp new file mode 100644 index 0000000000..3d1be2e163 --- /dev/null +++ b/dspace/jsp/controlledvocabulary/search.jsp @@ -0,0 +1,115 @@ +<%-- + - search.jsp + - + - Version: $Revision$ + - + - Date: $Date$ + - + - Copyright (c) 2002, Hewlett-Packard Company and Massachusetts + - Institute of Technology. All rights reserved. + - + - Redistribution and use in source and binary forms, with or without + - modification, are permitted provided that the following conditions are + - met: + - + - - Redistributions of source code must retain the above copyright + - notice, this list of conditions and the following disclaimer. + - + - - Redistributions in binary form must reproduce the above copyright + - notice, this list of conditions and the following disclaimer in the + - documentation and/or other materials provided with the distribution. + - + - - Neither the name of the Hewlett-Packard Company nor the name of the + - Massachusetts Institute of Technology nor the names of their + - contributors may be used to endorse or promote products derived from + - this software without specific prior written permission. + - + - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + - HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + - BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + - OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + - TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + - USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + - DAMAGE. + --%> + +<%-- + This jsp shows a search form with a controlled vocabulary tree. + The branches of the tree can be expanded/collapsed by means of javascript. + To be WAI compatible a new version of this jsp must be developed. + The add-on may be turn off in dspace.cfg +--%> + +<%@ page contentType="text/html;charset=UTF-8" %> +<%@ page import="javax.servlet.jsp.jstl.fmt.LocaleSupport" %> +<%@ taglib uri="/WEB-INF/dspace-tags.tld" prefix="dspace" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> + +<% + String filter = (String)(session.getAttribute("conceptsearch.filter") + != null?session.getAttribute("conceptsearch.filter"):""); +%> + + + + +

+ +
+ +
+ +

+

+ + +
+ +
+ + + + + + + + +
+ + + +
+ + "> + +
+
+
+ + "/> + +
+
+ +
+ +
+ + + +
+ + "> + +
+ + +
diff --git a/dspace/jsp/controlledvocabulary/vocabulary2html.xsl b/dspace/jsp/controlledvocabulary/vocabulary2html.xsl new file mode 100644 index 0000000000..b5d9204ef7 --- /dev/null +++ b/dspace/jsp/controlledvocabulary/vocabulary2html.xsl @@ -0,0 +1,75 @@ + + + + + + + + + + + + +
    + +
+
+ + + + + + +
  • + + + + + /image/controlledvocabulary/p.gif + ec(this, ''); + + + + + /image/controlledvocabulary/f.gif + + + + + + + + + + cb_ + + + + + + + + + + + + +
      + +
    +
    +
  • +
    + + + + + + + :: + + +
    diff --git a/dspace/jsp/controlledvocabulary/vocabularyprune.xsl b/dspace/jsp/controlledvocabulary/vocabularyprune.xsl new file mode 100644 index 0000000000..d61cb3e599 --- /dev/null +++ b/dspace/jsp/controlledvocabulary/vocabularyprune.xsl @@ -0,0 +1,44 @@ + + + + + + + + + abcdefghijklmnopqrstuvwxyz + ABCDEFGHIJKLMNOPQRSTUVWXYZ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dspace/jsp/help/index.html b/dspace/jsp/help/index.html index 2d6e43fd98..6e21dcfe42 100644 --- a/dspace/jsp/help/index.html +++ b/dspace/jsp/help/index.html @@ -19,6 +19,7 @@
    Browse
    Search
    Advanced Search
    +
    Subject Category Search
    Communities
    Collections
    Sign on to DSpace
    @@ -198,6 +199,34 @@ order and allows you to see the subcommunities and collections within each commu input boxes in order. If you leave the first one blank your search will not work.


    + + + + + + +
    SUBJECT CATEGORY SEARCHtop
    + +

    A controlled vocabulary is a set of terms which form a dictionary of descriptions +of particular types of content or subject matter. These are maintained by +standards bodies in order to standardise the way that similar materials are +categorised in archives. This aids searching by increasing the likelihood that +the relevant materials will be returned by the user's search.

    + +

    Filtering the category list will remove from the list any terms which do not +match the filter. The remaining terms are any category or sub category which +contains the filter term anywhere in the heirarchy. Expanding each category +will show you which terms (or sub terms) did match the filter.

    + +

    To search the archive items by the subject category, check as many boxes next +to the categories as necessary, before clicking "Search...". The search will +return all items that either match the categories selected exactly, or which +are categorised underneath a higher level category. Clicking on the "+" next +to the category will expand the tree to show you what refinements are available +for your selected category.

    + +
    + @@ -228,6 +257,7 @@ order and allows you to see the subcommunities and collections within each commu entry page displaying information, news and links reflecting the interests of that community, as well as a descriptive list of collections within the community.


    +
    COMMUNITIES
    @@ -495,6 +525,39 @@ order and allows you to see the subcommunities and collections within each commu

    Click on the "next" button to proceed, or "cancel/save" button to stop and save or cancel your submission.

    +
    + +
    COLLECTIONS
    + + + + + +
    SUBMIT: Controlled Vocabularytop of submittop
    + +

    A controlled vocabulary is a set of terms which form a dictionary of descriptions +of particular types of content or subject matter. These are maintained by +standards bodies in order to standardise the way that similar materials are +categorised in archives.

    + +

    Accurately categorising material using a controlled vocabulary increases the +likelihood that relevant results will be returned to users when searching +individual or multiple archives.

    + +

    To enter a controlled vocabulary term in the form, select "Subject Categories" +from underneath the input field. This will open a window containing the +available vocabularies. You may filter the vocabulary lists as described above +in order to find the terms most relevant to your submission. Once you have found +the term that you wish to enter, simply click on it, and it will be +automatically entered into the submission form and the popup window will close. +You may add as many subject category terms as you like into the form. Use +"Add More" on the right to generate more input boxes.

    + +

    Filtering the category list will remove from the list any terms which do not +match the filter. The remaining terms are any category or sub category which +contains the filter term anywhere in the heirarchy. Expanding each category +will show you which terms (or sub terms) did match the filter.

    +
    @@ -557,7 +620,9 @@ order and allows you to see the subcommunities and collections within each commu or "computer program" or "data set". Enter file descriptions for each item, and click on the "next" button to proceed.


    - + +
    +
    diff --git a/dspace/jsp/image/controlledvocabulary/f.gif b/dspace/jsp/image/controlledvocabulary/f.gif new file mode 100644 index 0000000000000000000000000000000000000000..550a47f8ee260b0386b40e5c73d071b8cbf1da05 GIT binary patch literal 162 zcmZ?wbhEHblwlBH*vtR|4Pe{=rW$~}hK2(N4m310{0EBvXZR1MfHaT=1d2ad7#SEi z8FYY>3?MTYSo{r6dam9ZvFL2&zZ1%R=NoGxJi3k-FPgfG$%G+TYq9a;#QU>EPqOpa vm04Zm*AN!!wp_AlM#j2%K7y0NqwcM7*5|n+yjY-pOI7Z_EB6Y#Ss1JVvrjza literal 0 HcmV?d00001 diff --git a/dspace/jsp/image/controlledvocabulary/m.gif b/dspace/jsp/image/controlledvocabulary/m.gif new file mode 100644 index 0000000000000000000000000000000000000000..81054a1e2b887b42c1b5e6d8496f49989b8579fb GIT binary patch literal 104 zcmZ?wbhEHbIKUo+-Ds(^u$P5M+(SQ@4 Z&3hdmtu7ZksL(Y(yy~voS|=6;YXH!g7h(Va literal 0 HcmV?d00001 diff --git a/dspace/jsp/image/controlledvocabulary/p.gif b/dspace/jsp/image/controlledvocabulary/p.gif new file mode 100644 index 0000000000000000000000000000000000000000..980edc6c2537283dd43ae013442cb7628d51d07d GIT binary patch literal 106 zcmZ?wbhEHbIKUo+-Ds(^u$P5M+@qiPa b&3hg16>fbx&8#O`E$8mfr4e3%f(+IG4dNLN literal 0 HcmV?d00001 diff --git a/dspace/jsp/layout/navbar-default.jsp b/dspace/jsp/layout/navbar-default.jsp index 0e55cee215..40982abe6d 100644 --- a/dspace/jsp/layout/navbar-default.jsp +++ b/dspace/jsp/layout/navbar-default.jsp @@ -40,13 +40,13 @@ <%-- - Default navigation bar - --%> +--%> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> <%@ page contentType="text/html;charset=UTF-8" %> -<%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %> +<%@ taglib uri="/WEB-INF/dspace-tags.tld" prefix="dspace" %> <%@ page import="java.util.ArrayList" %> <%@ page import="java.util.List" %> @@ -54,6 +54,8 @@ <%@ page import="org.dspace.content.Collection" %> <%@ page import="org.dspace.content.Community" %> <%@ page import="org.dspace.eperson.EPerson" %> +<%@ page import="org.dspace.core.ConfigurationManager" %> + <% // Is anyone logged in? @@ -106,6 +108,14 @@ <%-- --%> " />
    +<% + if (ConfigurationManager.getBooleanProperty("webui.controlledvocabulary.enable")) + { +%> +
    +<% + } +%>
    SUBMIT: File Formats
    diff --git a/dspace/jsp/styles.css.jsp b/dspace/jsp/styles.css.jsp index 97f21412c3..e6d6c15e40 100644 --- a/dspace/jsp/styles.css.jsp +++ b/dspace/jsp/styles.css.jsp @@ -329,6 +329,7 @@ UL { font-family: "verdana", "Arial", "Helvetica", sans-serif; font-family: "verdana", "Arial", "Helvetica", sans-serif; font-size: 8pt; text-align: center } + .submitFormWarn { margin-left: 10px; margin-right: 10px; @@ -588,3 +589,33 @@ UL { font-family: "verdana", "Arial", "Helvetica", sans-serif; .help td.leftAlign{font-size:10pt;} .help td.rightAlign{text-align:right; font-size:10pt;} + + +<%-- The following rules are used by the controlled-vocabulary add-on --%> + +ul.controlledvocabulary { + list-style-type:none; } + + +.controlledvocabulary ul li ul { + list-style-type:none; + display:none; } + +input.controlledvocabulary { + border:0px; } + +img.controlledvocabulary { + margin-right:8px ! important; + margin-left:11px ! important; + cursor:hand; } + +.submitFormHelpControlledVocabularies { + margin-left: 10px; + margin-right: 10px; + font-family: "verdana", "Arial", "Helvetica", sans-serif; + font-size: 8pt; + text-align: left; } + +.controlledVocabularyLink { + font-family: "verdana", "Arial", "Helvetica", sans-serif; + font-size: 8pt; } diff --git a/dspace/jsp/utils.js b/dspace/jsp/utils.js index b0d396af61..2d8fdc8290 100644 --- a/dspace/jsp/utils.js +++ b/dspace/jsp/utils.js @@ -169,3 +169,118 @@ function removeSelected(sourceList) } } } + + + + + + +//****************************************************** +// Functions used by controlled vocabulary add-on +// There might be overlaping with existing functions +//****************************************************** + +function expandCollapse(node, contextPath) { + node = node.parentNode; + var childNode = (node.getElementsByTagName("ul"))[0]; + + if(!childNode) return false; + + var image = node.getElementsByTagName("img")[0]; + + if(childNode.style.display != "block") { + childNode.style.display = "block"; + image.src = contextPath + "/image/controlledvocabulary/m.gif"; + } else { + childNode.style.display = "none"; + image.src = contextPath + "/image/controlledvocabulary/p.gif"; + } + + return false; +} + + +function getAnchorText(ahref) { + if(isMicrosoft()) return ahref.childNodes.item(0).nodeValue; + else return ahref.text; +} + +function getTextValue(node) { + if(node.nodeName == "A") { + return getAnchorText(node); + } else { + return ""; + } + +} + + +function getParentTextNode(node) { + var parentNode = node.parentNode.parentNode.parentNode; + var children = parentNode.childNodes; + var textNode; + for(var i=0; i< children.length; i++) { + var child = children.item(i); + if(child.className == "value") { + return child; + } + } + return null; +} + +function ec(node, contextPath) { + expandCollapse(node, contextPath); + return false; +} + + +function i(node) { + return sendBackToParentWindow(node); +} + + +function getChildrenByTagName(rootNode, tagName) { + var children = rootNode.childNodes; + var result = new Array(0); + if(children == null) return result; + for(var i=0; i 0; + } + + /** + * Converts a XML Vocabulary to a HTML tree + * + * @param vocabularies + * A hashtable with all the XML taxonomies/vocabularies loaded as + * values + * @param xslt + * the filename of the stylesheet to apply the XML taxonomies + * @param allowMultipleSelection + * include checkboxes next to the taxonomy terms + * @param contextPath + * The context path + * @return the HTML that represents the vocabularies + */ + private String renderVocabulariesAsHTML(Hashtable vocabularies, + String xslt, boolean allowMultipleSelection, String contextPath) + { + String result = ""; + Iterator iter = vocabularies.values().iterator(); + while (iter.hasNext()) + { + Document controlledVocabularyXML = (Document) iter.next(); + result += renderVocabularyAsHTML(controlledVocabularyXML, xslt, + allowMultipleSelection, contextPath); + } + return result; + } + + /** + * Applies a filter to the vocabularies, i.e. it prunes the trees by + * removing all the branches that do not contain the words in the filter. + * + * @param vocabularies + * A hashtable with all the XML taxonomies/vocabularies loaded as + * values + * @param vocabularyPrunningXSLT + * the filename of the stylesheet that trimms the taxonomies + * @return An hashtable with all the filtered vocabularies + */ + private Hashtable filterVocabularies(Hashtable vocabularies, + String vocabularyPrunningXSLT) + { + Hashtable prunnedVocabularies = new Hashtable(); + Enumeration enumeration = vocabularies.keys(); + while (enumeration.hasMoreElements()) + { + String controlledVocabularyKey = (String) enumeration.nextElement(); + Document controlledVocabulary = (Document) vocabularies + .get(controlledVocabularyKey); + prunnedVocabularies.put(controlledVocabularyKey, filterVocabulary( + controlledVocabulary, vocabularyPrunningXSLT, getFilter())); + } + return prunnedVocabularies; + } + + /** + * Renders a taxonomy as HTML by applying a stylesheet. + * + * @param vocabulary + * The XML document representing a taxonomy + * @param controlledVocabulary2HtmlXSLT + * The filename of the stylesheet that converts the taxonomy to + * HTML + * @param allowMultipleSelection + * include checkboxes next to the taxonomy terms + * @param contextPath + * The context path + * @return the provided taxonomy as HTML. + */ + public String renderVocabularyAsHTML(Document vocabulary, + String controlledVocabulary2HtmlXSLT, + boolean allowMultipleSelection, String contextPath) + { + if (vocabulary == null) + return ""; + + String result = ""; + try + { + + Hashtable parameters = new Hashtable(); + parameters.put("allowMultipleSelection", + allowMultipleSelection ? "yes" : "no"); + parameters.put("contextPath", contextPath); + result = XMLUtil.transformDocumentAsString(vocabulary, parameters, + controlledVocabulary2HtmlXSLT); + } + catch (Exception e) + { + e.printStackTrace(); + } + return result; + } + + /** + * Applies a filter to the provided vocabulary, i.e. it prunes the tree by + * removing all the branches that do not contain the words in the filter. + * + * @param vocabulary + * The vocabulary to be trimmed + * @param vocabularyPrunningXSLT + * The filename of the stylesheet that trims the vocabulary + * @param filter + * The filter to be applied + * @return The trimmed vocabulary. + */ + public Document filterVocabulary(Document vocabulary, + String vocabularyPrunningXSLT, String filter) + { + if (vocabulary == null) + return null; + + try + { + Hashtable parameters = new Hashtable(); + parameters.put("filter", filter); + Document prunnedVocabulary = XMLUtil.transformDocument(vocabulary, + parameters, vocabularyPrunningXSLT); + return prunnedVocabulary; + } + catch (Exception e) + { + e.printStackTrace(); + return null; + } + + } + + /** + * Loads into memory all the vocabularies found in the given directory. All + * files with .xml extension are considered to be controlled vocabularies. + * + * @param directory + * where the files are positioned + * @return an hashtable with the filenames of the vocabularies as keys and + * the XML documents representing the vocabularies as values. + */ + private static Hashtable loadControlledVocabularies(String directory) + { + Hashtable controlledVocabularies = new Hashtable(); + File dir = new File(directory); + + FilenameFilter filter = new FilenameFilter() + { + public boolean accept(File dir, String name) + { + return name.endsWith(".xml"); + } + }; + String[] children = dir.list(filter); + + if (children != null && children.length > 0) + { + for (int i = 0; i < children.length; i++) + { + String filename = children[i]; + + try + { + Document controlledVocabulary = XMLUtil.loadXML(directory + + filename); + controlledVocabularies.put(filename, controlledVocabulary); + log.warn("Loaded vocabulary: " + filename); + } + catch (Exception e) + { + log.warn("Failed to load vocabulary from " + filename, e); + } + } + } + else + { + log.warn("Could not find any vocabularies..."); + } + return controlledVocabularies; + + } + + /** + * Gets the filter provided as parameter to the tag + * + * @return the filter + */ + public String getFilter() + { + return filter; + } + + /** + * Sets the filter + * + * @param filter + * the filter + */ + public void setFilter(String filter) + { + this.filter = filter; + } + + /** + * Returns the value of the multiple selection parameter + * + * @return true if the multiple selection was selected + */ + public boolean isAllowMultipleSelection() + { + return allowMultipleSelection; + } + + /** + * Defines if we want to be able to select multiple terms of the taxonomy + * + * @param allowMultipleSelection + * true if we want to be able to select more than on term + */ + public void setAllowMultipleSelection(boolean allowMultipleSelection) + { + this.allowMultipleSelection = allowMultipleSelection; + } + + /** + * Gets the name of the vocabulary to be displayed + * + * @return the name of the vocabulary + */ + public String getVocabulary() + { + return vocabulary; + } + + /** + * Sets the name of the vocabulary to be displayed. If no name is provided, + * all vocabularies loaded will be rendered to the output + * + * @param vocabulary + * the name of the vocabulary to be selected + */ + public void setVocabulary(String vocabulary) + { + this.vocabulary = vocabulary; + } + +} diff --git a/dspace/src/org/dspace/app/webui/servlet/ControlledVocabularySearchServlet.java b/dspace/src/org/dspace/app/webui/servlet/ControlledVocabularySearchServlet.java new file mode 100644 index 0000000000..b25cdbf75c --- /dev/null +++ b/dspace/src/org/dspace/app/webui/servlet/ControlledVocabularySearchServlet.java @@ -0,0 +1,390 @@ +/* + * ConceptSearchServlet.java + * + * Version: $Revision$ + * + * Date: $Date$ + * + * Copyright (c) 2002, Hewlett-Packard Company and Massachusetts Institute of + * Technology. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: - + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. - Redistributions in binary + * form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided + * with the distribution. - Neither the name of the Hewlett-Packard Company nor + * the name of the Massachusetts Institute of Technology nor the names of their + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package org.dspace.app.webui.servlet; + +import java.io.IOException; +import java.net.URLEncoder; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Vector; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.log4j.Logger; +import org.dspace.app.webui.util.JSPManager; +import org.dspace.app.webui.util.UIUtil; +import org.dspace.authorize.AuthorizeException; +import org.dspace.content.Collection; +import org.dspace.content.Community; +import org.dspace.content.Item; +import org.dspace.core.Constants; +import org.dspace.core.Context; +import org.dspace.core.LogManager; +import org.dspace.handle.HandleManager; +import org.dspace.search.DSQuery; +import org.dspace.search.QueryArgs; +import org.dspace.search.QueryResults; + +/** + * Servlet that provides funcionality for searching the repository using a + * controlled vocabulary as a basis for selecting the search keywords. + * + * @author Miguel Ferreira + * @version $Revision$ + */ +public class ControlledVocabularySearchServlet extends DSpaceServlet +{ + // the log + private static Logger log = Logger + .getLogger(ControlledVocabularySearchServlet.class); + + // the jsp that displays the HTML version of controlled-vocabulary + private static final String SEARCH_JSP = "/controlledvocabulary/search.jsp"; + + // the jsp that will show the search results + private static final String RESULTS_JSP = "/controlledvocabulary/results.jsp"; + + /** + * Handles requests + */ + protected void doDSGet(Context context, HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException, + SQLException, AuthorizeException + { + + String action = request.getParameter("action") == null ? "" : request + .getParameter("action"); + + if (action.equals("search")) + { + List keywords = extractKeywords(request); + String query = join(keywords, " or "); + doSearch(context, request, query); + JSPManager.showJSP(request, response, RESULTS_JSP); + } + else if (action.equals("filter")) + { + String filter = request.getParameter("filter"); + request.getSession().setAttribute("conceptsearch.filter", filter); + JSPManager.showJSP(request, response, SEARCH_JSP); + } + else + { + JSPManager.showJSP(request, response, SEARCH_JSP); + } + } + + /** + * Collects the selected terms from the HTML taxonomy displayed on the + * search form + * + * @param request + * The HttpServletRequest + * @return A Vector with the selected terms from the taxonomy. + */ + private List extractKeywords(HttpServletRequest request) + { + List keywords = new Vector(); + Enumeration enumeration = request.getParameterNames(); + while (enumeration.hasMoreElements()) + { + String element = (String) enumeration.nextElement(); + if (element.startsWith("cb_")) + { + keywords.add("\"" + request.getParameter(element) + "\""); + } + } + return keywords; + } + + /** + * Searches the repository and and puts the results in the request object + * + * @param context + * The DSpace context + * @param request + * The request object + * @param query + * The query expression + * @throws IOException + * @throws SQLException + */ + private void doSearch(Context context, HttpServletRequest request, + String query) throws IOException, SQLException + { + // Get the query + // String query = request.getParameter("query"); + int start = UIUtil.getIntParameter(request, "start"); + String advanced = request.getParameter("advanced"); + String fromAdvanced = request.getParameter("from_advanced"); + String advancedQuery = ""; + HashMap queryHash = new HashMap(); + + // can't start earlier than 0 in the results! + if (start < 0) + { + start = 0; + } + + List itemHandles = new ArrayList(); + List collectionHandles = new ArrayList(); + List communityHandles = new ArrayList(); + + Item[] resultsItems; + Collection[] resultsCollections; + Community[] resultsCommunities; + + QueryResults qResults = null; + QueryArgs qArgs = new QueryArgs(); + + // if the "advanced" flag is set, build the query string from the + // multiple query fields + if (advanced != null) + { + query = qArgs.buildQuery(request); + advancedQuery = qArgs.buildHTTPQuery(request); + } + + // Ensure the query is non-null + if (query == null) + { + query = ""; + } + + // Get the location parameter, if any + String location = request.getParameter("location"); + String newURL; + + // Build log information + String logInfo = ""; + + // Get our location + Community community = UIUtil.getCommunityLocation(request); + Collection collection = UIUtil.getCollectionLocation(request); + + // get the start of the query results page + // List resultObjects = null; + qArgs.setQuery(query); + qArgs.setStart(start); + + // Perform the search + if (collection != null) + { + logInfo = "collection_id=" + collection.getID() + ","; + + // Values for drop-down box + request.setAttribute("community", community); + request.setAttribute("collection", collection); + + qResults = DSQuery.doQuery(context, qArgs, collection); + } + else if (community != null) + { + logInfo = "community_id=" + community.getID() + ","; + + request.setAttribute("community", community); + + // Get the collections within the community for the dropdown box + request + .setAttribute("collection.array", community + .getCollections()); + + qResults = DSQuery.doQuery(context, qArgs, community); + } + else + { + // Get all communities for dropdown box + Community[] communities = Community.findAll(context); + request.setAttribute("community.array", communities); + + qResults = DSQuery.doQuery(context, qArgs); + } + + // now instantiate the results and put them in their buckets + for (int i = 0; i < qResults.getHitHandles().size(); i++) + { + String myHandle = (String) qResults.getHitHandles().get(i); + Integer myType = (Integer) qResults.getHitTypes().get(i); + + // add the handle to the appropriate lists + switch (myType.intValue()) + { + case Constants.ITEM: + itemHandles.add(myHandle); + + break; + + case Constants.COLLECTION: + collectionHandles.add(myHandle); + + break; + + case Constants.COMMUNITY: + communityHandles.add(myHandle); + + break; + } + } + + int numCommunities = communityHandles.size(); + int numCollections = collectionHandles.size(); + int numItems = itemHandles.size(); + + // Make objects from the handles - make arrays, fill them out + resultsCommunities = new Community[numCommunities]; + resultsCollections = new Collection[numCollections]; + resultsItems = new Item[numItems]; + + for (int i = 0; i < numItems; i++) + { + String myhandle = (String) itemHandles.get(i); + + Object o = HandleManager.resolveToObject(context, myhandle); + + resultsItems[i] = (Item) o; + + if (resultsItems[i] == null) + { + throw new SQLException("Query \"" + query + + "\" returned unresolvable handle: " + myhandle); + } + } + + for (int i = 0; i < collectionHandles.size(); i++) + { + String myhandle = (String) collectionHandles.get(i); + + Object o = HandleManager.resolveToObject(context, myhandle); + + resultsCollections[i] = (Collection) o; + + if (resultsCollections[i] == null) + { + throw new SQLException("Query \"" + query + + "\" returned unresolvable handle: " + myhandle); + } + } + + for (int i = 0; i < communityHandles.size(); i++) + { + String myhandle = (String) communityHandles.get(i); + + Object o = HandleManager.resolveToObject(context, myhandle); + + resultsCommunities[i] = (Community) o; + + if (resultsCommunities[i] == null) + { + throw new SQLException("Query \"" + query + + "\" returned unresolvable handle: " + myhandle); + } + } + + // Log + log.info(LogManager.getHeader(context, "search", logInfo + "query=\"" + + query + "\",results=(" + resultsCommunities.length + "," + + resultsCollections.length + "," + resultsItems.length + ")")); + + // Pass in some page qualities + // total number of pages + int pageTotal = 1 + ((qResults.getHitCount() - 1) / qResults + .getPageSize()); + + // current page being displayed + int pageCurrent = 1 + (qResults.getStart() / qResults.getPageSize()); + + // pageLast = min(pageCurrent+9,pageTotal) + int pageLast = ((pageCurrent + 9) > pageTotal) ? pageTotal + : (pageCurrent + 9); + + // pageFirst = max(1,pageCurrent-9) + int pageFirst = ((pageCurrent - 9) > 1) ? (pageCurrent - 9) : 1; + + // Pass the results to the display JSP + request.setAttribute("items", resultsItems); + request.setAttribute("communities", resultsCommunities); + request.setAttribute("collections", resultsCollections); + + request.setAttribute("pagetotal", new Integer(pageTotal)); + request.setAttribute("pagecurrent", new Integer(pageCurrent)); + request.setAttribute("pagelast", new Integer(pageLast)); + request.setAttribute("pagefirst", new Integer(pageFirst)); + + request.setAttribute("queryresults", qResults); + + // And the original query string + request.setAttribute("query", query); + + } + + /** + * Joins each element present in a list with a separator + * + * @param list + * The list of elements + * @param separator + * The separator that will be used between each element + * @return A string with all the elements concatened and separated by the + * provided connector + */ + public static String join(List list, String separator) + { + String result = ""; + Iterator iterator = list.listIterator(); + while (iterator.hasNext()) + { + result += iterator.next().toString(); + if (iterator.hasNext()) + result += separator; + } + return result; + } + + /** + * Handle posts + */ + protected void doDSPost(Context context, HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException, + SQLException, AuthorizeException + { + doDSGet(context, request, response); + } + +} diff --git a/dspace/src/org/dspace/app/webui/servlet/ControlledVocabularyServlet.java b/dspace/src/org/dspace/app/webui/servlet/ControlledVocabularyServlet.java new file mode 100644 index 0000000000..a4ae4d55b2 --- /dev/null +++ b/dspace/src/org/dspace/app/webui/servlet/ControlledVocabularyServlet.java @@ -0,0 +1,86 @@ +/* + * ControlledVocabularyServlet.java + * + * Version: $Revision$ + * + * Date: $Date$ + * + * Copyright (c) 2002, Hewlett-Packard Company and Massachusetts Institute of + * Technology. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: - + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. - Redistributions in binary + * form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided + * with the distribution. - Neither the name of the Hewlett-Packard Company nor + * the name of the Massachusetts Institute of Technology nor the names of their + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package org.dspace.app.webui.servlet; + +import java.io.IOException; +import java.sql.SQLException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.dspace.authorize.AuthorizeException; +import org.dspace.core.Context; + +/** + * Servlet that handles the controlled vocabulary + * + * @author Miguel Ferreira + * @version $Revision$ + */ +public class ControlledVocabularyServlet extends DSpaceServlet +{ + // private static Logger log = + // Logger.getLogger(ControlledVocabularyServlet.class); + + protected void doDSGet(Context context, HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException, + SQLException, AuthorizeException + { + + String ID = ""; + String filter = ""; + String callerUrl = request.getParameter("callerUrl"); + + if (request.getParameter("ID") != null) + ID = request.getParameter("ID"); + + if (request.getParameter("filter") != null) + filter = request.getParameter("filter"); + + request.getSession() + .setAttribute("controlledvocabulary.filter", filter); + request.getSession().setAttribute("controlledvocabulary.ID", ID); + response.sendRedirect(callerUrl); + } + + protected void doDSPost(Context context, HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException, + SQLException, AuthorizeException + { + + doDSGet(context, request, response); + } + +} diff --git a/dspace/src/org/dspace/app/webui/util/DCInput.java b/dspace/src/org/dspace/app/webui/util/DCInput.java index fafd62a6b5..6dada97e39 100644 --- a/dspace/src/org/dspace/app/webui/util/DCInput.java +++ b/dspace/src/org/dspace/app/webui/util/DCInput.java @@ -47,119 +47,137 @@ import org.dspace.content.MetadataSchema; /** * Class representing a line in an input form. - * + * * @author Brian S. Hughes, based on work by Jenny Toves, OCLC * @version */ public class DCInput { - /** the DC element name */ - private String dcElement = null; - /** the DC qualifier, if any */ - private String dcQualifier = null; - /** the DC namespace schema */ - private String dcSchema = null; - /** a label describing input */ - private String label = null; - /** the input type */ - private String inputType = null; - /** is input required? */ - private boolean required = false; - /** if required, text to display when missing */ - private String warning = null; - /** is input repeatable? */ - private boolean repeatable = false; - /** 'hint' text to display */ - private String hint = null; - /** if input list-controlled, name of list */ - private String valueListName = null; - /** if input list-controlled, the list itself */ - private List valueList = null; - /** if non-null, visibility scope restriction */ - private String visibility = null; - + /** the DC element name */ + private String dcElement = null; + + /** the DC qualifier, if any */ + private String dcQualifier = null; + + /** the DC namespace schema */ + private String dcSchema = null; + + /** a label describing input */ + private String label = null; + + /** the input type */ + private String inputType = null; + + /** is input required? */ + private boolean required = false; + + /** if required, text to display when missing */ + private String warning = null; + + /** is input repeatable? */ + private boolean repeatable = false; + + /** 'hint' text to display */ + private String hint = null; + + /** if input list-controlled, name of list */ + private String valueListName = null; + + /** if input list-controlled, the list itself */ + private List valueList = null; + + /** if non-null, visibility scope restriction */ + private String visibility = null; + + /** the name of the controlled vocabulary to use */ + private String vocabulary = null; + /** - * Class constructor for creating a DCInput object - * based on the contents of a HashMap - * - * @param row the corresponding row in the table + * Class constructor for creating a DCInput object based on the contents of + * a HashMap + * + * @param row + * the corresponding row in the table */ public DCInput(Map fieldMap, Map listMap) { - dcElement = (String)fieldMap.get("dc-element"); - dcQualifier = (String)fieldMap.get("dc-qualifier"); - + dcElement = (String) fieldMap.get("dc-element"); + dcQualifier = (String) fieldMap.get("dc-qualifier"); + // Default the schema to dublin core - dcSchema = (String)fieldMap.get("dc-schema"); - if (dcSchema == null) { + dcSchema = (String) fieldMap.get("dc-schema"); + if (dcSchema == null) + { dcSchema = MetadataSchema.DC_SCHEMA; } - String repStr = (String)fieldMap.get("repeatable"); - repeatable = "true".equalsIgnoreCase(repStr) || "yes".equalsIgnoreCase(repStr); - label = (String)fieldMap.get("label"); - inputType = (String)fieldMap.get("input-type"); - // these types are list-controlled - if ( "dropdown".equals( inputType) || "qualdrop_value".equals( inputType )) - { - valueListName = (String)fieldMap.get("value-pairs-name"); - valueList = (List)listMap.get( valueListName ); - } - hint = (String)fieldMap.get("hint"); - warning = (String)fieldMap.get("required"); - required = ( warning != null && warning.length() > 0 ); - visibility = (String)fieldMap.get("visibility"); + String repStr = (String) fieldMap.get("repeatable"); + repeatable = "true".equalsIgnoreCase(repStr) + || "yes".equalsIgnoreCase(repStr); + label = (String) fieldMap.get("label"); + inputType = (String) fieldMap.get("input-type"); + // these types are list-controlled + if ("dropdown".equals(inputType) || "qualdrop_value".equals(inputType)) + { + valueListName = (String) fieldMap.get("value-pairs-name"); + valueList = (List) listMap.get(valueListName); + } + hint = (String) fieldMap.get("hint"); + warning = (String) fieldMap.get("required"); + required = (warning != null && warning.length() > 0); + visibility = (String) fieldMap.get("visibility"); + vocabulary = (String) fieldMap.get("vocabulary"); } - + /** - * Is this DCInput for display in the given scope? The scope should - * be either "workflow" or "submit", as per the input forms definition. - * If the internal visibility is set to "null" then this will always - * return true. + * Is this DCInput for display in the given scope? The scope should be + * either "workflow" or "submit", as per the input forms definition. If the + * internal visibility is set to "null" then this will always return true. * - * @param scope String identifying the scope that this input's visibility - * should be tested for + * @param scope + * String identifying the scope that this input's visibility + * should be tested for * * @return whether the input should be displayed or not */ public boolean isVisible(String scope) { - return (visibility == null || visibility.equals(scope)); + return (visibility == null || visibility.equals(scope)); } /** * Get the repeatable flag for this row - * + * * @return the repeatable flag */ public boolean isRepeatable() { - return repeatable; + return repeatable; } /** * Alternate way of calling isRepeatable() - * + * * @return the repeatable flag */ public boolean getRepeatable() { - return isRepeatable(); + return isRepeatable(); } /** * Get the input type for this row - * + * * @return the input type */ public String getInputType() { return inputType; } - + /** * Get the DC element for this form row. - * + * * @return the DC element */ public String getElement() @@ -169,58 +187,60 @@ public class DCInput /** * Get the DC namespace prefix for this form row. - * + * * @return the DC namespace prefix */ public String getSchema() { return dcSchema; } - /** - * Get the warning string for a missing required field, formatted for an HTML table. - * + * Get the warning string for a missing required field, formatted for an + * HTML table. + * * @return the string prompt if required field was ignored */ public String getWarning() { - return "" + warning + ""; + return "" + warning + + ""; } - + /** * Is there a required string for this form row? - * + * * @return true if a required string is set */ public boolean isRequired() { - return required; + return required; } - + /** * Get the DC qualifier for this form row. - * + * * @return the DC qualifier */ public String getQualifier() { return dcQualifier; } - + /** * Get the hint for this form row, formatted for an HTML table - * + * * @return the hints */ public String getHints() { - return "" + hint + ""; + return "" + hint + + ""; } - + /** * Get the label for this form row. - * + * * @return the label */ public String getLabel() @@ -229,71 +249,104 @@ public class DCInput } /** - * Get the name of the pairs type - * + * Get the name of the pairs type + * * @return the pairs type name */ public String getPairsType() { - return valueListName; + return valueListName; } - + /** - * Get the name of the pairs type - * + * Get the name of the pairs type + * * @return the pairs type name */ public List getPairs() { - return valueList; - } - - /** - * Gets the display string that corresponds to the passed storage string in a - * particular display-storage pair set. - * - * @param allPairs HashMap of all display-storage pair sets - * @param pairTypeName Name of display-storage pair set to search - * @param storageString the string that gets stored - * - * @return the displayed string whose selection causes storageString to be stored, null if no match - */ - public String getDisplayString(String pairTypeName, String storedString) - { - if (valueList != null) - { - for (int i = 0; i < valueList.size(); i += 2) - { - if (((String)valueList.get(i+1)).equals(storedString)) - { - return (String)valueList.get(i); - } - } - } - return null; + return valueList; } /** - * Gets the stored string that corresponds to the passed display string in a particular display-storage pair set. - * - * @param allPairs HashMap of all display-storage pair sets - * @param pairTypeName Name of display-storage pair set to search - * @param displayString the string that gets displayed - * - * @return the string that gets stored when displayString gets selected, null if no match + * Get the name of the controlled vocabulary that is associated with this + * field + * + * @return the name of associated the vocabulary + */ + public String getVocabulary() + { + return vocabulary; + } + + /** + * Set the name of the controlled vocabulary that is associated with this + * field + * + * @param vocabulary + * the name of the vocabulary + */ + public void setVocabulary(String vocabulary) + { + this.vocabulary = vocabulary; + } + + /** + * Gets the display string that corresponds to the passed storage string in + * a particular display-storage pair set. + * + * @param allPairs + * HashMap of all display-storage pair sets + * @param pairTypeName + * Name of display-storage pair set to search + * @param storageString + * the string that gets stored + * + * @return the displayed string whose selection causes storageString to be + * stored, null if no match + */ + public String getDisplayString(String pairTypeName, String storedString) + { + if (valueList != null) + { + for (int i = 0; i < valueList.size(); i += 2) + { + if (((String) valueList.get(i + 1)).equals(storedString)) + { + return (String) valueList.get(i); + } + } + } + return null; + } + + /** + * Gets the stored string that corresponds to the passed display string in a + * particular display-storage pair set. + * + * @param allPairs + * HashMap of all display-storage pair sets + * @param pairTypeName + * Name of display-storage pair set to search + * @param displayString + * the string that gets displayed + * + * @return the string that gets stored when displayString gets selected, + * null if no match */ public String getStoredString(String pairTypeName, String displayedString) { - if (valueList != null) - { - for (int i = 0; i < valueList.size(); i += 2) - { - if (((String)valueList.get(i)).equals(displayedString)) - { - return (String)valueList.get(i+1); - } - } - } - return null; + if (valueList != null) + { + for (int i = 0; i < valueList.size(); i += 2) + { + if (((String) valueList.get(i)).equals(displayedString)) + { + return (String) valueList.get(i + 1); + } + } + } + return null; } + } diff --git a/dspace/src/org/dspace/app/webui/util/XMLUtil.java b/dspace/src/org/dspace/app/webui/util/XMLUtil.java new file mode 100644 index 0000000000..2739430686 --- /dev/null +++ b/dspace/src/org/dspace/app/webui/util/XMLUtil.java @@ -0,0 +1,217 @@ +/* + * XMLUtil.java + * + * Version: $Revision$ + * + * Date: $Date$ + * + * Copyright (c) 2002, Hewlett-Packard Company and Massachusetts Institute of + * Technology. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: - + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. - Redistributions in binary + * form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided + * with the distribution. - Neither the name of the Hewlett-Packard Company nor + * the name of the Massachusetts Institute of Technology nor the names of their + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package org.dspace.app.webui.util; + +import java.io.File; +import java.io.IOException; +import java.io.StringWriter; +import java.util.Enumeration; +import java.util.Hashtable; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMResult; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; + +import org.w3c.dom.Document; +import org.xml.sax.SAXException; + +/** + * This class provides a set of static methods to load and transform XML + * documents. It supports parameter-aware stylesheets (XSLT). + * + * @author Miguel Ferreira + * + */ +public class XMLUtil +{ + + /** + * Loads a W3C XML document from a file. + * + * @param filename + * The name of the file to be loaded + * @return a document object model object representing the XML file + * @throws IOException + * @throws ParserConfigurationException + * @throws SAXException + */ + public static Document loadXML(String filename) throws IOException, + ParserConfigurationException, SAXException + { + DocumentBuilder builder = DocumentBuilderFactory.newInstance() + .newDocumentBuilder(); + return builder.parse(new File(filename)); + } + + /** + * Applies a stylesheet to a given xml document. + * + * @param xmlDocument + * the xml document to be transformed + * @param xsltFilename + * the filename of the stylesheet + * @return the transformed xml document + * @throws Exception + */ + public static Document transformDocument(Document xmlDocument, + String xsltFilename) throws Exception + { + return transformDocument(xmlDocument, new Hashtable(), xsltFilename); + } + + /** + * Applies a stylesheet (that receives parameters) to a given xml document. + * + * @param xmlDocument + * the xml document to be transformed + * @param parameters + * the hashtable with the parameters to be passed to the + * stylesheet + * @param xsltFilename + * the filename of the stylesheet + * @return the transformed xml document + * @throws Exception + */ + public static Document transformDocument(Document xmlDocument, + Hashtable parameters, String xsltFilename) throws Exception + { + + // Generate a Transformer. + Transformer transformer = TransformerFactory.newInstance() + .newTransformer(new StreamSource(xsltFilename)); + + // set transformation parameters + if (parameters != null) + { + Enumeration keys = parameters.keys(); + while (keys.hasMoreElements()) + { + String key = (String) keys.nextElement(); + String value = (String) parameters.get(key); + transformer.setParameter(key, value); + } + + } + + // Create an empy DOMResult object for the output. + DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance(); + dFactory.setNamespaceAware(true); + DocumentBuilder dBuilder = dFactory.newDocumentBuilder(); + Document dstDocument = dBuilder.newDocument(); + + DOMResult domResult = new DOMResult(dstDocument); + + // Perform the transformation. + transformer.transform(new DOMSource(xmlDocument), domResult); + // Now you can get the output Node from the DOMResult. + return dstDocument; + } + + /** + * Applies a stylesheet (that receives parameters) to a given xml document. + * The resulting XML document is converted to a string after transformation. + * + * @param xmlDocument + * the xml document to be transformed + * @param parameters + * the hashtable with the parameters to be passed to the + * stylesheet + * @param xsltFilename + * the filename of the stylesheet + * @return the transformed xml document as a string + * @throws Exception + */ + public static String transformDocumentAsString(Document xmlDocument, + Hashtable parameters, String xsltFilename) throws Exception + { + + // Generate a Transformer. + Transformer transformer = TransformerFactory.newInstance() + .newTransformer(new StreamSource(xsltFilename)); + + // set transformation parameters + if (parameters != null) + { + Enumeration keys = parameters.keys(); + while (keys.hasMoreElements()) + { + String key = (String) keys.nextElement(); + String value = (String) parameters.get(key); + transformer.setParameter(key, value); + } + + } + + StringWriter stringWriter = new StringWriter(); + StreamResult streamResult = new StreamResult(stringWriter); + + // Perform the transformation. + transformer.transform(new DOMSource(xmlDocument), streamResult); + // Now you can get the output Node from the DOMResult. + return stringWriter.toString(); + } + + /** + * Applies a stylesheet to a given xml document. + * + * @param xmlDocument + * the xml document to be transformed + * @param xsltFilename + * the filename of the stylesheet + * @return the transformed xml document + * @throws Exception + */ + public static String transformDocumentAsString(Document xmlDocument, + String xsltFilename) throws Exception + { + // Generate a Transformer. + Transformer transformer = TransformerFactory.newInstance() + .newTransformer(new StreamSource(xsltFilename)); + + StringWriter stringWriter = new StringWriter(); + StreamResult streamResult = new StreamResult(stringWriter); + + // Perform the transformation. + transformer.transform(new DOMSource(xmlDocument), streamResult); + // Now you can get the output Node from the DOMResult. + return stringWriter.toString(); + } + +}