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,21 +489,27 @@ 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) {
if (splitlimit != -1) {
if (getRecordCounter() % splitlimit == 0) {
try { try {
endCollection(); endCollection();
endDocument();
writer.close(); writer.close();
newWriter(fileNamePattern, fileNameCounter, bufferSize, compress); newWriter(fileNamePattern, fileNameCounter, bufferSize, compress);
setupEventConsumer(writer, indent); setupEventConsumer(writer, indent);
startDocument();
beginCollection(); beginCollection();
} catch (IOException e) { } catch (IOException e) {
logger.log(Level.SEVERE, e.getMessage(), e); logger.log(Level.SEVERE, e.getMessage(), e);
} }
} }
} }
}
}
private void newWriter(String fileNamePattern, AtomicInteger fileNameCounter, private void newWriter(String fileNamePattern, AtomicInteger fileNameCounter,
int bufferSize, boolean compress) int bufferSize, boolean compress)

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>