Description of systag. Adam's and Mike's versions both here.
[idzebra-moved-to-github.git] / doc / recordmodel.xml
1  <chapter id="record-model">
2   <!-- $Id: recordmodel.xml,v 1.15 2002-12-03 16:40:17 adam Exp $ -->
3   <title>The Record Model</title>
4   
5   <para>
6    The Zebra system is designed to support a wide range of data management
7    applications. The system can be configured to handle virtually any
8    kind of structured data. Each record in the system is associated with
9    a <emphasis>record schema</emphasis> which lends context to the data
10    elements of the record.
11    Any number of record schemas can coexist in the system.
12    Although it may be wise to use only a single schema within
13    one database, the system poses no such restrictions.
14   </para>
15
16   <para>
17    The record model described in this chapter applies to the fundamental,
18    structured
19    record type <literal>grs</literal>, introduced in
20    <xref linkend="record-types"/>.
21    <!--
22    FIXME - Need to describe the simple string-tag model, or at least 
23    refer to it here. -H
24    -->
25   </para>
26
27   <para>
28    Records pass through three different states during processing in the
29    system.
30   </para>
31
32   <para>
33
34    <itemizedlist>
35     <listitem>
36      
37      <para>
38       When records are accessed by the system, they are represented
39       in their local, or native format. This might be SGML or HTML files,
40       News or Mail archives, MARC records. If the system doesn't already
41       know how to read the type of data you need to store, you can set up an
42       input filter by preparing conversion rules based on regular
43       expressions and possibly augmented by a flexible scripting language
44       (Tcl).
45       The input filter produces as output an internal representation,
46       a tree structure.
47
48      </para>
49     </listitem>
50     <listitem>
51
52      <para>
53       When records are processed by the system, they are represented
54       in a tree-structure, constructed by tagged data elements hanging off a
55       root node. The tagged elements may contain data or yet more tagged
56       elements in a recursive structure. The system performs various
57       actions on this tree structure (indexing, element selection, schema
58       mapping, etc.),
59
60      </para>
61     </listitem>
62     <listitem>
63
64      <para>
65       Before transmitting records to the client, they are first
66       converted from the internal structure to a form suitable for exchange
67       over the network - according to the Z39.50 standard.
68      </para>
69     </listitem>
70
71    </itemizedlist>
72
73   </para>
74
75   <sect1 id="local-representation">
76    <title>Local Representation</title>
77
78    <para>
79     As mentioned earlier, Zebra places few restrictions on the type of
80     data that you can index and manage. Generally, whatever the form of
81     the data, it is parsed by an input filter specific to that format, and
82     turned into an internal structure that Zebra knows how to handle. This
83     process takes place whenever the record is accessed - for indexing and
84     retrieval.
85    </para>
86
87    <para>
88     The RecordType parameter in the <literal>zebra.cfg</literal> file, or
89     the <literal>-t</literal> option to the indexer tells Zebra how to
90     process input records.
91     Two basic types of processing are available - raw text and structured
92     data. Raw text is just that, and it is selected by providing the
93     argument <emphasis>text</emphasis> to Zebra. Structured records are
94     all handled internally using the basic mechanisms described in the
95     subsequent sections.
96     Zebra can read structured records in many different formats.
97     How this is done is governed by additional parameters after the
98     "grs" keyword, separated by "." characters.
99    </para>
100
101    <para>
102     Four basic subtypes to the <emphasis>grs</emphasis> type are
103     currently available:
104    </para>
105
106    <para>
107     <variablelist>
108      <varlistentry>
109       <term>grs.sgml</term>
110       <listitem>
111        <para>
112         This is the canonical input format &mdash;
113         described below. It is a simple SGML-like syntax.
114        </para>
115       </listitem>
116      </varlistentry>
117      <varlistentry>
118       <term>grs.regx.<emphasis>filter</emphasis></term>
119       <listitem>
120        <para>
121         This enables a user-supplied input
122         filter. The mechanisms of these filters are described below.
123        </para>
124       </listitem>
125      </varlistentry>
126      <varlistentry>
127       <term>grs.tcl.<emphasis>filter</emphasis></term>
128       <listitem>
129        <para>
130         Similar to grs.regx but using Tcl for rules.
131        </para>
132       </listitem>
133      </varlistentry>
134      <varlistentry>
135       <term>grs.marc.<emphasis>abstract syntax</emphasis></term>
136       <listitem>
137        <para>
138         This allows Zebra to read
139         records in the ISO2709 (MARC) encoding standard. In this case, the
140         last parameter <emphasis>abstract syntax</emphasis> names the
141         <literal>.abs</literal> file (see below)
142         which describes the specific MARC structure of the input record as
143         well as the indexing rules.
144        </para>
145       </listitem>
146      </varlistentry>
147      <varlistentry>
148       <term>grs.xml</term>
149       <listitem>
150        <para>
151         This filter reads XML records. Only one record per file
152         is supported. The filter is only available if Zebra/YAZ
153         is compiled with EXPAT support.
154        </para>
155       </listitem>
156      </varlistentry>
157
158     </variablelist>
159    </para>
160
161    <sect2>
162     <title>Canonical Input Format</title>
163
164     <para>
165      Although input data can take any form, it is sometimes useful to
166      describe the record processing capabilities of the system in terms of
167      a single, canonical input format that gives access to the full
168      spectrum of structure and flexibility in the system. In Zebra, this
169      canonical format is an "SGML-like" syntax.
170     </para>
171
172     <para>
173      To use the canonical format specify <literal>grs.sgml</literal> as
174      the record type.
175     </para>
176
177     <para>
178      Consider a record describing an information resource (such a record is
179      sometimes known as a <emphasis>locator record</emphasis>).
180      It might contain a field describing the distributor of the
181      information resource, which might in turn be partitioned into
182      various fields providing details about the distributor, like this:
183     </para>
184
185     <para>
186
187      <screen>
188       &#60;Distributor&#62;
189         &#60;Name&#62; USGS/WRD &#60;/Name&#62;
190         &#60;Organization&#62; USGS/WRD &#60;/Organization&#62;
191         &#60;Street-Address&#62;
192           U.S. GEOLOGICAL SURVEY, 505 MARQUETTE, NW
193         &#60;/Street-Address&#62;
194         &#60;City&#62; ALBUQUERQUE &#60;/City&#62;
195         &#60;State&#62; NM &#60;/State&#62;
196         &#60;Zip-Code&#62; 87102 &#60;/Zip-Code&#62;
197         &#60;Country&#62; USA &#60;/Country&#62;
198         &#60;Telephone&#62; (505) 766-5560 &#60;/Telephone&#62;
199       &#60;/Distributor&#62;
200      </screen>
201
202     </para>
203
204     <!-- There is no indentation in the example above!  -H
205     -note-
206      -para-
207       The indentation used above is used to illustrate how Zebra
208       interprets the mark-up. The indentation, in itself, has no
209       significance to the parser for the canonical input format, which
210       discards superfluous whitespace.
211      -/para-
212     -/note-
213     -->
214
215     <para>
216      The keywords surrounded by &lt;...&gt; are
217      <emphasis>tags</emphasis>, while the sections of text
218      in between are the <emphasis>data elements</emphasis>.
219      A data element is characterized by its location in the tree
220      that is made up by the nested elements.
221      Each element is terminated by a closing tag - beginning
222      with <literal>&#60;</literal>/, and containing the same symbolic
223      tag-name as the corresponding opening tag.
224      The general closing tag - <literal>&lt;/&gt;</literal> -
225      terminates the element started by the last opening tag. The
226      structuring of elements is significant.
227      The element <emphasis>Telephone</emphasis>,
228      for instance, may be indexed and presented to the client differently,
229      depending on whether it appears inside the
230      <emphasis>Distributor</emphasis> element, or some other,
231      structured data element such a <emphasis>Supplier</emphasis> element.
232     </para>
233
234     <sect3>
235      <title>Record Root</title>
236
237      <para>
238       The first tag in a record describes the root node of the tree that
239       makes up the total record. In the canonical input format, the root tag
240       should contain the name of the schema that lends context to the
241       elements of the record
242       (see <xref linkend="internal-representation"/>).
243       The following is a GILS record that
244       contains only a single element (strictly speaking, that makes it an
245       illegal GILS record, since the GILS profile includes several mandatory
246       elements - Zebra does not validate the contents of a record against
247       the Z39.50 profile, however - it merely attempts to match up elements
248       of a local representation with the given schema):
249      </para>
250
251      <para>
252
253       <screen>
254        &#60;gils&#62;
255           &#60;title&#62;Zen and the Art of Motorcycle Maintenance&#60;/title&#62;
256        &#60;/gils&#62;
257       </screen>
258
259      </para>
260
261     </sect3>
262
263     <sect3><!-- ### we shouldn't make such a big deal about this -->
264      <title>Variants</title>
265
266      <para>
267       Zebra allows you to provide individual data elements in a number of
268       <emphasis>variant forms</emphasis>. Examples of variant forms are
269       textual data elements which might appear in different languages, and
270       images which may appear in different formats or layouts.
271       The variant system in Zebra is essentially a representation of
272       the variant mechanism of Z39.50-1995.
273      </para>
274
275      <para>
276       The following is an example of a title element which occurs in two
277       different languages.
278      </para>
279
280      <para>
281
282       <screen>
283        &#60;title&#62;
284        &#60;var lang lang "eng"&#62;
285        Zen and the Art of Motorcycle Maintenance&#60;/&#62;
286        &#60;var lang lang "dan"&#62;
287        Zen og Kunsten at Vedligeholde en Motorcykel&#60;/&#62;
288        &#60;/title&#62;
289       </screen>
290
291      </para>
292
293      <para>
294       The syntax of the <emphasis>variant element</emphasis> is
295       <literal>&lt;var class type value&gt;</literal>.
296       The available values for the <emphasis>class</emphasis> and
297       <emphasis>type</emphasis> fields are given by the variant set
298       that is associated with the current schema
299       (see <xref linkend="variant-set"/>).
300      </para>
301
302      <para>
303       Variant elements are terminated by the general end-tag &#60;/&#62;, by
304       the variant end-tag &#60;/var&#62;, by the appearance of another variant
305       tag with the same <emphasis>class</emphasis> and
306       <emphasis>value</emphasis> settings, or by the
307       appearance of another, normal tag. In other words, the end-tags for
308       the variants used in the example above could have been omitted.
309      </para>
310
311      <para>
312       Variant elements can be nested. The element
313      </para>
314
315      <para>
316
317       <screen>
318        &#60;title&#62;
319        &#60;var lang lang "eng"&#62;&#60;var body iana "text/plain"&#62;
320        Zen and the Art of Motorcycle Maintenance
321        &#60;/title&#62;
322       </screen>
323
324      </para>
325
326      <para>
327       Associates two variant components to the variant list for the title
328       element.
329      </para>
330
331      <para>
332       Given the nesting rules described above, we could write
333      </para>
334
335      <para>
336
337       <screen>
338        &#60;title&#62;
339        &#60;var body iana "text/plain&#62;
340        &#60;var lang lang "eng"&#62;
341        Zen and the Art of Motorcycle Maintenance
342        &#60;var lang lang "dan"&#62;
343        Zen og Kunsten at Vedligeholde en Motorcykel
344        &#60;/title&#62;
345       </screen>
346
347      </para>
348
349      <para>
350       The title element above comes in two variants. Both have the IANA body
351       type "text/plain", but one is in English, and the other in
352       Danish. The client, using the element selection mechanism of Z39.50,
353       can retrieve information about the available variant forms of data
354       elements, or it can select specific variants based on the requirements
355       of the end-user.
356      </para>
357
358     </sect3>
359
360    </sect2>
361
362    <sect2>
363     <title>Input Filters</title>
364
365     <para>
366      In order to handle general input formats, Zebra allows the
367      operator to define filters which read individual records in their
368      native format and produce an internal representation that the system
369      can work with.
370     </para>
371
372     <para>
373      Input filters are ASCII files, generally with the suffix
374      <literal>.flt</literal>.
375      The system looks for the files in the directories given in the
376      <emphasis>profilePath</emphasis> setting in the
377      <literal>zebra.cfg</literal> files.
378      The record type for the filter is
379      <literal>grs.regx.</literal><emphasis>filter-filename</emphasis>
380      (fundamental type <literal>grs</literal>, file read
381      type <literal>regx</literal>, argument
382      <emphasis>filter-filename</emphasis>).
383     </para>
384     
385     <para>
386      Generally, an input filter consists of a sequence of rules, where each
387      rule consists of a sequence of expressions, followed by an action. The
388      expressions are evaluated against the contents of the input record,
389      and the actions normally contribute to the generation of an internal
390      representation of the record.
391     </para>
392     
393     <para>
394      An expression can be either of the following:
395     </para>
396
397     <para>
398      <variablelist>
399
400       <varlistentry>
401        <term>INIT</term>
402        <listitem>
403         <para>
404          The action associated with this expression is evaluated
405          exactly once in the lifetime of the application, before any records
406          are read. It can be used in conjunction with an action that
407          initializes tables or other resources that are used in the processing
408          of input records.
409         </para>
410        </listitem>
411       </varlistentry>
412       <varlistentry>
413        <term>BEGIN</term>
414        <listitem>
415         <para>
416          Matches the beginning of the record. It can be used to
417          initialize variables, etc. Typically, the
418          <emphasis>BEGIN</emphasis> rule is also used
419          to establish the root node of the record.
420         </para>
421        </listitem>
422       </varlistentry>
423       <varlistentry>
424        <term>END</term>
425        <listitem>
426         <para>
427          Matches the end of the record - when all of the contents
428          of the record has been processed.
429         </para>
430        </listitem>
431       </varlistentry>
432       <varlistentry>
433        <term>/pattern/</term>
434        <listitem>
435         <para>
436          Matches a string of characters from the input record.
437         </para>
438        </listitem>
439       </varlistentry>
440       <varlistentry>
441        <term>BODY</term>
442        <listitem>
443         <para>
444          This keyword may only be used between two patterns.
445          It matches everything between (not including) those patterns.
446         </para>
447        </listitem>
448       </varlistentry>
449       <varlistentry>
450        <term>FINISH</term>
451        <listitem>
452         <para>
453          The expression associated with this pattern is evaluated
454          once, before the application terminates. It can be used to release
455          system resources - typically ones allocated in the
456          <emphasis>INIT</emphasis> step.
457         </para>
458        </listitem>
459       </varlistentry>
460      </variablelist>
461     </para>
462
463     <para>
464      An action is surrounded by curly braces ({...}), and
465      consists of a sequence of statements. Statements may be separated
466      by newlines or semicolons (;).
467      Within actions, the strings that matched the expressions
468      immediately preceding the action can be referred to as
469      $0, $1, $2, etc.
470     </para>
471
472     <para>
473      The available statements are:
474     </para>
475
476     <para>
477      <variablelist>
478
479       <varlistentry>
480        <term>begin <emphasis>type [parameter ... ]</emphasis></term>
481        <listitem>
482         <para>
483          Begin a new
484          data element. The type is one of the following:
485          <variablelist>
486           
487           <varlistentry>
488            <term>record</term>
489            <listitem>
490             <para>
491              Begin a new record. The following parameter should be the
492              name of the schema that describes the structure of the record, eg.
493              <literal>gils</literal> or <literal>wais</literal> (see below).
494              The <literal>begin record</literal> call should precede
495              any other use of the <emphasis>begin</emphasis> statement.
496             </para>
497            </listitem>
498           </varlistentry>
499           <varlistentry>
500            <term>element</term>
501            <listitem>
502             <para>
503              Begin a new tagged element. The parameter is the
504              name of the tag. If the tag is not matched anywhere in the tagsets
505              referenced by the current schema, it is treated as a local string
506              tag.
507             </para>
508            </listitem>
509           </varlistentry>
510           <varlistentry>
511            <term>variant</term>
512            <listitem>
513             <para>
514              Begin a new node in a variant tree. The parameters are
515              <emphasis>class type value</emphasis>.
516             </para>
517            </listitem>
518           </varlistentry>
519          </variablelist>
520         </para>
521        </listitem>
522       </varlistentry>
523       <varlistentry>
524        <term>data</term>
525        <listitem>
526         <para>
527          Create a data element. The concatenated arguments make
528          up the value of the data element.
529          The option <literal>-text</literal> signals that
530          the layout (whitespace) of the data should be retained for
531          transmission.
532          The option <literal>-element</literal>
533          <emphasis>tag</emphasis> wraps the data up in
534          the <emphasis>tag</emphasis>.
535          The use of the <literal>-element</literal> option is equivalent to
536          preceding the command with a <emphasis>begin
537           element</emphasis> command, and following
538          it with the <emphasis>end</emphasis> command.
539         </para>
540        </listitem>
541       </varlistentry>
542       <varlistentry>
543        <term>end <emphasis>[type]</emphasis></term>
544        <listitem>
545         <para>
546          Close a tagged element. If no parameter is given,
547          the last element on the stack is terminated.
548          The first parameter, if any, is a type name, similar
549          to the <emphasis>begin</emphasis> statement.
550          For the <emphasis>element</emphasis> type, a tag
551          name can be provided to terminate a specific tag.
552         </para>
553        </listitem>
554       </varlistentry>
555      </variablelist>
556     </para>
557
558     <para>
559      The following input filter reads a Usenet news file, producing a
560      record in the WAIS schema. Note that the body of a news posting is
561      separated from the list of headers by a blank line (or rather a
562      sequence of two newline characters.
563     </para>
564
565     <para>
566
567      <screen>
568       BEGIN                { begin record wais }
569
570       /^From:/ BODY /$/    { data -element name $1 }
571       /^Subject:/ BODY /$/ { data -element title $1 }
572       /^Date:/ BODY /$/    { data -element lastModified $1 }
573       /\n\n/ BODY END      {
574       begin element bodyOfDisplay
575       begin variant body iana "text/plain"
576       data -text $1
577       end record
578       }
579      </screen>
580
581     </para>
582
583     <para>
584      If Zebra is compiled with support for Tcl (Tool Command Language)
585      enabled, the statements described above are supplemented with a complete
586      scripting environment, including control structures (conditional
587      expressions and loop constructs), and powerful string manipulation
588      mechanisms for modifying the elements of a record. Tcl is a popular
589      scripting environment, with several tutorials available both online
590      and in hardcopy.
591     </para>
592
593    </sect2>
594
595   </sect1>
596
597   <sect1 id="internal-representation">
598    <title>Internal Representation</title>
599
600    <para>
601     When records are manipulated by the system, they're represented in a
602     tree-structure, with data elements at the leaf nodes, and tags or
603     variant components at the non-leaf nodes. The root-node identifies the
604     schema that lends context to the tagging and structuring of the
605     record. Imagine a simple record, consisting of a 'title' element and
606     an 'author' element:
607    </para>
608
609    <para>
610
611     <screen>
612      ROOT 
613         TITLE     "Zen and the Art of Motorcycle Maintenance"
614         AUTHOR    "Robert Pirsig"
615     </screen>
616
617    </para>
618
619    <para>
620     A slightly more complex record would have the author element consist
621     of two elements, a surname and a first name:
622    </para>
623
624    <para>
625
626     <screen>
627      ROOT  
628         TITLE  "Zen and the Art of Motorcycle Maintenance"
629         AUTHOR
630            FIRST-NAME "Robert"
631            SURNAME    "Pirsig"
632     </screen>
633
634    </para>
635
636    <para>
637     The root of the record will refer to the record schema that describes
638     the structuring of this particular record. The schema defines the
639     element tags (TITLE, FIRST-NAME, etc.) that may occur in the record, as
640     well as the structuring (SURNAME should appear below AUTHOR, etc.). In
641     addition, the schema establishes element set names that are used by
642     the client to request a subset of the elements of a given record. The
643     schema may also establish rules for converting the record to a
644     different schema, by stating, for each element, a mapping to a
645     different tag path.
646    </para>
647
648    <sect2>
649     <title>Tagged Elements</title>
650
651     <para>
652      A data element is characterized by its tag, and its position in the
653      structure of the record. For instance, while the tag "telephone
654      number" may be used different places in a record, we may need to
655      distinguish between these occurrences, both for searching and
656      presentation purposes. For instance, while the phone numbers for the
657      "customer" and the "service provider" are both
658      representatives for the same type of resource (a telephone number), it
659      is essential that they be kept separate. The record schema provides
660      the structure of the record, and names each data element (defined by
661      the sequence of tags - the tag path - by which the element can be
662      reached from the root of the record).
663     </para>
664
665    </sect2>
666
667    <sect2>
668     <title>Variants</title>
669
670     <para>
671      The children of a tag node may be either more tag nodes, a data node
672      (possibly accompanied by tag nodes),
673      or a tree of variant nodes. The children of  variant nodes are either
674      more variant nodes or a data node (possibly accompanied by more
675      variant nodes). Each leaf node, which is normally a
676      data node, corresponds to a <emphasis>variant form</emphasis> of the
677      tagged element identified by the tag which parents the variant tree.
678      The following title element occurs in two different languages:
679     </para>
680
681     <para>
682
683      <screen>
684       VARIANT LANG=ENG  "War and Peace"
685       TITLE
686       VARIANT LANG=DAN  "Krig og Fred"
687      </screen>
688
689     </para>
690
691     <para>
692      Which of the two elements are transmitted to the client by the server
693      depends on the specifications provided by the client, if any.
694     </para>
695     
696     <para>
697      In practice, each variant node is associated with a triple of class,
698      type, value, corresponding to the variant mechanism of Z39.50.
699     </para>
700     
701    </sect2>
702    
703    <sect2>
704     <title>Data Elements</title>
705     
706     <para>
707      Data nodes have no children (they are always leaf nodes in the record
708      tree).
709     </para>
710     
711     <!--
712     FIXME! Documentation needs extension here about types of nodes - numerical,
713     textual, etc., plus the various types of inclusion notes.
714    </para>
715     -->
716     
717    </sect2>
718    
719   </sect1>
720   
721   <sect1 id="data-model">
722    <title>Configuring Your Data Model</title>
723    
724    <para>
725     The following sections describe the configuration files that govern
726     the internal management of data records. The system searches for the files
727     in the directories specified by the <emphasis>profilePath</emphasis>
728     setting in the <literal>zebra.cfg</literal> file.
729    </para>
730
731    <sect2>
732     <title>The Abstract Syntax</title>
733
734     <para>
735      The abstract syntax definition (also known as an Abstract Record
736      Structure, or ARS) is the focal point of the
737      record schema description. For a given schema, the ABS file may state any
738      or all of the following:
739     </para>
740
741     <!--
742      FIXME - Need a diagram here, or a simple explanation how it all hangs together -H
743     -->
744
745     <para>
746
747      <itemizedlist>
748       <listitem>
749
750        <para>
751         The object identifier of the Z39.50 schema associated
752         with the ARS, so that it can be referred to by the client.
753        </para>
754       </listitem>
755
756       <listitem>
757        <para>
758         The attribute set (which can possibly be a compound of multiple
759         sets) which applies in the profile. This is used when indexing and
760         searching the records belonging to the given profile.
761        </para>
762       </listitem>
763
764       <listitem>
765        <para>
766         The tag set (again, this can consist of several different sets).
767         This is used when reading the records from a file, to recognize the
768         different tags, and when transmitting the record to the client -
769         mapping the tags to their numerical representation, if they are
770         known.
771        </para>
772       </listitem>
773       
774       <listitem>
775        <para>
776         The variant set which is used in the profile. This provides a
777         vocabulary for specifying the <emphasis>forms</emphasis> of
778         data that appear inside the records.
779        </para>
780       </listitem>
781
782       <listitem>
783        <para>
784         Element set names, which are a shorthand way for the client to
785         ask for a subset of the data elements contained in a record. Element
786         set names, in the retrieval module, are mapped to <emphasis>element
787          specifications</emphasis>, which contain information equivalent to the
788         <emphasis>Espec-1</emphasis> syntax of Z39.50.
789        </para>
790       </listitem>
791
792       <listitem>
793        <para>
794         Map tables, which may specify mappings to
795         <emphasis>other</emphasis> database profiles, if desired.
796        </para>
797       </listitem>
798
799       <listitem>
800        <para>
801         Possibly, a set of rules describing the mapping of elements to a
802         MARC representation.
803
804        </para>
805       </listitem>
806
807       <listitem>      
808        <para>
809         A list of element descriptions (this is the actual ARS of the
810         schema, in Z39.50 terms), which lists the ways in which the various
811         tags can be used and organized hierarchically.
812        </para>
813       </listitem>
814
815      </itemizedlist>
816
817     </para>
818
819     <para>
820      Several of the entries above simply refer to other files, which
821      describe the given objects.
822     </para>
823
824    </sect2>
825
826    <sect2>
827     <title>The Configuration Files</title>
828
829     <para>
830      This section describes the syntax and use of the various tables which
831      are used by the retrieval module.
832     </para>
833
834     <para>
835      The number of different file types may appear daunting at first, but
836      each type corresponds fairly clearly to a single aspect of the Z39.50
837      retrieval facilities. Further, the average database administrator,
838      who is simply reusing an existing profile for which tables already
839      exist, shouldn't have to worry too much about the contents of these tables.
840     </para>
841
842     <para>
843      Generally, the files are simple ASCII files, which can be maintained
844      using any text editor. Blank lines, and lines beginning with a (#) are
845      ignored. Any characters on a line followed by a (#) are also ignored.
846      All other lines contain <emphasis>directives</emphasis>, which provide
847      some setting or value to the system.
848      Generally, settings are characterized by a single
849      keyword, identifying the setting, followed by a number of parameters.
850      Some settings are repeatable (r), while others may occur only once in a
851      file. Some settings are optional (o), while others again are
852      mandatory (m).
853     </para>
854     
855    </sect2>
856    
857    <sect2 id="abs-file">
858     <title>The Abstract Syntax (.abs) Files</title>
859     
860     <para>
861      The name of this file type is slightly misleading in Z39.50 terms,
862      since, apart from the actual abstract syntax of the profile, it also
863      includes most of the other definitions that go into a database
864      profile.
865     </para>
866     
867     <para>
868      When a record in the canonical, SGML-like format is read from a file
869      or from the database, the first tag of the file should reference the
870      profile that governs the layout of the record. If the first tag of the
871      record is, say, <literal>&lt;gils&gt;</literal>, the system will look
872      for the profile definition in the file <literal>gils.abs</literal>.
873      Profile definitions are cached, so they only have to be read once
874      during the lifespan of the current process. 
875     </para>
876
877     <para>
878      When writing your own input filters, the
879      <emphasis>record-begin</emphasis> command
880      introduces the profile, and should always be called first thing when
881      introducing a new record.
882     </para>
883     
884     <para>
885      The file may contain the following directives:
886     </para>
887     
888     <para>
889      <variablelist>
890       
891       <varlistentry>
892        <term>name <replaceable>symbolic-name</replaceable></term>
893        <listitem>
894         <para>
895          (m) This provides a shorthand name or
896          description for the profile. Mostly useful for diagnostic purposes.
897         </para>
898        </listitem>
899       </varlistentry>
900       <varlistentry>
901        <term>reference <replaceable>OID-name</replaceable></term>
902        <listitem>
903         <para>
904          (m) The reference name of the OID for the profile.
905          The reference names can be found in the <emphasis>util</emphasis>
906          module of YAZ.
907         </para>
908        </listitem>
909       </varlistentry>
910       <varlistentry>
911        <term>attset <replaceable>filename</replaceable></term>
912        <listitem>
913         <para>
914          (m) The attribute set that is used for
915          indexing and searching records belonging to this profile.
916         </para>
917        </listitem>
918       </varlistentry>
919       <varlistentry>
920        <term>tagset <replaceable>filename</replaceable></term>
921        <listitem>
922         <para>
923          (o) The tag set (if any) that describe
924          that fields of the records.
925         </para>
926        </listitem>
927       </varlistentry>
928       <varlistentry>
929        <term>varset <replaceable>filename</replaceable></term>
930        <listitem>
931         <para>
932          (o) The variant set used in the profile.
933         </para>
934        </listitem>
935       </varlistentry>
936       <varlistentry>
937        <term>maptab <replaceable>filename</replaceable></term>
938        <listitem>
939         <para>
940          (o,r) This points to a
941          conversion table that might be used if the client asks for the record
942          in a different schema from the native one.
943         </para>
944        </listitem>
945       </varlistentry>
946       <varlistentry>
947        <term>marc <replaceable>filename</replaceable></term>
948        <listitem>
949         <para>
950          (o) Points to a file containing parameters
951          for representing the record contents in the ISO2709 syntax.
952          Read the description of the MARC representation facility below.
953         </para>
954        </listitem>
955       </varlistentry>
956       <varlistentry>
957        <term>esetname <replaceable>name filename</replaceable></term>
958        <listitem>
959         <para>
960          (o,r) Associates the
961          given element set name with an element selection file. If an (@) is
962          given in place of the filename, this corresponds to a null mapping for
963          the given element set name.
964         </para>
965        </listitem>
966       </varlistentry>
967       <varlistentry>
968        <term>any <replaceable>tags</replaceable></term>
969        <listitem>
970         <para>
971          (o) This directive specifies a list of attributes
972          which should be appended to the attribute list given for each
973          element. The effect is to make every single element in the abstract
974          syntax searchable by way of the given attributes. This directive
975          provides an efficient way of supporting free-text searching across all
976          elements. However, it does increase the size of the index
977          significantly. The attributes can be qualified with a structure, as in
978          the <replaceable>elm</replaceable> directive below.
979         </para>
980        </listitem>
981       </varlistentry>
982       <varlistentry>
983        <term>elm <replaceable>path name attributes</replaceable></term>
984        <listitem>
985         <para>
986          (o,r) Adds an element to the abstract record syntax of the schema.
987          The <replaceable>path</replaceable> follows the
988          syntax which is suggested by the Z39.50 document - that is, a sequence
989          of tags separated by slashes (&#x2f;). Each tag is given as a
990          comma-separated pair of tag type and -value surrounded by parenthesis.
991          The <replaceable>name</replaceable> is the name of the element, and
992          the <replaceable>attributes</replaceable>
993          specifies which attributes to use when indexing the element in a
994          comma-separated list.
995          A ! in place of the attribute name is equivalent to
996          specifying an attribute name identical to the element name.
997          A - in place of the attribute name
998          specifies that no indexing is to take place for the given element.
999          The attributes can be qualified with <replaceable>field
1000           types</replaceable> to specify which
1001          character set should govern the indexing procedure for that field.
1002          The same data element may be indexed into several different
1003          fields, using different character set definitions.
1004          See the <xref linkend="field-structure-and-character-sets"/>.
1005          The default field type is <literal>w</literal> for
1006          <emphasis>word</emphasis>.
1007         </para>
1008        </listitem>
1009       </varlistentry>
1010       
1011       <varlistentry>
1012        <term>xelm <replaceable>xpath attributes</replaceable></term>
1013        <listitem>
1014         <para>
1015          Specifies indexing for record nodes given by
1016          <replaceable>xpath</replaceable>. Unlike directive
1017          elm, this directive allows you to index attribute
1018          contents. The <replaceable>xpath</replaceable> uses
1019          a syntax similar to XPath. The <replaceable>attributes</replaceable>
1020          have same syntax and meaning as directive elm, except that operator
1021          ! refers to the nodes selected by <replaceable>xpath</replaceable>.
1022          <!--
1023          xelm   /         !:w                 default index
1024          xelm   //        !:w                 additional index
1025          xelm   /gils/title/@att    myatt:w   index attribute @att in myatt
1026          xelm   title/@att          myatt:w   same meaning.
1027          -->
1028         </para>
1029        </listitem>
1030       </varlistentry>
1031       
1032       <varlistentry>
1033        <term>encoding <replaceable>encodingname</replaceable></term>
1034        <listitem>
1035         <para>
1036          This directive specifies character encoding for external records.
1037          For records such as XML that specifies encoding within the
1038          file via a header this directive is ignored.
1039          If neither this directive is given, nor an encoding is set
1040          within external records, ISO-8859-1 encoding is assumed.
1041          </para>
1042        </listitem>
1043       </varlistentry>
1044       <varlistentry>
1045        <term>xpath <literal>enable</literal>/<literal>disable</literal></term>
1046        <listitem>
1047         <para>
1048          If this directive is followed by <literal>enable</literal>,
1049          then extra indexing is performed to allow for XPath-like queries.
1050          If this directive is not specified - equivalent to 
1051          <literal>disable</literal> - no extra XPath-indexing is performed.
1052         </para>
1053        </listitem>
1054       </varlistentry>
1055
1056         <!-- Adam's version -->
1057       <varlistentry>
1058        <term>systag <replaceable>systemtag</replaceable> <replaceable>element</replaceable></term>
1059        <listitem>
1060         <para>
1061          This directive maps system information to an element during
1062          retrieval. This information is dynamically created. The
1063          following system tags are defined
1064          <variablelist>
1065           <varlistentry>
1066            <term>size</term>
1067            <listitem>
1068             <para>
1069              Size of record in bytes. By default this
1070              is mapped to element <literal>size</literal>.
1071             </para>
1072            </listitem>
1073           </varlistentry>
1074
1075           <varlistentry>
1076            <term>rank</term>
1077            <listitem>
1078             <para>
1079              Score/rank of record. By default this
1080              is mapped to element <literal>rank</literal>.
1081              If no score was calculated for the record (non-ranked
1082              searched) search this directive is ignored.
1083             </para>
1084            </listitem>
1085           </varlistentry>
1086           
1087           <varlistentry>
1088            <term>sysno</term>
1089            <listitem> 
1090             <para>
1091              Zebra's system number (record ID) for the
1092              record. By default this is mapped to element
1093              <literal>localControlNumber</literal>.
1094             </para>
1095            </listitem>
1096           </varlistentry>
1097          </variablelist>
1098          If you do not want a particular system tag to be applied,
1099          then set the resulting element to something undefined in the
1100          abs file (such as <literal>none</literal>).
1101         </para>
1102        </listitem>
1103       </varlistentry>
1104
1105         <!-- Mike's version -->
1106       <varlistentry>
1107        <term>
1108         systag
1109         <replaceable>systemTag</replaceable>
1110         <replaceable>actualTag</replaceable>
1111        </term>
1112        <listitem>
1113         <para>
1114          Specifies what information, if any, Zebra should
1115          automatically include in retrieval records for the 
1116          ``system fields'' that it supports.
1117          <replaceable>systemTag</replaceable> may
1118          be any of the following:
1119          <variablelist>
1120           <varlistentry>
1121            <term><literal>rank</literal></term>
1122            <listitem><para>
1123             An integer indicating the relevance-ranking score
1124             assigned to the record.
1125            </para></listitem>
1126           </varlistentry>
1127           <varlistentry>
1128            <term><literal>sysno</literal></term>
1129            <listitem><para>
1130             An automatically generated identifier for the record,
1131             unique within this database.  It is represented by the
1132             <literal>&lt;localControlNumber&gt;</literal> element in
1133             XML and the <literal>(1,14)</literal> tag in GRS-1.
1134            </para></listitem>
1135           </varlistentry>
1136           <varlistentry>
1137            <term><literal>size</literal></term>
1138            <listitem><para>
1139             The size, in bytes, of the retrieved record.
1140            </para></listitem>
1141           </varlistentry>
1142          </variablelist>
1143         </para>
1144         <para>
1145          The <replaceable>actualTag</replaceable> parameter may be
1146          <literal>none</literal> to indicate that the named element
1147          should be omitted from retrieval records.
1148         </para>
1149        </listitem>
1150       </varlistentry>
1151      </variablelist>
1152     </para>
1153     
1154     <note>
1155      <para>
1156       The mechanism for controlling indexing is not adequate for
1157       complex databases, and will probably be moved into a separate
1158       configuration table eventually.
1159      </para>
1160     </note>
1161     
1162     <para>
1163      The following is an excerpt from the abstract syntax file for the GILS
1164      profile.
1165     </para>
1166
1167     <para>
1168
1169      <screen>
1170       name gils
1171       reference GILS-schema
1172       attset gils.att
1173       tagset gils.tag
1174       varset var1.var
1175
1176       maptab gils-usmarc.map
1177
1178       # Element set names
1179
1180       esetname VARIANT gils-variant.est  # for WAIS-compliance
1181       esetname B gils-b.est
1182       esetname G gils-g.est
1183       esetname F @
1184
1185       elm (1,10)              rank                        -
1186       elm (1,12)              url                         -
1187       elm (1,14)              localControlNumber     Local-number
1188       elm (1,16)              dateOfLastModification Date/time-last-modified
1189       elm (2,1)               title                       w:!,p:!
1190       elm (4,1)               controlIdentifier      Identifier-standard
1191       elm (2,6)               abstract               Abstract
1192       elm (4,51)              purpose                     !
1193       elm (4,52)              originator                  - 
1194       elm (4,53)              accessConstraints           !
1195       elm (4,54)              useConstraints              !
1196       elm (4,70)              availability                -
1197       elm (4,70)/(4,90)       distributor                 -
1198       elm (4,70)/(4,90)/(2,7) distributorName             !
1199       elm (4,70)/(4,90)/(2,10 distributorOrganization     !
1200       elm (4,70)/(4,90)/(4,2) distributorStreetAddress    !
1201       elm (4,70)/(4,90)/(4,3) distributorCity             !
1202      </screen>
1203
1204     </para>
1205
1206    </sect2>
1207
1208    <sect2 id="attset-files">
1209     <title>The Attribute Set (.att) Files</title>
1210
1211     <para>
1212      This file type describes the <replaceable>Use</replaceable> elements of
1213      an attribute set. 
1214      It contains the following directives. 
1215     </para>
1216     
1217     <para>
1218      <variablelist>
1219       <varlistentry>
1220        <term>name <replaceable>symbolic-name</replaceable></term>
1221        <listitem>
1222         <para>
1223          (m) This provides a shorthand name or
1224          description for the attribute set.
1225          Mostly useful for diagnostic purposes.
1226         </para>
1227        </listitem></varlistentry>
1228       <varlistentry>
1229        <term>reference <replaceable>OID-name</replaceable></term>
1230        <listitem>
1231         <para>
1232          (m) The reference name of the OID for
1233          the attribute set.
1234          The reference names can be found in the <replaceable>util</replaceable>
1235          module of <replaceable>YAZ</replaceable>.
1236         </para>
1237        </listitem></varlistentry>
1238       <varlistentry>
1239        <term>include <replaceable>filename</replaceable></term>
1240        <listitem>
1241         <para>
1242          (o,r) This directive is used to
1243          include another attribute set as a part of the current one. This is
1244          used when a new attribute set is defined as an extension to another
1245          set. For instance, many new attribute sets are defined as extensions
1246          to the <replaceable>bib-1</replaceable> set.
1247          This is an important feature of the retrieval
1248          system of Z39.50, as it ensures the highest possible level of
1249          interoperability, as those access points of your database which are
1250          derived from the external set (say, bib-1) can be used even by clients
1251          who are unaware of the new set.
1252         </para>
1253        </listitem></varlistentry>
1254       <varlistentry>
1255        <term>att
1256         <replaceable>att-value att-name [local-value]</replaceable></term>
1257        <listitem>
1258         <para>
1259          (o,r) This
1260          repeatable directive introduces a new attribute to the set. The
1261          attribute value is stored in the index (unless a
1262          <replaceable>local-value</replaceable> is
1263          given, in which case this is stored). The name is used to refer to the
1264          attribute from the <replaceable>abstract syntax</replaceable>. 
1265         </para>
1266        </listitem></varlistentry>
1267      </variablelist>
1268     </para>
1269
1270     <para>
1271      This is an excerpt from the GILS attribute set definition.
1272      Notice how the file describing the <emphasis>bib-1</emphasis>
1273      attribute set is referenced.
1274     </para>
1275
1276     <para>
1277
1278      <screen>
1279       name gils
1280       reference GILS-attset
1281       include bib1.att
1282
1283       att 2001          distributorName
1284       att 2002          indextermsControlled
1285       att 2003          purpose
1286       att 2004          accessConstraints
1287       att 2005          useConstraints
1288      </screen>
1289
1290     </para>
1291
1292    </sect2>
1293
1294    <sect2>
1295     <title>The Tag Set (.tag) Files</title>
1296
1297     <para>
1298      This file type defines the tagset of the profile, possibly by
1299      referencing other tag sets (most tag sets, for instance, will include
1300      tagsetG and tagsetM from the Z39.50 specification. The file may
1301      contain the following directives.
1302     </para>
1303
1304     <para>
1305      <variablelist>
1306
1307       <varlistentry>
1308        <term>name <emphasis>symbolic-name</emphasis></term>
1309        <listitem>
1310         <para>
1311          (m) This provides a shorthand name or
1312          description for the tag set. Mostly useful for diagnostic purposes.
1313         </para>
1314        </listitem></varlistentry>
1315       <varlistentry>
1316        <term>reference <emphasis>OID-name</emphasis></term>
1317        <listitem>
1318         <para>
1319          (o) The reference name of the OID for the tag set.
1320          The reference names can be found in the <emphasis>util</emphasis>
1321          module of <emphasis>YAZ</emphasis>.
1322          The directive is optional, since not all tag sets
1323          are registered outside of their schema.
1324         </para>
1325        </listitem></varlistentry>
1326       <varlistentry>
1327        <term>type <emphasis>integer</emphasis></term>
1328        <listitem>
1329         <para>
1330          (m) The type number of the tagset within the schema
1331          profile (note: this specification really should belong to the .abs
1332          file. This will be fixed in a future release).
1333         </para>
1334        </listitem></varlistentry>
1335       <varlistentry>
1336        <term>include <emphasis>filename</emphasis></term>
1337        <listitem>
1338         <para>
1339          (o,r) This directive is used
1340          to include the definitions of other tag sets into the current one.
1341         </para>
1342        </listitem></varlistentry>
1343       <varlistentry>
1344        <term>tag <emphasis>number names type</emphasis></term>
1345        <listitem>
1346         <para>
1347          (o,r) Introduces a new tag to the set.
1348          The <emphasis>number</emphasis> is the tag number as used
1349          in the protocol (there is currently no mechanism for
1350          specifying string tags at this point, but this would be quick
1351          work to add).
1352          The <emphasis>names</emphasis> parameter is a list of names
1353          by which the tag should be recognized in the input file format.
1354          The names should be separated by slashes (/).
1355          The <emphasis>type</emphasis> is the recommended data type of
1356          the tag.
1357          It should be one of the following:
1358
1359          <itemizedlist>
1360           <listitem>
1361            <para>
1362             structured
1363            </para>
1364           </listitem>
1365
1366           <listitem>
1367            <para>
1368             string
1369            </para>
1370           </listitem>
1371
1372           <listitem>
1373            <para>
1374             numeric
1375            </para>
1376           </listitem>
1377
1378           <listitem>
1379            <para>
1380             bool
1381            </para>
1382           </listitem>
1383
1384           <listitem>
1385            <para>
1386             oid
1387            </para>
1388           </listitem>
1389
1390           <listitem>
1391            <para>
1392             generalizedtime
1393            </para>
1394           </listitem>
1395
1396           <listitem>
1397            <para>
1398             intunit
1399            </para>
1400           </listitem>
1401
1402           <listitem>
1403            <para>
1404             int
1405            </para>
1406           </listitem>
1407
1408           <listitem>
1409            <para>
1410             octetstring
1411            </para>
1412           </listitem>
1413
1414           <listitem>
1415            <para>
1416             null
1417            </para>
1418           </listitem>
1419
1420          </itemizedlist>
1421
1422         </para>
1423        </listitem></varlistentry>
1424      </variablelist>
1425     </para>
1426
1427     <para>
1428      The following is an excerpt from the TagsetG definition file.
1429     </para>
1430
1431     <para>
1432      <screen>
1433       name tagsetg
1434       reference TagsetG
1435       type 2
1436
1437       tag       1       title           string
1438       tag       2       author          string
1439       tag       3       publicationPlace string
1440       tag       4       publicationDate string
1441       tag       5       documentId      string
1442       tag       6       abstract        string
1443       tag       7       name            string
1444       tag       8       date            generalizedtime
1445       tag       9       bodyOfDisplay   string
1446       tag       10      organization    string
1447      </screen>
1448     </para>
1449
1450    </sect2>
1451
1452    <sect2 id="variant-set">
1453     <title>The Variant Set (.var) Files</title>
1454
1455     <para>
1456      The variant set file is a straightforward representation of the
1457      variant set definitions associated with the protocol. At present, only
1458      the <emphasis>Variant-1</emphasis> set is known.
1459     </para>
1460
1461     <para>
1462      These are the directives allowed in the file.
1463     </para>
1464
1465     <para>
1466      <variablelist>
1467
1468       <varlistentry>
1469        <term>name <emphasis>symbolic-name</emphasis></term>
1470        <listitem>
1471         <para>
1472          (m) This provides a shorthand name or
1473          description for the variant set. Mostly useful for diagnostic purposes.
1474         </para>
1475        </listitem></varlistentry>
1476       <varlistentry>
1477        <term>reference <emphasis>OID-name</emphasis></term>
1478        <listitem>
1479         <para>
1480          (o) The reference name of the OID for
1481          the variant set, if one is required. The reference names can be found
1482          in the <emphasis>util</emphasis> module of <emphasis>YAZ</emphasis>.
1483         </para>
1484        </listitem></varlistentry>
1485       <varlistentry>
1486        <term>class <emphasis>integer class-name</emphasis></term>
1487        <listitem>
1488         <para>
1489          (m,r) Introduces a new
1490          class to the variant set.
1491         </para>
1492        </listitem></varlistentry>
1493       <varlistentry>
1494        <term>type <emphasis>integer type-name datatype</emphasis></term>
1495        <listitem>
1496         <para>
1497          (m,r) Addes a
1498          new type to the current class (the one introduced by the most recent
1499          <emphasis>class</emphasis> directive).
1500          The type names belong to the same name space as the one used
1501          in the tag set definition file.
1502         </para>
1503        </listitem></varlistentry>
1504      </variablelist>
1505     </para>
1506
1507     <para>
1508      The following is an excerpt from the file describing the variant set
1509      <emphasis>Variant-1</emphasis>.
1510     </para>
1511
1512     <para>
1513
1514      <screen>
1515       name variant-1
1516       reference Variant-1
1517
1518       class 1 variantId
1519
1520       type      1       variantId               octetstring
1521
1522       class 2 body
1523
1524       type      1       iana                    string
1525       type      2       z39.50                  string
1526       type      3       other                   string
1527      </screen>
1528
1529     </para>
1530
1531    </sect2>
1532
1533    <sect2>
1534     <title>The Element Set (.est) Files</title>
1535
1536     <para>
1537      The element set specification files describe a selection of a subset
1538      of the elements of a database record. The element selection mechanism
1539      is equivalent to the one supplied by the <emphasis>Espec-1</emphasis>
1540      syntax of the Z39.50 specification.
1541      In fact, the internal representation of an element set
1542      specification is identical to the <emphasis>Espec-1</emphasis> structure,
1543      and we'll refer you to the description of that structure for most of
1544      the detailed semantics of the directives below.
1545     </para>
1546
1547     <note>
1548      <para>
1549       Not all of the Espec-1 functionality has been implemented yet.
1550       The fields that are mentioned below all work as expected, unless
1551       otherwise is noted.
1552      </para>
1553     </note>
1554     
1555     <para>
1556      The directives available in the element set file are as follows:
1557     </para>
1558
1559     <para>
1560      <variablelist>
1561       <varlistentry>
1562        <term>defaultVariantSetId <emphasis>OID-name</emphasis></term>
1563        <listitem>
1564         <para>
1565          (o) If variants are used in
1566          the following, this should provide the name of the variantset used
1567          (it's not currently possible to specify a different set in the
1568          individual variant request). In almost all cases (certainly all
1569          profiles known to us), the name
1570          <literal>Variant-1</literal> should be given here.
1571         </para>
1572        </listitem></varlistentry>
1573       <varlistentry>
1574        <term>defaultVariantRequest <emphasis>variant-request</emphasis></term>
1575        <listitem>
1576         <para>
1577          (o) This directive
1578          provides a default variant request for
1579          use when the individual element requests (see below) do not contain a
1580          variant request. Variant requests consist of a blank-separated list of
1581          variant components. A variant compont is a comma-separated,
1582          parenthesized triple of variant class, type, and value (the two former
1583          values being represented as integers). The value can currently only be
1584          entered as a string (this will change to depend on the definition of
1585          the variant in question). The special value (@) is interpreted as a
1586          null value, however.
1587         </para>
1588        </listitem></varlistentry>
1589       <varlistentry>
1590        <term>simpleElement
1591         <emphasis>path ['variant' variant-request]</emphasis></term>
1592        <listitem>
1593         <para>
1594          (o,r) This corresponds to a simple element request
1595          in <emphasis>Espec-1</emphasis>.
1596          The path consists of a sequence of tag-selectors, where each of
1597          these can consist of either:
1598         </para>
1599
1600         <para>
1601          <itemizedlist>
1602           <listitem>
1603            <para>
1604             A simple tag, consisting of a comma-separated type-value pair in
1605             parenthesis, possibly followed by a colon (:) followed by an
1606             occurrences-specification (see below). The tag-value can be a number
1607             or a string. If the first character is an apostrophe ('), this
1608             forces the value to be interpreted as a string, even if it
1609             appears to be numerical.
1610            </para>
1611           </listitem>
1612
1613           <listitem>
1614            <para>
1615             A WildThing, represented as a question mark (?), possibly
1616             followed by a colon (:) followed by an occurrences
1617             specification (see below).
1618            </para>
1619           </listitem>
1620
1621           <listitem>
1622            <para>
1623             A WildPath, represented as an asterisk (*). Note that the last
1624             element of the path should not be a wildPath (wildpaths don't
1625             work in this version).
1626            </para>
1627           </listitem>
1628
1629          </itemizedlist>
1630
1631         </para>
1632
1633         <para>
1634          The occurrences-specification can be either the string
1635          <literal>all</literal>, the string <literal>last</literal>, or
1636          an explicit value-range. The value-range is represented as
1637          an integer (the starting point), possibly followed by a
1638          plus (+) and a second integer (the number of elements, default
1639          being one).
1640         </para>
1641
1642         <para>
1643          The variant-request has the same syntax as the defaultVariantRequest
1644          above. Note that it may sometimes be useful to give an empty variant
1645          request, simply to disable the default for a specific set of fields
1646          (we aren't certain if this is proper <emphasis>Espec-1</emphasis>,
1647          but it works in this implementation).
1648         </para>
1649        </listitem></varlistentry>
1650      </variablelist>
1651     </para>
1652
1653     <para>
1654      The following is an example of an element specification belonging to
1655      the GILS profile.
1656     </para>
1657
1658     <para>
1659
1660      <screen>
1661       simpleelement (1,10)
1662       simpleelement (1,12)
1663       simpleelement (2,1)
1664       simpleelement (1,14)
1665       simpleelement (4,1)
1666       simpleelement (4,52)
1667      </screen>
1668
1669     </para>
1670
1671    </sect2>
1672
1673    <sect2 id="schema-mapping">
1674     <title>The Schema Mapping (.map) Files</title>
1675
1676     <para>
1677      Sometimes, the client might want to receive a database record in
1678      a schema that differs from the native schema of the record. For
1679      instance, a client might only know how to process WAIS records, while
1680      the database record is represented in a more specific schema, such as
1681      GILS. In this module, a mapping of data to one of the MARC formats is
1682      also thought of as a schema mapping (mapping the elements of the
1683      record into fields consistent with the given MARC specification, prior
1684      to actually converting the data to the ISO2709). This use of the
1685      object identifier for USMARC as a schema identifier represents an
1686      overloading of the OID which might not be entirely proper. However,
1687      it represents the dual role of schema and record syntax which
1688      is assumed by the MARC family in Z39.50.
1689     </para>
1690
1691     <!--
1692      <emphasis>NOTE: FIXME! The schema-mapping functions are so far limited to a
1693       straightforward mapping of elements. This should be extended with
1694       mechanisms for conversions of the element contents, and conditional
1695       mappings of elements based on the record contents.</emphasis>
1696     -->
1697
1698     <para>
1699      These are the directives of the schema mapping file format:
1700     </para>
1701
1702     <para>
1703      <variablelist>
1704
1705       <varlistentry>
1706        <term>targetName <emphasis>name</emphasis></term>
1707        <listitem>
1708         <para>
1709          (m) A symbolic name for the target schema
1710          of the table. Useful mostly for diagnostic purposes.
1711         </para>
1712        </listitem></varlistentry>
1713       <varlistentry>
1714        <term>targetRef <emphasis>OID-name</emphasis></term>
1715        <listitem>
1716         <para>
1717          (m) An OID name for the target schema.
1718          This is used, for instance, by a server receiving a request to present
1719          a record in a different schema from the native one.
1720          The name, again, is found in the <emphasis>oid</emphasis>
1721          module of <emphasis>YAZ</emphasis>.
1722         </para>
1723        </listitem></varlistentry>
1724       <varlistentry>
1725        <term>map <emphasis>element-name target-path</emphasis></term>
1726        <listitem>
1727         <para>
1728          (o,r) Adds
1729          an element mapping rule to the table.
1730         </para>
1731        </listitem></varlistentry>
1732      </variablelist>
1733     </para>
1734
1735    </sect2>
1736
1737    <sect2>
1738     <title>The MARC (ISO2709) Representation (.mar) Files</title>
1739
1740     <para>
1741      This file provides rules for representing a record in the ISO2709
1742      format. The rules pertain mostly to the values of the constant-length
1743      header of the record.
1744     </para>
1745
1746     <!--
1747      NOTE: FIXME! This will be described better. We're in the process of
1748       re-evaluating and most likely changing the way that MARC records are
1749       handled by the system.</emphasis>
1750     -->
1751
1752    </sect2>
1753
1754    <sect2 id="field-structure-and-character-sets">
1755     <title>Field Structure and Character Sets
1756     </title>
1757
1758     <para>
1759      In order to provide a flexible approach to national character set
1760      handling, Zebra allows the administrator to configure the set up the
1761      system to handle any 8-bit character set &mdash; including sets that
1762      require multi-octet diacritics or other multi-octet characters. The
1763      definition of a character set includes a specification of the
1764      permissible values, their sort order (this affects the display in the
1765      SCAN function), and relationships between upper- and lowercase
1766      characters. Finally, the definition includes the specification of
1767      space characters for the set.
1768     </para>
1769
1770     <para>
1771      The operator can define different character sets for different fields,
1772      typical examples being standard text fields, numerical fields, and
1773      special-purpose fields such as WWW-style linkages (URx).
1774     </para>
1775
1776     <para>
1777      The field types, and hence character sets, are associated with data
1778      elements by the .abs files (see above).
1779      The file <literal>default.idx</literal>
1780      provides the association between field type codes (as used in the .abs
1781      files) and the character map files (with the .chr suffix). The format
1782      of the .idx file is as follows
1783     </para>
1784
1785     <para>
1786      <variablelist>
1787
1788       <varlistentry>
1789        <term>index <emphasis>field type code</emphasis></term>
1790        <listitem>
1791         <para>
1792          This directive introduces a new search index code.
1793          The argument is a one-character code to be used in the
1794          .abs files to select this particular index type. An index, roughly,
1795          corresponds to a particular structure attribute during search. Refer
1796          to <xref linkend="search"/>.
1797         </para>
1798        </listitem></varlistentry>
1799       <varlistentry>
1800        <term>sort <emphasis>field code type</emphasis></term>
1801        <listitem>
1802         <para>
1803          This directive introduces a 
1804          sort index. The argument is a one-character code to be used in the
1805          .abs fie to select this particular index type. The corresponding
1806          use attribute must be used in the sort request to refer to this
1807          particular sort index. The corresponding character map (see below)
1808          is used in the sort process.
1809         </para>
1810        </listitem></varlistentry>
1811       <varlistentry>
1812        <term>completeness <emphasis>boolean</emphasis></term>
1813        <listitem>
1814         <para>
1815          This directive enables or disables complete field indexing.
1816          The value of the <emphasis>boolean</emphasis> should be 0
1817          (disable) or 1. If completeness is enabled, the index entry will
1818          contain the complete contents of the field (up to a limit), with words
1819          (non-space characters) separated by single space characters
1820          (normalized to " " on display). When completeness is
1821          disabled, each word is indexed as a separate entry. Complete subfield
1822          indexing is most useful for fields which are typically browsed (eg.
1823          titles, authors, or subjects), or instances where a match on a
1824          complete subfield is essential (eg. exact title searching). For fields
1825          where completeness is disabled, the search engine will interpret a
1826          search containing space characters as a word proximity search.
1827         </para>
1828        </listitem></varlistentry>
1829       <varlistentry>
1830        <term>charmap <emphasis>filename</emphasis></term>
1831        <listitem>
1832         <para>
1833          This is the filename of the character
1834          map to be used for this index for field type.
1835         </para>
1836        </listitem></varlistentry>
1837      </variablelist>
1838     </para>
1839
1840     <para>
1841      The contents of the character map files are structured as follows:
1842     </para>
1843
1844     <para>
1845      <variablelist>
1846
1847       <varlistentry>
1848        <term>lowercase <emphasis>value-set</emphasis></term>
1849        <listitem>
1850         <para>
1851          This directive introduces the basic value set of the field type.
1852          The format is an ordered list (without spaces) of the
1853          characters which may occur in "words" of the given type.
1854          The order of the entries in the list determines the
1855          sort order of the index. In addition to single characters, the
1856          following combinations are legal:
1857         </para>
1858
1859         <para>
1860
1861          <itemizedlist>
1862           <listitem>
1863            <para>
1864             Backslashes may be used to introduce three-digit octal, or
1865             two-digit hex representations of single characters
1866             (preceded by <literal>x</literal>).
1867             In addition, the combinations
1868             \\, \\r, \\n, \\t, \\s (space &mdash; remember that real
1869             space-characters may not occur in the value definition), and
1870             \\ are recognized, with their usual interpretation.
1871            </para>
1872           </listitem>
1873
1874           <listitem>
1875            <para>
1876             Curly braces {} may be used to enclose ranges of single
1877             characters (possibly using the escape convention described in the
1878             preceding point), eg. {a-z} to introduce the
1879             standard range of ASCII characters.
1880             Note that the interpretation of such a range depends on
1881             the concrete representation in your local, physical character set.
1882            </para>
1883           </listitem>
1884
1885           <listitem>
1886            <para>
1887             paranthesises () may be used to enclose multi-byte characters -
1888             eg. diacritics or special national combinations (eg. Spanish
1889             "ll"). When found in the input stream (or a search term),
1890             these characters are viewed and sorted as a single character, with a
1891             sorting value depending on the position of the group in the value
1892             statement.
1893            </para>
1894           </listitem>
1895
1896          </itemizedlist>
1897
1898         </para>
1899        </listitem></varlistentry>
1900       <varlistentry>
1901        <term>uppercase <emphasis>value-set</emphasis></term>
1902        <listitem>
1903         <para>
1904          This directive introduces the
1905          upper-case equivalencis to the value set (if any). The number and
1906          order of the entries in the list should be the same as in the
1907          <literal>lowercase</literal> directive.
1908         </para>
1909        </listitem></varlistentry>
1910       <varlistentry>
1911        <term>space <emphasis>value-set</emphasis></term>
1912        <listitem>
1913         <para>
1914          This directive introduces the character
1915          which separate words in the input stream. Depending on the
1916          completeness mode of the field in question, these characters either
1917          terminate an index entry, or delimit individual "words" in
1918          the input stream. The order of the elements is not significant &mdash;
1919          otherwise the representation is the same as for the
1920          <literal>uppercase</literal> and <literal>lowercase</literal>
1921          directives.
1922         </para>
1923        </listitem></varlistentry>
1924       <varlistentry>
1925        <term>map <emphasis>value-set</emphasis>
1926         <emphasis>target</emphasis></term>
1927        <listitem>
1928         <para>
1929          This directive introduces a
1930          mapping between each of the members of the value-set on the left to
1931          the character on the right. The character on the right must occur in
1932          the value set (the <literal>lowercase</literal> directive) of
1933          the character set, but
1934          it may be a paranthesis-enclosed multi-octet character. This directive
1935          may be used to map diacritics to their base characters, or to map
1936          HTML-style character-representations to their natural form, etc.
1937         </para>
1938        </listitem></varlistentry>
1939      </variablelist>
1940     </para>
1941
1942    </sect2>
1943
1944   </sect1>
1945
1946   <sect1 id="formats">
1947    <title>Exchange Formats</title>
1948
1949    <para>
1950     Converting records from the internal structure to en exchange format
1951     is largely an automatic process. Currently, the following exchange
1952     formats are supported:
1953    </para>
1954
1955    <para>
1956     <itemizedlist>
1957      <listitem>
1958       <para>
1959        GRS-1. The internal representation is based on GRS-1/XML, so the
1960        conversion here is straightforward. The system will create
1961        applied variant and supported variant lists as required, if a record
1962        contains variant information.
1963       </para>
1964      </listitem>
1965
1966      <listitem>
1967       <para>
1968        XML. The internal representation is based on GRS-1/XML so
1969        the mapping is trivial. Note that XML schemas, preprocessing
1970        instructions and comments are not part of the internal representation
1971        and therefore will never be part of a generated XML record.
1972        Future versions of the Zebra will support that.
1973       </para>
1974      </listitem>
1975
1976      <listitem>
1977       <para>
1978        SUTRS. Again, the mapping is fairly straightforward. Indentation
1979        is used to show the hierarchical structure of the record. All
1980        "GRS" type records support both the GRS-1 and SUTRS
1981        representations.
1982        <!-- FIXME - What is SUTRS - should be expanded here -->
1983       </para>
1984      </listitem>
1985
1986      <listitem>
1987       <para>
1988        ISO2709-based formats (USMARC, etc.). Only records with a
1989        two-level structure (corresponding to fields and subfields) can be
1990        directly mapped to ISO2709. For records with a different structuring
1991        (eg., GILS), the representation in a structure like USMARC involves a
1992        schema-mapping (see <xref linkend="schema-mapping"/>), to an
1993        "implied" USMARC schema (implied,
1994        because there is no formal schema which specifies the use of the
1995        USMARC fields outside of ISO2709). The resultant, two-level record is
1996        then mapped directly from the internal representation to ISO2709. See
1997        the GILS schema definition files for a detailed example of this
1998        approach.
1999       </para>
2000      </listitem>
2001
2002      <listitem>
2003       <para>
2004        Explain. This representation is only available for records
2005        belonging to the Explain schema.
2006       </para>
2007      </listitem>
2008
2009      <listitem>
2010       <para>
2011        Summary. This ASN-1 based structure is only available for records
2012        belonging to the Summary schema - or schema which provide a mapping
2013        to this schema (see the description of the schema mapping facility
2014        above).
2015       </para>
2016      </listitem>
2017
2018      <listitem>
2019       <para>
2020        SOIF. Support for this syntax is experimental, and is currently
2021        keyed to a private Index Data OID (1.2.840.10003.5.1000.81.2). All
2022        abstract syntaxes can be mapped to the SOIF format, although nested
2023        elements are represented by concatenation of the tag names at each
2024        level.
2025        <!-- FIXME - Is this used anywhere ? -H -->
2026       </para>
2027      </listitem>
2028
2029     </itemizedlist>
2030    </para>
2031   </sect1>
2032
2033  </chapter>
2034  <!-- Keep this comment at the end of the file
2035  Local variables:
2036  mode: sgml
2037  sgml-omittag:t
2038  sgml-shorttag:t
2039  sgml-minimize-attributes:nil
2040  sgml-always-quote-attributes:t
2041  sgml-indent-step:1
2042  sgml-indent-data:t
2043  sgml-parent-document: "zebra.xml"
2044  sgml-local-catalogs: nil
2045  sgml-namecase-general:t
2046  End:
2047  -->