Project

General

Profile

« Previous | Next » 

Revision 51930

more VTD utilities

View differences:

modules/dnet-openaireplus-mapping-utils/trunk/src/main/java/eu/dnetlib/data/transform/xml/VtdUtilityParser.java
7 7

  
8 8
import com.google.common.collect.Lists;
9 9
import com.google.common.collect.Maps;
10
import com.ximpleware.AutoPilot;
11
import com.ximpleware.ParseException;
12
import com.ximpleware.VTDGen;
13
import com.ximpleware.VTDNav;
10
import com.ximpleware.*;
14 11

  
15 12
public class VtdUtilityParser {
16 13

  
......
32 29
		return vg;
33 30
	}
34 31

  
32
	public static int countNodes(final AutoPilot ap, final VTDNav vn, final String xpath) throws VtdException {
33
		try {
34
			ap.selectXPath(xpath);
35
			ap.bind(vn);
36
			final Double i = ap.evalXPathToNumber();
37
			return i.intValue();
38
		} catch (XPathParseException e) {
39
			throw new VtdException(e);
40
		}
41
	}
42

  
35 43
	public static List<Node> getNodes(final AutoPilot ap, final VTDNav vn, final String xpath) throws VtdException {
36 44
		return getTextValuesWithAttributes(ap, vn, xpath, Lists.newArrayList());
37 45
	}

Also available in: Unified diff