|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| package org.qedeq.kernel.xml.mapper; |
|
19 |
| |
|
20 |
| import java.io.IOException; |
|
21 |
| |
|
22 |
| import javax.xml.parsers.ParserConfigurationException; |
|
23 |
| |
|
24 |
| import org.qedeq.kernel.context.ModuleContext; |
|
25 |
| import org.qedeq.kernel.xml.tracker.SimpleXPath; |
|
26 |
| import org.qedeq.kernel.xml.tracker.XPathLocationFinder; |
|
27 |
| import org.xml.sax.SAXException; |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| public final class Context2SimpleXPath { |
|
36 |
| |
|
37 |
| |
|
38 |
| |
|
39 |
| |
|
40 |
0
| private Context2SimpleXPath() {
|
|
41 |
| |
|
42 |
| } |
|
43 |
| |
|
44 |
| |
|
45 |
| |
|
46 |
| |
|
47 |
| |
|
48 |
| |
|
49 |
| |
|
50 |
| |
|
51 |
4
| public static final SimpleXPath getXPath(final ModuleContext context) {
|
|
52 |
4
| String xpath = Context2XPath.getXPath(context);
|
|
53 |
4
| try {
|
|
54 |
4
| final SimpleXPath find = XPathLocationFinder.getXPathLocation(
|
|
55 |
| context.getModuleLocation(), xpath); |
|
56 |
4
| if (find.getStartLocation() == null) {
|
|
57 |
0
| System.out.println(context);
|
|
58 |
0
| throw new RuntimeException("start not found: " + find);
|
|
59 |
| } |
|
60 |
4
| if (find.getEndLocation() == null) {
|
|
61 |
0
| System.out.println(context);
|
|
62 |
0
| throw new RuntimeException("end not found: " + find);
|
|
63 |
| } |
|
64 |
4
| return find;
|
|
65 |
| } catch (ParserConfigurationException e) { |
|
66 |
0
| throw new RuntimeException(e);
|
|
67 |
| } catch (SAXException e) { |
|
68 |
0
| throw new RuntimeException(e);
|
|
69 |
| } catch (IOException e) { |
|
70 |
0
| throw new RuntimeException(e);
|
|
71 |
| } |
|
72 |
| } |
|
73 |
| |
|
74 |
| } |