From e3f8a3e28a9edcb0f224d03c0a4f9c1ea94ed494 Mon Sep 17 00:00:00 2001 From: Philipp Zumstein Date: Tue, 3 Jan 2023 12:39:46 +0100 Subject: [PATCH] =?UTF-8?q?Verbessert=20die=20Behandlung=20von=20mehrglied?= =?UTF-8?q?rigen=20Schlagw=C3=B6rter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #145 + ersetzt #142 --- isbn/lib.php | 27 +++++++++++++++++++-------- isbn/obvsg.php | 2 ++ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/isbn/lib.php b/isbn/lib.php index 993e8f8..a8b3624 100644 --- a/isbn/lib.php +++ b/isbn/lib.php @@ -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"]', @@ -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) { diff --git a/isbn/obvsg.php b/isbn/obvsg.php index 05d8084..494de7c 100644 --- a/isbn/obvsg.php +++ b/isbn/obvsg.php @@ -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)")]' );