| 1 |
<?php |
<?php |
| 2 |
// $Id: crossref_unixref_parser.inc,v 1.1.2.5 2009/04/17 02:01:40 rjerome Exp $ |
// $Id: crossref_unixref_parser.inc,v 1.4 2009/06/01 01:31:41 rjerome Exp $ |
| 3 |
function unixref_startElement($parser, $name, $attrs) { |
function unixref_startElement($parser, $name, $attrs) { |
| 4 |
global $node, $element, $attribute, $auth_category, $contrib_count, $org_count; |
global $node, $element, $attribute, $auth_category, $contrib_count, $org_count; |
| 5 |
switch ($name) { |
switch ($name) { |
| 16 |
case 'sa_component': |
case 'sa_component': |
| 17 |
$node['biblio_type'] = _unixref_type_map($name); |
$node['biblio_type'] = _unixref_type_map($name); |
| 18 |
break; |
break; |
| 19 |
|
case 'journal_article': |
| 20 |
|
case 'conference_paper': |
| 21 |
|
case 'content_item': |
| 22 |
|
case 'report-paper_metadata': |
| 23 |
|
case 'standard_metadata': |
| 24 |
|
case 'database_date': |
| 25 |
|
case 'component': |
| 26 |
|
$node['year'] = ''; |
| 27 |
|
$node['doi'] = ''; |
| 28 |
|
break; |
| 29 |
case 'person_name' : |
case 'person_name' : |
| 30 |
$auth_category = _unixref_get_contributor_category($attrs['contributor_role']); |
$auth_category = _unixref_get_contributor_category($attrs['contributor_role']); |
| 31 |
if (!isset($contrib_count)) |
if (!isset($contrib_count)) |
| 46 |
} |
} |
| 47 |
$element = $name; |
$element = $name; |
| 48 |
} |
} |
| 49 |
|
function unixref_decode(&$item, $key) { |
| 50 |
|
$item = html_entity_decode($item, NULL, 'UTF-8'); |
| 51 |
|
print $key.' = '. $item . "\n"; |
| 52 |
|
} |
| 53 |
function unixref_endElement($parser, $name) { |
function unixref_endElement($parser, $name) { |
| 54 |
global $node, $nids, $element, $attribute, $terms, $batch_proc, $session_id, $save_node, $auth_category, $contrib_count, $org_count; |
global $node, $nids, $element, $attribute, $terms, $batch_proc, $session_id, $save_node, $auth_category, $contrib_count, $org_count; |
| 55 |
switch ($name) { |
switch ($name) { |
| 56 |
case 'doi_record' : |
case 'doi_record' : |
| 57 |
|
array_walk_recursive($node,'unixref_decode' ); |
| 58 |
$nids[] = biblio_save_node($node, $batch, $session_id, $save_node); |
$nids[] = biblio_save_node($node, $batch, $session_id, $save_node); |
| 59 |
break; |
break; |
| 60 |
case 'person_name' : |
case 'person_name' : |
| 91 |
case 'database_date': |
case 'database_date': |
| 92 |
case 'component': |
case 'component': |
| 93 |
$node['biblio_year'] = $node['year']; |
$node['biblio_year'] = $node['year']; |
| 94 |
|
$node['biblio_doi'] = $node['doi']; |
| 95 |
break; |
break; |
| 96 |
case 'issn': |
case 'issn': |
| 97 |
if($attribute == 'issn_print') $node['biblio_issn'] = $node['issn']; |
if($attribute == 'issn_print') $node['biblio_issn'] = $node['issn']; |
| 98 |
|
$node['issn'] = ''; |
| 99 |
break; |
break; |
| 100 |
case 'isbn': |
case 'isbn': |
| 101 |
if($attribute == 'isbn_print') $node['biblio_isbn'] = $node['isbn']; |
if($attribute == 'isbn_print') $node['biblio_isbn'] = $node['isbn']; |
| 102 |
|
$node['isbn'] = ''; |
| 103 |
break; |
break; |
| 104 |
default : |
default : |
| 105 |
} |
} |
| 108 |
} |
} |
| 109 |
function unixref_characterData($parser, $data) { |
function unixref_characterData($parser, $data) { |
| 110 |
global $node, $element, $auth_category, $contrib_count, $org_count; |
global $node, $element, $auth_category, $contrib_count, $org_count; |
| 111 |
|
$data = htmlspecialchars_decode($data); |
| 112 |
if (trim($data)) { |
if (trim($data)) { |
| 113 |
switch ($element) { |
switch ($element) { |
| 114 |
case 'surname' : |
case 'surname' : |
| 157 |
'issue' => 'biblio_issue', |
'issue' => 'biblio_issue', |
| 158 |
'edition_number' => 'biblio_edition', |
'edition_number' => 'biblio_edition', |
| 159 |
'section' => 'biblio_section', |
'section' => 'biblio_section', |
| 160 |
'doi' => 'biblio_doi', |
'doi' => 'doi', |
| 161 |
'title' => 'title', |
'title' => 'title', |
| 162 |
'isbn' => 'isbn', |
'isbn' => 'isbn', |
| 163 |
'issn' => 'issn', |
'issn' => 'issn', |