Revision 42184
Added by Michele Artini almost 8 years ago
ProvenanceExtractor.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.oai.mongo; |
2 | 2 |
|
3 |
import eu.dnetlib.miscutils.functional.UnaryFunction; |
|
3 |
import java.util.function.Function; |
|
4 |
|
|
4 | 5 |
import org.dom4j.Document; |
5 | 6 |
import org.dom4j.Node; |
6 | 7 |
|
7 | 8 |
/** |
8 | 9 |
* Function to deliver only the about/provenance content of a record as XML String. |
9 | 10 |
*/ |
10 |
public class ProvenanceExtractor implements UnaryFunction<String, Document> {
|
|
11 |
public class ProvenanceExtractor implements Function<Document, String> {
|
|
11 | 12 |
|
12 | 13 |
@Override |
13 |
public String evaluate(final Document xmlDoc) { |
|
14 |
// Node provenanceNode = xmlDoc.selectSingleNode("//*[local-name() = 'about']/*[local-name() = 'provenance']"); |
|
15 |
Node provenanceNode = xmlDoc.selectSingleNode("/*[local-name()='record']/*[local-name() = 'about']/*[local-name() = 'provenance']"); |
|
16 |
if (provenanceNode != null) return provenanceNode.asXML(); |
|
17 |
else return null; |
|
14 |
public String apply(final Document xmlDoc) { |
|
15 |
// Node provenanceNode = xmlDoc.selectSingleNode("//*[local-name() = 'about']/*[local-name() = 'provenance']"); |
|
16 |
final Node provenanceNode = xmlDoc.selectSingleNode("/*[local-name()='record']/*[local-name() = 'about']/*[local-name() = 'provenance']"); |
|
17 |
if (provenanceNode != null) { |
|
18 |
return provenanceNode.asXML(); |
|
19 |
} else { |
|
20 |
return null; |
|
21 |
} |
|
18 | 22 |
} |
19 | 23 |
} |
Also available in: Unified diff
oai import