//check how many entries are in the first result of the xpathQuery and
//go through each result
for (int k = 0; k < queryList.get(0).getLength(); k++) {
Literal subject = LiteralFactory.createAnonymousLiteral("<" + id + ">");
Triple typeTriple = new Triple(subject, Literals.RDF.TYPE, this.TYPE);
res.add(typeTriple);
//check how many XPath expressions were submitted and go trough each result
//add all entries to the res = (intermediate) result
for (int i = 0; i < queryList.size(); i++) {
//get data out of the XPath result node list
String data = queryList.get(i).item(k).getTextContent().trim();
// evaluate regex for information selection
boolean addValues=true;
// if regex given
if (this.regexString.get(i).length()>0) {
final Pattern pattern = Pattern.compile(this.regexString.get(i));
final Matcher matcher = pattern.matcher(data);
// if regex valid, extract information
if (matcher.find() == true) {
//the last regex value in parentheses is chosen as group
if(matcher.groupCount()!=0){
data = matcher.group(matcher.groupCount());
} else { // otherwise group 0 is chosen as complete expression
data = matcher.group(0);
String buffer = data;
data="";
// the whole result string is checked for digits which will remain in result
// others symbols are removed
for(int j=0;j<buffer.length();j++){
Character c= buffer.charAt(j);
if(Character.isDigit(c)){
data=data+c;
}
}
}
} else { // if regex invalid ignore data
addValues = false;
}
}
// create triple out of selected data
if (addValues){
System.out.println(data);
Literal obj = Literals.createTyped(data, this.dataString.get(i));
Triple genTriple = new Triple(subject, this.literalList.get(i), obj);
res.add(genTriple);
}
}
//increase counter for individual subject generation
id++;