add hbzfix XML examples
This commit is contained in:
parent
780cade9ca
commit
503647ec9b
4 changed files with 292 additions and 0 deletions
73
src/test/java/org/xbib/marc/xml/BadRecordIdentifierTest.java
Normal file
73
src/test/java/org/xbib/marc/xml/BadRecordIdentifierTest.java
Normal file
|
@ -0,0 +1,73 @@
|
|||
package org.xbib.marc.xml;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.xbib.marc.Marc;
|
||||
import org.xbib.marc.MarcRecord;
|
||||
import org.xbib.marc.MarcRecordListener;
|
||||
import org.xbib.marc.transformer.value.MarcValueTransformer;
|
||||
import org.xbib.marc.transformer.value.MarcValueTransformers;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class BadRecordIdentifierTest {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(BadRecordIdentifierTest.class.getName());
|
||||
|
||||
@Test
|
||||
public void testBadRecordId() throws Exception {
|
||||
String s = "badid.xml";
|
||||
InputStream in = getClass().getResourceAsStream(s);
|
||||
AtomicBoolean found = new AtomicBoolean();
|
||||
MarcRecordListener marcRecordListener = new MarcRecordListener() {
|
||||
@Override
|
||||
public void beginCollection() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void record(MarcRecord marcRecord) {
|
||||
logger.log(Level.INFO, "record = " + marcRecord);
|
||||
found.set(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endCollection() {
|
||||
}
|
||||
};
|
||||
MarcContentHandler marcListener = new MarcContentHandler();
|
||||
marcListener.setMarcRecordListener(marcRecordListener);
|
||||
MarcValueTransformer marcValueTransformer = BadRecordIdentifierTest::clean;
|
||||
MarcValueTransformers marcValueTransformers = new MarcValueTransformers();
|
||||
marcValueTransformers.setMarcValueTransformer("001$$", marcValueTransformer);
|
||||
Marc.builder()
|
||||
.setInputStream(in)
|
||||
.setCharset(StandardCharsets.UTF_8)
|
||||
.setContentHandler(marcListener)
|
||||
.setMarcValueTransformers(marcValueTransformers)
|
||||
.build()
|
||||
.xmlReader()
|
||||
.parse();
|
||||
assertTrue(found.get());
|
||||
}
|
||||
|
||||
private static String clean(String string) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (string != null) {
|
||||
for (char ch : string.toCharArray()) {
|
||||
if (ch < 32 || ch > 127) {
|
||||
break;
|
||||
}
|
||||
if (sb.length() > 31) {
|
||||
break;
|
||||
}
|
||||
sb.append(ch);
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
67
src/test/java/org/xbib/marc/xml/HbzfixXMLTest.java
Normal file
67
src/test/java/org/xbib/marc/xml/HbzfixXMLTest.java
Normal file
|
@ -0,0 +1,67 @@
|
|||
/**
|
||||
* Copyright 2016-2022 Jörg Prante <joergprante@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a>
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.xbib.marc.xml;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.xbib.marc.Marc;
|
||||
import org.xbib.marc.MarcRecord;
|
||||
import org.xbib.marc.MarcRecordListener;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class HbzfixXMLTest {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(HbzfixXMLTest.class.getName());
|
||||
|
||||
@Test
|
||||
public void testHbzFixRecordListener() throws Exception {
|
||||
String s = "hbzfix.xml";
|
||||
InputStream in = getClass().getResourceAsStream(s);
|
||||
AtomicBoolean found = new AtomicBoolean();
|
||||
MarcRecordListener marcRecordListener = new MarcRecordListener() {
|
||||
@Override
|
||||
public void beginCollection() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void record(MarcRecord marcRecord) {
|
||||
logger.log(Level.INFO, "record = " + marcRecord);
|
||||
found.set(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endCollection() {
|
||||
}
|
||||
};
|
||||
// attach record listener
|
||||
MarcContentHandler marcListener = new MarcContentHandler();
|
||||
marcListener.setMarcRecordListener(marcRecordListener);
|
||||
Marc.builder()
|
||||
.setInputStream(in)
|
||||
.setCharset(StandardCharsets.UTF_8)
|
||||
.setContentHandler(marcListener)
|
||||
.build()
|
||||
.xmlReader()
|
||||
.parse();
|
||||
assertTrue(found.get());
|
||||
}
|
||||
}
|
76
src/test/resources/org/xbib/marc/xml/badid.xml
Normal file
76
src/test/resources/org/xbib/marc/xml/badid.xml
Normal file
|
@ -0,0 +1,76 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<marc:collection xmlns:marc="http://www.loc.gov/MARC21/slim">
|
||||
<marc:record>
|
||||
<marc:leader>00000nam a2200000uu 4500</marc:leader>
|
||||
<marc:controlfield tag="001">(DE-447)EMARCHITECTS - BURST<53><54>003 North Haven . MASAHARU TAKASAKI - Tenchi House Nagoya . JYRKI TASA - House Moby Dick Espoo . CHRIS TATE Forest House Titirangi . TEZUKA ARCHITECTS - Pitched Roof House Nagano . TNA - Ring House Karuizawa, Nagano/ Mosaic House Tokyo . VO TRONG NGHIA - Stacking Green Ho Chi Minh City . WEBER l HUMMEL - Huse u Erlangen . WILLIAMS AND TSIEN - Shelter Island House Shelter Island . ZECC - Stairway to Heaven Utrecht . ZHANG LEI - Brick House 01 Nanjing/ Concrete Slit House Nanjing . PETER ZUMTHOR - Single-Family Hose Jenaz</marc:controlfield>
|
||||
<marc:controlfield tag="003">DE-1020</marc:controlfield>
|
||||
<marc:controlfield tag="005">20200401000000.0</marc:controlfield>
|
||||
<marc:controlfield tag="008">200401s2014 gw |||| |||| 00||| ger|c</marc:controlfield>
|
||||
<marc:datafield tag="020" ind1=" " ind2=" ">
|
||||
<marc:subfield code="a">9783473327218</marc:subfield>
|
||||
</marc:datafield>
|
||||
<marc:datafield tag="020" ind1=" " ind2=" ">
|
||||
<marc:subfield code="a">3473327212</marc:subfield>
|
||||
</marc:datafield>
|
||||
<marc:datafield tag="040" ind1=" " ind2=" ">
|
||||
<marc:subfield code="a">DE-1020</marc:subfield>
|
||||
<marc:subfield code="b">ger</marc:subfield>
|
||||
<marc:subfield code="c">DE-605</marc:subfield>
|
||||
</marc:datafield>
|
||||
<marc:datafield tag="245" ind1=" " ind2=" ">
|
||||
<marc:subfield code="a">Weltraum</marc:subfield>
|
||||
<marc:subfield code="b">[mit ausklappbaren Entdecker-Seiten ; 8 - 12 Jahre]</marc:subfield>
|
||||
<marc:subfield code="c">[Text und Konzept: Stefan Greschik. Ill.: Jochen Windecker. Comic-Ill.: Billa Spiegelhauer. Fachl. Beratung:
|
||||
Richard Bräucker]</marc:subfield>
|
||||
</marc:datafield>
|
||||
<marc:datafield tag="264" ind1=" " ind2="1">
|
||||
<marc:subfield code="a">Ravensburg</marc:subfield>
|
||||
<marc:subfield code="b">Ravensburger Buchverl.</marc:subfield>
|
||||
<marc:subfield code="c">2014</marc:subfield>
|
||||
</marc:datafield>
|
||||
<marc:datafield tag="300" ind1=" " ind2=" ">
|
||||
<marc:subfield code="a">54 S.</marc:subfield>
|
||||
</marc:datafield>
|
||||
<marc:datafield tag="924" ind1=" " ind2=" ">
|
||||
<marc:subfield code="b">DE-1020</marc:subfield>
|
||||
<marc:subfield code="c">NRW</marc:subfield>
|
||||
</marc:datafield>
|
||||
</marc:record>
|
||||
<marc:record>
|
||||
<marc:leader>00000nam a2200000uu 4500</marc:leader>
|
||||
<marc:controlfield tag="001">(DE-1020)E998535454</marc:controlfield>
|
||||
<marc:controlfield tag="003">DE-1020</marc:controlfield>
|
||||
<marc:controlfield tag="005">20200401000000.0</marc:controlfield>
|
||||
<marc:controlfield tag="008">200401s2014 gw |||| |||| 00||| ger|c</marc:controlfield>
|
||||
<marc:datafield tag="020" ind1=" " ind2=" ">
|
||||
<marc:subfield code="a">9783473328888</marc:subfield>
|
||||
</marc:datafield>
|
||||
<marc:datafield tag="020" ind1=" " ind2=" ">
|
||||
<marc:subfield code="a">347332888X</marc:subfield>
|
||||
</marc:datafield>
|
||||
<marc:datafield tag="040" ind1=" " ind2=" ">
|
||||
<marc:subfield code="a">DE-1020</marc:subfield>
|
||||
<marc:subfield code="b">ger</marc:subfield>
|
||||
<marc:subfield code="c">DE-605</marc:subfield>
|
||||
</marc:datafield>
|
||||
<marc:datafield tag="100" ind1="1" ind2=" ">
|
||||
<marc:subfield code="a">Nieländer, Peter</marc:subfield>
|
||||
</marc:datafield>
|
||||
<marc:datafield tag="245" ind1=" " ind2=" ">
|
||||
<marc:subfield code="a">Rund um den Fußball</marc:subfield>
|
||||
<marc:subfield code="c">[Ill. und Text: Peter Nieländer]</marc:subfield>
|
||||
</marc:datafield>
|
||||
<marc:datafield tag="264" ind1=" " ind2="1">
|
||||
<marc:subfield code="a">Ravensburg</marc:subfield>
|
||||
<marc:subfield code="b">Ravensburger Buchverl.</marc:subfield>
|
||||
<marc:subfield code="c">2014</marc:subfield>
|
||||
</marc:datafield>
|
||||
<marc:datafield tag="300" ind1=" " ind2=" ">
|
||||
<marc:subfield code="a">[16] S.</marc:subfield>
|
||||
</marc:datafield>
|
||||
<marc:datafield tag="924" ind1=" " ind2=" ">
|
||||
<marc:subfield code="b">DE-1020</marc:subfield>
|
||||
<marc:subfield code="c">NRW</marc:subfield>
|
||||
</marc:datafield>
|
||||
</marc:record>
|
||||
</marc:collection>
|
76
src/test/resources/org/xbib/marc/xml/hbzfix.xml
Normal file
76
src/test/resources/org/xbib/marc/xml/hbzfix.xml
Normal file
|
@ -0,0 +1,76 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<marc:collection xmlns:marc="http://www.loc.gov/MARC21/slim">
|
||||
<marc:record>
|
||||
<marc:leader>00000nam a2200000uu 4500</marc:leader>
|
||||
<marc:controlfield tag="001">(DE-1020)E998535450</marc:controlfield>
|
||||
<marc:controlfield tag="003">DE-1020</marc:controlfield>
|
||||
<marc:controlfield tag="005">20200401000000.0</marc:controlfield>
|
||||
<marc:controlfield tag="008">200401s2014 gw |||| |||| 00||| ger|c</marc:controlfield>
|
||||
<marc:datafield tag="020" ind1=" " ind2=" ">
|
||||
<marc:subfield code="a">9783473327218</marc:subfield>
|
||||
</marc:datafield>
|
||||
<marc:datafield tag="020" ind1=" " ind2=" ">
|
||||
<marc:subfield code="a">3473327212</marc:subfield>
|
||||
</marc:datafield>
|
||||
<marc:datafield tag="040" ind1=" " ind2=" ">
|
||||
<marc:subfield code="a">DE-1020</marc:subfield>
|
||||
<marc:subfield code="b">ger</marc:subfield>
|
||||
<marc:subfield code="c">DE-605</marc:subfield>
|
||||
</marc:datafield>
|
||||
<marc:datafield tag="245" ind1=" " ind2=" ">
|
||||
<marc:subfield code="a">Weltraum</marc:subfield>
|
||||
<marc:subfield code="b">[mit ausklappbaren Entdecker-Seiten ; 8 - 12 Jahre]</marc:subfield>
|
||||
<marc:subfield code="c">[Text und Konzept: Stefan Greschik. Ill.: Jochen Windecker. Comic-Ill.: Billa Spiegelhauer. Fachl. Beratung:
|
||||
Richard Bräucker]</marc:subfield>
|
||||
</marc:datafield>
|
||||
<marc:datafield tag="264" ind1=" " ind2="1">
|
||||
<marc:subfield code="a">Ravensburg</marc:subfield>
|
||||
<marc:subfield code="b">Ravensburger Buchverl.</marc:subfield>
|
||||
<marc:subfield code="c">2014</marc:subfield>
|
||||
</marc:datafield>
|
||||
<marc:datafield tag="300" ind1=" " ind2=" ">
|
||||
<marc:subfield code="a">54 S.</marc:subfield>
|
||||
</marc:datafield>
|
||||
<marc:datafield tag="924" ind1=" " ind2=" ">
|
||||
<marc:subfield code="b">DE-1020</marc:subfield>
|
||||
<marc:subfield code="c">NRW</marc:subfield>
|
||||
</marc:datafield>
|
||||
</marc:record>
|
||||
<marc:record>
|
||||
<marc:leader>00000nam a2200000uu 4500</marc:leader>
|
||||
<marc:controlfield tag="001">(DE-1020)E998535454</marc:controlfield>
|
||||
<marc:controlfield tag="003">DE-1020</marc:controlfield>
|
||||
<marc:controlfield tag="005">20200401000000.0</marc:controlfield>
|
||||
<marc:controlfield tag="008">200401s2014 gw |||| |||| 00||| ger|c</marc:controlfield>
|
||||
<marc:datafield tag="020" ind1=" " ind2=" ">
|
||||
<marc:subfield code="a">9783473328888</marc:subfield>
|
||||
</marc:datafield>
|
||||
<marc:datafield tag="020" ind1=" " ind2=" ">
|
||||
<marc:subfield code="a">347332888X</marc:subfield>
|
||||
</marc:datafield>
|
||||
<marc:datafield tag="040" ind1=" " ind2=" ">
|
||||
<marc:subfield code="a">DE-1020</marc:subfield>
|
||||
<marc:subfield code="b">ger</marc:subfield>
|
||||
<marc:subfield code="c">DE-605</marc:subfield>
|
||||
</marc:datafield>
|
||||
<marc:datafield tag="100" ind1="1" ind2=" ">
|
||||
<marc:subfield code="a">Nieländer, Peter</marc:subfield>
|
||||
</marc:datafield>
|
||||
<marc:datafield tag="245" ind1=" " ind2=" ">
|
||||
<marc:subfield code="a">Rund um den Fußball</marc:subfield>
|
||||
<marc:subfield code="c">[Ill. und Text: Peter Nieländer]</marc:subfield>
|
||||
</marc:datafield>
|
||||
<marc:datafield tag="264" ind1=" " ind2="1">
|
||||
<marc:subfield code="a">Ravensburg</marc:subfield>
|
||||
<marc:subfield code="b">Ravensburger Buchverl.</marc:subfield>
|
||||
<marc:subfield code="c">2014</marc:subfield>
|
||||
</marc:datafield>
|
||||
<marc:datafield tag="300" ind1=" " ind2=" ">
|
||||
<marc:subfield code="a">[16] S.</marc:subfield>
|
||||
</marc:datafield>
|
||||
<marc:datafield tag="924" ind1=" " ind2=" ">
|
||||
<marc:subfield code="b">DE-1020</marc:subfield>
|
||||
<marc:subfield code="c">NRW</marc:subfield>
|
||||
</marc:datafield>
|
||||
</marc:record>
|
||||
</marc:collection>
|
Loading…
Reference in a new issue