|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| |
|
20 |
| |
|
21 |
| |
|
22 |
| package nu.xom; |
|
23 |
| |
|
24 |
| import java.util.Iterator; |
|
25 |
| import java.util.List; |
|
26 |
| import java.util.ListIterator; |
|
27 |
| |
|
28 |
| import org.jaxen.BaseXPath; |
|
29 |
| import org.jaxen.FunctionContext; |
|
30 |
| import org.jaxen.JaxenException; |
|
31 |
| import org.jaxen.XPathFunctionContext; |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
| |
|
38 |
| |
|
39 |
| |
|
40 |
| class JaxenConnector extends BaseXPath { |
|
41 |
| |
|
42 |
| |
|
43 |
| private static final long serialVersionUID = 9025734269448515308L; |
|
44 |
| |
|
45 |
| private static FunctionContext functionContext = new XPathFunctionContext(false); |
|
46 |
| |
|
47 |
| |
|
48 |
622
| JaxenConnector(String expression) throws JaxenException {
|
|
49 |
622
| super(expression, new JaxenNavigator());
|
|
50 |
| |
|
51 |
622
| this.setFunctionContext(functionContext);
|
|
52 |
| } |
|
53 |
| |
|
54 |
| |
|
55 |
622
| public List selectNodes(Object expression) throws JaxenException {
|
|
56 |
| |
|
57 |
622
| List result = super.selectNodes(expression);
|
|
58 |
| |
|
59 |
| |
|
60 |
594
| ListIterator iterator = result.listIterator();
|
|
61 |
594
| while (iterator.hasNext()) {
|
|
62 |
1801
| Object next = iterator.next();
|
|
63 |
1801
| if (next instanceof List) {
|
|
64 |
40
| List list = (List) next;
|
|
65 |
| |
|
66 |
40
| iterator.set(list.get(0));
|
|
67 |
| |
|
68 |
40
| if (list.size() > 1) {
|
|
69 |
14
| Iterator texts = list.listIterator(1);
|
|
70 |
14
| while (texts.hasNext()) {
|
|
71 |
23
| iterator.add(texts.next());
|
|
72 |
| } |
|
73 |
| } |
|
74 |
| } |
|
75 |
| } |
|
76 |
594
| return result;
|
|
77 |
| |
|
78 |
| } |
|
79 |
| |
|
80 |
| |
|
81 |
| } |
|
82 |
| |