Initial metaproxy setup for bibframe - part of MP-553
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 8 Jul 2014 13:00:15 +0000 (15:00 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 8 Jul 2014 13:00:35 +0000 (15:00 +0200)
bibframe/config.xml [new file with mode: 0644]
bibframe/cql2pqf.txt [new file with mode: 0644]
bibframe/explain.xml [new file with mode: 0644]
bibframe/xsl/sru.xsl [new file with mode: 0644]

diff --git a/bibframe/config.xml b/bibframe/config.xml
new file mode 100644 (file)
index 0000000..d30231f
--- /dev/null
@@ -0,0 +1,70 @@
+<?xml version="1.0"?>
+<metaproxy xmlns="http://indexdata.com/metaproxy" version="1.0">
+  <dlpath>../src</dlpath>
+  <start route="start"/>
+  <filters>
+    <filter id="frontend" type="frontend_net">
+      <port>@:9070</port>
+      <stat-req>/fn_stat</stat-req>
+    </filter>
+  </filters>
+  <routes>
+    <route id="start">
+      <filter refid="frontend"/>
+      <filter type="http_file">
+        <area>
+          <documentroot>xsl</documentroot>
+          <prefix>/xsl</prefix>
+        </area>
+      </filter>
+      <filter type="sru_z3950">
+        <stylesheet>/xsl/sru.xsl</stylesheet>
+        <database name="Default">
+         <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
+                     href="explain.xml"/>
+       </database>
+      </filter>
+      <filter type="cql_rpn">
+        <conversion file="cql2pqf.txt"/>
+      </filter>
+      <filter type="log">
+         <category access="false" line="true" apdu="false" />
+        <message>F</message>
+      </filter>
+      <filter type="xquery">
+       <elementset name="bibframe" backend="marcxml"/>
+       <script name="/home/adam/proj/marc2bibframe/xbin/zorba3-0.xqy"/>
+       <record name="marcxmluri"/>
+       <variable name="serialization" value="rdxml"/>
+       <variable name="baseuri" value="http://base/"/>
+      </filter>
+      <filter type="record_transform">
+       <retrievalinfo  xmlns="http://indexdata.com/yaz" version="1.0">
+         <retrieval syntax="usmarc" name="F"/>
+         <retrieval syntax="usmarc" name="B"/>
+         <retrieval syntax="xml" name="marcxml"
+                    identifier="info:srw/schema/1/marcxml-v1.1">
+           <backend syntax="usmarc" name="F">
+             <marc inputformat="marc" outputformat="marcxml"
+                   inputcharset="marc-8" outputcharset="utf-8"/>
+           </backend>
+         </retrieval>
+       </retrievalinfo>
+      </filter>
+      <filter type="virt_db">
+       <virtual>
+         <database>Default</database>
+         <target>z3950.loc.gov:7090/voyager</target>
+       </virtual>
+      </filter>
+      <filter type="log">
+       <category access="false" line="true" apdu="false" />
+        <message>B</message>
+      </filter>
+      <filter type="z3950_client">
+      </filter>
+      <filter type="bounce"/>
+    </route>
+  </routes>
+</metaproxy>
+
diff --git a/bibframe/cql2pqf.txt b/bibframe/cql2pqf.txt
new file mode 100644 (file)
index 0000000..f61d3dd
--- /dev/null
@@ -0,0 +1,85 @@
+
+# Propeties file to drive org.z3950.zing.cql.CQLNode's toPQF()
+# back-end and the YAZ CQL-to-PQF converter.  This specifies the
+# interpretation of various CQL indexes, relations, etc. in terms
+# of Type-1 query attributes.
+#
+# This file is created from a valid ZeeRex Explain XML record using the 
+# XSLT transformation 'explain2cqlpqftxt.xsl'
+#
+# xsltproc explain2cqlpqf.xsl explain.xml
+    
+
+# Title: Metaproxy SRU explain record
+
+# Set info
+# Default set
+set = info:srw/cql-context-set/1/cql-v1.1
+
+set.cql = info:srw/cql-context-set/1/cql-v1.1
+set.rec = info:srw/cql-context-set/2/rec-1.0
+set.dc = info:srw/cql-context-set/1/dc-v1.1
+set.bib1 = 1.2.840.10003.3.1
+
+# Index info
+index.cql.serverChoice = 1=1010 
+index.cql.all = 1=1010 
+index.rec.id = 1=12 4=3 
+index.dc.title = 1=4 
+index.dc.creator = 1=1003 
+index.dc.subject = 1=47 
+index.dc.description = 1=62 
+index.dc.publisher = 1=1018 
+index.dc.contributor = 1=1003 
+index.dc.date = 1=30 
+index.dc.type = 1=1034 
+index.dc.format = 1=1013 
+index.dc.identifier = 1=7 
+index.dc.source = 1=1019 
+
+# Relation info
+relation.<  = 2=1
+relation.eq  = 2=3
+relation.>  = 2=5
+
+
+# Default Relation
+relation.scr = 2=3
+
+# RelationModifier info
+
+
+# Position attributes 
+position.first                          = 3=1 6=1
+position.any                            = 3=3 6=1
+position.last                           = 3=4 6=1
+position.firstAndLast                   = 3=3 6=3
+
+# Structure attributes may be specified for individual relations; a
+# default structure attribute my be specified by the pseudo-relation
+# "*", to be used whenever a relation not listed here occurs.
+#
+structure.exact                         = 4=108
+structure.all                           = 4=2
+structure.any                           = 4=2
+structure.*                             = 4=1
+structure.eq                            = 4=3
+
+# Truncation attributes used to implement CQL wildcard patterns.  The
+# simpler forms, left, right- and both-truncation will be used for the
+# simplest patterns, so that we produce PQF queries that conform more
+# closely to the Bath Profile.  However, when a more complex pattern
+# such as "foo*bar" is used, we fall back on Z39.58-style masking.
+#
+truncation.right                        = 5=1
+truncation.left                         = 5=2
+truncation.both                         = 5=3
+truncation.none                         = 5=100
+truncation.z3958                        = 5=104
+
+# Finally, any additional attributes that should always be included
+# with each term can be specified in the "always" property.
+#
+# always                                        = 6=1
+# 6=1: completeness = incomplete subfield
+    
\ No newline at end of file
diff --git a/bibframe/explain.xml b/bibframe/explain.xml
new file mode 100644 (file)
index 0000000..42c1c72
--- /dev/null
@@ -0,0 +1,245 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+
+<!-- this file configures the SRU/SRW explain response -->
+<!-- see: http://explain.z3950.org/dtd/commentary.html -->
+<!-- validate this using zeerex-2.0.xsd -->
+<!-- Extensions see: http://explain.z3950.org/dtd/extensions.html -->
+
+<explain xmlns="http://explain.z3950.org/dtd/2.0/">
+
+  <serverInfo protocol="SRU">
+    <host>foo.somehost.somewhere</host>
+    <port>9000</port>
+    <database>Default</database>
+  </serverInfo>
+
+  <databaseInfo>
+    <title lang="en" primary="true">Metaproxy SRU explain record</title>
+    <description lang="en" primary="true">
+      Some description of this service
+    </description>
+    <author>Index Data, http://www.indexdata.com</author>
+    <contact>Index Data, info(at)indexdata(dot)com</contact>
+  </databaseInfo>
+
+  <indexInfo>
+    <set name="cql" identifier="info:srw/cql-context-set/1/cql-v1.1">
+      <title>CQL Standard Set</title>
+    </set>
+    <set name="rec" identifier="info:srw/cql-context-set/2/rec-1.0">
+      <title>Record Standard Set</title>
+    </set>
+    <set name="dc" identifier="info:srw/cql-context-set/1/dc-v1.1">
+      <title>Dublin Core Set</title>
+    </set>
+    <set name="bib1" identifier="1.2.840.10003.3.1">
+      <title>BIB-1 Z39.50 Standard Set</title>
+    </set>
+
+    <!-- CQL standard index -->
+    <index search="true" scan="true" sort="false">
+      <title lang="en">CQL Server Choice</title>
+      <map><name set="cql">serverChoice</name></map>
+      <map>
+        <attr type="1" set="bib1">1010</attr>
+      </map>
+    </index>
+    <index search="true" scan="true" sort="false">
+      <title lang="en">CQL All</title>
+      <map><name set="cql">all</name></map>
+      <map>
+        <attr type="1" set="bib1">1010</attr>
+      </map>
+    </index>
+
+    <!-- Record ID index -->
+    <index search="true" scan="true" sort="false">
+      <title lang="en">Record ID</title>
+      <map><name set="rec">id</name></map>
+      <map>
+        <attr type="1" set="bib1">12</attr>
+        <attr type="4" set="bib1">3</attr>
+      </map>
+    </index>
+
+    <!-- Dublin Core Indexes -->
+    <index search="true" scan="true" sort="false">
+      <title lang="en">DC Title</title>
+      <map><name set="dc">title</name></map>
+      <map>
+        <attr type="1" set="bib1">4</attr>
+      </map>
+    </index>
+    <index search="true" scan="true" sort="false">
+      <title lang="en">DC Creator</title>
+      <map><name set="dc">creator</name></map>
+      <map>
+        <attr type="1" set="bib1">1003</attr>
+      </map>
+    </index>
+    <index search="true" scan="true" sort="false">
+      <title lang="en">DC Subject</title>
+      <map><name set="dc">subject</name></map>
+      <map>
+        <attr type="1" set="bib1">47</attr>
+      </map>
+    </index>
+    <index search="true" scan="true" sort="false">
+      <title lang="en">DC Description</title>
+      <map><name set="dc">description</name></map>
+      <map>
+        <attr type="1" set="bib1">62</attr>
+      </map>
+    </index>
+    <index search="true" scan="true" sort="false">
+      <title lang="en">DC Publisher</title>
+      <map><name set="dc">publisher</name></map>
+      <map>
+        <attr type="1" set="bib1">1018</attr>
+      </map>
+    </index>
+    <index search="true" scan="true" sort="false">
+      <title lang="en">DC Contributor</title>
+      <map><name set="dc">contributor</name></map>
+      <map>
+        <attr type="1" set="bib1">1003</attr>
+      </map>
+    </index>
+    <index search="true" scan="true" sort="false">
+      <title lang="en">DC Date</title>
+      <map><name set="dc">date</name></map>
+      <map>
+        <attr type="1" set="bib1">30</attr>
+      </map>
+    </index>
+    <index search="true" scan="true" sort="false">
+      <title lang="en">DC Type</title>
+      <map><name set="dc">type</name></map>
+      <map>
+        <attr type="1" set="bib1">1034</attr>
+      </map>
+    </index>
+    <index search="true" scan="true" sort="false">
+      <title lang="en">DC Format</title>
+      <map><name set="dc">format</name></map>
+      <map>
+        <attr type="1" set="bib1">1013</attr>
+      </map>
+    </index>
+    <index search="true" scan="true" sort="false">
+      <title lang="en">DC Identifier</title>
+      <map><name set="dc">identifier</name></map>
+      <map>
+        <attr type="1" set="bib1">7</attr>
+      </map>
+    </index>
+    <index search="true" scan="true" sort="false">
+      <title lang="en">DC Source</title>
+      <map><name set="dc">source</name></map>
+      <map>
+        <attr type="1" set="bib1">1019</attr>
+      </map>
+    </index>
+    <!--
+    <index search="true" scan="true" sort="false">
+      <title lang="en">DC Language</title>
+      <map><name set="dc">language</name></map>
+      <map>
+        <attr type="1" set="bib1">54</attr>
+      </map>
+    </index>
+    <index search="true" scan="true" sort="false">
+      <title lang="en">DC Relation</title>
+      <map><name set="dc">relation</name></map>
+      <map>
+        <attr type="1" set="bib1">1026</attr>
+      </map>
+    </index>
+    <index search="true" scan="true" sort="false">
+      <title lang="en">DC Coverage</title>
+      <map><name set="dc">coverage</name></map>
+      <map>
+        <attr type="1" set="bib1">58</attr>
+      </map>
+    </index>
+    <index search="true" scan="true" sort="false">
+      <title lang="en">DC Rights</title>
+      <map><name set="dc">rights</name></map>
+      <map>
+        <attr type="1" set="bib1">dc:rights</attr>
+      </map>
+    </index>
+    -->
+  </indexInfo>
+
+  <schemaInfo>
+    <schema identifier="info:srw/schema/1/marcxml-v1.1"
+            location="http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"
+            name="marcxml"
+            retrieve="true">
+      <title lang="en">MARCXML</title>
+    </schema>
+    <schema identifier="http://www.loc.gov/zing/srw/bibframe"
+            name="bibframe"
+            retrieve="true">
+      <title lang="en">BIBFRAME</title>
+    </schema>
+  </schemaInfo>
+
+
+  <configInfo>
+
+    <!-- searchRetrieve settings -->
+    <default type="contextSet">cql</default>
+    <default type="index">all</default>
+    <default type="relation">=</default>
+    <supports type="relation">&lt;</supports> <!-- 2=1 OK -->
+    <supports type="relation">&lt;=</supports> <!-- 2=2 OK -->
+    <supports type="relation">=</supports> <!-- 2=3 OK -->
+    <supports type="relation">&gt;=</supports> <!-- 2=4 OK -->
+    <supports type="relation">&gt;</supports> <!-- 2=5 OK -->
+    <!--<supports type="relationModifier">relevant</supports> --><!-- 2=102 -->
+    <!--<supports type="relationModifier">phonetic</supports> --><!-- 2=100 -->
+    <!--<supports type="relationModifier">stem</supports> --><!-- 2=101  -->
+
+    <!-- <supports type="proximity"></supports> -->
+          <!-- title = (house prox/distance=1/unit=word  the) -->
+    <!-- proximity modifier supported by the server or index
+         (relation, distance, unit, ordering) -->
+    <!-- <supports type="proximityModifier"></supports> -->
+    <!-- boolean modifier supported by the server or index -->
+    <!-- <supports type="booleanModifier"></supports> -->
+    <supports type="maskingCharacter">*</supports>
+    <supports type="maskingCharacter">?</supports>
+    <supports type="emptyTerm"></supports>
+
+    <!-- sorting settings -->
+    <!-- <supports type="sort"></supports> -->
+    <!-- supported sortmodifier (ascending, missingValue, caseSensitive) -->
+    <!-- <supports type="sortModifier"></supports> -->
+
+    <!-- presentation settings -->
+    <default type="numberOfRecords">0</default>
+    <default type="retrieveSchema">dc</default>
+    <default type="recordPacking">xml</default>
+
+    <setting type="stylesheet">/xsl/sru.xsl</setting>
+    <!-- <setting type="maximumRecords">1000</setting> -->
+    <!-- <supports type="resultSets"></supports>  -->
+
+    <!-- scan settings -->
+
+    <!-- scan operation supported -->
+    <supports type="scan"></supports>
+    <default type="numberOfTerms">20</default>
+
+    <!-- other server settings -->
+    <!-- <supports type="version">1.1</supports> -->
+    <setting type="resultSetTTL">0</setting>
+    <!-- <supports type="extraSearchData"></supports> -->
+    <!-- <supports type="extraExplainData"></supports> -->
+    <!-- <supports type="profile"></supports> -->
+  </configInfo>
+
+</explain>
diff --git a/bibframe/xsl/sru.xsl b/bibframe/xsl/sru.xsl
new file mode 100644 (file)
index 0000000..2a0ccf1
--- /dev/null
@@ -0,0 +1,216 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:srw="http://www.loc.gov/zing/srw/"
+                xmlns:dc="http://www.loc.gov/zing/srw/dcschema/v1.0/"
+                xmlns:zr="http://explain.z3950.org/dtd/2.0/"
+                xmlns:diag="http://www.loc.gov/zing/srw/diagnostic/"
+                version="1.0">
+
+  <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
+
+  <xsl:template match="text()"/>
+
+  <xsl:template match="/">
+    <xsl:call-template name="html"/>
+  </xsl:template>
+
+  <xsl:template name="html">
+    <html>
+      <head>
+        <title>
+          <xsl:value-of select="//zr:explain/zr:databaseInfo/zr:title"/>
+        </title>
+        <link href="css.css" rel="stylesheet"
+              type="text/css" media="screen, all"/>
+      </head>
+      <body>
+        <div class="body">
+          <xsl:apply-templates/>
+        </div>
+      </body>
+    </html>
+  </xsl:template>
+
+  <xsl:template match="zr:explain">
+    <xsl:call-template name="dbinfo"/>
+    <xsl:call-template name="diagnostic"/>
+    <xsl:call-template name="indexinfo"/>
+    <xsl:call-template name="relationinfo"/>
+    <xsl:call-template name="searchform"/>
+  </xsl:template>
+
+  <xsl:template match="srw:searchRetrieveResponse">
+    <h2>Search Results</h2>
+    <xsl:call-template name="diagnostic"/>
+    <xsl:call-template name="displaysearch"/>
+  </xsl:template>
+
+  <xsl:template name="dbinfo">
+    <div class="dbinfo">
+      <h1><xsl:value-of select="//zr:explain/zr:databaseInfo/zr:title"/>
+      </h1>
+      <h2><xsl:value-of select="//zr:explain/zr:databaseInfo/zr:description"/>
+      </h2>
+      <h4>
+        <xsl:value-of select="//zr:explain/zr:databaseInfo/zr:author"/>
+        <br/>
+        <xsl:value-of select="//zr:explain/zr:databaseInfo/zr:history"/>
+      </h4>
+    </div>
+  </xsl:template>
+
+  <xsl:template name="searchform">
+    <div class="searchform">
+      <form name="searchform"  method="get"> <!-- action=".." -->
+        <input type="hidden" name="version" value="1.1"/>
+        <input type="hidden" name="operation" value="searchRetrieve"/>
+        <div class="query">
+          <input type="text" name="query"/>
+        </div>
+        <div class="parameters">
+          <xsl:text>startRecord: </xsl:text>
+          <input type="text" name="startRecord" value="1"/>
+          <xsl:text> maximumRecords: </xsl:text>
+          <input type="text" name="maximumRecords" value="5"/>
+          <xsl:text> recordSchema: </xsl:text>
+          <select name="recordSchema">
+          <xsl:for-each select="//zr:schemaInfo/zr:schema">
+            <option value="{@name}">
+              <xsl:value-of select="zr:title"/>
+            </option>
+          </xsl:for-each>
+          </select>
+          <xsl:text> recordPacking: </xsl:text>
+          <select name="recordPacking">
+            <option value="string">string</option>
+            <option value="xml">XML</option>
+          </select>
+          <xsl:text> stylesheet: </xsl:text>
+          <select name="stylesheet">
+            <option value="/xsl/sru.xsl">SRU</option>
+            <option value="">NONE</option>
+          </select>
+        </div>
+
+        <div class="submit">
+          <input type="submit" value="Send Search Request"/>
+        </div>
+      </form>
+    </div>
+  </xsl:template>
+
+  <xsl:template name="indexinfo">
+     <div class="dbinfo">
+       <xsl:for-each
+          select="//zr:indexInfo/zr:index[zr:map/zr:name/@set]">
+        <xsl:variable name="index">
+          <xsl:value-of select="zr:map/zr:name/@set"/>
+          <xsl:text>.</xsl:text>
+          <xsl:value-of select="zr:map/zr:name/text()"/>
+        </xsl:variable>
+        <b><xsl:value-of select="$index"/><br/></b>
+      </xsl:for-each>
+     </div>
+  </xsl:template>
+
+
+  <xsl:template name="relationinfo">
+    <!--
+      <xsl:variable name="defrel"
+                    select="//zr:configInfo/zr:default[@type='relation']"/>
+      <b><xsl:value-of select="$defrel"/><br/></b>
+      -->
+      <xsl:for-each select="//zr:configInfo/zr:supports[@type='relation']">
+        <xsl:variable name="rel" select="text()"/>
+        <b><xsl:value-of select="$rel"/><br/></b>
+      </xsl:for-each>
+  </xsl:template>
+
+
+  <!-- diagnostics -->
+  <xsl:template name="diagnostic">
+    <xsl:for-each select="//diag:diagnostic">
+     <div class="diagnostic">
+        <!-- <xsl:value-of select="diag:uri"/> -->
+        <xsl:text> </xsl:text>
+        <xsl:value-of select="diag:message"/>
+        <xsl:text>: </xsl:text>
+        <xsl:value-of select="diag:details"/>
+      </div>
+    </xsl:for-each>
+  </xsl:template>
+
+  <xsl:template name="displaysearch">
+    <div class="searchresults">
+      <xsl:for-each select="srw:numberOfRecords">
+        <h4>
+          <xsl:text>Number of Records: </xsl:text>
+          <xsl:value-of select="."/>
+        </h4>
+      </xsl:for-each>
+      <xsl:for-each select="srw:nextRecordPosition">
+        <h4>
+          <xsl:text>Next Record Position: </xsl:text>
+          <xsl:value-of select="."/>
+         </h4>
+      </xsl:for-each>
+
+      <xsl:for-each select="srw:records">
+        <xsl:for-each select="srw:record">
+          <div class="record">
+            <p>
+              <xsl:text>Record: </xsl:text>
+              <xsl:value-of select="srw:recordPosition"/>
+              <xsl:text> : </xsl:text>
+              <xsl:value-of select="srw:recordSchema"/>
+              <xsl:text> : </xsl:text>
+              <xsl:value-of select="srw:recordPacking"/>
+            </p>
+            <p>
+              <pre>
+                <xsl:value-of select="srw:recordData"/>
+              </pre>
+            </p>
+          </div>
+        </xsl:for-each>
+      </xsl:for-each>
+    </div>
+  </xsl:template>
+
+  <xsl:template name="displayscan">
+    <div class="scanresults">
+
+      <xsl:for-each select="srw:terms">
+        <xsl:for-each select="srw:term">
+          <div class="term">
+
+              <!-- <xsl:text>Term: </xsl:text> -->
+              <xsl:for-each select="srw:displayTerm">
+                <xsl:value-of select="."/>
+                <xsl:text> : </xsl:text>
+              </xsl:for-each>
+
+              <xsl:for-each select="srw:value">
+                <xsl:value-of select="."/>
+              </xsl:for-each>
+
+              <xsl:for-each select="srw:numberOfRecords">
+                <xsl:text> (</xsl:text>
+                <xsl:value-of select="."/>
+                <xsl:text>)</xsl:text>
+              </xsl:for-each>
+
+              <xsl:for-each select="srw:extraTermData">
+                <xsl:text> - </xsl:text>
+                <xsl:value-of select="."/>
+              </xsl:for-each>
+
+          </div>
+        </xsl:for-each>
+      </xsl:for-each>
+
+    </div>
+  </xsl:template>
+
+
+</xsl:stylesheet>