Skip to content

Commit edb3a8d

Browse files
committed
Merge #558 from remote-tracking branch 'origin/548-fixMarcLeaderInentationWhenUsingType'
2 parents 76b7a06 + 8414f02 commit edb3a8d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

metafacture-biblio/src/main/java/org/metafacture/biblio/marc21/MarcXmlEncoder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ public void literal(final String name, final String value) {
338338
if (name.equals(Marc21EventNames.MARCXML_TYPE_LITERAL)) {
339339
if (value != null) {
340340
builder.insert(recordAttributeOffset, String.format(ATTRIBUTE_TEMPLATE, name, value));
341+
recordLeaderOffset = builder.length();
341342
}
342343
}
343344
else if (!appendLeader(name, value)) {

metafacture-biblio/src/test/java/org/metafacture/biblio/marc21/MarcXmlEncoderTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,21 @@ public void issue336_createRecordWithTopLevelLeader_dummy() {
241241
assertEquals(expected, actual);
242242
}
243243

244+
@Test
245+
public void issue548_createRecordWithTypeAttributeInRecordTagAndLeader() {
246+
encoder.startRecord(RECORD_ID);
247+
encoder.literal("type", "Bibliographic");
248+
encoder.startEntity(Marc21EventNames.LEADER_ENTITY);
249+
encoder.literal(Marc21EventNames.LEADER_ENTITY, "dummy");
250+
encoder.endEntity();
251+
encoder.endRecord();
252+
encoder.closeStream();
253+
String expected = XML_DECLARATION + XML_ROOT_OPEN + "<marc:record type=\"Bibliographic\">" +
254+
"<marc:leader>dummy</marc:leader></marc:record>" + XML_MARC_COLLECTION_END_TAG;
255+
String actual = resultCollector.toString();
256+
assertEquals(expected, actual);
257+
}
258+
244259
@Test
245260
public void issue336_createRecordWithTopLevelLeader_defaultMarc21Xml() {
246261
issue336_createRecordWithTopLevelLeader(encoder, "00000naa a2200000uc 4500");

0 commit comments

Comments
 (0)