From d09aef2b0f7bd651a1132750144cb9d1460dca91 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 22 Aug 2011 12:37:14 +0200 Subject: [PATCH] zoom: new target profile element literalTransform This element holds XSLT, encoded as string, for target. Only if present and non-zero length it is considered present. This takes precedence over transform. --- NEWS | 4 +++ etc/config-zoom.xml | 84 ++++++++++++++++++++++++++++++++++++++++++++ src/filter_zoom.cpp | 30 +++++++++++++++- xml/schema/filter_zoom.rnc | 1 + 4 files changed, 118 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 4222a38..1a70c13 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +zoom: new target profile element literalTransform that holds XSLT +(encoded as string) for target. Only if present and non-zero length it is +considered present. This takes precedence over transform. + --- 1.3.5 2011/08/12 z3950_client: mark non-surrogate diagnostics from backend. diff --git a/etc/config-zoom.xml b/etc/config-zoom.xml index dbb72f6..9887b5b 100644 --- a/etc/config-zoom.xml +++ b/etc/config-zoom.xml @@ -57,6 +57,90 @@ 1=title s=pw t=l,r get dc.xsl + <?xml version="1.0" encoding="UTF-8"?> +<!-- + + This stylesheet expects oai/dc records +--> +<xsl:stylesheet + version="1.0" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:pz="http://www.indexdata.com/pazpar2/1.0" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:dcterms="http://purl.org/dc/terms/"> + + <xsl:output indent="yes" + method="xml" + version="1.0" + encoding="UTF-8"/> + + <xsl:param name="medium" /> + + <xsl:template match="/*"> + <pz:record> + + <pz:metadata type="id"> + <xsl:value-of select="dc:identifier"/> + </pz:metadata> + + <xsl:for-each select="dc:title"> + <pz:metadata type="title"> + <xsl:value-of select="."/> + </pz:metadata> + </xsl:for-each> + + <xsl:for-each select="dc:date"> + <pz:metadata type="date"> + <xsl:value-of select="."/> + </pz:metadata> + </xsl:for-each> + + <xsl:for-each select="dc:subject"> + <pz:metadata type="subject"> + <xsl:value-of select="."/> + </pz:metadata> + </xsl:for-each> + + <xsl:for-each select="dc:creator"> + <pz:metadata type="author"> + <xsl:value-of select="."/> + </pz:metadata> + </xsl:for-each> + + <xsl:for-each select="dc:description"> + <pz:metadata type="description"> + <xsl:value-of select="."/> + </pz:metadata> + </xsl:for-each> + + <xsl:for-each select="dc:identifier"> + <pz:metadata type="electronic-url"> + <xsl:value-of select="."/> + </pz:metadata> + </xsl:for-each> + + <xsl:for-each select="dc:type"> + <pz:metadata type="medium"> + <xsl:value-of select="."/> + </pz:metadata> + </xsl:for-each> + + <xsl:for-each select="dcterms:bibliographicCitation"> + <pz:metadata type="citation"> + <xsl:value-of select="."/> + </pz:metadata> + </xsl:for-each> + + <pz:metadata type="medium"> + <xsl:value-of select="$medium" /> + </pz:metadata> + + </pz:record> + </xsl:template> + + <xsl:template match="text()"/> + +</xsl:stylesheet> dfr.jstor.org/sru diff --git a/src/filter_zoom.cpp b/src/filter_zoom.cpp index 533da78..ff73e19 100644 --- a/src/filter_zoom.cpp +++ b/src/filter_zoom.cpp @@ -66,6 +66,7 @@ namespace metaproxy_1 { std::string element_set; std::string record_encoding; std::string transform_xsl_fname; + std::string transform_xsl_content; std::string urlRecipe; std::string contentConnector; bool use_turbomarc; @@ -466,6 +467,11 @@ yf::Zoom::SearchablePtr yf::Zoom::Impl::parse_torus_record(const xmlNode *ptr) s->transform_xsl_fname = mp::xml::get_text(ptr); } else if (!strcmp((const char *) ptr->name, + "literalTransform")) + { + s->transform_xsl_content = mp::xml::get_text(ptr); + } + else if (!strcmp((const char *) ptr->name, "urlRecipe")) { s->urlRecipe = mp::xml::get_text(ptr); @@ -699,7 +705,29 @@ yf::Zoom::BackendPtr yf::Zoom::Frontend::get_backend_from_databases( } xsltStylesheetPtr xsp = 0; - if (sptr->transform_xsl_fname.length()) + if (sptr->transform_xsl_content.length()) + { + xmlDoc *xsp_doc = xmlParseMemory(sptr->transform_xsl_content.c_str(), + sptr->transform_xsl_content.length()); + if (!xsp_doc) + { + *error = YAZ_BIB1_TEMPORARY_SYSTEM_ERROR; + *addinfo = (char *) odr_malloc(odr, 40); + sprintf(*addinfo, "xmlParseMemory failed"); + BackendPtr b; + return b; + } + xsp = xsltParseStylesheetDoc(xsp_doc); + if (!xsp) + { + *error = YAZ_BIB1_DATABASE_DOES_NOT_EXIST; + *addinfo = odr_strdup(odr, "xsltParseStylesheetDoc failed"); + BackendPtr b; + xmlFreeDoc(xsp_doc); + return b; + } + } + else if (sptr->transform_xsl_fname.length()) { const char *path = 0; diff --git a/xml/schema/filter_zoom.rnc b/xml/schema/filter_zoom.rnc index 95d21a0..f9e682b 100644 --- a/xml/schema/filter_zoom.rnc +++ b/xml/schema/filter_zoom.rnc @@ -29,6 +29,7 @@ filter_zoom = element mp:requestSyntax { xsd:string }?, element mp:sru { xsd:string }?, element mp:transform { xsd:string }?, + element mp:literalTransform { xsd:string }?, element mp:urlRecipe { xsd:string }?, element mp:zurl { xsd:string }, element mp:cfAuth { xsd:string }?, -- 1.7.10.4