1 | |
package org.apache.maven.doxia.module.fml; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import org.apache.maven.doxia.macro.MacroExecutionException; |
23 | |
import org.apache.maven.doxia.parser.XhtmlBaseParser; |
24 | |
import org.apache.maven.doxia.sink.Sink; |
25 | |
import org.apache.maven.doxia.sink.SinkEventAttributeSet; |
26 | |
|
27 | |
import org.codehaus.plexus.util.xml.pull.XmlPullParser; |
28 | |
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; |
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | 10 | public class FmlContentParser |
38 | |
extends XhtmlBaseParser |
39 | |
implements FmlMarkup |
40 | |
{ |
41 | |
|
42 | |
private boolean isEmptyElement; |
43 | |
|
44 | |
|
45 | |
protected void handleStartTag( XmlPullParser parser, Sink sink ) |
46 | |
throws XmlPullParserException, MacroExecutionException |
47 | |
{ |
48 | 1386 | isEmptyElement = parser.isEmptyElementTag(); |
49 | |
|
50 | 1386 | if ( parser.getName().equals( QUESTION_TAG.toString() ) |
51 | |
|| parser.getName().equals( TITLE.toString() ) |
52 | |
|| parser.getName().equals( ANSWER_TAG.toString() ) ) |
53 | |
{ |
54 | |
|
55 | 588 | return; |
56 | |
} |
57 | 798 | else if ( parser.getName().equals( SOURCE_TAG.toString() ) ) |
58 | |
{ |
59 | 52 | verbatim(); |
60 | |
|
61 | 52 | sink.verbatim( SinkEventAttributeSet.BOXED ); |
62 | |
} |
63 | 746 | else if ( !baseStartTag( parser, sink ) ) |
64 | |
{ |
65 | 2 | if ( isEmptyElement ) |
66 | |
{ |
67 | 0 | handleUnknown( parser, sink, TAG_TYPE_SIMPLE ); |
68 | |
} |
69 | |
else |
70 | |
{ |
71 | 2 | handleUnknown( parser, sink, TAG_TYPE_START ); |
72 | |
} |
73 | |
|
74 | 2 | if ( getLog().isDebugEnabled() ) |
75 | |
{ |
76 | 0 | String position = "[" + parser.getLineNumber() + ":" |
77 | |
+ parser.getColumnNumber() + "]"; |
78 | 0 | String tag = "<" + parser.getName() + ">"; |
79 | |
|
80 | 0 | getLog().debug( "Unrecognized fml tag: " + tag + " at " + position ); |
81 | |
} |
82 | |
} |
83 | 798 | } |
84 | |
|
85 | |
|
86 | |
protected void handleEndTag( XmlPullParser parser, Sink sink ) |
87 | |
throws XmlPullParserException, MacroExecutionException |
88 | |
{ |
89 | 1386 | if ( parser.getName().equals( QUESTION_TAG.toString() ) |
90 | |
|| parser.getName().equals( TITLE.toString() ) |
91 | |
|| parser.getName().equals( ANSWER_TAG.toString() ) ) |
92 | |
{ |
93 | |
|
94 | 588 | return; |
95 | |
} |
96 | 798 | else if ( parser.getName().equals( SOURCE_TAG.toString() ) ) |
97 | |
{ |
98 | 52 | verbatim_(); |
99 | |
|
100 | 52 | sink.verbatim_(); |
101 | |
} |
102 | 746 | else if ( !baseEndTag( parser, sink ) ) |
103 | |
{ |
104 | 2 | if ( !isEmptyElement ) |
105 | |
{ |
106 | 2 | handleUnknown( parser, sink, TAG_TYPE_END ); |
107 | |
} |
108 | |
} |
109 | |
|
110 | 798 | isEmptyElement = false; |
111 | 798 | } |
112 | |
|
113 | |
|
114 | |
protected void init() |
115 | |
{ |
116 | 2352 | super.init(); |
117 | |
|
118 | 2352 | this.isEmptyElement = false; |
119 | 2352 | } |
120 | |
} |