add XML declaration to each split file in MarcXchangeWriter

This commit is contained in:
Jörg Prante 2022-12-02 20:24:28 +01:00
parent dfefc49fee
commit d2905637c1
4 changed files with 19 additions and 10 deletions

View file

@ -489,18 +489,24 @@ public class MarcXchangeWriter extends MarcContentHandler implements Flushable,
}
/**
* Split records if configured.
* Split records if configured. A splitlimit of -1 prevents splitting.
*/
private void afterRecord() {
if (fileNamePattern != null && getRecordCounter() % splitlimit == 0) {
try {
endCollection();
writer.close();
newWriter(fileNamePattern, fileNameCounter, bufferSize, compress);
setupEventConsumer(writer, indent);
beginCollection();
} catch (IOException e) {
logger.log(Level.SEVERE, e.getMessage(), e);
if (fileNamePattern != null) {
if (splitlimit != -1) {
if (getRecordCounter() % splitlimit == 0) {
try {
endCollection();
endDocument();
writer.close();
newWriter(fileNamePattern, fileNameCounter, bufferSize, compress);
setupEventConsumer(writer, indent);
startDocument();
beginCollection();
} catch (IOException e) {
logger.log(Level.SEVERE, e.getMessage(), e);
}
}
}
}
}

View file

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<collection xmlns="info:lc/xmlns/marcxchange-v2">
<record format="MARC21" type="Bibliographic">
<leader>01737nam 22004334a 4500</leader>

View file

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<collection xmlns="info:lc/xmlns/marcxchange-v2">
<record format="MARC21" type="Bibliographic">
<leader>01215cam 2200313 a 4500</leader>

View file

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<collection xmlns="info:lc/xmlns/marcxchange-v2">
<record format="MARC21" type="Bibliographic">
<leader>01613cam 2200409 a 4500</leader>