Skip to content

Commit

Permalink
Merge pull request #441 from metafacture/440-doNotTrimControlField
Browse files Browse the repository at this point in the history
Do not trim control field values in MARCXML handler.
  • Loading branch information
blackwinter authored Feb 17, 2022
2 parents 89793c7 + df6a862 commit 7799c1e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ else if (DATAFIELD.equals(localName)) {
getReceiver().endEntity();
}
else if (CONTROLFIELD.equals(localName)) {
getReceiver().literal(currentTag, builder.toString().trim());
getReceiver().literal(currentTag, builder.toString());
}
else if (RECORD.equals(localName) && checkNamespace(uri)) {
getReceiver().endRecord();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ public void shouldFindTagAttributeAtSecondPositionInControlFieldElement()
verify(receiver).literal("001", fieldValue);
}

@Test
public void issue440_shouldNotRemoveWhitespaceFromControlFields() throws SAXException {
final AttributesImpl attributes = new AttributesImpl();
attributes.addAttribute(NAMESPACE, "tag", "tag", "CDATA", "008");

final String fieldValue = " t20202020au |||||||||||| ||||ger d";

marcXmlHandler.startElement(NAMESPACE, CONTROLFIELD, "", attributes);
marcXmlHandler.characters(fieldValue.toCharArray(), 0, fieldValue.length());
marcXmlHandler.endElement(NAMESPACE, CONTROLFIELD, "");

verify(receiver).literal("008", fieldValue);
}

@Test
public void issue233ShouldNotRemoveWhitespaceFromLeader()
throws SAXException {
Expand Down

0 comments on commit 7799c1e

Please sign in to comment.