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)) { 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");