1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
package org.apache.maven.doxia.document.io.xpp3; |
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
import java.io.IOException; |
15 | |
import java.io.InputStream; |
16 | |
import java.io.Reader; |
17 | |
import java.text.DateFormat; |
18 | |
import java.util.Locale; |
19 | |
import org.apache.maven.doxia.document.DocumentAuthor; |
20 | |
import org.apache.maven.doxia.document.DocumentCover; |
21 | |
import org.apache.maven.doxia.document.DocumentHyperlinkBehaviour; |
22 | |
import org.apache.maven.doxia.document.DocumentMeta; |
23 | |
import org.apache.maven.doxia.document.DocumentModel; |
24 | |
import org.apache.maven.doxia.document.DocumentStatistic; |
25 | |
import org.apache.maven.doxia.document.DocumentTOC; |
26 | |
import org.apache.maven.doxia.document.DocumentTOCItem; |
27 | |
import org.apache.maven.doxia.document.DocumentTemplate; |
28 | |
import org.codehaus.plexus.util.ReaderFactory; |
29 | |
import org.codehaus.plexus.util.xml.pull.MXParser; |
30 | |
import org.codehaus.plexus.util.xml.pull.XmlPullParser; |
31 | |
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; |
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
@SuppressWarnings( "all" ) |
39 | 2 | public class DocumentXpp3Reader |
40 | |
{ |
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | 2 | private boolean addDefaultEntities = true; |
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
private boolean checkFieldWithDuplicate( XmlPullParser parser, String tagName, String alias, java.util.Set parsed ) |
74 | |
throws XmlPullParserException |
75 | |
{ |
76 | 1340 | if ( !( parser.getName().equals( tagName ) || parser.getName().equals( alias ) ) ) |
77 | |
{ |
78 | 1200 | return false; |
79 | |
} |
80 | 140 | if ( !parsed.add( tagName ) ) |
81 | |
{ |
82 | 0 | throw new XmlPullParserException( "Duplicated tag: '" + tagName + "'", parser, null ); |
83 | |
} |
84 | 140 | return true; |
85 | |
} |
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
|
97 | |
private void checkUnknownAttribute( XmlPullParser parser, String attribute, String tagName, boolean strict ) |
98 | |
throws XmlPullParserException, IOException |
99 | |
{ |
100 | |
|
101 | 0 | if ( strict ) |
102 | |
{ |
103 | 0 | throw new XmlPullParserException( "Unknown attribute '" + attribute + "' for tag '" + tagName + "'", parser, null ); |
104 | |
} |
105 | 0 | } |
106 | |
|
107 | |
|
108 | |
|
109 | |
|
110 | |
|
111 | |
|
112 | |
|
113 | |
|
114 | |
|
115 | |
private void checkUnknownElement( XmlPullParser parser, boolean strict ) |
116 | |
throws XmlPullParserException, IOException |
117 | |
{ |
118 | 0 | if ( strict ) |
119 | |
{ |
120 | 0 | throw new XmlPullParserException( "Unrecognised tag: '" + parser.getName() + "'", parser, null ); |
121 | |
} |
122 | |
|
123 | 0 | for ( int unrecognizedTagCount = 1; unrecognizedTagCount > 0; ) |
124 | |
{ |
125 | 0 | int eventType = parser.next(); |
126 | 0 | if ( eventType == XmlPullParser.START_TAG ) |
127 | |
{ |
128 | 0 | unrecognizedTagCount++; |
129 | |
} |
130 | 0 | else if ( eventType == XmlPullParser.END_TAG ) |
131 | |
{ |
132 | 0 | unrecognizedTagCount--; |
133 | |
} |
134 | 0 | } |
135 | 0 | } |
136 | |
|
137 | |
|
138 | |
|
139 | |
|
140 | |
|
141 | |
|
142 | |
public boolean getAddDefaultEntities() |
143 | |
{ |
144 | 0 | return addDefaultEntities; |
145 | |
} |
146 | |
|
147 | |
|
148 | |
|
149 | |
|
150 | |
|
151 | |
|
152 | |
|
153 | |
|
154 | |
|
155 | |
|
156 | |
private boolean getBooleanValue( String s, String attribute, XmlPullParser parser ) |
157 | |
throws XmlPullParserException |
158 | |
{ |
159 | 0 | return getBooleanValue( s, attribute, parser, null ); |
160 | |
} |
161 | |
|
162 | |
|
163 | |
|
164 | |
|
165 | |
|
166 | |
|
167 | |
|
168 | |
|
169 | |
|
170 | |
|
171 | |
|
172 | |
private boolean getBooleanValue( String s, String attribute, XmlPullParser parser, String defaultValue ) |
173 | |
throws XmlPullParserException |
174 | |
{ |
175 | 4 | if ( s != null && s.length() != 0 ) |
176 | |
{ |
177 | 4 | return Boolean.valueOf( s ).booleanValue(); |
178 | |
} |
179 | 0 | if ( defaultValue != null ) |
180 | |
{ |
181 | 0 | return Boolean.valueOf( defaultValue ).booleanValue(); |
182 | |
} |
183 | 0 | return false; |
184 | |
} |
185 | |
|
186 | |
|
187 | |
|
188 | |
|
189 | |
|
190 | |
|
191 | |
|
192 | |
|
193 | |
|
194 | |
|
195 | |
|
196 | |
private byte getByteValue( String s, String attribute, XmlPullParser parser, boolean strict ) |
197 | |
throws XmlPullParserException |
198 | |
{ |
199 | 0 | if ( s != null ) |
200 | |
{ |
201 | |
try |
202 | |
{ |
203 | 0 | return Byte.valueOf( s ).byteValue(); |
204 | |
} |
205 | 0 | catch ( NumberFormatException nfe ) |
206 | |
{ |
207 | 0 | if ( strict ) |
208 | |
{ |
209 | 0 | throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a byte", parser, nfe ); |
210 | |
} |
211 | |
} |
212 | |
} |
213 | 0 | return 0; |
214 | |
} |
215 | |
|
216 | |
|
217 | |
|
218 | |
|
219 | |
|
220 | |
|
221 | |
|
222 | |
|
223 | |
|
224 | |
|
225 | |
private char getCharacterValue( String s, String attribute, XmlPullParser parser ) |
226 | |
throws XmlPullParserException |
227 | |
{ |
228 | 0 | if ( s != null ) |
229 | |
{ |
230 | 0 | return s.charAt( 0 ); |
231 | |
} |
232 | 0 | return 0; |
233 | |
} |
234 | |
|
235 | |
|
236 | |
|
237 | |
|
238 | |
|
239 | |
|
240 | |
|
241 | |
|
242 | |
|
243 | |
|
244 | |
private java.util.Date getDateValue( String s, String attribute, XmlPullParser parser ) |
245 | |
throws XmlPullParserException |
246 | |
{ |
247 | 0 | return getDateValue( s, attribute, null, parser ); |
248 | |
} |
249 | |
|
250 | |
|
251 | |
|
252 | |
|
253 | |
|
254 | |
|
255 | |
|
256 | |
|
257 | |
|
258 | |
|
259 | |
|
260 | |
private java.util.Date getDateValue( String s, String attribute, String dateFormat, XmlPullParser parser ) |
261 | |
throws XmlPullParserException |
262 | |
{ |
263 | 10 | if ( s != null ) |
264 | |
{ |
265 | 10 | String effectiveDateFormat = dateFormat; |
266 | 10 | if ( dateFormat == null ) |
267 | |
{ |
268 | 10 | effectiveDateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS"; |
269 | |
} |
270 | 10 | if ( "long".equals( effectiveDateFormat ) ) |
271 | |
{ |
272 | |
try |
273 | |
{ |
274 | 0 | return new java.util.Date( Long.parseLong( s ) ); |
275 | |
} |
276 | 0 | catch ( NumberFormatException e ) |
277 | |
{ |
278 | 0 | throw new XmlPullParserException( e.getMessage(), parser, e ); |
279 | |
} |
280 | |
} |
281 | |
else |
282 | |
{ |
283 | |
try |
284 | |
{ |
285 | 10 | DateFormat dateParser = new java.text.SimpleDateFormat( effectiveDateFormat, Locale.US ); |
286 | 10 | return dateParser.parse( s ); |
287 | |
} |
288 | 0 | catch ( java.text.ParseException e ) |
289 | |
{ |
290 | 0 | throw new XmlPullParserException( e.getMessage(), parser, e ); |
291 | |
} |
292 | |
} |
293 | |
} |
294 | 0 | return null; |
295 | |
} |
296 | |
|
297 | |
|
298 | |
|
299 | |
|
300 | |
|
301 | |
|
302 | |
|
303 | |
|
304 | |
|
305 | |
|
306 | |
|
307 | |
private double getDoubleValue( String s, String attribute, XmlPullParser parser, boolean strict ) |
308 | |
throws XmlPullParserException |
309 | |
{ |
310 | 0 | if ( s != null ) |
311 | |
{ |
312 | |
try |
313 | |
{ |
314 | 0 | return Double.valueOf( s ).doubleValue(); |
315 | |
} |
316 | 0 | catch ( NumberFormatException nfe ) |
317 | |
{ |
318 | 0 | if ( strict ) |
319 | |
{ |
320 | 0 | throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe ); |
321 | |
} |
322 | |
} |
323 | |
} |
324 | 0 | return 0; |
325 | |
} |
326 | |
|
327 | |
|
328 | |
|
329 | |
|
330 | |
|
331 | |
|
332 | |
|
333 | |
|
334 | |
|
335 | |
|
336 | |
|
337 | |
private float getFloatValue( String s, String attribute, XmlPullParser parser, boolean strict ) |
338 | |
throws XmlPullParserException |
339 | |
{ |
340 | 0 | if ( s != null ) |
341 | |
{ |
342 | |
try |
343 | |
{ |
344 | 0 | return Float.valueOf( s ).floatValue(); |
345 | |
} |
346 | 0 | catch ( NumberFormatException nfe ) |
347 | |
{ |
348 | 0 | if ( strict ) |
349 | |
{ |
350 | 0 | throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe ); |
351 | |
} |
352 | |
} |
353 | |
} |
354 | 0 | return 0; |
355 | |
} |
356 | |
|
357 | |
|
358 | |
|
359 | |
|
360 | |
|
361 | |
|
362 | |
|
363 | |
|
364 | |
|
365 | |
|
366 | |
|
367 | |
private int getIntegerValue( String s, String attribute, XmlPullParser parser, boolean strict ) |
368 | |
throws XmlPullParserException |
369 | |
{ |
370 | 0 | if ( s != null ) |
371 | |
{ |
372 | |
try |
373 | |
{ |
374 | 0 | return Integer.valueOf( s ).intValue(); |
375 | |
} |
376 | 0 | catch ( NumberFormatException nfe ) |
377 | |
{ |
378 | 0 | if ( strict ) |
379 | |
{ |
380 | 0 | throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be an integer", parser, nfe ); |
381 | |
} |
382 | |
} |
383 | |
} |
384 | 0 | return 0; |
385 | |
} |
386 | |
|
387 | |
|
388 | |
|
389 | |
|
390 | |
|
391 | |
|
392 | |
|
393 | |
|
394 | |
|
395 | |
|
396 | |
|
397 | |
private long getLongValue( String s, String attribute, XmlPullParser parser, boolean strict ) |
398 | |
throws XmlPullParserException |
399 | |
{ |
400 | 32 | if ( s != null ) |
401 | |
{ |
402 | |
try |
403 | |
{ |
404 | 32 | return Long.valueOf( s ).longValue(); |
405 | |
} |
406 | 0 | catch ( NumberFormatException nfe ) |
407 | |
{ |
408 | 0 | if ( strict ) |
409 | |
{ |
410 | 0 | throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a long integer", parser, nfe ); |
411 | |
} |
412 | |
} |
413 | |
} |
414 | 0 | return 0; |
415 | |
} |
416 | |
|
417 | |
|
418 | |
|
419 | |
|
420 | |
|
421 | |
|
422 | |
|
423 | |
|
424 | |
|
425 | |
|
426 | |
|
427 | |
private String getRequiredAttributeValue( String s, String attribute, XmlPullParser parser, boolean strict ) |
428 | |
throws XmlPullParserException |
429 | |
{ |
430 | 0 | if ( s == null ) |
431 | |
{ |
432 | 0 | if ( strict ) |
433 | |
{ |
434 | 0 | throw new XmlPullParserException( "Missing required value for attribute '" + attribute + "'", parser, null ); |
435 | |
} |
436 | |
} |
437 | 0 | return s; |
438 | |
} |
439 | |
|
440 | |
|
441 | |
|
442 | |
|
443 | |
|
444 | |
|
445 | |
|
446 | |
|
447 | |
|
448 | |
|
449 | |
|
450 | |
private short getShortValue( String s, String attribute, XmlPullParser parser, boolean strict ) |
451 | |
throws XmlPullParserException |
452 | |
{ |
453 | 0 | if ( s != null ) |
454 | |
{ |
455 | |
try |
456 | |
{ |
457 | 0 | return Short.valueOf( s ).shortValue(); |
458 | |
} |
459 | 0 | catch ( NumberFormatException nfe ) |
460 | |
{ |
461 | 0 | if ( strict ) |
462 | |
{ |
463 | 0 | throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a short integer", parser, nfe ); |
464 | |
} |
465 | |
} |
466 | |
} |
467 | 0 | return 0; |
468 | |
} |
469 | |
|
470 | |
|
471 | |
|
472 | |
|
473 | |
|
474 | |
|
475 | |
|
476 | |
private String getTrimmedValue( String s ) |
477 | |
{ |
478 | 176 | if ( s != null ) |
479 | |
{ |
480 | 176 | s = s.trim(); |
481 | |
} |
482 | 176 | return s; |
483 | |
} |
484 | |
|
485 | |
|
486 | |
|
487 | |
|
488 | |
|
489 | |
|
490 | |
|
491 | |
private void initParser( XmlPullParser parser ) |
492 | |
throws XmlPullParserException |
493 | |
{ |
494 | 2 | if ( addDefaultEntities ) |
495 | |
{ |
496 | |
|
497 | |
|
498 | |
|
499 | |
|
500 | 2 | parser.defineEntityReplacementText( "nbsp", "\u00a0" ); |
501 | 2 | parser.defineEntityReplacementText( "iexcl", "\u00a1" ); |
502 | 2 | parser.defineEntityReplacementText( "cent", "\u00a2" ); |
503 | 2 | parser.defineEntityReplacementText( "pound", "\u00a3" ); |
504 | 2 | parser.defineEntityReplacementText( "curren", "\u00a4" ); |
505 | 2 | parser.defineEntityReplacementText( "yen", "\u00a5" ); |
506 | 2 | parser.defineEntityReplacementText( "brvbar", "\u00a6" ); |
507 | 2 | parser.defineEntityReplacementText( "sect", "\u00a7" ); |
508 | 2 | parser.defineEntityReplacementText( "uml", "\u00a8" ); |
509 | 2 | parser.defineEntityReplacementText( "copy", "\u00a9" ); |
510 | 2 | parser.defineEntityReplacementText( "ordf", "\u00aa" ); |
511 | 2 | parser.defineEntityReplacementText( "laquo", "\u00ab" ); |
512 | 2 | parser.defineEntityReplacementText( "not", "\u00ac" ); |
513 | 2 | parser.defineEntityReplacementText( "shy", "\u00ad" ); |
514 | 2 | parser.defineEntityReplacementText( "reg", "\u00ae" ); |
515 | 2 | parser.defineEntityReplacementText( "macr", "\u00af" ); |
516 | 2 | parser.defineEntityReplacementText( "deg", "\u00b0" ); |
517 | 2 | parser.defineEntityReplacementText( "plusmn", "\u00b1" ); |
518 | 2 | parser.defineEntityReplacementText( "sup2", "\u00b2" ); |
519 | 2 | parser.defineEntityReplacementText( "sup3", "\u00b3" ); |
520 | 2 | parser.defineEntityReplacementText( "acute", "\u00b4" ); |
521 | 2 | parser.defineEntityReplacementText( "micro", "\u00b5" ); |
522 | 2 | parser.defineEntityReplacementText( "para", "\u00b6" ); |
523 | 2 | parser.defineEntityReplacementText( "middot", "\u00b7" ); |
524 | 2 | parser.defineEntityReplacementText( "cedil", "\u00b8" ); |
525 | 2 | parser.defineEntityReplacementText( "sup1", "\u00b9" ); |
526 | 2 | parser.defineEntityReplacementText( "ordm", "\u00ba" ); |
527 | 2 | parser.defineEntityReplacementText( "raquo", "\u00bb" ); |
528 | 2 | parser.defineEntityReplacementText( "frac14", "\u00bc" ); |
529 | 2 | parser.defineEntityReplacementText( "frac12", "\u00bd" ); |
530 | 2 | parser.defineEntityReplacementText( "frac34", "\u00be" ); |
531 | 2 | parser.defineEntityReplacementText( "iquest", "\u00bf" ); |
532 | 2 | parser.defineEntityReplacementText( "Agrave", "\u00c0" ); |
533 | 2 | parser.defineEntityReplacementText( "Aacute", "\u00c1" ); |
534 | 2 | parser.defineEntityReplacementText( "Acirc", "\u00c2" ); |
535 | 2 | parser.defineEntityReplacementText( "Atilde", "\u00c3" ); |
536 | 2 | parser.defineEntityReplacementText( "Auml", "\u00c4" ); |
537 | 2 | parser.defineEntityReplacementText( "Aring", "\u00c5" ); |
538 | 2 | parser.defineEntityReplacementText( "AElig", "\u00c6" ); |
539 | 2 | parser.defineEntityReplacementText( "Ccedil", "\u00c7" ); |
540 | 2 | parser.defineEntityReplacementText( "Egrave", "\u00c8" ); |
541 | 2 | parser.defineEntityReplacementText( "Eacute", "\u00c9" ); |
542 | 2 | parser.defineEntityReplacementText( "Ecirc", "\u00ca" ); |
543 | 2 | parser.defineEntityReplacementText( "Euml", "\u00cb" ); |
544 | 2 | parser.defineEntityReplacementText( "Igrave", "\u00cc" ); |
545 | 2 | parser.defineEntityReplacementText( "Iacute", "\u00cd" ); |
546 | 2 | parser.defineEntityReplacementText( "Icirc", "\u00ce" ); |
547 | 2 | parser.defineEntityReplacementText( "Iuml", "\u00cf" ); |
548 | 2 | parser.defineEntityReplacementText( "ETH", "\u00d0" ); |
549 | 2 | parser.defineEntityReplacementText( "Ntilde", "\u00d1" ); |
550 | 2 | parser.defineEntityReplacementText( "Ograve", "\u00d2" ); |
551 | 2 | parser.defineEntityReplacementText( "Oacute", "\u00d3" ); |
552 | 2 | parser.defineEntityReplacementText( "Ocirc", "\u00d4" ); |
553 | 2 | parser.defineEntityReplacementText( "Otilde", "\u00d5" ); |
554 | 2 | parser.defineEntityReplacementText( "Ouml", "\u00d6" ); |
555 | 2 | parser.defineEntityReplacementText( "times", "\u00d7" ); |
556 | 2 | parser.defineEntityReplacementText( "Oslash", "\u00d8" ); |
557 | 2 | parser.defineEntityReplacementText( "Ugrave", "\u00d9" ); |
558 | 2 | parser.defineEntityReplacementText( "Uacute", "\u00da" ); |
559 | 2 | parser.defineEntityReplacementText( "Ucirc", "\u00db" ); |
560 | 2 | parser.defineEntityReplacementText( "Uuml", "\u00dc" ); |
561 | 2 | parser.defineEntityReplacementText( "Yacute", "\u00dd" ); |
562 | 2 | parser.defineEntityReplacementText( "THORN", "\u00de" ); |
563 | 2 | parser.defineEntityReplacementText( "szlig", "\u00df" ); |
564 | 2 | parser.defineEntityReplacementText( "agrave", "\u00e0" ); |
565 | 2 | parser.defineEntityReplacementText( "aacute", "\u00e1" ); |
566 | 2 | parser.defineEntityReplacementText( "acirc", "\u00e2" ); |
567 | 2 | parser.defineEntityReplacementText( "atilde", "\u00e3" ); |
568 | 2 | parser.defineEntityReplacementText( "auml", "\u00e4" ); |
569 | 2 | parser.defineEntityReplacementText( "aring", "\u00e5" ); |
570 | 2 | parser.defineEntityReplacementText( "aelig", "\u00e6" ); |
571 | 2 | parser.defineEntityReplacementText( "ccedil", "\u00e7" ); |
572 | 2 | parser.defineEntityReplacementText( "egrave", "\u00e8" ); |
573 | 2 | parser.defineEntityReplacementText( "eacute", "\u00e9" ); |
574 | 2 | parser.defineEntityReplacementText( "ecirc", "\u00ea" ); |
575 | 2 | parser.defineEntityReplacementText( "euml", "\u00eb" ); |
576 | 2 | parser.defineEntityReplacementText( "igrave", "\u00ec" ); |
577 | 2 | parser.defineEntityReplacementText( "iacute", "\u00ed" ); |
578 | 2 | parser.defineEntityReplacementText( "icirc", "\u00ee" ); |
579 | 2 | parser.defineEntityReplacementText( "iuml", "\u00ef" ); |
580 | 2 | parser.defineEntityReplacementText( "eth", "\u00f0" ); |
581 | 2 | parser.defineEntityReplacementText( "ntilde", "\u00f1" ); |
582 | 2 | parser.defineEntityReplacementText( "ograve", "\u00f2" ); |
583 | 2 | parser.defineEntityReplacementText( "oacute", "\u00f3" ); |
584 | 2 | parser.defineEntityReplacementText( "ocirc", "\u00f4" ); |
585 | 2 | parser.defineEntityReplacementText( "otilde", "\u00f5" ); |
586 | 2 | parser.defineEntityReplacementText( "ouml", "\u00f6" ); |
587 | 2 | parser.defineEntityReplacementText( "divide", "\u00f7" ); |
588 | 2 | parser.defineEntityReplacementText( "oslash", "\u00f8" ); |
589 | 2 | parser.defineEntityReplacementText( "ugrave", "\u00f9" ); |
590 | 2 | parser.defineEntityReplacementText( "uacute", "\u00fa" ); |
591 | 2 | parser.defineEntityReplacementText( "ucirc", "\u00fb" ); |
592 | 2 | parser.defineEntityReplacementText( "uuml", "\u00fc" ); |
593 | 2 | parser.defineEntityReplacementText( "yacute", "\u00fd" ); |
594 | 2 | parser.defineEntityReplacementText( "thorn", "\u00fe" ); |
595 | 2 | parser.defineEntityReplacementText( "yuml", "\u00ff" ); |
596 | |
|
597 | |
|
598 | |
|
599 | |
|
600 | |
|
601 | 2 | parser.defineEntityReplacementText( "OElig", "\u0152" ); |
602 | 2 | parser.defineEntityReplacementText( "oelig", "\u0153" ); |
603 | 2 | parser.defineEntityReplacementText( "Scaron", "\u0160" ); |
604 | 2 | parser.defineEntityReplacementText( "scaron", "\u0161" ); |
605 | 2 | parser.defineEntityReplacementText( "Yuml", "\u0178" ); |
606 | 2 | parser.defineEntityReplacementText( "circ", "\u02c6" ); |
607 | 2 | parser.defineEntityReplacementText( "tilde", "\u02dc" ); |
608 | 2 | parser.defineEntityReplacementText( "ensp", "\u2002" ); |
609 | 2 | parser.defineEntityReplacementText( "emsp", "\u2003" ); |
610 | 2 | parser.defineEntityReplacementText( "thinsp", "\u2009" ); |
611 | 2 | parser.defineEntityReplacementText( "zwnj", "\u200c" ); |
612 | 2 | parser.defineEntityReplacementText( "zwj", "\u200d" ); |
613 | 2 | parser.defineEntityReplacementText( "lrm", "\u200e" ); |
614 | 2 | parser.defineEntityReplacementText( "rlm", "\u200f" ); |
615 | 2 | parser.defineEntityReplacementText( "ndash", "\u2013" ); |
616 | 2 | parser.defineEntityReplacementText( "mdash", "\u2014" ); |
617 | 2 | parser.defineEntityReplacementText( "lsquo", "\u2018" ); |
618 | 2 | parser.defineEntityReplacementText( "rsquo", "\u2019" ); |
619 | 2 | parser.defineEntityReplacementText( "sbquo", "\u201a" ); |
620 | 2 | parser.defineEntityReplacementText( "ldquo", "\u201c" ); |
621 | 2 | parser.defineEntityReplacementText( "rdquo", "\u201d" ); |
622 | 2 | parser.defineEntityReplacementText( "bdquo", "\u201e" ); |
623 | 2 | parser.defineEntityReplacementText( "dagger", "\u2020" ); |
624 | 2 | parser.defineEntityReplacementText( "Dagger", "\u2021" ); |
625 | 2 | parser.defineEntityReplacementText( "permil", "\u2030" ); |
626 | 2 | parser.defineEntityReplacementText( "lsaquo", "\u2039" ); |
627 | 2 | parser.defineEntityReplacementText( "rsaquo", "\u203a" ); |
628 | 2 | parser.defineEntityReplacementText( "euro", "\u20ac" ); |
629 | |
|
630 | |
|
631 | |
|
632 | |
|
633 | |
|
634 | 2 | parser.defineEntityReplacementText( "fnof", "\u0192" ); |
635 | 2 | parser.defineEntityReplacementText( "Alpha", "\u0391" ); |
636 | 2 | parser.defineEntityReplacementText( "Beta", "\u0392" ); |
637 | 2 | parser.defineEntityReplacementText( "Gamma", "\u0393" ); |
638 | 2 | parser.defineEntityReplacementText( "Delta", "\u0394" ); |
639 | 2 | parser.defineEntityReplacementText( "Epsilon", "\u0395" ); |
640 | 2 | parser.defineEntityReplacementText( "Zeta", "\u0396" ); |
641 | 2 | parser.defineEntityReplacementText( "Eta", "\u0397" ); |
642 | 2 | parser.defineEntityReplacementText( "Theta", "\u0398" ); |
643 | 2 | parser.defineEntityReplacementText( "Iota", "\u0399" ); |
644 | 2 | parser.defineEntityReplacementText( "Kappa", "\u039a" ); |
645 | 2 | parser.defineEntityReplacementText( "Lambda", "\u039b" ); |
646 | 2 | parser.defineEntityReplacementText( "Mu", "\u039c" ); |
647 | 2 | parser.defineEntityReplacementText( "Nu", "\u039d" ); |
648 | 2 | parser.defineEntityReplacementText( "Xi", "\u039e" ); |
649 | 2 | parser.defineEntityReplacementText( "Omicron", "\u039f" ); |
650 | 2 | parser.defineEntityReplacementText( "Pi", "\u03a0" ); |
651 | 2 | parser.defineEntityReplacementText( "Rho", "\u03a1" ); |
652 | 2 | parser.defineEntityReplacementText( "Sigma", "\u03a3" ); |
653 | 2 | parser.defineEntityReplacementText( "Tau", "\u03a4" ); |
654 | 2 | parser.defineEntityReplacementText( "Upsilon", "\u03a5" ); |
655 | 2 | parser.defineEntityReplacementText( "Phi", "\u03a6" ); |
656 | 2 | parser.defineEntityReplacementText( "Chi", "\u03a7" ); |
657 | 2 | parser.defineEntityReplacementText( "Psi", "\u03a8" ); |
658 | 2 | parser.defineEntityReplacementText( "Omega", "\u03a9" ); |
659 | 2 | parser.defineEntityReplacementText( "alpha", "\u03b1" ); |
660 | 2 | parser.defineEntityReplacementText( "beta", "\u03b2" ); |
661 | 2 | parser.defineEntityReplacementText( "gamma", "\u03b3" ); |
662 | 2 | parser.defineEntityReplacementText( "delta", "\u03b4" ); |
663 | 2 | parser.defineEntityReplacementText( "epsilon", "\u03b5" ); |
664 | 2 | parser.defineEntityReplacementText( "zeta", "\u03b6" ); |
665 | 2 | parser.defineEntityReplacementText( "eta", "\u03b7" ); |
666 | 2 | parser.defineEntityReplacementText( "theta", "\u03b8" ); |
667 | 2 | parser.defineEntityReplacementText( "iota", "\u03b9" ); |
668 | 2 | parser.defineEntityReplacementText( "kappa", "\u03ba" ); |
669 | 2 | parser.defineEntityReplacementText( "lambda", "\u03bb" ); |
670 | 2 | parser.defineEntityReplacementText( "mu", "\u03bc" ); |
671 | 2 | parser.defineEntityReplacementText( "nu", "\u03bd" ); |
672 | 2 | parser.defineEntityReplacementText( "xi", "\u03be" ); |
673 | 2 | parser.defineEntityReplacementText( "omicron", "\u03bf" ); |
674 | 2 | parser.defineEntityReplacementText( "pi", "\u03c0" ); |
675 | 2 | parser.defineEntityReplacementText( "rho", "\u03c1" ); |
676 | 2 | parser.defineEntityReplacementText( "sigmaf", "\u03c2" ); |
677 | 2 | parser.defineEntityReplacementText( "sigma", "\u03c3" ); |
678 | 2 | parser.defineEntityReplacementText( "tau", "\u03c4" ); |
679 | 2 | parser.defineEntityReplacementText( "upsilon", "\u03c5" ); |
680 | 2 | parser.defineEntityReplacementText( "phi", "\u03c6" ); |
681 | 2 | parser.defineEntityReplacementText( "chi", "\u03c7" ); |
682 | 2 | parser.defineEntityReplacementText( "psi", "\u03c8" ); |
683 | 2 | parser.defineEntityReplacementText( "omega", "\u03c9" ); |
684 | 2 | parser.defineEntityReplacementText( "thetasym", "\u03d1" ); |
685 | 2 | parser.defineEntityReplacementText( "upsih", "\u03d2" ); |
686 | 2 | parser.defineEntityReplacementText( "piv", "\u03d6" ); |
687 | 2 | parser.defineEntityReplacementText( "bull", "\u2022" ); |
688 | 2 | parser.defineEntityReplacementText( "hellip", "\u2026" ); |
689 | 2 | parser.defineEntityReplacementText( "prime", "\u2032" ); |
690 | 2 | parser.defineEntityReplacementText( "Prime", "\u2033" ); |
691 | 2 | parser.defineEntityReplacementText( "oline", "\u203e" ); |
692 | 2 | parser.defineEntityReplacementText( "frasl", "\u2044" ); |
693 | 2 | parser.defineEntityReplacementText( "weierp", "\u2118" ); |
694 | 2 | parser.defineEntityReplacementText( "image", "\u2111" ); |
695 | 2 | parser.defineEntityReplacementText( "real", "\u211c" ); |
696 | 2 | parser.defineEntityReplacementText( "trade", "\u2122" ); |
697 | 2 | parser.defineEntityReplacementText( "alefsym", "\u2135" ); |
698 | 2 | parser.defineEntityReplacementText( "larr", "\u2190" ); |
699 | 2 | parser.defineEntityReplacementText( "uarr", "\u2191" ); |
700 | 2 | parser.defineEntityReplacementText( "rarr", "\u2192" ); |
701 | 2 | parser.defineEntityReplacementText( "darr", "\u2193" ); |
702 | 2 | parser.defineEntityReplacementText( "harr", "\u2194" ); |
703 | 2 | parser.defineEntityReplacementText( "crarr", "\u21b5" ); |
704 | 2 | parser.defineEntityReplacementText( "lArr", "\u21d0" ); |
705 | 2 | parser.defineEntityReplacementText( "uArr", "\u21d1" ); |
706 | 2 | parser.defineEntityReplacementText( "rArr", "\u21d2" ); |
707 | 2 | parser.defineEntityReplacementText( "dArr", "\u21d3" ); |
708 | 2 | parser.defineEntityReplacementText( "hArr", "\u21d4" ); |
709 | 2 | parser.defineEntityReplacementText( "forall", "\u2200" ); |
710 | 2 | parser.defineEntityReplacementText( "part", "\u2202" ); |
711 | 2 | parser.defineEntityReplacementText( "exist", "\u2203" ); |
712 | 2 | parser.defineEntityReplacementText( "empty", "\u2205" ); |
713 | 2 | parser.defineEntityReplacementText( "nabla", "\u2207" ); |
714 | 2 | parser.defineEntityReplacementText( "isin", "\u2208" ); |
715 | 2 | parser.defineEntityReplacementText( "notin", "\u2209" ); |
716 | 2 | parser.defineEntityReplacementText( "ni", "\u220b" ); |
717 | 2 | parser.defineEntityReplacementText( "prod", "\u220f" ); |
718 | 2 | parser.defineEntityReplacementText( "sum", "\u2211" ); |
719 | 2 | parser.defineEntityReplacementText( "minus", "\u2212" ); |
720 | 2 | parser.defineEntityReplacementText( "lowast", "\u2217" ); |
721 | 2 | parser.defineEntityReplacementText( "radic", "\u221a" ); |
722 | 2 | parser.defineEntityReplacementText( "prop", "\u221d" ); |
723 | 2 | parser.defineEntityReplacementText( "infin", "\u221e" ); |
724 | 2 | parser.defineEntityReplacementText( "ang", "\u2220" ); |
725 | 2 | parser.defineEntityReplacementText( "and", "\u2227" ); |
726 | 2 | parser.defineEntityReplacementText( "or", "\u2228" ); |
727 | 2 | parser.defineEntityReplacementText( "cap", "\u2229" ); |
728 | 2 | parser.defineEntityReplacementText( "cup", "\u222a" ); |
729 | 2 | parser.defineEntityReplacementText( "int", "\u222b" ); |
730 | 2 | parser.defineEntityReplacementText( "there4", "\u2234" ); |
731 | 2 | parser.defineEntityReplacementText( "sim", "\u223c" ); |
732 | 2 | parser.defineEntityReplacementText( "cong", "\u2245" ); |
733 | 2 | parser.defineEntityReplacementText( "asymp", "\u2248" ); |
734 | 2 | parser.defineEntityReplacementText( "ne", "\u2260" ); |
735 | 2 | parser.defineEntityReplacementText( "equiv", "\u2261" ); |
736 | 2 | parser.defineEntityReplacementText( "le", "\u2264" ); |
737 | 2 | parser.defineEntityReplacementText( "ge", "\u2265" ); |
738 | 2 | parser.defineEntityReplacementText( "sub", "\u2282" ); |
739 | 2 | parser.defineEntityReplacementText( "sup", "\u2283" ); |
740 | 2 | parser.defineEntityReplacementText( "nsub", "\u2284" ); |
741 | 2 | parser.defineEntityReplacementText( "sube", "\u2286" ); |
742 | 2 | parser.defineEntityReplacementText( "supe", "\u2287" ); |
743 | 2 | parser.defineEntityReplacementText( "oplus", "\u2295" ); |
744 | 2 | parser.defineEntityReplacementText( "otimes", "\u2297" ); |
745 | 2 | parser.defineEntityReplacementText( "perp", "\u22a5" ); |
746 | 2 | parser.defineEntityReplacementText( "sdot", "\u22c5" ); |
747 | 2 | parser.defineEntityReplacementText( "lceil", "\u2308" ); |
748 | 2 | parser.defineEntityReplacementText( "rceil", "\u2309" ); |
749 | 2 | parser.defineEntityReplacementText( "lfloor", "\u230a" ); |
750 | 2 | parser.defineEntityReplacementText( "rfloor", "\u230b" ); |
751 | 2 | parser.defineEntityReplacementText( "lang", "\u2329" ); |
752 | 2 | parser.defineEntityReplacementText( "rang", "\u232a" ); |
753 | 2 | parser.defineEntityReplacementText( "loz", "\u25ca" ); |
754 | 2 | parser.defineEntityReplacementText( "spades", "\u2660" ); |
755 | 2 | parser.defineEntityReplacementText( "clubs", "\u2663" ); |
756 | 2 | parser.defineEntityReplacementText( "hearts", "\u2665" ); |
757 | 2 | parser.defineEntityReplacementText( "diams", "\u2666" ); |
758 | |
|
759 | |
} |
760 | 2 | } |
761 | |
|
762 | |
|
763 | |
|
764 | |
|
765 | |
|
766 | |
|
767 | |
|
768 | |
|
769 | |
|
770 | |
private int nextTag( XmlPullParser parser ) |
771 | |
throws IOException, XmlPullParserException |
772 | |
{ |
773 | 0 | int eventType = parser.next(); |
774 | 0 | if ( eventType == XmlPullParser.TEXT ) |
775 | |
{ |
776 | 0 | eventType = parser.next(); |
777 | |
} |
778 | 0 | if ( eventType != XmlPullParser.START_TAG && eventType != XmlPullParser.END_TAG ) |
779 | |
{ |
780 | 0 | throw new XmlPullParserException( "expected START_TAG or END_TAG not " + XmlPullParser.TYPES[eventType], parser, null ); |
781 | |
} |
782 | 0 | return eventType; |
783 | |
} |
784 | |
|
785 | |
|
786 | |
|
787 | |
|
788 | |
|
789 | |
|
790 | |
|
791 | |
|
792 | |
|
793 | |
|
794 | |
private DocumentAuthor parseDocumentAuthor( XmlPullParser parser, boolean strict ) |
795 | |
throws IOException, XmlPullParserException |
796 | |
{ |
797 | 4 | String tagName = parser.getName(); |
798 | 4 | DocumentAuthor documentAuthor = new DocumentAuthor(); |
799 | 4 | for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) |
800 | |
{ |
801 | 0 | String name = parser.getAttributeName( i ); |
802 | 0 | String value = parser.getAttributeValue( i ); |
803 | |
|
804 | 0 | if ( name.indexOf( ':' ) >= 0 ) |
805 | |
{ |
806 | |
|
807 | |
} |
808 | |
else |
809 | |
{ |
810 | 0 | checkUnknownAttribute( parser, name, tagName, strict ); |
811 | |
} |
812 | |
} |
813 | 4 | java.util.Set parsed = new java.util.HashSet(); |
814 | 64 | while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) |
815 | |
{ |
816 | 60 | if ( checkFieldWithDuplicate( parser, "firstName", null, parsed ) ) |
817 | |
{ |
818 | 4 | documentAuthor.setFirstName( getTrimmedValue( parser.nextText() ) ); |
819 | |
} |
820 | 56 | else if ( checkFieldWithDuplicate( parser, "lastName", null, parsed ) ) |
821 | |
{ |
822 | 4 | documentAuthor.setLastName( getTrimmedValue( parser.nextText() ) ); |
823 | |
} |
824 | 52 | else if ( checkFieldWithDuplicate( parser, "name", null, parsed ) ) |
825 | |
{ |
826 | 4 | documentAuthor.setName( getTrimmedValue( parser.nextText() ) ); |
827 | |
} |
828 | 48 | else if ( checkFieldWithDuplicate( parser, "initials", null, parsed ) ) |
829 | |
{ |
830 | 4 | documentAuthor.setInitials( getTrimmedValue( parser.nextText() ) ); |
831 | |
} |
832 | 44 | else if ( checkFieldWithDuplicate( parser, "title", null, parsed ) ) |
833 | |
{ |
834 | 4 | documentAuthor.setTitle( getTrimmedValue( parser.nextText() ) ); |
835 | |
} |
836 | 40 | else if ( checkFieldWithDuplicate( parser, "position", null, parsed ) ) |
837 | |
{ |
838 | 4 | documentAuthor.setPosition( getTrimmedValue( parser.nextText() ) ); |
839 | |
} |
840 | 36 | else if ( checkFieldWithDuplicate( parser, "email", null, parsed ) ) |
841 | |
{ |
842 | 4 | documentAuthor.setEmail( getTrimmedValue( parser.nextText() ) ); |
843 | |
} |
844 | 32 | else if ( checkFieldWithDuplicate( parser, "phoneNumber", null, parsed ) ) |
845 | |
{ |
846 | 4 | documentAuthor.setPhoneNumber( getTrimmedValue( parser.nextText() ) ); |
847 | |
} |
848 | 28 | else if ( checkFieldWithDuplicate( parser, "faxNumber", null, parsed ) ) |
849 | |
{ |
850 | 4 | documentAuthor.setFaxNumber( getTrimmedValue( parser.nextText() ) ); |
851 | |
} |
852 | 24 | else if ( checkFieldWithDuplicate( parser, "companyName", null, parsed ) ) |
853 | |
{ |
854 | 4 | documentAuthor.setCompanyName( getTrimmedValue( parser.nextText() ) ); |
855 | |
} |
856 | 20 | else if ( checkFieldWithDuplicate( parser, "street", null, parsed ) ) |
857 | |
{ |
858 | 4 | documentAuthor.setStreet( getTrimmedValue( parser.nextText() ) ); |
859 | |
} |
860 | 16 | else if ( checkFieldWithDuplicate( parser, "city", null, parsed ) ) |
861 | |
{ |
862 | 4 | documentAuthor.setCity( getTrimmedValue( parser.nextText() ) ); |
863 | |
} |
864 | 12 | else if ( checkFieldWithDuplicate( parser, "postalCode", null, parsed ) ) |
865 | |
{ |
866 | 4 | documentAuthor.setPostalCode( getTrimmedValue( parser.nextText() ) ); |
867 | |
} |
868 | 8 | else if ( checkFieldWithDuplicate( parser, "country", null, parsed ) ) |
869 | |
{ |
870 | 4 | documentAuthor.setCountry( getTrimmedValue( parser.nextText() ) ); |
871 | |
} |
872 | 4 | else if ( checkFieldWithDuplicate( parser, "state", null, parsed ) ) |
873 | |
{ |
874 | 4 | documentAuthor.setState( getTrimmedValue( parser.nextText() ) ); |
875 | |
} |
876 | |
else |
877 | |
{ |
878 | 0 | checkUnknownElement( parser, strict ); |
879 | |
} |
880 | |
} |
881 | 4 | return documentAuthor; |
882 | |
} |
883 | |
|
884 | |
|
885 | |
|
886 | |
|
887 | |
|
888 | |
|
889 | |
|
890 | |
|
891 | |
|
892 | |
|
893 | |
private DocumentCover parseDocumentCover( XmlPullParser parser, boolean strict ) |
894 | |
throws IOException, XmlPullParserException |
895 | |
{ |
896 | 2 | String tagName = parser.getName(); |
897 | 2 | DocumentCover documentCover = new DocumentCover(); |
898 | 2 | for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) |
899 | |
{ |
900 | 0 | String name = parser.getAttributeName( i ); |
901 | 0 | String value = parser.getAttributeValue( i ); |
902 | |
|
903 | 0 | if ( name.indexOf( ':' ) >= 0 ) |
904 | |
{ |
905 | |
|
906 | |
} |
907 | |
else |
908 | |
{ |
909 | 0 | checkUnknownAttribute( parser, name, tagName, strict ); |
910 | |
} |
911 | |
} |
912 | 2 | java.util.Set parsed = new java.util.HashSet(); |
913 | 26 | while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) |
914 | |
{ |
915 | 24 | if ( checkFieldWithDuplicate( parser, "coverTitle", null, parsed ) ) |
916 | |
{ |
917 | 2 | documentCover.setCoverTitle( getTrimmedValue( parser.nextText() ) ); |
918 | |
} |
919 | 22 | else if ( checkFieldWithDuplicate( parser, "coverSubTitle", null, parsed ) ) |
920 | |
{ |
921 | 2 | documentCover.setCoverSubTitle( getTrimmedValue( parser.nextText() ) ); |
922 | |
} |
923 | 20 | else if ( checkFieldWithDuplicate( parser, "coverVersion", null, parsed ) ) |
924 | |
{ |
925 | 2 | documentCover.setCoverVersion( getTrimmedValue( parser.nextText() ) ); |
926 | |
} |
927 | 18 | else if ( checkFieldWithDuplicate( parser, "coverType", null, parsed ) ) |
928 | |
{ |
929 | 2 | documentCover.setCoverType( getTrimmedValue( parser.nextText() ) ); |
930 | |
} |
931 | 16 | else if ( checkFieldWithDuplicate( parser, "coverDate", null, parsed ) ) |
932 | |
{ |
933 | 2 | String dateFormat = null; |
934 | 2 | documentCover.setCoverDate( getDateValue( getTrimmedValue( parser.nextText() ), "coverDate", dateFormat, parser ) ); |
935 | 2 | } |
936 | 14 | else if ( checkFieldWithDuplicate( parser, "coverdate", null, parsed ) ) |
937 | |
{ |
938 | 2 | documentCover.setCoverdate( getTrimmedValue( parser.nextText() ) ); |
939 | |
} |
940 | 12 | else if ( checkFieldWithDuplicate( parser, "authors", null, parsed ) ) |
941 | |
{ |
942 | 2 | java.util.List authors = new java.util.ArrayList(); |
943 | 2 | documentCover.setAuthors( authors ); |
944 | 4 | while ( parser.nextTag() == XmlPullParser.START_TAG ) |
945 | |
{ |
946 | 2 | if ( "author".equals( parser.getName() ) ) |
947 | |
{ |
948 | 2 | authors.add( parseDocumentAuthor( parser, strict ) ); |
949 | |
} |
950 | |
else |
951 | |
{ |
952 | 0 | checkUnknownElement( parser, strict ); |
953 | |
} |
954 | |
} |
955 | 2 | } |
956 | 10 | else if ( checkFieldWithDuplicate( parser, "author", null, parsed ) ) |
957 | |
{ |
958 | 2 | documentCover.setAuthor( getTrimmedValue( parser.nextText() ) ); |
959 | |
} |
960 | 8 | else if ( checkFieldWithDuplicate( parser, "projectName", null, parsed ) ) |
961 | |
{ |
962 | 2 | documentCover.setProjectName( getTrimmedValue( parser.nextText() ) ); |
963 | |
} |
964 | 6 | else if ( checkFieldWithDuplicate( parser, "projectLogo", null, parsed ) ) |
965 | |
{ |
966 | 2 | documentCover.setProjectLogo( getTrimmedValue( parser.nextText() ) ); |
967 | |
} |
968 | 4 | else if ( checkFieldWithDuplicate( parser, "companyName", null, parsed ) ) |
969 | |
{ |
970 | 2 | documentCover.setCompanyName( getTrimmedValue( parser.nextText() ) ); |
971 | |
} |
972 | 2 | else if ( checkFieldWithDuplicate( parser, "companyLogo", null, parsed ) ) |
973 | |
{ |
974 | 2 | documentCover.setCompanyLogo( getTrimmedValue( parser.nextText() ) ); |
975 | |
} |
976 | |
else |
977 | |
{ |
978 | 0 | checkUnknownElement( parser, strict ); |
979 | |
} |
980 | |
} |
981 | 2 | return documentCover; |
982 | |
} |
983 | |
|
984 | |
|
985 | |
|
986 | |
|
987 | |
|
988 | |
|
989 | |
|
990 | |
|
991 | |
|
992 | |
|
993 | |
private DocumentHyperlinkBehaviour parseDocumentHyperlinkBehaviour( XmlPullParser parser, boolean strict ) |
994 | |
throws IOException, XmlPullParserException |
995 | |
{ |
996 | 2 | String tagName = parser.getName(); |
997 | 2 | DocumentHyperlinkBehaviour documentHyperlinkBehaviour = new DocumentHyperlinkBehaviour(); |
998 | 4 | for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) |
999 | |
{ |
1000 | 2 | String name = parser.getAttributeName( i ); |
1001 | 2 | String value = parser.getAttributeValue( i ); |
1002 | |
|
1003 | 2 | if ( name.indexOf( ':' ) >= 0 ) |
1004 | |
{ |
1005 | |
|
1006 | |
} |
1007 | 2 | else if ( "targetFrame".equals( name ) ) |
1008 | |
{ |
1009 | 2 | documentHyperlinkBehaviour.setTargetFrame( getTrimmedValue( value ) ); |
1010 | |
} |
1011 | |
else |
1012 | |
{ |
1013 | 0 | checkUnknownAttribute( parser, name, tagName, strict ); |
1014 | |
} |
1015 | |
} |
1016 | 2 | java.util.Set parsed = new java.util.HashSet(); |
1017 | 2 | while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) |
1018 | |
{ |
1019 | 0 | checkUnknownElement( parser, strict ); |
1020 | |
} |
1021 | 2 | return documentHyperlinkBehaviour; |
1022 | |
} |
1023 | |
|
1024 | |
|
1025 | |
|
1026 | |
|
1027 | |
|
1028 | |
|
1029 | |
|
1030 | |
|
1031 | |
|
1032 | |
|
1033 | |
private DocumentMeta parseDocumentMeta( XmlPullParser parser, boolean strict ) |
1034 | |
throws IOException, XmlPullParserException |
1035 | |
{ |
1036 | 2 | String tagName = parser.getName(); |
1037 | 2 | DocumentMeta documentMeta = new DocumentMeta(); |
1038 | 2 | for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) |
1039 | |
{ |
1040 | 0 | String name = parser.getAttributeName( i ); |
1041 | 0 | String value = parser.getAttributeValue( i ); |
1042 | |
|
1043 | 0 | if ( name.indexOf( ':' ) >= 0 ) |
1044 | |
{ |
1045 | |
|
1046 | |
} |
1047 | |
else |
1048 | |
{ |
1049 | 0 | checkUnknownAttribute( parser, name, tagName, strict ); |
1050 | |
} |
1051 | |
} |
1052 | 2 | java.util.Set parsed = new java.util.HashSet(); |
1053 | 52 | while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) |
1054 | |
{ |
1055 | 50 | if ( checkFieldWithDuplicate( parser, "title", null, parsed ) ) |
1056 | |
{ |
1057 | 2 | documentMeta.setTitle( getTrimmedValue( parser.nextText() ) ); |
1058 | |
} |
1059 | 48 | else if ( checkFieldWithDuplicate( parser, "author", null, parsed ) ) |
1060 | |
{ |
1061 | 2 | documentMeta.setAuthor( getTrimmedValue( parser.nextText() ) ); |
1062 | |
} |
1063 | 46 | else if ( checkFieldWithDuplicate( parser, "authors", null, parsed ) ) |
1064 | |
{ |
1065 | 2 | java.util.List authors = new java.util.ArrayList(); |
1066 | 2 | documentMeta.setAuthors( authors ); |
1067 | 4 | while ( parser.nextTag() == XmlPullParser.START_TAG ) |
1068 | |
{ |
1069 | 2 | if ( "author".equals( parser.getName() ) ) |
1070 | |
{ |
1071 | 2 | authors.add( parseDocumentAuthor( parser, strict ) ); |
1072 | |
} |
1073 | |
else |
1074 | |
{ |
1075 | 0 | checkUnknownElement( parser, strict ); |
1076 | |
} |
1077 | |
} |
1078 | 2 | } |
1079 | 44 | else if ( checkFieldWithDuplicate( parser, "subject", null, parsed ) ) |
1080 | |
{ |
1081 | 2 | documentMeta.setSubject( getTrimmedValue( parser.nextText() ) ); |
1082 | |
} |
1083 | 42 | else if ( checkFieldWithDuplicate( parser, "keywords", null, parsed ) ) |
1084 | |
{ |
1085 | 0 | documentMeta.setKeywords( getTrimmedValue( parser.nextText() ) ); |
1086 | |
} |
1087 | 42 | else if ( checkFieldWithDuplicate( parser, "keyWords", null, parsed ) ) |
1088 | |
{ |
1089 | 2 | java.util.List keyWords = new java.util.ArrayList(); |
1090 | 2 | documentMeta.setKeyWords( keyWords ); |
1091 | 6 | while ( parser.nextTag() == XmlPullParser.START_TAG ) |
1092 | |
{ |
1093 | 4 | if ( "keyWord".equals( parser.getName() ) ) |
1094 | |
{ |
1095 | 4 | keyWords.add( getTrimmedValue( parser.nextText() ) ); |
1096 | |
} |
1097 | |
else |
1098 | |
{ |
1099 | 0 | checkUnknownElement( parser, strict ); |
1100 | |
} |
1101 | |
} |
1102 | 2 | } |
1103 | 40 | else if ( checkFieldWithDuplicate( parser, "pageSize", null, parsed ) ) |
1104 | |
{ |
1105 | 2 | documentMeta.setPageSize( getTrimmedValue( parser.nextText() ) ); |
1106 | |
} |
1107 | 38 | else if ( checkFieldWithDuplicate( parser, "generator", null, parsed ) ) |
1108 | |
{ |
1109 | 2 | documentMeta.setGenerator( getTrimmedValue( parser.nextText() ) ); |
1110 | |
} |
1111 | 36 | else if ( checkFieldWithDuplicate( parser, "description", null, parsed ) ) |
1112 | |
{ |
1113 | 2 | documentMeta.setDescription( getTrimmedValue( parser.nextText() ) ); |
1114 | |
} |
1115 | 34 | else if ( checkFieldWithDuplicate( parser, "initialCreator", null, parsed ) ) |
1116 | |
{ |
1117 | 2 | documentMeta.setInitialCreator( getTrimmedValue( parser.nextText() ) ); |
1118 | |
} |
1119 | 32 | else if ( checkFieldWithDuplicate( parser, "creator", null, parsed ) ) |
1120 | |
{ |
1121 | 2 | documentMeta.setCreator( getTrimmedValue( parser.nextText() ) ); |
1122 | |
} |
1123 | 30 | else if ( checkFieldWithDuplicate( parser, "printedBy", null, parsed ) ) |
1124 | |
{ |
1125 | 2 | documentMeta.setPrintedBy( getTrimmedValue( parser.nextText() ) ); |
1126 | |
} |
1127 | 28 | else if ( checkFieldWithDuplicate( parser, "creationDate", null, parsed ) ) |
1128 | |
{ |
1129 | 2 | String dateFormat = null; |
1130 | 2 | documentMeta.setCreationDate( getDateValue( getTrimmedValue( parser.nextText() ), "creationDate", dateFormat, parser ) ); |
1131 | 2 | } |
1132 | 26 | else if ( checkFieldWithDuplicate( parser, "creationdate", null, parsed ) ) |
1133 | |
{ |
1134 | 2 | documentMeta.setCreationdate( getTrimmedValue( parser.nextText() ) ); |
1135 | |
} |
1136 | 24 | else if ( checkFieldWithDuplicate( parser, "date", null, parsed ) ) |
1137 | |
{ |
1138 | 2 | String dateFormat = null; |
1139 | 2 | documentMeta.setDate( getDateValue( getTrimmedValue( parser.nextText() ), "date", dateFormat, parser ) ); |
1140 | 2 | } |
1141 | 22 | else if ( checkFieldWithDuplicate( parser, "modifydate", null, parsed ) ) |
1142 | |
{ |
1143 | 2 | documentMeta.setModifydate( getTrimmedValue( parser.nextText() ) ); |
1144 | |
} |
1145 | 20 | else if ( checkFieldWithDuplicate( parser, "printDate", null, parsed ) ) |
1146 | |
{ |
1147 | 2 | String dateFormat = null; |
1148 | 2 | documentMeta.setPrintDate( getDateValue( getTrimmedValue( parser.nextText() ), "printDate", dateFormat, parser ) ); |
1149 | 2 | } |
1150 | 18 | else if ( checkFieldWithDuplicate( parser, "printdate", null, parsed ) ) |
1151 | |
{ |
1152 | 2 | documentMeta.setPrintdate( getTrimmedValue( parser.nextText() ) ); |
1153 | |
} |
1154 | 16 | else if ( checkFieldWithDuplicate( parser, "template", null, parsed ) ) |
1155 | |
{ |
1156 | 2 | documentMeta.setTemplate( parseDocumentTemplate( parser, strict ) ); |
1157 | |
} |
1158 | 14 | else if ( checkFieldWithDuplicate( parser, "hyperlinkBehaviour", null, parsed ) ) |
1159 | |
{ |
1160 | 2 | documentMeta.setHyperlinkBehaviour( parseDocumentHyperlinkBehaviour( parser, strict ) ); |
1161 | |
} |
1162 | 12 | else if ( checkFieldWithDuplicate( parser, "language", null, parsed ) ) |
1163 | |
{ |
1164 | 2 | documentMeta.setLanguage( getTrimmedValue( parser.nextText() ) ); |
1165 | |
} |
1166 | 10 | else if ( checkFieldWithDuplicate( parser, "editingCycles", null, parsed ) ) |
1167 | |
{ |
1168 | 2 | documentMeta.setEditingCycles( getLongValue( getTrimmedValue( parser.nextText() ), "editingCycles", parser, strict ) ); |
1169 | |
} |
1170 | 8 | else if ( checkFieldWithDuplicate( parser, "editingDuration", null, parsed ) ) |
1171 | |
{ |
1172 | 2 | documentMeta.setEditingDuration( getLongValue( getTrimmedValue( parser.nextText() ), "editingDuration", parser, strict ) ); |
1173 | |
} |
1174 | 6 | else if ( checkFieldWithDuplicate( parser, "documentStatistic", null, parsed ) ) |
1175 | |
{ |
1176 | 2 | documentMeta.setDocumentStatistic( parseDocumentStatistic( parser, strict ) ); |
1177 | |
} |
1178 | 4 | else if ( checkFieldWithDuplicate( parser, "confidential", null, parsed ) ) |
1179 | |
{ |
1180 | 2 | documentMeta.setConfidential( getBooleanValue( getTrimmedValue( parser.nextText() ), "confidential", parser, "false" ) ); |
1181 | |
} |
1182 | 2 | else if ( checkFieldWithDuplicate( parser, "draft", null, parsed ) ) |
1183 | |
{ |
1184 | 2 | documentMeta.setDraft( getBooleanValue( getTrimmedValue( parser.nextText() ), "draft", parser, "false" ) ); |
1185 | |
} |
1186 | |
else |
1187 | |
{ |
1188 | 0 | checkUnknownElement( parser, strict ); |
1189 | |
} |
1190 | |
} |
1191 | 2 | return documentMeta; |
1192 | |
} |
1193 | |
|
1194 | |
|
1195 | |
|
1196 | |
|
1197 | |
|
1198 | |
|
1199 | |
|
1200 | |
|
1201 | |
|
1202 | |
|
1203 | |
private DocumentModel parseDocumentModel( XmlPullParser parser, boolean strict ) |
1204 | |
throws IOException, XmlPullParserException |
1205 | |
{ |
1206 | 2 | String tagName = parser.getName(); |
1207 | 2 | DocumentModel documentModel = new DocumentModel(); |
1208 | 6 | for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) |
1209 | |
{ |
1210 | 4 | String name = parser.getAttributeName( i ); |
1211 | 4 | String value = parser.getAttributeValue( i ); |
1212 | |
|
1213 | 4 | if ( name.indexOf( ':' ) >= 0 ) |
1214 | |
{ |
1215 | |
|
1216 | |
} |
1217 | 4 | else if ( "xmlns".equals( name ) ) |
1218 | |
{ |
1219 | |
|
1220 | |
} |
1221 | 2 | else if ( "outputName".equals( name ) ) |
1222 | |
{ |
1223 | 2 | documentModel.setOutputName( getTrimmedValue( value ) ); |
1224 | |
} |
1225 | |
else |
1226 | |
{ |
1227 | 0 | checkUnknownAttribute( parser, name, tagName, strict ); |
1228 | |
} |
1229 | |
} |
1230 | 2 | java.util.Set parsed = new java.util.HashSet(); |
1231 | 8 | while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) |
1232 | |
{ |
1233 | 6 | if ( checkFieldWithDuplicate( parser, "meta", null, parsed ) ) |
1234 | |
{ |
1235 | 2 | documentModel.setMeta( parseDocumentMeta( parser, strict ) ); |
1236 | |
} |
1237 | 4 | else if ( checkFieldWithDuplicate( parser, "toc", null, parsed ) ) |
1238 | |
{ |
1239 | 2 | documentModel.setToc( parseDocumentTOC( parser, strict ) ); |
1240 | |
} |
1241 | 2 | else if ( checkFieldWithDuplicate( parser, "cover", null, parsed ) ) |
1242 | |
{ |
1243 | 2 | documentModel.setCover( parseDocumentCover( parser, strict ) ); |
1244 | |
} |
1245 | |
else |
1246 | |
{ |
1247 | 0 | checkUnknownElement( parser, strict ); |
1248 | |
} |
1249 | |
} |
1250 | 2 | return documentModel; |
1251 | |
} |
1252 | |
|
1253 | |
|
1254 | |
|
1255 | |
|
1256 | |
|
1257 | |
|
1258 | |
|
1259 | |
|
1260 | |
|
1261 | |
|
1262 | |
private DocumentStatistic parseDocumentStatistic( XmlPullParser parser, boolean strict ) |
1263 | |
throws IOException, XmlPullParserException |
1264 | |
{ |
1265 | 2 | String tagName = parser.getName(); |
1266 | 2 | DocumentStatistic documentStatistic = new DocumentStatistic(); |
1267 | 30 | for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) |
1268 | |
{ |
1269 | 28 | String name = parser.getAttributeName( i ); |
1270 | 28 | String value = parser.getAttributeValue( i ); |
1271 | |
|
1272 | 28 | if ( name.indexOf( ':' ) >= 0 ) |
1273 | |
{ |
1274 | |
|
1275 | |
} |
1276 | 28 | else if ( "pageCount".equals( name ) ) |
1277 | |
{ |
1278 | 2 | documentStatistic.setPageCount( getLongValue( getTrimmedValue( value ), "pageCount", parser, strict ) ); |
1279 | |
} |
1280 | 26 | else if ( "tableCount".equals( name ) ) |
1281 | |
{ |
1282 | 2 | documentStatistic.setTableCount( getLongValue( getTrimmedValue( value ), "tableCount", parser, strict ) ); |
1283 | |
} |
1284 | 24 | else if ( "drawCount".equals( name ) ) |
1285 | |
{ |
1286 | 2 | documentStatistic.setDrawCount( getLongValue( getTrimmedValue( value ), "drawCount", parser, strict ) ); |
1287 | |
} |
1288 | 22 | else if ( "imageCount".equals( name ) ) |
1289 | |
{ |
1290 | 2 | documentStatistic.setImageCount( getLongValue( getTrimmedValue( value ), "imageCount", parser, strict ) ); |
1291 | |
} |
1292 | 20 | else if ( "objectCount".equals( name ) ) |
1293 | |
{ |
1294 | 2 | documentStatistic.setObjectCount( getLongValue( getTrimmedValue( value ), "objectCount", parser, strict ) ); |
1295 | |
} |
1296 | 18 | else if ( "oleObjectCount".equals( name ) ) |
1297 | |
{ |
1298 | 2 | documentStatistic.setOleObjectCount( getLongValue( getTrimmedValue( value ), "oleObjectCount", parser, strict ) ); |
1299 | |
} |
1300 | 16 | else if ( "paragraphCount".equals( name ) ) |
1301 | |
{ |
1302 | 2 | documentStatistic.setParagraphCount( getLongValue( getTrimmedValue( value ), "paragraphCount", parser, strict ) ); |
1303 | |
} |
1304 | 14 | else if ( "wordCount".equals( name ) ) |
1305 | |
{ |
1306 | 2 | documentStatistic.setWordCount( getLongValue( getTrimmedValue( value ), "wordCount", parser, strict ) ); |
1307 | |
} |
1308 | 12 | else if ( "characterCount".equals( name ) ) |
1309 | |
{ |
1310 | 2 | documentStatistic.setCharacterCount( getLongValue( getTrimmedValue( value ), "characterCount", parser, strict ) ); |
1311 | |
} |
1312 | 10 | else if ( "rowCount".equals( name ) ) |
1313 | |
{ |
1314 | 2 | documentStatistic.setRowCount( getLongValue( getTrimmedValue( value ), "rowCount", parser, strict ) ); |
1315 | |
} |
1316 | 8 | else if ( "frameCount".equals( name ) ) |
1317 | |
{ |
1318 | 2 | documentStatistic.setFrameCount( getLongValue( getTrimmedValue( value ), "frameCount", parser, strict ) ); |
1319 | |
} |
1320 | 6 | else if ( "sentenceCount".equals( name ) ) |
1321 | |
{ |
1322 | 2 | documentStatistic.setSentenceCount( getLongValue( getTrimmedValue( value ), "sentenceCount", parser, strict ) ); |
1323 | |
} |
1324 | 4 | else if ( "syllableCount".equals( name ) ) |
1325 | |
{ |
1326 | 2 | documentStatistic.setSyllableCount( getLongValue( getTrimmedValue( value ), "syllableCount", parser, strict ) ); |
1327 | |
} |
1328 | 2 | else if ( "nonWhitespaceCharacterCount".equals( name ) ) |
1329 | |
{ |
1330 | 2 | documentStatistic.setNonWhitespaceCharacterCount( getLongValue( getTrimmedValue( value ), "nonWhitespaceCharacterCount", parser, strict ) ); |
1331 | |
} |
1332 | |
else |
1333 | |
{ |
1334 | 0 | checkUnknownAttribute( parser, name, tagName, strict ); |
1335 | |
} |
1336 | |
} |
1337 | 2 | java.util.Set parsed = new java.util.HashSet(); |
1338 | 2 | while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) |
1339 | |
{ |
1340 | 0 | checkUnknownElement( parser, strict ); |
1341 | |
} |
1342 | 2 | return documentStatistic; |
1343 | |
} |
1344 | |
|
1345 | |
|
1346 | |
|
1347 | |
|
1348 | |
|
1349 | |
|
1350 | |
|
1351 | |
|
1352 | |
|
1353 | |
|
1354 | |
private DocumentTOC parseDocumentTOC( XmlPullParser parser, boolean strict ) |
1355 | |
throws IOException, XmlPullParserException |
1356 | |
{ |
1357 | 2 | String tagName = parser.getName(); |
1358 | 2 | DocumentTOC documentTOC = new DocumentTOC(); |
1359 | 4 | for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) |
1360 | |
{ |
1361 | 2 | String name = parser.getAttributeName( i ); |
1362 | 2 | String value = parser.getAttributeValue( i ); |
1363 | |
|
1364 | 2 | if ( name.indexOf( ':' ) >= 0 ) |
1365 | |
{ |
1366 | |
|
1367 | |
} |
1368 | 2 | else if ( "name".equals( name ) ) |
1369 | |
{ |
1370 | 2 | documentTOC.setName( getTrimmedValue( value ) ); |
1371 | |
} |
1372 | 0 | else if ( "depth".equals( name ) ) |
1373 | |
{ |
1374 | 0 | documentTOC.setDepth( getIntegerValue( getTrimmedValue( value ), "depth", parser, strict ) ); |
1375 | |
} |
1376 | |
else |
1377 | |
{ |
1378 | 0 | checkUnknownAttribute( parser, name, tagName, strict ); |
1379 | |
} |
1380 | |
} |
1381 | 2 | java.util.Set parsed = new java.util.HashSet(); |
1382 | 6 | while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) |
1383 | |
{ |
1384 | 4 | if ( "item".equals( parser.getName() ) ) |
1385 | |
{ |
1386 | 4 | java.util.List items = documentTOC.getItems(); |
1387 | 4 | if ( items == null ) |
1388 | |
{ |
1389 | 0 | items = new java.util.ArrayList(); |
1390 | 0 | documentTOC.setItems( items ); |
1391 | |
} |
1392 | 4 | items.add( parseDocumentTOCItem( parser, strict ) ); |
1393 | 4 | } |
1394 | |
else |
1395 | |
{ |
1396 | 0 | checkUnknownElement( parser, strict ); |
1397 | |
} |
1398 | |
} |
1399 | 2 | return documentTOC; |
1400 | |
} |
1401 | |
|
1402 | |
|
1403 | |
|
1404 | |
|
1405 | |
|
1406 | |
|
1407 | |
|
1408 | |
|
1409 | |
|
1410 | |
|
1411 | |
private DocumentTOCItem parseDocumentTOCItem( XmlPullParser parser, boolean strict ) |
1412 | |
throws IOException, XmlPullParserException |
1413 | |
{ |
1414 | 4 | String tagName = parser.getName(); |
1415 | 4 | DocumentTOCItem documentTOCItem = new DocumentTOCItem(); |
1416 | 12 | for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) |
1417 | |
{ |
1418 | 8 | String name = parser.getAttributeName( i ); |
1419 | 8 | String value = parser.getAttributeValue( i ); |
1420 | |
|
1421 | 8 | if ( name.indexOf( ':' ) >= 0 ) |
1422 | |
{ |
1423 | |
|
1424 | |
} |
1425 | 8 | else if ( "name".equals( name ) ) |
1426 | |
{ |
1427 | 4 | documentTOCItem.setName( getTrimmedValue( value ) ); |
1428 | |
} |
1429 | 4 | else if ( "ref".equals( name ) ) |
1430 | |
{ |
1431 | 4 | documentTOCItem.setRef( getTrimmedValue( value ) ); |
1432 | |
} |
1433 | 0 | else if ( "collapse".equals( name ) ) |
1434 | |
{ |
1435 | 0 | documentTOCItem.setCollapse( getBooleanValue( getTrimmedValue( value ), "collapse", parser, "false" ) ); |
1436 | |
} |
1437 | |
else |
1438 | |
{ |
1439 | 0 | checkUnknownAttribute( parser, name, tagName, strict ); |
1440 | |
} |
1441 | |
} |
1442 | 4 | java.util.Set parsed = new java.util.HashSet(); |
1443 | 4 | while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) |
1444 | |
{ |
1445 | 0 | if ( "item".equals( parser.getName() ) ) |
1446 | |
{ |
1447 | 0 | java.util.List items = documentTOCItem.getItems(); |
1448 | 0 | if ( items == null ) |
1449 | |
{ |
1450 | 0 | items = new java.util.ArrayList(); |
1451 | 0 | documentTOCItem.setItems( items ); |
1452 | |
} |
1453 | 0 | items.add( parseDocumentTOCItem( parser, strict ) ); |
1454 | 0 | } |
1455 | |
else |
1456 | |
{ |
1457 | 0 | checkUnknownElement( parser, strict ); |
1458 | |
} |
1459 | |
} |
1460 | 4 | return documentTOCItem; |
1461 | |
} |
1462 | |
|
1463 | |
|
1464 | |
|
1465 | |
|
1466 | |
|
1467 | |
|
1468 | |
|
1469 | |
|
1470 | |
|
1471 | |
|
1472 | |
private DocumentTemplate parseDocumentTemplate( XmlPullParser parser, boolean strict ) |
1473 | |
throws IOException, XmlPullParserException |
1474 | |
{ |
1475 | 2 | String tagName = parser.getName(); |
1476 | 2 | DocumentTemplate documentTemplate = new DocumentTemplate(); |
1477 | 10 | for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) |
1478 | |
{ |
1479 | 8 | String name = parser.getAttributeName( i ); |
1480 | 8 | String value = parser.getAttributeValue( i ); |
1481 | |
|
1482 | 8 | if ( name.indexOf( ':' ) >= 0 ) |
1483 | |
{ |
1484 | |
|
1485 | |
} |
1486 | 8 | else if ( "href".equals( name ) ) |
1487 | |
{ |
1488 | 2 | documentTemplate.setHref( getTrimmedValue( value ) ); |
1489 | |
} |
1490 | 6 | else if ( "title".equals( name ) ) |
1491 | |
{ |
1492 | 2 | documentTemplate.setTitle( getTrimmedValue( value ) ); |
1493 | |
} |
1494 | 4 | else if ( "date".equals( name ) ) |
1495 | |
{ |
1496 | 2 | String dateFormat = null; |
1497 | 2 | documentTemplate.setDate( getDateValue( getTrimmedValue( value ), "date", dateFormat, parser ) ); |
1498 | 2 | } |
1499 | 2 | else if ( "modifydate".equals( name ) ) |
1500 | |
{ |
1501 | 2 | documentTemplate.setModifydate( getTrimmedValue( value ) ); |
1502 | |
} |
1503 | |
else |
1504 | |
{ |
1505 | 0 | checkUnknownAttribute( parser, name, tagName, strict ); |
1506 | |
} |
1507 | |
} |
1508 | 2 | java.util.Set parsed = new java.util.HashSet(); |
1509 | 2 | while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) |
1510 | |
{ |
1511 | 0 | checkUnknownElement( parser, strict ); |
1512 | |
} |
1513 | 2 | return documentTemplate; |
1514 | |
} |
1515 | |
|
1516 | |
|
1517 | |
|
1518 | |
|
1519 | |
|
1520 | |
|
1521 | |
|
1522 | |
|
1523 | |
|
1524 | |
|
1525 | |
public DocumentModel read( Reader reader, boolean strict ) |
1526 | |
throws IOException, XmlPullParserException |
1527 | |
{ |
1528 | 2 | XmlPullParser parser = new MXParser(); |
1529 | |
|
1530 | 2 | parser.setInput( reader ); |
1531 | |
|
1532 | 2 | initParser( parser ); |
1533 | |
|
1534 | 2 | return read( parser, strict ); |
1535 | |
} |
1536 | |
|
1537 | |
|
1538 | |
|
1539 | |
|
1540 | |
|
1541 | |
|
1542 | |
|
1543 | |
|
1544 | |
|
1545 | |
public DocumentModel read( Reader reader ) |
1546 | |
throws IOException, XmlPullParserException |
1547 | |
{ |
1548 | 2 | return read( reader, true ); |
1549 | |
} |
1550 | |
|
1551 | |
|
1552 | |
|
1553 | |
|
1554 | |
|
1555 | |
|
1556 | |
|
1557 | |
|
1558 | |
|
1559 | |
|
1560 | |
public DocumentModel read( InputStream in, boolean strict ) |
1561 | |
throws IOException, XmlPullParserException |
1562 | |
{ |
1563 | 0 | return read( ReaderFactory.newXmlReader( in ), strict ); |
1564 | |
} |
1565 | |
|
1566 | |
|
1567 | |
|
1568 | |
|
1569 | |
|
1570 | |
|
1571 | |
|
1572 | |
|
1573 | |
|
1574 | |
public DocumentModel read( InputStream in ) |
1575 | |
throws IOException, XmlPullParserException |
1576 | |
{ |
1577 | 0 | return read( ReaderFactory.newXmlReader( in ) ); |
1578 | |
} |
1579 | |
|
1580 | |
|
1581 | |
|
1582 | |
|
1583 | |
|
1584 | |
|
1585 | |
|
1586 | |
|
1587 | |
|
1588 | |
|
1589 | |
private DocumentModel read( XmlPullParser parser, boolean strict ) |
1590 | |
throws IOException, XmlPullParserException |
1591 | |
{ |
1592 | 2 | int eventType = parser.getEventType(); |
1593 | 4 | while ( eventType != XmlPullParser.END_DOCUMENT ) |
1594 | |
{ |
1595 | 4 | if ( eventType == XmlPullParser.START_TAG ) |
1596 | |
{ |
1597 | 2 | if ( strict && ! "document".equals( parser.getName() ) ) |
1598 | |
{ |
1599 | 0 | throw new XmlPullParserException( "Expected root element 'document' but found '" + parser.getName() + "'", parser, null ); |
1600 | |
} |
1601 | 2 | DocumentModel documentModel = parseDocumentModel( parser, strict ); |
1602 | 2 | documentModel.setModelEncoding( parser.getInputEncoding() ); |
1603 | 2 | return documentModel; |
1604 | |
} |
1605 | 2 | eventType = parser.next(); |
1606 | |
} |
1607 | 0 | throw new XmlPullParserException( "Expected root element 'document' but found no element at all: invalid XML document", parser, null ); |
1608 | |
} |
1609 | |
|
1610 | |
|
1611 | |
|
1612 | |
|
1613 | |
|
1614 | |
|
1615 | |
public void setAddDefaultEntities( boolean addDefaultEntities ) |
1616 | |
{ |
1617 | 0 | this.addDefaultEntities = addDefaultEntities; |
1618 | 0 | } |
1619 | |
|
1620 | |
} |