XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata);
xhtml.startDocument();
// At the end we want to close the tar stream to release any associated
// resources, but the underlying document stream should not be closed
TarInputStream tar =
new TarInputStream(new CloseShieldInputStream(stream));
try {
TarEntry entry = tar.getNextEntry();
while (entry != null) {
if (!entry.isDirectory()) {
Metadata entrydata = new Metadata();
entrydata.set(Metadata.RESOURCE_NAME_KEY, entry.getName());
parseEntry(tar, xhtml, entrydata);
}
entry = tar.getNextEntry();
}
} finally {
tar.close();
}
xhtml.endDocument();
}