XPath xpaNs = XPath.newInstance("./@ns");
XPath xpaTitle = XPath.newInstance("./@title");
XPath xpaRedirLinks = XPath.newInstance("redirlinks/bl");
while (itBacklink.hasNext()) {
Element currentBacklink = (Element) itBacklink.next();
Page link = DataManager.getPage(
getWiki(), xpaTitle.valueOf(currentBacklink), null, null, null);
link.setNamespace(xpaNs.valueOf(currentBacklink));
link.setPageId(xpaPageId.valueOf(currentBacklink));
if (currentBacklink.getAttribute("redirect") != null) {
link.addRedirect(page);
}
if (!list.contains(link)) {
list.add(link);
}
// Links through redirects
List listRedirLinks = xpaRedirLinks.selectNodes(currentBacklink);
if (listRedirLinks != null) {
List<Page> linkList = new ArrayList<Page>();
Iterator itRedirLink = listRedirLinks.iterator();
while (itRedirLink.hasNext()) {
currentBacklink = (Element) itRedirLink.next();
Page link2 = DataManager.getPage(
getWiki(), xpaTitle.valueOf(currentBacklink), null, null, null);
link2.setNamespace(xpaNs.valueOf(currentBacklink));
link2.setPageId(xpaPageId.valueOf(currentBacklink));
if (!list.contains(link2)) {
list.add(link2);
}
if (!linkList.contains(link2)) {
linkList.add(link2);