30. Erzeugung eines C3+-XML-Results aus den Metadaten von MyBib eDoc
Kapitel hinzufügen

JavaScript zur Erzeugung eines C3+-XML-Results im neuen Format zur Nutzung für das neue c3xmlconv-Programm unter Verwendung der C3+-Metadaten von MyBib eDoc. Das Script ist Bestandteil von BCS-2 V6 Professional. Sie finden es unter dem Dateinamen tt_generate_c3_plus_me_metadata_xml.js im folgenden Verzeichnis: C:\ProgramData\ImageWareComponents\BCS2_V6_64\js.

// -----------------------------------------------------------
// -----------------------------------------------------------
// Indexnames as Script-Variables:
// use them instead numerics...
// -----------------------------------------------------------
// -----------------------------------------------------------

// -----------------------------------------------------------
// -----------------------------------------------------------
// Indexnames as Script-Variables:
// use them instead numerics...
// -----------------------------------------------------------
// -----------------------------------------------------------

ind_c3_type               =  0;   // Index c3_type  Type: Optionsliste [kein zugeordneter Meta-Daten-Typ]: Typ für c3-xml (monograph, serial, periodical)
ind_c3_id                 =  1;   // Index c3_id  Type: Zeichenkette [kein zugeordneter Meta-Daten-Typ]:
ind_order_id              =  1;   // Index order_id  Type: Zeichenkette [kein zugeordneter Meta-Daten-Typ]: ME- Auftragsnummer
ind_medium_number         =  0;   // Index medium_number  Type: Zeichenkette [kein zugeordneter Meta-Daten-Typ]:
ind_swets_id              =  0;   // Index swets_id  Type: Zeichenkette [kein zugeordneter Meta-Daten-Typ]:
ind_library_network_id    =  0;   // Index library_network_id  Type: Zeichenkette [kein zugeordneter Meta-Daten-Typ]: Verbundkennung
ind_local_id              =  0;   // Index local_id  Type: Zeichenkette [kein zugeordneter Meta-Daten-Typ]:
ind_zdb_id                =  0;   // Index zdb_id  Type: Zeichenkette [ZDB ID]:
ind_main_title            =  2;   // Index main_title  Type: Zeichenkette [kein zugeordneter Meta-Daten-Typ]: Titel
ind_publisher             =  0;   // Index publisher  Type: Zeichenkette [kein zugeordneter Meta-Daten-Typ]:
ind_edition               =  0;   // Index edition  Type: Zeichenkette [kein zugeordneter Meta-Daten-Typ]:
ind_year                  =  3;   // Index year  Type: Zeichenkette [kein zugeordneter Meta-Daten-Typ]: Erscheinungsjahr des Werkes
ind_main_language         =  4;   // Index main_language  Type: Optionsliste [ISO 639-3 Language Code]: ISO639-3 Sprachen Abkürzung
ind_volume_issue          =  0;   // Index volume_issue  Type: Zeichenkette [kein zugeordneter Meta-Daten-Typ]:
ind_volume                =  0;   // Index volume  Type: Zeichenkette [kein zugeordneter Meta-Daten-Typ]:
ind_issue                 =  0;   // Index issue  Type: Zeichenkette [kein zugeordneter Meta-Daten-Typ]:
ind_publication_date      =  0;   // Index publication_date  Type: Zeichenkette [Datum der Veröffentlichung]:
ind_publication_place     =  0;   // Index publication_place  Type: Zeichenkette [Ort der Veröffentlichung]:
ind_callnumber            =  0;   // Index callnumber  Type: Zeichenkette [Signatur]:
ind_issn                  =  0;   // Index issn  Type: Zeichenkette [ISSN]:
ind_isbn                  =  0;   // Index isbn  Type: Zeichenkette [ISBN]:
ind_classification_code   = 8;   // Index classification_code  Type: Zeichenkette [kein zugeordneter Meta-Daten-Typ]:
ind_lib_network_isil      = 9;   // Index lib_network_isil  Type: Zeichenkette [kein zugeordneter Meta-Daten-Typ]:
ind_letzte_Seitennummer   =  5;   // Index letzte Seitennummer  Type: Zeichenkette [kein zugeordneter Meta-Daten-Typ]: letzte Seite  des letzten Artikel
ind_author_complete_works =  6;   // Index author_complete_works  Type: Zeichenkette [kein zugeordneter Meta-Daten-Typ]: Autor des Gesamtwerks
ind_local_system_isil     = 7;   // Index local_system_isil  Type: Zeichenkette [kein zugeordneter Meta-Daten-Typ]: lokale ISIL für einige Bibliotheken
ind_call_indicator        = 12;   // Index call_indicator  Type: Sammlung (Optionsliste mit Mehrfachauswahl) [kein zugeordneter Meta-Daten-Typ]: Abrufkennzeichen (Kollektion)
ind_supplier_isil         = 11;   // Index liefernde Bibliothel (ISIL)

// -----------------------------------------------------------
// -----------------------------------------------------------


//
// computes the complete C3+ Results for all Pages...
//


//
// separate Lists for iterating over
//
var cl           = job.c3PlusResults();
var languages    = [];
var titles       = [];
var sub_titles   = [];
var abstracts    = [];
var page_numbers = [];
var authors      = [];

// ut.notifyUser('#TOC-Items:', cl.length);

for (i = 0; i < cl.length; i++) {

    //
    // TOC-Item
    //
    ti = cl[i];

    language = ti['languages'];
    languages.push(language);

    title_map = ti['title'];
    title     = title_map['lang_default'];
    titles.push(title);

    sub_title_map = ti['sub_title'];
    if (! (sub_title_map === undefined)) {
       sub_title     = sub_title_map['lang_default'];
       sub_titles.push(sub_title);
    }

    abstract_map = ti['abstract'];
    if (! (abstract_map === undefined)) {
       abstract     = abstract_map['lang_default'];
       abstracts.push(abstract);
    }

    authors_map = ti['authors'];
    author      = authors_map['lang_default'];
    authors.push(author);

    page_num_map = ti['page_number'];
    page_num     = page_num_map['lang_default'];
    page_numbers.push(page_num);

} // for i...

// ut.notifyUser('#Titles', titles.length);
// ut.notifyUser('#Sub-Titles', sub_titles.length);
// ut.notifyUser('#Abstracts', abstracts.length);
// ut.notifyUser('#Pagenumbers', page_numbers.length);
// ut.notifyUser('#Authors', authors.length);

var aut_list;
var aut_map;
var aut;

//
// create Root Element
//
xr.initGenericDoc ("c3_xml");
xr.xmlAddAttribute ("version", "1.0");

//
// Meta-Data-Header
//
xr.xmlPush ("medium");
// momentan KEIN type...
//xr.xmlAddAttribute ("type", job.index(ind_c3_type));

c3pmd = job.getKeyValue('ME_Order_C3p_Meta_Data');

// c3id<>$or_item_c3_id<>RD
// title<>$or_item_title<>RD
// year<>$or_item_publ_date_comp<>RD
// issue<>$or_local_1<>RD
// volume<>$or_local_2<>RD
// transaction-group-qualifier<>$or_scan_id<>RD
// item-call-number<>$or_item_callname<>RD
// iwc-item-language<>$or_item_language<>RD
// iwc-lls-catalog-key<>$or_lls_catalog_key<>RD
// iwc-item-hbz-id<>$or_lls_network_id<>RD
// iwc-item-zdb-id<>$or_item_zdb_id<>RD
// iwc-item-classification<>$or_local_4<>RD
// item-issn<>$or_item_issn<>RD
// institution-code<>$or_responder_id<>RD

var meta   = job.getKeyValue("ME_Order_C3p_Meta_Data");
var keys   = "";
var values = "";
var md_item;
var value;
var writable;

//
// Iterate over all keys in the map...
//
for (var key in meta) {

    if (meta.hasOwnProperty(key)) {
//      keys = keys + key + ": " + meta[key] + "\n";
        md_item = meta[key];
        value = md_item["content"];
//      writable = md_item["writable"];
//      values = values + "'" + value + "', writable: " + writable + "\n"

        xr.xmlAddChild(key, value);

    } else {
//      keys = keys + "inh.: " + key + "\n";
//      values = values + "'" + meta[key] + "\n"
    }
}

//ut.notifyUser ("keys", keys);
//ut.notifyUser ("values", values);

//
// Alternative: einzelne Keys direkt ansprechen, nicht alle nehmen...
//
// xr.xmlAddChild("c3id", c3pmd['c3id']['content']);
// xr.xmlAddChild("title", c3pmd['title']['content']);
// xr.xmlAddChild("year", c3pmd['year']['content']);
// xr.xmlAddChild("issue", c3pmd['issue']['content']);
// xr.xmlAddChild("volume", c3pmd['volume']['content']);
// xr.xmlAddChild("transaction-group-qualifier", c3pmd['transaction-group-qualifier']['content']);
// xr.xmlAddChild("item-call-number", c3pmd['item-call-number']['content']);
// xr.xmlAddChild("iwc-item-language", c3pmd['iwc-item-language']['content']);
// xr.xmlAddChild("iwc-lls-catalog-key", c3pmd['iwc-lls-catalog-key']['content']);
// xr.xmlAddChild("iwc-item-hbz-id", c3pmd['iwc-item-hbz-id']['content']);
// xr.xmlAddChild("iwc-item-zdb-id", c3pmd['iwc-item-zdb-id']['content']);
// xr.xmlAddChild("iwc-item-classification", c3pmd['iwc-item-classification']['content']);
// xr.xmlAddChild("item-issn", c3pmd['item-issn']['content']);
// xr.xmlAddChild("institution-code", c3pmd['institution-code']['content']);

xr.xmlPush ("items");
xr.xmlAddAttribute ("count", authors.length);

//
// loop over Articles...
//

for (i = 0; i < authors.length; i++) {

    xr.xmlPush ("item");
    xr.xmlAddAttribute ("id", i+1);

    aut_list  = authors[i];
    language  = ut.trimmed(languages[i]);
    title     = ut.trimmed(titles[i]);
    sub_title = ut.trimmed(sub_titles[i]);
    abstract  = ut.trimmed(abstracts[i]);
    pg        = ut.trimmed(page_numbers[i]);
    sl        = ut.split(pg, "-");
    pg_from   = "";
    pg_to     = "";

    if (2 == sl.length) {
        pg_from = ut.trimmed(sl[0]);
        pg_to   = ut.trimmed(sl[1]);
    }

    if (pg_from.length && pg_to.length) {
       xr.xmlAddChild("page_from", pg_from);
        xr.xmlAddChild("page_to", pg_to);
    } else xr.xmlAddChild("page_from", pg);

      for (j = 0; j < aut_list.length; j++) {

         aut_map  = aut_list[j];
         aut_name = aut_map["name"];
         aut_id   = aut_map["gnd_id"];

         xr.xmlAddChild("author", aut_name);

          if (aut_id.length)
              xr.xmlAddAttribute("gnd_id", aut_id);

      } // for j...

      if (language.length)
         xr.xmlAddChild("language", language);

      if (title.length) {
         //
         // if we have a dedicated sub_title: take the title as is
         // and do not try to detect a sub_title within the title...
         //
         if (sub_title.length)
            xr.xmlAddChild("title", title);
         else {

            // create array of strings, split by ';'...
            var sl = title.split(';');

            //
            // nothing found, just leave with the title...
            //
            if (1 == sl.length) {
               xr.xmlAddChild("title", title);
            } else {

               xr.xmlAddChild("title", sl[0]);
               sl.shift();
               xr.xmlAddChild("sub_title", ut.join(sl, ' : '));

            } // if 1 == sl.length
         } // if sub_title.length...
      } // if title.length...

      if (sub_title.length)
         xr.xmlAddChild("sub_title", sub_title);

      if (abstract.length)
         xr.xmlAddChild("abtract", abstract);

    xr.xmlPop(); // item

} // for i...

xr.xmlPop(); // items

xr.xmlPop(); // medium

//
// Store XML Result in Job's KeyMap
//
job.setKeyValue("C3_PLUS_XML", xr.genericXmlString());

//
// return XML result
//
c3_xml = xr.genericXmlString();

// ut.notifyUser('C3 XML', c3_xml);

c3_xml;