From 2a22abb08a31fd2ce7343b26fdcb045bd8e42199 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 23 Jun 2011 12:56:22 +0200 Subject: [PATCH] zoom: configurable element sets for record transforms. The target profile based transform is specified by element_transform in element torus of of the ZOOM filter configuration ; default value is "pz2". Target profile based retrieval is specified by element_raw in configuration. It will perform same steps, but omit the XSL transform. Default value is "raw". --- doc/zoom.xml | 61 ++++++++++++++++++++++++++++++++++++-------- etc/config-zoom.xml | 4 ++- m4 | 2 +- src/filter_zoom.cpp | 44 +++++++++++++++++++++----------- xml/schema/filter_zoom.rnc | 2 ++ xml/schema/filter_zoom.rng | 10 ++++++++ xml/schema/filter_zoom.xsd | 2 ++ 7 files changed, 97 insertions(+), 28 deletions(-) diff --git a/doc/zoom.xml b/doc/zoom.xml index db06242..253be8f 100644 --- a/doc/zoom.xml +++ b/doc/zoom.xml @@ -62,7 +62,9 @@ and takes the following content: - attribute url + + attribute url + URL of Web service to be used to fetch target profile for a given database (udb). The special sequence %db of the URL is replaced by the @@ -70,14 +72,39 @@ - attribute xsldir + + attribute xsldir + Directory that is searched for XSL stylesheets. Stylesheets are specified in the target profile by the transform element. - element records + + attribute element_transform + + Specifies the element that triggers retrieval and transform using + the parameters elementSet, recordEncoding, requestSyntax, transform + from the target profile. Default value + is "pz2", due to the fact that for historical reasons the + common format is that used in Pazpar2. + + + + + attribute element_raw + + Specifies an element that triggers retrieval using the + parameters elementSet, recordEncoding, requestSyntax from the + target profile. Same actions as for element_transform, but without + the XSL transform. Useful for debugging. The default value is "raw". + + + + + element records + Local target profiles. This element may includes zero or more record elements (one per target profile). See section TARGET PROFILE. @@ -91,13 +118,19 @@ following content: - attribute cql - CQL field. + + attribute cql + + + CQL field that we are mapping "from". - attribute ccl - CCL field. + + attribute ccl + + + CCL field that we are mapping "to". @@ -209,11 +242,15 @@ elementSet Specifies the elementSet to be sent to the target if record - transform is enabled (not to be used with the record_transform + transform is enabled (not to be confused' with the record_transform module). The record transform is enabled only if the client uses - record syntax = XML and element set = - pz2. If record transform is not enabled, this - setting is not used and the element set specified by the client + record syntax = XML and a element set determined by + the element_transform / + element_raw from the configuration. + By default that is the element sets pz2 + and raw. + If record transform is not enabled, this setting is + not used and the element set specified by the client is passed verbatim. @@ -257,6 +294,8 @@ Specifies a XSL stylesheet filename to be used if record transform is anabled; see desciprion of elementSet. + The XSL transform is only used if the element set is set to the + value of element_transform in the configuration. diff --git a/etc/config-zoom.xml b/etc/config-zoom.xml index daea9da..171a1bc 100644 --- a/etc/config-zoom.xml +++ b/etc/config-zoom.xml @@ -10,6 +10,8 @@ @@ -78,7 +80,7 @@ - + diff --git a/m4 b/m4 index f7d7eb4..c9c894a 160000 --- a/m4 +++ b/m4 @@ -1 +1 @@ -Subproject commit f7d7eb4b44b7fdad1942e32856d6afc2e6dcabda +Subproject commit c9c894a0b63f9ce9578570e3507c3e6232ec4797 diff --git a/src/filter_zoom.cpp b/src/filter_zoom.cpp index f9c07df..9ceaf0c 100644 --- a/src/filter_zoom.cpp +++ b/src/filter_zoom.cpp @@ -134,6 +134,8 @@ namespace metaproxy_1 { std::map fieldmap; std::string xsldir; CCL_bibset bibset; + std::string element_transform; + std::string element_raw; std::map s_map; }; } @@ -314,7 +316,7 @@ void yf::Zoom::Impl::release_frontend(mp::Package &package) } } -yf::Zoom::Impl::Impl() +yf::Zoom::Impl::Impl() : element_transform("pz2") , element_raw("raw") { bibset = ccl_qual_mk(); } @@ -475,6 +477,10 @@ void yf::Zoom::Impl::configure(const xmlNode *ptr, bool test_only) torus_url = mp::xml::get_text(attr->children); else if (!strcmp((const char *) attr->name, "xsldir")) xsldir = mp::xml::get_text(attr->children); + else if (!strcmp((const char *) attr->name, "element_transform")) + element_transform = mp::xml::get_text(attr->children); + else if (!strcmp((const char *) attr->name, "element_raw")) + element_raw = mp::xml::get_text(attr->children); else throw mp::filter::FilterException( "Bad attribute " + std::string((const char *) @@ -683,7 +689,8 @@ Z_Records *yf::Zoom::Frontend::get_records(Odr_int start, { *number_of_records_returned = 0; Z_Records *records = 0; - bool enable_pz2_transform = false; + bool enable_pz2_retrieval = false; // whether target profile is used + bool enable_pz2_transform = false; // whether XSLT is used as well if (start < 0 || number_to_present <= 0) return records; @@ -696,27 +703,34 @@ Z_Records *yf::Zoom::Frontend::get_records(Odr_int start, char oid_name_str[OID_STR_MAX]; const char *syntax_name = 0; - - if (preferredRecordSyntax) + + if (preferredRecordSyntax && + !oid_oidcmp(preferredRecordSyntax, yaz_oid_recsyn_xml) + && element_set_name) { - if (!oid_oidcmp(preferredRecordSyntax, yaz_oid_recsyn_xml) - && element_set_name && - !strcmp(element_set_name, "pz2")) + if (!strcmp(element_set_name, m_p->element_transform.c_str())) { - if (b->sptr->request_syntax.length()) - syntax_name = b->sptr->request_syntax.c_str(); + enable_pz2_retrieval = true; enable_pz2_transform = true; } - else + else if (!strcmp(element_set_name, m_p->element_raw.c_str())) { - syntax_name = - yaz_oid_to_string_buf(preferredRecordSyntax, 0, oid_name_str); + enable_pz2_retrieval = true; } } + + if (enable_pz2_retrieval) + { + if (b->sptr->request_syntax.length()) + syntax_name = b->sptr->request_syntax.c_str(); + } + else if (preferredRecordSyntax) + syntax_name = + yaz_oid_to_string_buf(preferredRecordSyntax, 0, oid_name_str); b->set_option("preferredRecordSyntax", syntax_name); - if (enable_pz2_transform) + if (enable_pz2_retrieval) { element_set_name = 0; if (b->sptr->element_set.length()) @@ -756,7 +770,7 @@ Z_Records *yf::Zoom::Frontend::get_records(Odr_int start, npr = zget_surrogateDiagRec(odr, odr_database, sur_error, addinfo); } - else if (enable_pz2_transform) + else if (enable_pz2_retrieval) { char rec_type_str[100]; @@ -774,7 +788,7 @@ Z_Records *yf::Zoom::Frontend::get_records(Odr_int start, int rec_len; const char *rec_buf = ZOOM_record_get(recs[i], rec_type_str, &rec_len); - if (rec_buf && b->xsp) + if (rec_buf && b->xsp && enable_pz2_transform) { xmlDoc *rec_doc = xmlParseMemory(rec_buf, rec_len); if (rec_doc) diff --git a/xml/schema/filter_zoom.rnc b/xml/schema/filter_zoom.rnc index 3c22312..e148d78 100644 --- a/xml/schema/filter_zoom.rnc +++ b/xml/schema/filter_zoom.rnc @@ -9,6 +9,8 @@ filter_zoom = element mp:torus { attribute url { xsd:string }, attribute xsldir { xsd:string }?, + attribute element_transform { xsd:string }?, + attribute element_raw { xsd:string }?, element mp:records { element mp:record { element mp:authentication { xsd:string }?, diff --git a/xml/schema/filter_zoom.rng b/xml/schema/filter_zoom.rng index ce977e1..47983c9 100644 --- a/xml/schema/filter_zoom.rng +++ b/xml/schema/filter_zoom.rng @@ -26,6 +26,16 @@ + + + + + + + + + + diff --git a/xml/schema/filter_zoom.xsd b/xml/schema/filter_zoom.xsd index 979131f..4914d89 100644 --- a/xml/schema/filter_zoom.xsd +++ b/xml/schema/filter_zoom.xsd @@ -17,6 +17,8 @@ + + -- 1.7.10.4