use of com.ctc.wstx.exc.WstxParsingException in project RecordManager2 by moravianlibrary.
the class ZakonyProLidiFulltextXmlStreamReader method next.
public String next() {
boolean fulltext = false;
String result = "";
int countDiv = 0;
while (eventReader.hasNext()) {
try {
XMLEvent xmlEvent = eventReader.nextEvent();
if (xmlEvent.isStartElement()) {
switch(xmlEvent.asStartElement().getName().getLocalPart()) {
case ELEMENT_DIV:
if (isAttribute(xmlEvent.asStartElement(), ATTR_NAME_CLASS, ATTR_VALUE_FRAGS_NOVEL)) {
fulltext = true;
}
if (fulltext)
++countDiv;
break;
case ELEMENT_H3:
case ELEMENT_P:
if (fulltext) {
String xmlFragment = readElementBody(eventReader);
result += xmlFragment + "\n";
}
break;
default:
break;
}
} else if (xmlEvent.isEndElement()) {
switch(xmlEvent.asEndElement().getName().getLocalPart()) {
case ELEMENT_DIV:
if (fulltext)
--countDiv;
if (countDiv == 0)
fulltext = false;
break;
default:
break;
}
}
} catch (WstxEOFException e) {
break;
} catch (WstxParsingException e) {
} catch (XMLStreamException e) {
e.printStackTrace();
}
}
return result;
}
use of com.ctc.wstx.exc.WstxParsingException in project RecordManager2 by moravianlibrary.
the class ManuscriptoriumFulltextXmlStreamReader method next.
public String next() {
String result = "";
List<String> titles = new ArrayList<>();
while (eventReader.hasNext()) {
try {
XMLEvent xmlEvent = eventReader.nextEvent();
if (xmlEvent.isStartElement()) {
switch(xmlEvent.asStartElement().getName().getLocalPart()) {
case ELEMENT_UNCIPIT:
case ELEMENT_EXPLICIT:
case ELEMENT_COLOFON:
case ELEMENT_QUOTE:
case ELEMENT_TITLE:
case ELEMENT_RUBRIC:
String xmlFragment = readElementBody(eventReader);
if (!titles.contains(xmlFragment)) {
result += xmlFragment + "\n";
titles.add(xmlFragment);
}
break;
default:
break;
}
}
} catch (WstxEOFException e) {
break;
} catch (WstxParsingException e) {
} catch (XMLStreamException e) {
e.printStackTrace();
}
}
return result;
}
Aggregations