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() { private void afterRecord() {
if (fileNamePattern != null && getRecordCounter() % splitlimit == 0) { if (fileNamePattern != null) {
try { if (splitlimit != -1) {
endCollection(); if (getRecordCounter() % splitlimit == 0) {
writer.close(); try {
newWriter(fileNamePattern, fileNameCounter, bufferSize, compress); endCollection();
setupEventConsumer(writer, indent); endDocument();
beginCollection(); writer.close();
} catch (IOException e) { newWriter(fileNamePattern, fileNameCounter, bufferSize, compress);
logger.log(Level.SEVERE, e.getMessage(), e); 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"> <collection xmlns="info:lc/xmlns/marcxchange-v2">
<record format="MARC21" type="Bibliographic"> <record format="MARC21" type="Bibliographic">
<leader>01737nam 22004334a 4500</leader> <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"> <collection xmlns="info:lc/xmlns/marcxchange-v2">
<record format="MARC21" type="Bibliographic"> <record format="MARC21" type="Bibliographic">
<leader>01215cam 2200313 a 4500</leader> <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"> <collection xmlns="info:lc/xmlns/marcxchange-v2">
<record format="MARC21" type="Bibliographic"> <record format="MARC21" type="Bibliographic">
<leader>01613cam 2200409 a 4500</leader> <leader>01613cam 2200409 a 4500</leader>