From b57e9e4993ff22766814658f48ec35db3d6a7651 Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Fri, 20 Sep 2024 15:11:23 +0200 Subject: [PATCH 1/2] Add test (#548) --- .../biblio/marc21/MarcXmlEncoderTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/metafacture-biblio/src/test/java/org/metafacture/biblio/marc21/MarcXmlEncoderTest.java b/metafacture-biblio/src/test/java/org/metafacture/biblio/marc21/MarcXmlEncoderTest.java index 7e4186a5..8caac8d9 100644 --- a/metafacture-biblio/src/test/java/org/metafacture/biblio/marc21/MarcXmlEncoderTest.java +++ b/metafacture-biblio/src/test/java/org/metafacture/biblio/marc21/MarcXmlEncoderTest.java @@ -241,6 +241,21 @@ public void issue336_createRecordWithTopLevelLeader_dummy() { assertEquals(expected, actual); } + @Test + public void issue548_createRecordWithTypeAttributeInRecordTagAndLeader() { + encoder.startRecord(RECORD_ID); + encoder.literal("type", "Bibliographic"); + encoder.startEntity(Marc21EventNames.LEADER_ENTITY); + encoder.literal(Marc21EventNames.LEADER_ENTITY, "dummy"); + encoder.endEntity(); + encoder.endRecord(); + encoder.closeStream(); + String expected = XML_DECLARATION + XML_ROOT_OPEN + "" + + "dummy" + XML_MARC_COLLECTION_END_TAG; + String actual = resultCollector.toString(); + assertEquals(expected, actual); + } + @Test public void issue336_createRecordWithTopLevelLeader_defaultMarc21Xml() { issue336_createRecordWithTopLevelLeader(encoder, "00000naa a2200000uc 4500"); From 8414f02190c72878b72c9a4231f7db434f08e425 Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Fri, 20 Sep 2024 15:15:49 +0200 Subject: [PATCH 2/2] Fix leader indentation when record has a type attribute (#548) --- .../main/java/org/metafacture/biblio/marc21/MarcXmlEncoder.java | 1 + 1 file changed, 1 insertion(+) diff --git a/metafacture-biblio/src/main/java/org/metafacture/biblio/marc21/MarcXmlEncoder.java b/metafacture-biblio/src/main/java/org/metafacture/biblio/marc21/MarcXmlEncoder.java index 3d74a6f8..feecd64e 100644 --- a/metafacture-biblio/src/main/java/org/metafacture/biblio/marc21/MarcXmlEncoder.java +++ b/metafacture-biblio/src/main/java/org/metafacture/biblio/marc21/MarcXmlEncoder.java @@ -338,6 +338,7 @@ public void literal(final String name, final String value) { if (name.equals(Marc21EventNames.MARCXML_TYPE_LITERAL)) { if (value != null) { builder.insert(recordAttributeOffset, String.format(ATTRIBUTE_TEMPLATE, name, value)); + recordLeaderOffset = builder.length(); } } else if (!appendLeader(name, value)) {