Skip to content

Commit

Permalink
Verbessert die Behandlung von mehrgliedrigen Schlagwörter
Browse files Browse the repository at this point in the history
Fixes #145 + ersetzt #142
  • Loading branch information
zuphilip committed Jan 3, 2023
1 parent 6d340ce commit e3f8a3e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
27 changes: 19 additions & 8 deletions isbn/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@
'ddc' => '//datafield[@tag="082" and @ind2!="9"]/subfield[@code="a"]',
'sw' => array(
'mainPart' => '//datafield[starts-with(@tag,"6") and (subfield[@code="2"]="gbv" or subfield[@code="2"]="gnd")]',
'value' => './subfield[@code="a" or @code="t"]',
'additional' => './subfield[@code="9" or @code="g"]',
'value' => './subfield[@code="a"]',
'subvalues' => './subfield[@code="b" or @code="t"]',
'additional' => './subfield[@code="9" or @code="g" or @code="z"]',
'key' => './subfield[@code="0" and contains(text(), "(DE-588)")]'
),
'produktSigel' => '//datafield[@tag="912" and not(@ind2="7")]/subfield[@code="a"]',
Expand Down Expand Up @@ -97,15 +98,25 @@ function performMapping($map, $outputXml)
foreach ($mainPart as $singleMainPart) {
$value = $singleMainPart->xpath($xpath['value']);
$key = $singleMainPart->xpath($xpath['key']);
$additional = $singleMainPart->xpath($xpath['additional']);
if ($value) {
$valueText = getValues($value[0]);
if ($additional) {
$additionalText = getValues($additional[0]);
if (strpos($additionalText, ':') == 1) {
$additionalText = substr($additionalText, 2);
if (array_key_exists('subvalues', $xpath)) {
$subvalues = $singleMainPart->xpath($xpath['subvalues']);
$subvaluesArray = [$valueText];
foreach ($subvalues as $sub) {
array_push($subvaluesArray, getValues($sub));
}
$valueText = implode('. ', $subvaluesArray);
}
if (array_key_exists('additional', $xpath)) {
$additional = $singleMainPart->xpath($xpath['additional']);
if ($additional) {
$additionalText = getValues($additional[0]);
if (strpos($additionalText, ':') == 1) {
$additionalText = substr($additionalText, 2);
}
$valueText = $valueText . ' <' . $additionalText . '>';
}
$valueText = $valueText . ' <' . $additionalText . '>';
}

if ($key) {
Expand Down
2 changes: 2 additions & 0 deletions isbn/obvsg.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@
$map['sw'] = array(
'mainPart' => '//datafield[starts-with(@tag,"689")]',
'value' => './subfield[@code="a"]',
'subvalues' => './subfield[@code="b" or @code="t"]',
'additional' => './subfield[@code="g" or @code="z"]',
'key' => './subfield[@code="0" and contains(text(), "(DE-588)")]'
);

Expand Down

0 comments on commit e3f8a3e

Please sign in to comment.