1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.qedeq.kernel.xml.tracker; |
18 |
|
|
19 |
|
import java.io.File; |
20 |
|
import java.io.IOException; |
21 |
|
|
22 |
|
import javax.xml.parsers.ParserConfigurationException; |
23 |
|
|
24 |
|
import org.qedeq.base.io.IoUtility; |
25 |
|
import org.qedeq.base.utility.StringUtility; |
26 |
|
import org.qedeq.kernel.bo.context.KernelContext; |
27 |
|
import org.xml.sax.SAXException; |
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
@version |
34 |
|
@author |
35 |
|
|
|
|
| 0% |
Uncovered Elements: 87 (87) |
Complexity: 14 |
Complexity Density: 0,21 |
|
36 |
|
public final class XPathLocationFinder { |
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
41 |
0
|
private XPathLocationFinder() {... |
42 |
|
|
43 |
|
} |
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
@param |
49 |
|
@link |
50 |
|
@throws |
51 |
|
@throws |
52 |
|
@throws |
53 |
|
|
|
|
| 0% |
Uncovered Elements: 48 (48) |
Complexity: 12 |
Complexity Density: 0,38 |
|
54 |
0
|
public static final void main(final String[] args) throws ParserConfigurationException,... |
55 |
|
SAXException, IOException { |
56 |
0
|
String from = null; |
57 |
0
|
String xpath = null; |
58 |
|
|
59 |
0
|
if (args.length == 0) { |
60 |
0
|
printProgramInformation(); |
61 |
0
|
return; |
62 |
|
} |
63 |
|
|
64 |
0
|
for (int i = 0; i < args.length; i++) { |
65 |
0
|
if (args[i].startsWith("-")) { |
66 |
0
|
final String option = args[i].substring(1).toLowerCase(); |
67 |
0
|
if (option.equals("help") || option.equals("h") |
68 |
|
|| option.equals("?")) { |
69 |
0
|
printProgramInformation(); |
70 |
0
|
return; |
71 |
|
} |
72 |
0
|
if (option.equals("xpath") || option.equals("xp")) { |
73 |
0
|
if (i + 1 >= args.length) { |
74 |
0
|
printProgramInformation(); |
75 |
0
|
System.err.println("\"-xpath\" must be followed by a xpath."); |
76 |
0
|
return; |
77 |
|
} |
78 |
0
|
xpath = args[i + 1]; |
79 |
0
|
i++; |
80 |
|
} else { |
81 |
0
|
printProgramInformation(); |
82 |
0
|
System.err.println("Unknown option: " + option); |
83 |
0
|
return; |
84 |
|
} |
85 |
|
} else { |
86 |
0
|
from = args[i]; |
87 |
|
} |
88 |
|
} |
89 |
0
|
if (from == null) { |
90 |
0
|
printProgramInformation(); |
91 |
0
|
System.err.println("XML file must be specified."); |
92 |
0
|
return; |
93 |
|
} |
94 |
0
|
if (xpath == null) { |
95 |
0
|
printProgramInformation(); |
96 |
0
|
System.err.println("XPath file must be specified."); |
97 |
0
|
return; |
98 |
|
} |
99 |
0
|
System.out.println(StringUtility.getClassName(XPathLocationFinder.class) + ", running on: " |
100 |
|
+ KernelContext.getInstance().getDescriptiveKernelVersion()); |
101 |
0
|
XPathLocationParser.getXPathLocation(new File(from), xpath, |
102 |
|
IoUtility.toUrl(new File(from))); |
103 |
|
} |
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
|
|
|
| 0% |
Uncovered Elements: 36 (36) |
Complexity: 1 |
Complexity Density: 0,03 |
|
108 |
0
|
public static final void printProgramInformation() {... |
109 |
0
|
System.err.println("Name"); |
110 |
0
|
System.err.println("----"); |
111 |
0
|
System.err.println(StringUtility.getClassName(XPathLocationFinder.class) |
112 |
|
+ " - find simple XML paths"); |
113 |
0
|
System.err.println(); |
114 |
0
|
System.err.println("Synopsis"); |
115 |
0
|
System.err.println("-------------------"); |
116 |
0
|
System.err.println("[-h] -xp[ath] <simpleXPath> <xmlFile>"); |
117 |
0
|
System.err.println(); |
118 |
0
|
System.err.println("Description"); |
119 |
0
|
System.err.println("-----------"); |
120 |
0
|
System.err.println( |
121 |
|
"This program finds the location of a given simple XPath in an XML file."); |
122 |
0
|
System.err.println(); |
123 |
0
|
System.err.println("Options and Parameter"); |
124 |
0
|
System.err.println("---------------------"); |
125 |
0
|
System.err.println("-h writes this text and returns"); |
126 |
0
|
System.err.println("-xpath set the language filter (default: \"en\")"); |
127 |
0
|
System.err.println( |
128 |
|
"<simpleXPath> simple XML XPath, a subset of the abbreviation XPath notation"); |
129 |
0
|
System.err.println( |
130 |
|
" \"/element1/element2[3]@attribute\" is an example for such a"); |
131 |
0
|
System.err.println( |
132 |
|
" notation. This selects from the first occurrence of \"element1\""); |
133 |
0
|
System.err.println( |
134 |
|
" and from the third occurrence of subnode \"element2\" the attribute"); |
135 |
0
|
System.err.println( |
136 |
|
" \"attribute\". The attribute is optional. It is always exactly one"); |
137 |
0
|
System.err.println(" node or the attribute of one node specified."); |
138 |
0
|
System.err.println(" General syntax:"); |
139 |
0
|
System.err.println(" {<element>\"[\"<index>\"]}+[\"@\"<attribute>]"); |
140 |
0
|
System.err.println("<xmlFile> XML file"); |
141 |
0
|
System.err.println(); |
142 |
0
|
System.err.println("Parameter Examples"); |
143 |
0
|
System.err.println("------------------"); |
144 |
0
|
System.err.println( |
145 |
|
"-xp QEDEQ/CHAPTER/SECTION/NODE[2]/PRECEDING/AXIOM/FORMULA/FORALL/VAR@id"); |
146 |
0
|
System.err.println("sample/qedeq_basic_concept.xml"); |
147 |
0
|
System.err.println(); |
148 |
0
|
System.err.println("Further information"); |
149 |
0
|
System.err.println("-------------------"); |
150 |
0
|
System.err.println("For more information about *Hilbert II* look at:"); |
151 |
0
|
System.err.println("\thttp://www.qedeq.org/"); |
152 |
0
|
System.err.println(); |
153 |
|
} |
154 |
|
|
155 |
|
} |