boolean generateBookmarks = ClientConfiguration.getDefault().isGenerateBookmarks();
if (settings.isUsePageStructure()) {
FeedItem[] items = feed.getItems();
for (int i = 0, n = items.length; i < n; i++) {
String uri = resource.getURI() + "_item-" + (i + 1);
TextRecord textRecord = new TextRecord(uri,
jxlDocument.getOutputEncoding(),
jxlDocument.isUseHiresMargins());
HTMLSerializer serializer = new HTMLSerializer(textRecord, jxlDocument.getURIRewriter(),
settings.getTextColorBrightness(), settings.isParseTables(),
pluckerDocument);
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.transform(new DOMSource(formatter.getItemDocuments()[i]), new SAXResult(serializer));
pluckerDocument.addRecord(serializer.getDataRecord());
String[] pageURIs = serializer.getLinkURIs();
for (int j = 0; j < pageURIs.length; j++) {
if (!pageURIs[j].startsWith(resource.getURI() + "_item-")) {
addPageLink(pageURIs[j]);
}
}
String[] imageURIs = serializer.getEmbeddedImageURIs();
for (int j = 0; j < imageURIs.length; j++) {
addImageLink(imageURIs[j]);
}
if (generateBookmarks) {
addBookmark(items[i], formatter, uri);
}
}
} else {
FeedItem[] items = feed.getItems();
for (int i = 0; i < items.length; i++) {
FeedItem item = items[i];
URIRewriter rewriter = jxlDocument.getURIRewriter();
String uri = rewriter.rewrite(item.getURL());
if (generateBookmarks && settings.isUseLinkStructure()) {
addBookmark(items[i], formatter, uri);
}
}
}
Transformer transformer = TransformerFactory.newInstance().newTransformer();
TextRecord textRecord = resource.createTextRecord(jxlDocument.getOutputEncoding(),
jxlDocument.isUseHiresMargins());
TextRecordResult result = new TextRecordResult(textRecord, jxlDocument.getURIRewriter(),
settings.getTextColorBrightness(), settings.isParseTables(),
pluckerDocument);
transformer.transform(new DOMSource(formatter.getIndexDocument()), result);