2 Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
3 See the file copying.txt for copying permission.
12 that ,| are not mixed in a model group
17 static const char KW_ANY
[] = { ASCII_A
, ASCII_N
, ASCII_Y
, '\0' };
18 static const char KW_ATTLIST
[] = { ASCII_A
, ASCII_T
, ASCII_T
, ASCII_L
, ASCII_I
, ASCII_S
, ASCII_T
, '\0' };
19 static const char KW_CDATA
[] = { ASCII_C
, ASCII_D
, ASCII_A
, ASCII_T
, ASCII_A
, '\0' };
20 static const char KW_DOCTYPE
[] = { ASCII_D
, ASCII_O
, ASCII_C
, ASCII_T
, ASCII_Y
, ASCII_P
, ASCII_E
, '\0' };
21 static const char KW_ELEMENT
[] = { ASCII_E
, ASCII_L
, ASCII_E
, ASCII_M
, ASCII_E
, ASCII_N
, ASCII_T
, '\0' };
22 static const char KW_EMPTY
[] = { ASCII_E
, ASCII_M
, ASCII_P
, ASCII_T
, ASCII_Y
, '\0' };
23 static const char KW_ENTITIES
[] = { ASCII_E
, ASCII_N
, ASCII_T
, ASCII_I
, ASCII_T
, ASCII_I
, ASCII_E
, ASCII_S
, '\0' };
24 static const char KW_ENTITY
[] = { ASCII_E
, ASCII_N
, ASCII_T
, ASCII_I
, ASCII_T
, ASCII_Y
, '\0' };
25 static const char KW_FIXED
[] = { ASCII_F
, ASCII_I
, ASCII_X
, ASCII_E
, ASCII_D
, '\0' };
26 static const char KW_ID
[] = { ASCII_I
, ASCII_D
, '\0' };
27 static const char KW_IDREF
[] = { ASCII_I
, ASCII_D
, ASCII_R
, ASCII_E
, ASCII_F
, '\0' };
28 static const char KW_IDREFS
[] = { ASCII_I
, ASCII_D
, ASCII_R
, ASCII_E
, ASCII_F
, ASCII_S
, '\0' };
29 static const char KW_IGNORE
[] = { ASCII_I
, ASCII_G
, ASCII_N
, ASCII_O
, ASCII_R
, ASCII_E
, '\0' };
30 static const char KW_IMPLIED
[] = { ASCII_I
, ASCII_M
, ASCII_P
, ASCII_L
, ASCII_I
, ASCII_E
, ASCII_D
, '\0' };
31 static const char KW_INCLUDE
[] = { ASCII_I
, ASCII_N
, ASCII_C
, ASCII_L
, ASCII_U
, ASCII_D
, ASCII_E
, '\0' };
32 static const char KW_NDATA
[] = { ASCII_N
, ASCII_D
, ASCII_A
, ASCII_T
, ASCII_A
, '\0' };
33 static const char KW_NMTOKEN
[] = { ASCII_N
, ASCII_M
, ASCII_T
, ASCII_O
, ASCII_K
, ASCII_E
, ASCII_N
, '\0' };
34 static const char KW_NMTOKENS
[] = { ASCII_N
, ASCII_M
, ASCII_T
, ASCII_O
, ASCII_K
, ASCII_E
, ASCII_N
, ASCII_S
, '\0' };
35 static const char KW_NOTATION
[] = { ASCII_N
, ASCII_O
, ASCII_T
, ASCII_A
, ASCII_T
, ASCII_I
, ASCII_O
, ASCII_N
, '\0' };
36 static const char KW_PCDATA
[] = { ASCII_P
, ASCII_C
, ASCII_D
, ASCII_A
, ASCII_T
, ASCII_A
, '\0' };
37 static const char KW_PUBLIC
[] = { ASCII_P
, ASCII_U
, ASCII_B
, ASCII_L
, ASCII_I
, ASCII_C
, '\0' };
38 static const char KW_REQUIRED
[] = { ASCII_R
, ASCII_E
, ASCII_Q
, ASCII_U
, ASCII_I
, ASCII_R
, ASCII_E
, ASCII_D
, '\0' };
39 static const char KW_SYSTEM
[] = { ASCII_S
, ASCII_Y
, ASCII_S
, ASCII_T
, ASCII_E
, ASCII_M
, '\0' };
41 #ifndef MIN_BYTES_PER_CHAR
42 #define MIN_BYTES_PER_CHAR(enc) ((enc)->minBytesPerChar)
46 #define setTopLevel(state) \
47 ((state)->handler = ((state)->documentEntity \
50 #else /* not XML_DTD */
51 #define setTopLevel(state) ((state)->handler = internalSubset)
52 #endif /* not XML_DTD */
54 typedef int PROLOG_HANDLER(PROLOG_STATE
*state
,
61 prolog0
, prolog1
, prolog2
,
62 doctype0
, doctype1
, doctype2
, doctype3
, doctype4
, doctype5
,
64 entity0
, entity1
, entity2
, entity3
, entity4
, entity5
, entity6
,
65 entity7
, entity8
, entity9
,
66 notation0
, notation1
, notation2
, notation3
, notation4
,
67 attlist0
, attlist1
, attlist2
, attlist3
, attlist4
, attlist5
, attlist6
,
68 attlist7
, attlist8
, attlist9
,
69 element0
, element1
, element2
, element3
, element4
, element5
, element6
,
72 externalSubset0
, externalSubset1
,
73 condSect0
, condSect1
, condSect2
,
79 int common(PROLOG_STATE
*state
, int tok
);
82 int prolog0(PROLOG_STATE
*state
,
89 case XML_TOK_PROLOG_S
:
90 state
->handler
= prolog1
;
92 case XML_TOK_XML_DECL
:
93 state
->handler
= prolog1
;
94 return XML_ROLE_XML_DECL
;
96 state
->handler
= prolog1
;
99 state
->handler
= prolog1
;
101 return XML_ROLE_NONE
;
102 case XML_TOK_DECL_OPEN
:
103 if (!XmlNameMatchesAscii(enc
,
104 ptr
+ 2 * MIN_BYTES_PER_CHAR(enc
),
108 state
->handler
= doctype0
;
109 return XML_ROLE_NONE
;
110 case XML_TOK_INSTANCE_START
:
111 state
->handler
= error
;
112 return XML_ROLE_INSTANCE_START
;
114 return common(state
, tok
);
118 int prolog1(PROLOG_STATE
*state
,
125 case XML_TOK_PROLOG_S
:
126 return XML_ROLE_NONE
;
128 case XML_TOK_COMMENT
:
130 return XML_ROLE_NONE
;
131 case XML_TOK_DECL_OPEN
:
132 if (!XmlNameMatchesAscii(enc
,
133 ptr
+ 2 * MIN_BYTES_PER_CHAR(enc
),
137 state
->handler
= doctype0
;
138 return XML_ROLE_NONE
;
139 case XML_TOK_INSTANCE_START
:
140 state
->handler
= error
;
141 return XML_ROLE_INSTANCE_START
;
143 return common(state
, tok
);
147 int prolog2(PROLOG_STATE
*state
,
154 case XML_TOK_PROLOG_S
:
155 return XML_ROLE_NONE
;
157 case XML_TOK_COMMENT
:
158 return XML_ROLE_NONE
;
159 case XML_TOK_INSTANCE_START
:
160 state
->handler
= error
;
161 return XML_ROLE_INSTANCE_START
;
163 return common(state
, tok
);
167 int doctype0(PROLOG_STATE
*state
,
174 case XML_TOK_PROLOG_S
:
175 return XML_ROLE_NONE
;
177 case XML_TOK_PREFIXED_NAME
:
178 state
->handler
= doctype1
;
179 return XML_ROLE_DOCTYPE_NAME
;
181 return common(state
, tok
);
185 int doctype1(PROLOG_STATE
*state
,
192 case XML_TOK_PROLOG_S
:
193 return XML_ROLE_NONE
;
194 case XML_TOK_OPEN_BRACKET
:
195 state
->handler
= internalSubset
;
196 return XML_ROLE_NONE
;
197 case XML_TOK_DECL_CLOSE
:
198 state
->handler
= prolog2
;
199 return XML_ROLE_DOCTYPE_CLOSE
;
201 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_SYSTEM
)) {
202 state
->handler
= doctype3
;
203 return XML_ROLE_NONE
;
205 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_PUBLIC
)) {
206 state
->handler
= doctype2
;
207 return XML_ROLE_NONE
;
211 return common(state
, tok
);
215 int doctype2(PROLOG_STATE
*state
,
222 case XML_TOK_PROLOG_S
:
223 return XML_ROLE_NONE
;
224 case XML_TOK_LITERAL
:
225 state
->handler
= doctype3
;
226 return XML_ROLE_DOCTYPE_PUBLIC_ID
;
228 return common(state
, tok
);
232 int doctype3(PROLOG_STATE
*state
,
239 case XML_TOK_PROLOG_S
:
240 return XML_ROLE_NONE
;
241 case XML_TOK_LITERAL
:
242 state
->handler
= doctype4
;
243 return XML_ROLE_DOCTYPE_SYSTEM_ID
;
245 return common(state
, tok
);
249 int doctype4(PROLOG_STATE
*state
,
256 case XML_TOK_PROLOG_S
:
257 return XML_ROLE_NONE
;
258 case XML_TOK_OPEN_BRACKET
:
259 state
->handler
= internalSubset
;
260 return XML_ROLE_NONE
;
261 case XML_TOK_DECL_CLOSE
:
262 state
->handler
= prolog2
;
263 return XML_ROLE_DOCTYPE_CLOSE
;
265 return common(state
, tok
);
269 int doctype5(PROLOG_STATE
*state
,
276 case XML_TOK_PROLOG_S
:
277 return XML_ROLE_NONE
;
278 case XML_TOK_DECL_CLOSE
:
279 state
->handler
= prolog2
;
280 return XML_ROLE_DOCTYPE_CLOSE
;
282 return common(state
, tok
);
286 int internalSubset(PROLOG_STATE
*state
,
293 case XML_TOK_PROLOG_S
:
294 return XML_ROLE_NONE
;
295 case XML_TOK_DECL_OPEN
:
296 if (XmlNameMatchesAscii(enc
,
297 ptr
+ 2 * MIN_BYTES_PER_CHAR(enc
),
300 state
->handler
= entity0
;
301 return XML_ROLE_NONE
;
303 if (XmlNameMatchesAscii(enc
,
304 ptr
+ 2 * MIN_BYTES_PER_CHAR(enc
),
307 state
->handler
= attlist0
;
308 return XML_ROLE_NONE
;
310 if (XmlNameMatchesAscii(enc
,
311 ptr
+ 2 * MIN_BYTES_PER_CHAR(enc
),
314 state
->handler
= element0
;
315 return XML_ROLE_NONE
;
317 if (XmlNameMatchesAscii(enc
,
318 ptr
+ 2 * MIN_BYTES_PER_CHAR(enc
),
321 state
->handler
= notation0
;
322 return XML_ROLE_NONE
;
326 case XML_TOK_COMMENT
:
327 return XML_ROLE_NONE
;
328 case XML_TOK_PARAM_ENTITY_REF
:
329 return XML_ROLE_PARAM_ENTITY_REF
;
330 case XML_TOK_CLOSE_BRACKET
:
331 state
->handler
= doctype5
;
332 return XML_ROLE_NONE
;
334 return common(state
, tok
);
340 int externalSubset0(PROLOG_STATE
*state
,
346 state
->handler
= externalSubset1
;
347 if (tok
== XML_TOK_XML_DECL
)
348 return XML_ROLE_TEXT_DECL
;
349 return externalSubset1(state
, tok
, ptr
, end
, enc
);
353 int externalSubset1(PROLOG_STATE
*state
,
360 case XML_TOK_COND_SECT_OPEN
:
361 state
->handler
= condSect0
;
362 return XML_ROLE_NONE
;
363 case XML_TOK_COND_SECT_CLOSE
:
364 if (state
->includeLevel
== 0)
366 state
->includeLevel
-= 1;
367 return XML_ROLE_NONE
;
368 case XML_TOK_PROLOG_S
:
369 return XML_ROLE_NONE
;
370 case XML_TOK_CLOSE_BRACKET
:
373 if (state
->includeLevel
)
375 return XML_ROLE_NONE
;
377 return internalSubset(state
, tok
, ptr
, end
, enc
);
379 return common(state
, tok
);
385 int entity0(PROLOG_STATE
*state
,
392 case XML_TOK_PROLOG_S
:
393 return XML_ROLE_NONE
;
394 case XML_TOK_PERCENT
:
395 state
->handler
= entity1
;
396 return XML_ROLE_NONE
;
398 state
->handler
= entity2
;
399 return XML_ROLE_GENERAL_ENTITY_NAME
;
401 return common(state
, tok
);
405 int entity1(PROLOG_STATE
*state
,
412 case XML_TOK_PROLOG_S
:
413 return XML_ROLE_NONE
;
415 state
->handler
= entity7
;
416 return XML_ROLE_PARAM_ENTITY_NAME
;
418 return common(state
, tok
);
422 int entity2(PROLOG_STATE
*state
,
429 case XML_TOK_PROLOG_S
:
430 return XML_ROLE_NONE
;
432 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_SYSTEM
)) {
433 state
->handler
= entity4
;
434 return XML_ROLE_NONE
;
436 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_PUBLIC
)) {
437 state
->handler
= entity3
;
438 return XML_ROLE_NONE
;
441 case XML_TOK_LITERAL
:
442 state
->handler
= declClose
;
443 return XML_ROLE_ENTITY_VALUE
;
445 return common(state
, tok
);
449 int entity3(PROLOG_STATE
*state
,
456 case XML_TOK_PROLOG_S
:
457 return XML_ROLE_NONE
;
458 case XML_TOK_LITERAL
:
459 state
->handler
= entity4
;
460 return XML_ROLE_ENTITY_PUBLIC_ID
;
462 return common(state
, tok
);
467 int entity4(PROLOG_STATE
*state
,
474 case XML_TOK_PROLOG_S
:
475 return XML_ROLE_NONE
;
476 case XML_TOK_LITERAL
:
477 state
->handler
= entity5
;
478 return XML_ROLE_ENTITY_SYSTEM_ID
;
480 return common(state
, tok
);
484 int entity5(PROLOG_STATE
*state
,
491 case XML_TOK_PROLOG_S
:
492 return XML_ROLE_NONE
;
493 case XML_TOK_DECL_CLOSE
:
495 return XML_ROLE_EXTERNAL_GENERAL_ENTITY_NO_NOTATION
;
497 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_NDATA
)) {
498 state
->handler
= entity6
;
499 return XML_ROLE_NONE
;
503 return common(state
, tok
);
507 int entity6(PROLOG_STATE
*state
,
514 case XML_TOK_PROLOG_S
:
515 return XML_ROLE_NONE
;
517 state
->handler
= declClose
;
518 return XML_ROLE_ENTITY_NOTATION_NAME
;
520 return common(state
, tok
);
524 int entity7(PROLOG_STATE
*state
,
531 case XML_TOK_PROLOG_S
:
532 return XML_ROLE_NONE
;
534 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_SYSTEM
)) {
535 state
->handler
= entity9
;
536 return XML_ROLE_NONE
;
538 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_PUBLIC
)) {
539 state
->handler
= entity8
;
540 return XML_ROLE_NONE
;
543 case XML_TOK_LITERAL
:
544 state
->handler
= declClose
;
545 return XML_ROLE_ENTITY_VALUE
;
547 return common(state
, tok
);
551 int entity8(PROLOG_STATE
*state
,
558 case XML_TOK_PROLOG_S
:
559 return XML_ROLE_NONE
;
560 case XML_TOK_LITERAL
:
561 state
->handler
= entity9
;
562 return XML_ROLE_ENTITY_PUBLIC_ID
;
564 return common(state
, tok
);
568 int entity9(PROLOG_STATE
*state
,
575 case XML_TOK_PROLOG_S
:
576 return XML_ROLE_NONE
;
577 case XML_TOK_LITERAL
:
578 state
->handler
= declClose
;
579 return XML_ROLE_ENTITY_SYSTEM_ID
;
581 return common(state
, tok
);
585 int notation0(PROLOG_STATE
*state
,
592 case XML_TOK_PROLOG_S
:
593 return XML_ROLE_NONE
;
595 state
->handler
= notation1
;
596 return XML_ROLE_NOTATION_NAME
;
598 return common(state
, tok
);
602 int notation1(PROLOG_STATE
*state
,
609 case XML_TOK_PROLOG_S
:
610 return XML_ROLE_NONE
;
612 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_SYSTEM
)) {
613 state
->handler
= notation3
;
614 return XML_ROLE_NONE
;
616 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_PUBLIC
)) {
617 state
->handler
= notation2
;
618 return XML_ROLE_NONE
;
622 return common(state
, tok
);
626 int notation2(PROLOG_STATE
*state
,
633 case XML_TOK_PROLOG_S
:
634 return XML_ROLE_NONE
;
635 case XML_TOK_LITERAL
:
636 state
->handler
= notation4
;
637 return XML_ROLE_NOTATION_PUBLIC_ID
;
639 return common(state
, tok
);
643 int notation3(PROLOG_STATE
*state
,
650 case XML_TOK_PROLOG_S
:
651 return XML_ROLE_NONE
;
652 case XML_TOK_LITERAL
:
653 state
->handler
= declClose
;
654 return XML_ROLE_NOTATION_SYSTEM_ID
;
656 return common(state
, tok
);
660 int notation4(PROLOG_STATE
*state
,
667 case XML_TOK_PROLOG_S
:
668 return XML_ROLE_NONE
;
669 case XML_TOK_LITERAL
:
670 state
->handler
= declClose
;
671 return XML_ROLE_NOTATION_SYSTEM_ID
;
672 case XML_TOK_DECL_CLOSE
:
674 return XML_ROLE_NOTATION_NO_SYSTEM_ID
;
676 return common(state
, tok
);
680 int attlist0(PROLOG_STATE
*state
,
687 case XML_TOK_PROLOG_S
:
688 return XML_ROLE_NONE
;
690 case XML_TOK_PREFIXED_NAME
:
691 state
->handler
= attlist1
;
692 return XML_ROLE_ATTLIST_ELEMENT_NAME
;
694 return common(state
, tok
);
698 int attlist1(PROLOG_STATE
*state
,
705 case XML_TOK_PROLOG_S
:
706 return XML_ROLE_NONE
;
707 case XML_TOK_DECL_CLOSE
:
709 return XML_ROLE_NONE
;
711 case XML_TOK_PREFIXED_NAME
:
712 state
->handler
= attlist2
;
713 return XML_ROLE_ATTRIBUTE_NAME
;
715 return common(state
, tok
);
719 int attlist2(PROLOG_STATE
*state
,
726 case XML_TOK_PROLOG_S
:
727 return XML_ROLE_NONE
;
730 static const char *types
[] = {
741 for (i
= 0; i
< (int)(sizeof(types
)/sizeof(types
[0])); i
++)
742 if (XmlNameMatchesAscii(enc
, ptr
, end
, types
[i
])) {
743 state
->handler
= attlist8
;
744 return XML_ROLE_ATTRIBUTE_TYPE_CDATA
+ i
;
747 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_NOTATION
)) {
748 state
->handler
= attlist5
;
749 return XML_ROLE_NONE
;
752 case XML_TOK_OPEN_PAREN
:
753 state
->handler
= attlist3
;
754 return XML_ROLE_NONE
;
756 return common(state
, tok
);
760 int attlist3(PROLOG_STATE
*state
,
767 case XML_TOK_PROLOG_S
:
768 return XML_ROLE_NONE
;
769 case XML_TOK_NMTOKEN
:
771 case XML_TOK_PREFIXED_NAME
:
772 state
->handler
= attlist4
;
773 return XML_ROLE_ATTRIBUTE_ENUM_VALUE
;
775 return common(state
, tok
);
779 int attlist4(PROLOG_STATE
*state
,
786 case XML_TOK_PROLOG_S
:
787 return XML_ROLE_NONE
;
788 case XML_TOK_CLOSE_PAREN
:
789 state
->handler
= attlist8
;
790 return XML_ROLE_NONE
;
792 state
->handler
= attlist3
;
793 return XML_ROLE_NONE
;
795 return common(state
, tok
);
799 int attlist5(PROLOG_STATE
*state
,
806 case XML_TOK_PROLOG_S
:
807 return XML_ROLE_NONE
;
808 case XML_TOK_OPEN_PAREN
:
809 state
->handler
= attlist6
;
810 return XML_ROLE_NONE
;
812 return common(state
, tok
);
817 int attlist6(PROLOG_STATE
*state
,
824 case XML_TOK_PROLOG_S
:
825 return XML_ROLE_NONE
;
827 state
->handler
= attlist7
;
828 return XML_ROLE_ATTRIBUTE_NOTATION_VALUE
;
830 return common(state
, tok
);
834 int attlist7(PROLOG_STATE
*state
,
841 case XML_TOK_PROLOG_S
:
842 return XML_ROLE_NONE
;
843 case XML_TOK_CLOSE_PAREN
:
844 state
->handler
= attlist8
;
845 return XML_ROLE_NONE
;
847 state
->handler
= attlist6
;
848 return XML_ROLE_NONE
;
850 return common(state
, tok
);
855 int attlist8(PROLOG_STATE
*state
,
862 case XML_TOK_PROLOG_S
:
863 return XML_ROLE_NONE
;
864 case XML_TOK_POUND_NAME
:
865 if (XmlNameMatchesAscii(enc
,
866 ptr
+ MIN_BYTES_PER_CHAR(enc
),
869 state
->handler
= attlist1
;
870 return XML_ROLE_IMPLIED_ATTRIBUTE_VALUE
;
872 if (XmlNameMatchesAscii(enc
,
873 ptr
+ MIN_BYTES_PER_CHAR(enc
),
876 state
->handler
= attlist1
;
877 return XML_ROLE_REQUIRED_ATTRIBUTE_VALUE
;
879 if (XmlNameMatchesAscii(enc
,
880 ptr
+ MIN_BYTES_PER_CHAR(enc
),
883 state
->handler
= attlist9
;
884 return XML_ROLE_NONE
;
887 case XML_TOK_LITERAL
:
888 state
->handler
= attlist1
;
889 return XML_ROLE_DEFAULT_ATTRIBUTE_VALUE
;
891 return common(state
, tok
);
895 int attlist9(PROLOG_STATE
*state
,
902 case XML_TOK_PROLOG_S
:
903 return XML_ROLE_NONE
;
904 case XML_TOK_LITERAL
:
905 state
->handler
= attlist1
;
906 return XML_ROLE_FIXED_ATTRIBUTE_VALUE
;
908 return common(state
, tok
);
912 int element0(PROLOG_STATE
*state
,
919 case XML_TOK_PROLOG_S
:
920 return XML_ROLE_NONE
;
922 case XML_TOK_PREFIXED_NAME
:
923 state
->handler
= element1
;
924 return XML_ROLE_ELEMENT_NAME
;
926 return common(state
, tok
);
930 int element1(PROLOG_STATE
*state
,
937 case XML_TOK_PROLOG_S
:
938 return XML_ROLE_NONE
;
940 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_EMPTY
)) {
941 state
->handler
= declClose
;
942 return XML_ROLE_CONTENT_EMPTY
;
944 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_ANY
)) {
945 state
->handler
= declClose
;
946 return XML_ROLE_CONTENT_ANY
;
949 case XML_TOK_OPEN_PAREN
:
950 state
->handler
= element2
;
952 return XML_ROLE_GROUP_OPEN
;
954 return common(state
, tok
);
958 int element2(PROLOG_STATE
*state
,
965 case XML_TOK_PROLOG_S
:
966 return XML_ROLE_NONE
;
967 case XML_TOK_POUND_NAME
:
968 if (XmlNameMatchesAscii(enc
,
969 ptr
+ MIN_BYTES_PER_CHAR(enc
),
972 state
->handler
= element3
;
973 return XML_ROLE_CONTENT_PCDATA
;
976 case XML_TOK_OPEN_PAREN
:
978 state
->handler
= element6
;
979 return XML_ROLE_GROUP_OPEN
;
981 case XML_TOK_PREFIXED_NAME
:
982 state
->handler
= element7
;
983 return XML_ROLE_CONTENT_ELEMENT
;
984 case XML_TOK_NAME_QUESTION
:
985 state
->handler
= element7
;
986 return XML_ROLE_CONTENT_ELEMENT_OPT
;
987 case XML_TOK_NAME_ASTERISK
:
988 state
->handler
= element7
;
989 return XML_ROLE_CONTENT_ELEMENT_REP
;
990 case XML_TOK_NAME_PLUS
:
991 state
->handler
= element7
;
992 return XML_ROLE_CONTENT_ELEMENT_PLUS
;
994 return common(state
, tok
);
998 int element3(PROLOG_STATE
*state
,
1002 const ENCODING
*enc
)
1005 case XML_TOK_PROLOG_S
:
1006 return XML_ROLE_NONE
;
1007 case XML_TOK_CLOSE_PAREN
:
1008 case XML_TOK_CLOSE_PAREN_ASTERISK
:
1009 state
->handler
= declClose
;
1010 return XML_ROLE_GROUP_CLOSE_REP
;
1012 state
->handler
= element4
;
1013 return XML_ROLE_NONE
;
1015 return common(state
, tok
);
1019 int element4(PROLOG_STATE
*state
,
1023 const ENCODING
*enc
)
1026 case XML_TOK_PROLOG_S
:
1027 return XML_ROLE_NONE
;
1029 case XML_TOK_PREFIXED_NAME
:
1030 state
->handler
= element5
;
1031 return XML_ROLE_CONTENT_ELEMENT
;
1033 return common(state
, tok
);
1037 int element5(PROLOG_STATE
*state
,
1041 const ENCODING
*enc
)
1044 case XML_TOK_PROLOG_S
:
1045 return XML_ROLE_NONE
;
1046 case XML_TOK_CLOSE_PAREN_ASTERISK
:
1047 state
->handler
= declClose
;
1048 return XML_ROLE_GROUP_CLOSE_REP
;
1050 state
->handler
= element4
;
1051 return XML_ROLE_NONE
;
1053 return common(state
, tok
);
1057 int element6(PROLOG_STATE
*state
,
1061 const ENCODING
*enc
)
1064 case XML_TOK_PROLOG_S
:
1065 return XML_ROLE_NONE
;
1066 case XML_TOK_OPEN_PAREN
:
1068 return XML_ROLE_GROUP_OPEN
;
1070 case XML_TOK_PREFIXED_NAME
:
1071 state
->handler
= element7
;
1072 return XML_ROLE_CONTENT_ELEMENT
;
1073 case XML_TOK_NAME_QUESTION
:
1074 state
->handler
= element7
;
1075 return XML_ROLE_CONTENT_ELEMENT_OPT
;
1076 case XML_TOK_NAME_ASTERISK
:
1077 state
->handler
= element7
;
1078 return XML_ROLE_CONTENT_ELEMENT_REP
;
1079 case XML_TOK_NAME_PLUS
:
1080 state
->handler
= element7
;
1081 return XML_ROLE_CONTENT_ELEMENT_PLUS
;
1083 return common(state
, tok
);
1087 int element7(PROLOG_STATE
*state
,
1091 const ENCODING
*enc
)
1094 case XML_TOK_PROLOG_S
:
1095 return XML_ROLE_NONE
;
1096 case XML_TOK_CLOSE_PAREN
:
1098 if (state
->level
== 0)
1099 state
->handler
= declClose
;
1100 return XML_ROLE_GROUP_CLOSE
;
1101 case XML_TOK_CLOSE_PAREN_ASTERISK
:
1103 if (state
->level
== 0)
1104 state
->handler
= declClose
;
1105 return XML_ROLE_GROUP_CLOSE_REP
;
1106 case XML_TOK_CLOSE_PAREN_QUESTION
:
1108 if (state
->level
== 0)
1109 state
->handler
= declClose
;
1110 return XML_ROLE_GROUP_CLOSE_OPT
;
1111 case XML_TOK_CLOSE_PAREN_PLUS
:
1113 if (state
->level
== 0)
1114 state
->handler
= declClose
;
1115 return XML_ROLE_GROUP_CLOSE_PLUS
;
1117 state
->handler
= element6
;
1118 return XML_ROLE_GROUP_SEQUENCE
;
1120 state
->handler
= element6
;
1121 return XML_ROLE_GROUP_CHOICE
;
1123 return common(state
, tok
);
1129 int condSect0(PROLOG_STATE
*state
,
1133 const ENCODING
*enc
)
1136 case XML_TOK_PROLOG_S
:
1137 return XML_ROLE_NONE
;
1139 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_INCLUDE
)) {
1140 state
->handler
= condSect1
;
1141 return XML_ROLE_NONE
;
1143 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_IGNORE
)) {
1144 state
->handler
= condSect2
;
1145 return XML_ROLE_NONE
;
1149 return common(state
, tok
);
1153 int condSect1(PROLOG_STATE
*state
,
1157 const ENCODING
*enc
)
1160 case XML_TOK_PROLOG_S
:
1161 return XML_ROLE_NONE
;
1162 case XML_TOK_OPEN_BRACKET
:
1163 state
->handler
= externalSubset1
;
1164 state
->includeLevel
+= 1;
1165 return XML_ROLE_NONE
;
1167 return common(state
, tok
);
1171 int condSect2(PROLOG_STATE
*state
,
1175 const ENCODING
*enc
)
1178 case XML_TOK_PROLOG_S
:
1179 return XML_ROLE_NONE
;
1180 case XML_TOK_OPEN_BRACKET
:
1181 state
->handler
= externalSubset1
;
1182 return XML_ROLE_IGNORE_SECT
;
1184 return common(state
, tok
);
1187 #endif /* XML_DTD */
1190 int declClose(PROLOG_STATE
*state
,
1194 const ENCODING
*enc
)
1197 case XML_TOK_PROLOG_S
:
1198 return XML_ROLE_NONE
;
1199 case XML_TOK_DECL_CLOSE
:
1201 return XML_ROLE_NONE
;
1203 return common(state
, tok
);
1209 int ignore(PROLOG_STATE
*state
,
1213 const ENCODING
*enc
)
1216 case XML_TOK_DECL_CLOSE
:
1217 state
->handler
= internalSubset
;
1220 return XML_ROLE_NONE
;
1222 return common(state
, tok
);
1227 int error(PROLOG_STATE
*state
,
1231 const ENCODING
*enc
)
1233 return XML_ROLE_NONE
;
1237 int common(PROLOG_STATE
*state
, int tok
)
1240 if (!state
->documentEntity
&& tok
== XML_TOK_PARAM_ENTITY_REF
)
1241 return XML_ROLE_INNER_PARAM_ENTITY_REF
;
1243 state
->handler
= error
;
1244 return XML_ROLE_ERROR
;
1247 void XmlPrologStateInit(PROLOG_STATE
*state
)
1249 state
->handler
= prolog0
;
1251 state
->documentEntity
= 1;
1252 state
->includeLevel
= 0;
1253 #endif /* XML_DTD */
1258 void XmlPrologStateInitExternalEntity(PROLOG_STATE
*state
)
1260 state
->handler
= externalSubset0
;
1261 state
->documentEntity
= 0;
1262 state
->includeLevel
= 0;
1265 #endif /* XML_DTD */