filler
Page d'accueilfiller
filler

élément de remplissageélément de remplissageélément de remplissageélément de remplissageélément de remplissage
élément de remplissageEnglishContactez-NousCarte du siteMembres seulement
Réseau de connaissances en sciences de la terreRéseau de connaissances en sciences de la terreRéseau de connaissances en sciences de la terre
élément de remplissage

Au sujet de RCCST
Services et outils
Projets
Groupes de travail
Participants
Liens connexes
filler

Services et outils
spacer

Logiciel-serveur de métadonnées Z39.50


NAME

zserver.pl - Z39.50 server, with GEO compliance, for Solaris and Windows.


SYNOPSIS

  • zserver.pl
    Starts up Zserver with the default configuration. Zserver will read in the map file fgdcMap.xml and monitor port 9999 for connection requests.

  • zserver.pl -m/test/user/TestMap.xml -p9000
    Starts up Zserver with the map file "/test/user/TestMap.xml" and monitors port 9000 for connection requests.

    On Windows, the syntax for specifying the same map file is "\test\user\TestMap.xml".


DESCRIPTION

Zserver uses Z39.50 to make databases available as GEO profile compliant metadata.

Z39.50 (http://lcweb.loc.gov/z3950/agency/markup/toc.html) is a communication protocol specifying how server and client software exchange messages to retrieve information. The server software in this case is Zserver. Most client software were created for bibliographic databases. However, the client at http://cgkn.net/cur/datacat/index.php focuses on geospatial metadata.

GEO profile (http://www.blueangeltech.com/standards/GeoProfile/geo22.htm) is a framework for organizing information known as geospatial metadata. Using this framework, end-users can indicate the metadata of interest without knowing how the underlying databases organize the data.

Feature Highlights


COMMAND LINE PARAMETERS

On the command line invoking Zserver, you can supply parameters separated by spaces.

  • -m<map_file_name>

    For example, "zserver.pl -m/test/user/TestMap.xml" specifies the map file "/test/user/TestMap.xml".

    On Windows, the syntax for specifying the same map file is "\test\user\TestMap.xml".

  • -p<port_number>

    For example, "zserver.pl -p9000" asks Zserver to monitor port 9000 for connection requests.

    Note that when multiple parameters are specified, the port parameter must be the last.

  • -pf<pre-fetch_count>

    For example, "zserver.pl -pf200" asks Zserver to pre-fetch 200 matching records after each search. By pre-fetching records, Zserver does not have to issue a separate database request for individual records. The overall response is therefore improved. The price for such improvement is the memory used for storing the pre-fetched records.

    When Zserver receives a request for records beyond the pre-fetched ones, Zserver will ask the database server for those records and, if applicable, the preceding ones. For example, with 200 records pre-fetched and there is a request for the 284th record, Zserver will issue a database request for record 201 to 284. After that, any requests for record 1 to 284 will cause Zserver to look into the 284 pre-fetched records.

    The default is 100.

  • -trace

    For example, "zserver.pl -trace" asks Zserver to output overall trace messages.

  • -tracepqf

    For example, "zserver.pl -tracepqf" asks Zserver to output trace messages on the parsing of search query. PQF stands for Prefix Query Format. It is the search query's format.


LIMITATIONS

Zserver includes the following limitations:


SETUP

Here is a 3-step process of getting Zserver up and running:

  1. Download and install http://cgkn.net/cur/zserver/zserver-0.82.tar.gz.
     
    For Solaris, see Installing on Solaris.

    For Windows, see Installing on Windows.

  2. Edit the map file to tell Zserver how the individual GEO profile "use" attributes should be mapped to database fields. See MAP FILE FORMAT.

  3. Start Zserver (e.g. perl zserver.pl). For parameter description, see COMMAND LINE PARAMETERS.

Installing on Solaris

On a Solaris machine with Perl and C installed, you need to compile and install the following:

Installing on Windows

Note:
On Windows (Win32), you can go through the same compile-and-install process as in Solaris. You don't need DBD::Oracle and DBD::Pg. However, you need Microsoft Visual C++. Without that, you have to install pre-compiled binaries.

This section is about installing pre-compiled binaries. The reference in parenthesis after a package name refers to either a binary distribution's URL or an ActivePerl "ppm install" command.

In the case of an URL, download and install the binary. Note the version number. It is important to get the specified version.

In the case of a PPM (Perl Package Manager) command, run it inside a Command Prompt window to install the package.

To run Zserver on Windows, you need the following:

  • ActivePerl 5.8.3 Build 809 (http://ftp.activestate.com/ActivePerl/Windows/5.8/ActivePerl-5.8.3.809-MSWin32-x86.msi)
  • Oracle Software (http://www.oracle.com)
  • Required only if you want to access Oracle databases.

    Note that when you run Zserver on a machine without Oracle installed, and yet the map file (see MAP FILE FORMAT) has <database> elements referring to an Oracle database, you will see errors about the Oracle database during Zserver start-up. You can ignore the errors as long as Zserver won't be asked to access the Oracle database.

  • PostgreSQL ODBC Driver (http://gborg.postgresql.org/project/psqlodbc/genpage.php)
  • Required only if you want to access PostgreSQL databases.

  • DBI (ppm install DBI)
  • DBD::ODBC (ppm install DBD::ODBC)
  • Except for accessing Oracle databases, Zserver does not require a DSN (Data Source Name) defined on the machine running Zserver. However, when Zserver cannot connect to a database, you can go through the process of adding a System DSN (Start> Settings> Control Panel> Administrative Tools> Data Sources (ODBC)) to determine whether there are problems with the environment.

    • When selecting a driver, note the fact that Zserver uses the following drivers:
       "PostgreSQL" for PostgreSql 
       "SQL Server" for MS SQL

    • After specifying a name for the DSN, you will see the option like "Connect to SQL Server to obtain default settings for the additional configuration options.". Select it and provide the Login ID and Password as used in the database mapping. Then click on Next. If the connection cannot go through, you will see error messages. Resolve the issues before trying Zserver again.

  • XML::LibXML::Common (ppm install http://theoryx5.uwinnipeg.ca/ppmpackages/XML-LibXML-Common.ppd)
    • In response to the "Fetch libxml2.dll [yes]" prompt, press enter to download and install the DLL.

    • In response to the "Where should libxml2.dll be placed? [Perl/bin]" question, enter a directory that is in the system variable "path".

  • XML::SAX (ppm install http://theoryx5.uwinnipeg.ca/ppms/XML-SAX.ppd)
  • After installation, check the SAX directory to look for a file called ParserDetails.ini. If there is no such file, create a blank file and name it as such.
     
    If ActivePerl was installed on c:\perl, the SAX directory is typically c:\perl\site\lib\XML\SAX.

  • XML::LibXML (ppm install http://theoryx5.uwinnipeg.ca/ppms/XML-LibXML.ppd)
  • XML::LibXSLT (ppm install http://theoryx5.uwinnipeg.ca/ppms/XML-LibXSLT.ppd)
    • In response to the "Fetch libxslt_win32.dll [yes]" prompt, press enter to download and install the DLL.

    • In response to the "Where should libxslt_win32.dll be placed? [Perl/bin]" question, enter a directory that is in the system variable "path".

    • In response to the "Fetch libexslt_win32.dll [yes]" prompt, press enter to download and install the DLL.

    • In response to the "Where should libexslt_win32.dll be placed? [Perl/bin]" question, enter a directory that is in the system variable "path".

  • YAZ 2.0.20 (http://ftp.indexdata.dk/pub/yaz/win32/yaz_2.0.20.exe)
  • After installing YAZ, remember to add the YAZ installation directory to the system variable "path". It is required by SimpleServer.

  • Net::Z3950::SimpleServer (ppm install http://cgkn.net/cur/zserver/Net-Z3950-SimpleServer.ppd)
  • If for whatever reasons you need to re-build the SimpleServer PPM package, see Building a SimpleServer PPM package.

Building a SimpleServer PPM package

A SimpleServer PPM package allows SimpleServer to be installed on a Windows machine that was not set up for compilation.

To build the package, you need a machine with ActivePerl 5.8+, YAZ 2+, and Microsoft Visual C++ installed. After downloading the SimpleServer 0.08+ source, go to the source directory and do the following:

  • Change Makefile.PL
    • Comment out the line starting with "my $libs". For example,
       #my $libs = `yaz-config --libs threads` || die "ERROR: Unable to call script: yaz-config";

    • Specify in LIBS, the location of yaz.lib. For example,
          'LIBS'      => 'c:\bin\yaz\lib\yaz.lib',

    • Specify in INC, the YAZ include path. For example,
          'INC'       => '-Ic:\bin\yaz\include',

    • Add, right after the 'INC' line, the following lines:
          'AUTHOR' => 'Index Data(www.indexdata.dk)',
          'ABSTRACT' => 'Z39.50(ActivePerl 5.8.3.809, Yaz 2.0.20)',

      Note that the abstract includes the version numbers of ActivePerl and Yaz that the SimpleServer is compiled with. Update those numbers to reflect the versions you are using.

  • Compile SimpleServer and create a ppd
  • Start up a Visual Studio .NET 2003 Command Prompt window (Start> Programs> Microsoft Visual Studio .NET 2003> Visual Studio .NET Tools> Visual Studio .NET 2003 Command Prompt) and execute the following commands:

    • perl MakeFile.PL

    • nmake

    • nmake ppd

  • Copy run-time library
  • "nmake" in the above created a set of binaries inside the directory blib. You need to copy the C run-time library %SystemRoot%\system32\msvcr71.dll to blib\arch\auto\Net\Z3950\SimpleServer.

  • Create an archive
  • Use tar and gzip to create an archive of the blib binaries. For example,
     tar cvf Net-Z3950-SimpleServer.tar blib
     gzip --best Net-Z3950-SimpleServer.tar
  • Specify archive in ppd
    • Open Net-Z3950-SimpleServer.ppd and locate the line:
       <CODEBASE HREF="" />
    • Change it to specify the archive. For example,
       <CODEBASE HREF="Net-Z3950-SimpleServer.tar.gz" />

Now the package is ready. It is consisted of the ppd file and the .gz archive. Both of them have to be in the same directory. If that directory is on the web, people can install SimpleServer by opening a Command Prompt window and issuing a command such as:

 ppm install http://cgkn.net/cur/zserver/Net-Z3950-SimpleServer.ppd


MAP FILE FORMAT

To indicate how the GEO profile "use" attributes should be mapped to a database, you need a map file. The map file is in XML format and has a <schema> element.

Zserver comes with the default map file fgdcMap.xml. It resides in the same directory where you find Zserver. A recommended way of creating your own map file is to modify fgdcMap.xml. In it, you can remove any of the <database> elements, except the one with dbNameFromClient="ignore". That <database> element must remain in the map file.

To specify a new database mapping, add a <database> element to <schema>, then add <field> elements to <database>.

Note that, as specified in the XML standard, the element and attribute names are case-sensitive. To have the character "<" appears inside an attribute value, you have to use "&lt;".

<database>

The <database> element's attributes provide database connection information. For example:

    <database
              dbSystem="postgreSql"
              dbNameFromClient="MIRAGE"
              dbNameToServer="gscmaps"
              host="region11.agg.nrcan.gc.ca"
              port="1234"
              user="userAbc"
              password="userAbcPassword"
    >

A <database> element has the following attributes:
  • dbNameFromClient
  • The name that a database is known to the client (software or user) connecting to Zserver.

    Note that, as stated in the Z39.50 specification, section 3.2.2.1.2 (http://lcweb.loc.gov/z3950/agency/markup/04.html), the name is case-insensitive. Thus, "MyDatabase" is the same as "mydatabase".

  • dbNameToServer
  • The name that a database is known to the managing database server. This name typically appears in a database connection string.

  • dbSystem
  • A case-sensitive code indicating the type of database server managing the database. The valid codes are :
    • msSql
    • Microsoft SQL server.

    • odbcSocketServer
    • odbcSocketServer refers to a type of database connection in which there is an ODBC Socket Server running on a Windows PC acting as a bridge between a Microsoft SQL server and Zserver.

      ODBC Socket Server is the slowest form of database access. The socket server does not support partial fetching of matching records. It always returns all the matching records. Depending on how fast the socket server can respond, which is affected by the amount of matching data from a query, a timeout can occur at the TCP/IP level.

      ODBC Socket Server is available from http://odbcsock.sourceforge.net. After installing it, remember to create a DSN (Data Source Name) with the same name as that in dbNameToServer.

      Zserver's support of ODBC Socket Server is experimental.

    • oracle
    • To access an Oracle database from a Zserver running on Windows, you need to define a system DSN with the same name as that in dbNameToServer.

    • postgreSql
    • PostgreSQL server.

  • host
  • The host name or IP address of the machine on which the database server is running.

    For an Oracle database, this attribute is ignored by the Zserver running on a Windows machine.

  • port
  • The port number which the database server will monitor for database access.

    For a Microsoft SQL server database, this attribute is ignored on Windows. It is optional on Solaris.

    For an ODBC Socket Server database, this attribute is ignored.

    For an Oracle database, this attribute is ignored on Windows. it is required on Solaris.

  • user
  • The user name for logging in to the database server.

  • password
  • The password for logging in to the database server.

<field>

The <field> element specifies how an "use" attribute as defined in the GEO profile is mapped to a database. For examples:

    <field 
        usePath="metadata->dataqual->lineage->srcinfo->srccite->citeinfo->title" 
        table="tableName" 
        column="columnName" 
    />

    <field 
        usePath="metadata->idinfo->citation->citeinfo->pubdate"
        sql="to_char(metamaps.publication_date,'YYYYMMDD')" 
    />

    <field
        usePath="metadata->idinfo->ptcontac->cntinfo->cntaddr->country"
        const="Canada"
    />

Note that a database mapping must have at least two <field> elements. One of them must be mapped to a table column.

A <field> element recognizes the following attributes (some are applicable only to certain mapping):

  • column
  • Name of the database column that an "use" attribute is mapped to.

    A <field> element with "column" attribute cannot have "sql" or "const" attributes.

  • const
  • A constant text string that an "use" attribute is mapped to. The constant must be enclosed within double quotes ("). Please note the following special handling of characters found in a constant:
    1. All ampersand (&) characters within the constant must be changed to &amp;.

    2. To have a constant including executable HTML, replace the less than sign (<) by &lt;. For example,
       const="HTML code: &lt;a href='http://gdcinfo.agg.nrcan.gc.ca/gdc/index_f.html'>Centre de données géoscientifiques&lt;/a>"
    3. To have a constant including HTML intended only for display and not for execution, replace < by &amp;amp;lt;. For example,
       const="HTML display: &amp;amp;lt;a href='http://gdcinfo.agg.nrcan.gc.ca/gdc/index_f.html'>Centre de données géoscientifiques&amp;amp;lt;/a>"

    A <field> element with "const" attribute cannot have "table", "column", or "sql" attributes.

  • sql
  • A SQL scalar expression that an "use" attribute is mapped to. The expression must be enclosed within double quotes (").

    A scalar expression is an expression returning a single value. For example,

     "to_char(metamaps.ending_date,'YYYYMMDD')"

    The SQL expression can have subqueries, i.e. SELECT queries returning a single value. Therefore, you can link tables together. For example, let's say the "use" attribute, Series Name (sername), is stored in a table column. But the name stored there is a short name. There is another table translating short names to long names. To map Series Name to a long name, you can do the following:

     <field 
         usePath="metadata->idinfo->citation->citeinfo->title" 
         table="main_table" 
         column="title" 
     />  
     <field
         usePath="metadata->idinfo->citation->citeinfo->serinfo->sername"
         sql="SELECT long_name FROM name_table WHERE name_table.short_name = main_table.short_name"
     />

    Note that it is OK for the subquery to reference main_table even though main_table is not in the subquery's FROM clause. That is because main_table is referenced from somewhere else, i.e. the Title <field> element. In other words, the Title <field> element pulls in main_table and makes it available to all the subqueries within the same database mapping.

    When formulating a subquery, make sure that it returns a single value, not a column.

    A <field> element with "sql" attribute cannot have "table", "column", or "const" attributes.

  • table
  • Name of a database table in which a column is mapped to an "use" attribute.

    A <field> element with "table" attribute cannot have "sql" or "const" attributes.

  • usePath
  • The path of an "use" attribute.


PATHS

To prepare a map file, you need to understand paths. This section provides an introduction.

About paths
GEO specifies the relationships among "use" attributes. For instance, GEO states that:
"Metadata" includes "Identification Information".

"Identification Information" includes "Point of Contact".

"Point of Contact" includes "Contact Information".

"Contact Information" includes "Contact Address".

"Contact Address" includes "Country".

Expressing the above series of relationships as a path using the "use" attribute short names, we have:

metadata->idinfo->ptcontac->cntinfo->cntaddr->country

Furthermore, GEO allows some attributes to appear in multiple places. For instance, "Contact Information" can appear in four places. Since "Country" is a part of "Contact Information", "Country" has four possible paths:

metadata->dataqual->lineage->procstep->proccont->cntinfo->cntaddr->country

metadata->distinfo->distrib->cntinfo->cntaddr->country

metadata->idinfo->ptcontac->cntinfo->cntaddr->country

metadata->metainfo->metc->cntinfo->cntaddr->country

When you specify an "use" attribute, you need to indicate which of the possible paths you have in mind. You do that by including the path in the usePath attribute. For example,

usePath="metadata->idinfo->ptcontac->cntinfo->cntaddr->country"

Ramification of mapping an attribute more than once
As shown in the above illustration, an "use" attribute may appear in multiple places - each with an unique path. When a database map has entries referring to the same "use" attribute, each with a different path, it affects how Zserver selects matching records.

For example, let's say a database map includes the following <field> elements:

    <field
        usePath="metadata->dataqual->lineage->srcinfo->srccite->citeinfo->title" 
        table="Landscapes" 
        column="srcTitle" 
    />
    <field 
        usePath="metadata->idinfo->citation->citeinfo->title" 
        table="Landscapes" 
        column="idTitle" 
    />

Both <field> elements address Title. One refers to the Title in Source Information (srcinfo); the other refers to the Title in Identification Information (idinfo).

When Zserver processes a query looking for records with Title containing "abc", a record will be selected when its Title in Identification Information or Source Information contains "abc".

Discovering paths
Here is a way to discover all the possible paths for an "use" attribute:
  1. Find the "use" attribute's numeric value by going to the "<useDefList>" section in the map file and search for a "titleKey" with your "use" attribute's title. When you find such line, the "value" entry on that line is the "use" attribute's numeric value.

    For example, to get the numeric value of the use attribute, Contact Person, search for "Contact Person" (enclosed within double quotes). You will see that Contact Person has the numeric value of 2023.

  2. With the numeric value in hand, search further down the map file for an "<usePath" line with the "valueKey" equals to the "use" attribute's numeric value.

    Once you've located that line, you will see a group of "<usePath" lines with the same "valueKey", if the "use" attribute can appear in multiple places. The "pathKey" entries in those lines are the available paths that you can use in specifying a field for the "use" attribute.

    To carry on with the Contact Person example, when you search for an "<usePath" line with "2023", you will see a number of lines with such value. You can use any of those pathKey values to specify a path in your database mapping.

  3. A path is consisted of short names. The meaning of those short names may not be very intuitive. To expand the short names, search further down the map file for the short name path.

    Continuing with the Contact Person example, when you search for:

    "metadata->dataqual->lineage->procstep->proccont->cntinfo->cntorgp->cntper"

    you will see that it means:

    'Metadata'->'Data Quality Information'->'Lineage'->'Process Step'->'Process Contact'->'Contact Information'->'Contact Organization Primary'->'Contact Person'

    You CANNOT use a path with expanded names to specify a field in the database mapping. You must use a path with short names.


AUTHORS

Jean-François Doyon (Canadian Centre for Remote Sensing, Natural Resources Canada) started Zserver.

Zoltan Bardossy (Natural Resources Canada) further enhanced it.

Boniface Lau (under contract to James Rupert at Natural Resources Canada) rewrote Zserver to add numerous functionality and provided user documentation. The latest release is 0.82.


COPYRIGHT

Copyright (c) 2004 Natural Resources Canada

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

 

Haut de page  
spacer spacer
Au sujet de RCCST | Services et outils | Projets
Groupes de travail | Participants | Liens connexes
Page d'accueil |English | Contactez-Nous | Carte de suite | Membres seulement