31. Erzeugung eines C3+-XML-Results
Kapitel hinzufügen

JavaScript zur Erzeugung eines C3+-XML-Results im neuen Format zur Nutzung für das neue c3xmlconv-Programm. Das Script ist Bestandteil von BCS-2 V6 Professional. Sie finden es unter dem Dateinamen tt_generate_c3_plus_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              =  0;   // 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    =  2;   // 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                =  3;   // Index zdb_id  Type: Zeichenkette [ZDB ID]:
ind_main_title            =  4;   // 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                  =  7;   // Index year  Type: Zeichenkette [kein zugeordneter Meta-Daten-Typ]: Erscheinungsjahr des Werkes
ind_main_language         =  5;   // 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                =  6;   // Index volume  Type: Zeichenkette [kein zugeordneter Meta-Daten-Typ]:
ind_issue                 =  8;   // 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   = 11;   // Index classification_code  Type: Zeichenkette [kein zugeordneter Meta-Daten-Typ]:
ind_lib_network_isil      = 12;   // Index lib_network_isil  Type: Zeichenkette [kein zugeordneter Meta-Daten-Typ]:
ind_letzte_Seitennummer   =  9;   // Index letzte Seitennummer  Type: Zeichenkette [kein zugeordneter Meta-Daten-Typ]: letzte Seite  des letzten Artikel
ind_author_complete_works =  0;   // Index author_complete_works  Type: Zeichenkette [kein zugeordneter Meta-Daten-Typ]: Autor des Gesamtwerks
ind_local_system_isil     = 14;   // Index local_system_isil  Type: Zeichenkette [kein zugeordneter Meta-Daten-Typ]: lokale ISIL für einige Bibliotheken
ind_call_indicator        = 15;   // Index call_indicator  Type: Sammlung (Optionsliste mit Mehrfachauswahl) [kein zugeordneter Meta-Daten-Typ]: Abrufkennzeichen (Kollektion)
ind_supplier_isil         = 10;   // 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));


//
// c3_id ist Kennung der verwendeten Regel
//
xr.xmlAddChild("c3_id", job.index(ind_c3_id));

//
// order_id: ME-Auftragsnummer oder BCS-2 Job-Nummer
//
// kein ME-Kontext in diesem WF!
// dafuer wird die BCS-2 Job-Nummer genommen !
xr.xmlAddChild("order_id", job.name);

//
// medium_number
//
// keine medium_number
//xr.xmlAddChild("medium_number", job.index(ind_medium_number));

//
// swets_id
//
// keine Swets-ID !
//xr.xmlAddChild("swets_id", job.index(ind_swets_id));

//
// library_network_id
//
xr.xmlAddChild("library_network_id", job.index(ind_library_network_id));

//
// local_id
//
// keine local_id
//xr.xmlAddChild("local_id", job.index(ind_local_id));

//
// zdb_id
//
xr.xmlAddChild("zdb_id", job.index(ind_zdb_id));

//
// main_title
//
xr.xmlAddChild("main_title", job.index(ind_main_title));

//
// publisher
//
// kein Publisher
//xr.xmlAddChild("publisher", job.index(ind_publisher));

//
// edition
//
// keine Edition
//xr.xmlAddChild("edition", job.index(ind_edition));

//
// year
//
xr.xmlAddChild("year", job.index(ind_year));

//
// main_language
//
xr.xmlAddChild("main_language", ut.iso639_3_to_iso639_2B(job.techIndex(ind_main_language)));

//
// volume_issue
//
// kein volume_issue, statt dessen volume und heftnummer
//xr.xmlAddChild("volume_issue", job.index(ind_volume_issue));

//
// volume
//
xr.xmlAddChild("volume", job.index(ind_volume));

//
// issue
//
xr.xmlAddChild("issue", job.index(ind_issue));

//
// publication_date
//
// kein publication_date
//xr.xmlAddChild("publication_date", job.index(ind_publication_date));

//
// publication_place
//
// kein publication_place
//xr.xmlAddChild("publication_place", job.index(ind_publication_place));

//
// callnumber
//
// keine Signatur
//xr.xmlAddChild("callnumber", job.index(ind_callnumber));

//
// issn
//
// keine ISSN
//xr.xmlAddChild("issn", job.index(ind_issn));

//
// isbn
//
// keine ISBN
//xr.xmlAddChild("isbn", job.index(ind_isbn));

//
// classification_code
//
xr.xmlAddChild("classification_code", job.index(ind_classification_code));
xr.xmlAddAttribute ("type", "ssgn");

//
// library_network_isil
//
xr.xmlAddChild("library_network_isil", job.index(ind_lib_network_isil));

//
// supplier_isil
//
xr.xmlAddChild("supplier_isil", job.index(ind_supplier_isil));

//
// complete_works_author (Autor des Gesamtwerks)
// local_system_isil
// call_indicator
//

cw_author         = "";
local_system_isil = "";
call_indicator    = "";

if (ind_author_complete_works > 0) {
   cw_author = job.index(ind_author_complete_works).trim();
}

if (ind_local_system_isil > 0) {
   local_system_isil = job.index(ind_local_system_isil).trim();
}

if (ind_call_indicator > 0) {
   call_indicator = job.index(ind_call_indicator).trim();
}

if (cw_author.length > 0)
  xr.xmlAddChild("main_author", cw_author);

if (local_system_isil.length > 0)
   xr.xmlAddChild("local_system_isil", local_system_isil);

if (call_indicator.length > 0)
   xr.xmlAddChild("call_indicator", call_indicator);

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"];

         if (aut_name.length > 0) {

            xr.xmlAddChild("author", aut_name);

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

         } // aut_name.lenght > 0...

      } // 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;