1 /* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
2 See the file COPYING for copying permission.
5 #ifdef COMPILED_FROM_DSP
7 #elif defined(MACOS_CLASSIC)
10 #include <expat_config.h>
11 #endif /* ndef COMPILED_FROM_DSP */
19 that ,| are not mixed in a model group
24 static const char KW_ANY
[] = {
25 ASCII_A
, ASCII_N
, ASCII_Y
, '\0' };
26 static const char KW_ATTLIST
[] = {
27 ASCII_A
, ASCII_T
, ASCII_T
, ASCII_L
, ASCII_I
, ASCII_S
, ASCII_T
, '\0' };
28 static const char KW_CDATA
[] = {
29 ASCII_C
, ASCII_D
, ASCII_A
, ASCII_T
, ASCII_A
, '\0' };
30 static const char KW_DOCTYPE
[] = {
31 ASCII_D
, ASCII_O
, ASCII_C
, ASCII_T
, ASCII_Y
, ASCII_P
, ASCII_E
, '\0' };
32 static const char KW_ELEMENT
[] = {
33 ASCII_E
, ASCII_L
, ASCII_E
, ASCII_M
, ASCII_E
, ASCII_N
, ASCII_T
, '\0' };
34 static const char KW_EMPTY
[] = {
35 ASCII_E
, ASCII_M
, ASCII_P
, ASCII_T
, ASCII_Y
, '\0' };
36 static const char KW_ENTITIES
[] = {
37 ASCII_E
, ASCII_N
, ASCII_T
, ASCII_I
, ASCII_T
, ASCII_I
, ASCII_E
, ASCII_S
,
39 static const char KW_ENTITY
[] = {
40 ASCII_E
, ASCII_N
, ASCII_T
, ASCII_I
, ASCII_T
, ASCII_Y
, '\0' };
41 static const char KW_FIXED
[] = {
42 ASCII_F
, ASCII_I
, ASCII_X
, ASCII_E
, ASCII_D
, '\0' };
43 static const char KW_ID
[] = {
44 ASCII_I
, ASCII_D
, '\0' };
45 static const char KW_IDREF
[] = {
46 ASCII_I
, ASCII_D
, ASCII_R
, ASCII_E
, ASCII_F
, '\0' };
47 static const char KW_IDREFS
[] = {
48 ASCII_I
, ASCII_D
, ASCII_R
, ASCII_E
, ASCII_F
, ASCII_S
, '\0' };
49 static const char KW_IGNORE
[] = {
50 ASCII_I
, ASCII_G
, ASCII_N
, ASCII_O
, ASCII_R
, ASCII_E
, '\0' };
51 static const char KW_IMPLIED
[] = {
52 ASCII_I
, ASCII_M
, ASCII_P
, ASCII_L
, ASCII_I
, ASCII_E
, ASCII_D
, '\0' };
53 static const char KW_INCLUDE
[] = {
54 ASCII_I
, ASCII_N
, ASCII_C
, ASCII_L
, ASCII_U
, ASCII_D
, ASCII_E
, '\0' };
55 static const char KW_NDATA
[] = {
56 ASCII_N
, ASCII_D
, ASCII_A
, ASCII_T
, ASCII_A
, '\0' };
57 static const char KW_NMTOKEN
[] = {
58 ASCII_N
, ASCII_M
, ASCII_T
, ASCII_O
, ASCII_K
, ASCII_E
, ASCII_N
, '\0' };
59 static const char KW_NMTOKENS
[] = {
60 ASCII_N
, ASCII_M
, ASCII_T
, ASCII_O
, ASCII_K
, ASCII_E
, ASCII_N
, ASCII_S
,
62 static const char KW_NOTATION
[] =
63 { ASCII_N
, ASCII_O
, ASCII_T
, ASCII_A
, ASCII_T
, ASCII_I
, ASCII_O
, ASCII_N
,
65 static const char KW_PCDATA
[] = {
66 ASCII_P
, ASCII_C
, ASCII_D
, ASCII_A
, ASCII_T
, ASCII_A
, '\0' };
67 static const char KW_PUBLIC
[] = {
68 ASCII_P
, ASCII_U
, ASCII_B
, ASCII_L
, ASCII_I
, ASCII_C
, '\0' };
69 static const char KW_REQUIRED
[] = {
70 ASCII_R
, ASCII_E
, ASCII_Q
, ASCII_U
, ASCII_I
, ASCII_R
, ASCII_E
, ASCII_D
,
72 static const char KW_SYSTEM
[] = {
73 ASCII_S
, ASCII_Y
, ASCII_S
, ASCII_T
, ASCII_E
, ASCII_M
, '\0' };
75 #ifndef MIN_BYTES_PER_CHAR
76 #define MIN_BYTES_PER_CHAR(enc) ((enc)->minBytesPerChar)
80 #define setTopLevel(state) \
81 ((state)->handler = ((state)->documentEntity \
84 #else /* not XML_DTD */
85 #define setTopLevel(state) ((state)->handler = internalSubset)
86 #endif /* not XML_DTD */
88 typedef int PTRCALL
PROLOG_HANDLER(PROLOG_STATE
*state
,
95 prolog0
, prolog1
, prolog2
,
96 doctype0
, doctype1
, doctype2
, doctype3
, doctype4
, doctype5
,
98 entity0
, entity1
, entity2
, entity3
, entity4
, entity5
, entity6
,
99 entity7
, entity8
, entity9
, entity10
,
100 notation0
, notation1
, notation2
, notation3
, notation4
,
101 attlist0
, attlist1
, attlist2
, attlist3
, attlist4
, attlist5
, attlist6
,
102 attlist7
, attlist8
, attlist9
,
103 element0
, element1
, element2
, element3
, element4
, element5
, element6
,
106 externalSubset0
, externalSubset1
,
107 condSect0
, condSect1
, condSect2
,
112 static int FASTCALL
common(PROLOG_STATE
*state
, int tok
);
115 prolog0(PROLOG_STATE
*state
,
122 case XML_TOK_PROLOG_S
:
123 state
->handler
= prolog1
;
124 return XML_ROLE_NONE
;
125 case XML_TOK_XML_DECL
:
126 state
->handler
= prolog1
;
127 return XML_ROLE_XML_DECL
;
129 state
->handler
= prolog1
;
131 case XML_TOK_COMMENT
:
132 state
->handler
= prolog1
;
133 return XML_ROLE_COMMENT
;
135 return XML_ROLE_NONE
;
136 case XML_TOK_DECL_OPEN
:
137 if (!XmlNameMatchesAscii(enc
,
138 ptr
+ 2 * MIN_BYTES_PER_CHAR(enc
),
142 state
->handler
= doctype0
;
143 return XML_ROLE_DOCTYPE_NONE
;
144 case XML_TOK_INSTANCE_START
:
145 state
->handler
= error
;
146 return XML_ROLE_INSTANCE_START
;
148 return common(state
, tok
);
152 prolog1(PROLOG_STATE
*state
,
159 case XML_TOK_PROLOG_S
:
160 return XML_ROLE_NONE
;
163 case XML_TOK_COMMENT
:
164 return XML_ROLE_COMMENT
;
166 return XML_ROLE_NONE
;
167 case XML_TOK_DECL_OPEN
:
168 if (!XmlNameMatchesAscii(enc
,
169 ptr
+ 2 * MIN_BYTES_PER_CHAR(enc
),
173 state
->handler
= doctype0
;
174 return XML_ROLE_DOCTYPE_NONE
;
175 case XML_TOK_INSTANCE_START
:
176 state
->handler
= error
;
177 return XML_ROLE_INSTANCE_START
;
179 return common(state
, tok
);
183 prolog2(PROLOG_STATE
*state
,
190 case XML_TOK_PROLOG_S
:
191 return XML_ROLE_NONE
;
194 case XML_TOK_COMMENT
:
195 return XML_ROLE_COMMENT
;
196 case XML_TOK_INSTANCE_START
:
197 state
->handler
= error
;
198 return XML_ROLE_INSTANCE_START
;
200 return common(state
, tok
);
204 doctype0(PROLOG_STATE
*state
,
211 case XML_TOK_PROLOG_S
:
212 return XML_ROLE_DOCTYPE_NONE
;
214 case XML_TOK_PREFIXED_NAME
:
215 state
->handler
= doctype1
;
216 return XML_ROLE_DOCTYPE_NAME
;
218 return common(state
, tok
);
222 doctype1(PROLOG_STATE
*state
,
229 case XML_TOK_PROLOG_S
:
230 return XML_ROLE_DOCTYPE_NONE
;
231 case XML_TOK_OPEN_BRACKET
:
232 state
->handler
= internalSubset
;
233 return XML_ROLE_DOCTYPE_INTERNAL_SUBSET
;
234 case XML_TOK_DECL_CLOSE
:
235 state
->handler
= prolog2
;
236 return XML_ROLE_DOCTYPE_CLOSE
;
238 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_SYSTEM
)) {
239 state
->handler
= doctype3
;
240 return XML_ROLE_DOCTYPE_NONE
;
242 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_PUBLIC
)) {
243 state
->handler
= doctype2
;
244 return XML_ROLE_DOCTYPE_NONE
;
248 return common(state
, tok
);
252 doctype2(PROLOG_STATE
*state
,
259 case XML_TOK_PROLOG_S
:
260 return XML_ROLE_DOCTYPE_NONE
;
261 case XML_TOK_LITERAL
:
262 state
->handler
= doctype3
;
263 return XML_ROLE_DOCTYPE_PUBLIC_ID
;
265 return common(state
, tok
);
269 doctype3(PROLOG_STATE
*state
,
276 case XML_TOK_PROLOG_S
:
277 return XML_ROLE_DOCTYPE_NONE
;
278 case XML_TOK_LITERAL
:
279 state
->handler
= doctype4
;
280 return XML_ROLE_DOCTYPE_SYSTEM_ID
;
282 return common(state
, tok
);
286 doctype4(PROLOG_STATE
*state
,
293 case XML_TOK_PROLOG_S
:
294 return XML_ROLE_DOCTYPE_NONE
;
295 case XML_TOK_OPEN_BRACKET
:
296 state
->handler
= internalSubset
;
297 return XML_ROLE_DOCTYPE_INTERNAL_SUBSET
;
298 case XML_TOK_DECL_CLOSE
:
299 state
->handler
= prolog2
;
300 return XML_ROLE_DOCTYPE_CLOSE
;
302 return common(state
, tok
);
306 doctype5(PROLOG_STATE
*state
,
313 case XML_TOK_PROLOG_S
:
314 return XML_ROLE_DOCTYPE_NONE
;
315 case XML_TOK_DECL_CLOSE
:
316 state
->handler
= prolog2
;
317 return XML_ROLE_DOCTYPE_CLOSE
;
319 return common(state
, tok
);
323 internalSubset(PROLOG_STATE
*state
,
330 case XML_TOK_PROLOG_S
:
331 return XML_ROLE_NONE
;
332 case XML_TOK_DECL_OPEN
:
333 if (XmlNameMatchesAscii(enc
,
334 ptr
+ 2 * MIN_BYTES_PER_CHAR(enc
),
337 state
->handler
= entity0
;
338 return XML_ROLE_ENTITY_NONE
;
340 if (XmlNameMatchesAscii(enc
,
341 ptr
+ 2 * MIN_BYTES_PER_CHAR(enc
),
344 state
->handler
= attlist0
;
345 return XML_ROLE_ATTLIST_NONE
;
347 if (XmlNameMatchesAscii(enc
,
348 ptr
+ 2 * MIN_BYTES_PER_CHAR(enc
),
351 state
->handler
= element0
;
352 return XML_ROLE_ELEMENT_NONE
;
354 if (XmlNameMatchesAscii(enc
,
355 ptr
+ 2 * MIN_BYTES_PER_CHAR(enc
),
358 state
->handler
= notation0
;
359 return XML_ROLE_NOTATION_NONE
;
364 case XML_TOK_COMMENT
:
365 return XML_ROLE_COMMENT
;
366 case XML_TOK_PARAM_ENTITY_REF
:
367 return XML_ROLE_PARAM_ENTITY_REF
;
368 case XML_TOK_CLOSE_BRACKET
:
369 state
->handler
= doctype5
;
370 return XML_ROLE_DOCTYPE_NONE
;
372 return common(state
, tok
);
378 externalSubset0(PROLOG_STATE
*state
,
384 state
->handler
= externalSubset1
;
385 if (tok
== XML_TOK_XML_DECL
)
386 return XML_ROLE_TEXT_DECL
;
387 return externalSubset1(state
, tok
, ptr
, end
, enc
);
391 externalSubset1(PROLOG_STATE
*state
,
398 case XML_TOK_COND_SECT_OPEN
:
399 state
->handler
= condSect0
;
400 return XML_ROLE_NONE
;
401 case XML_TOK_COND_SECT_CLOSE
:
402 if (state
->includeLevel
== 0)
404 state
->includeLevel
-= 1;
405 return XML_ROLE_NONE
;
406 case XML_TOK_PROLOG_S
:
407 return XML_ROLE_NONE
;
408 case XML_TOK_CLOSE_BRACKET
:
411 if (state
->includeLevel
)
413 return XML_ROLE_NONE
;
415 return internalSubset(state
, tok
, ptr
, end
, enc
);
417 return common(state
, tok
);
423 entity0(PROLOG_STATE
*state
,
430 case XML_TOK_PROLOG_S
:
431 return XML_ROLE_ENTITY_NONE
;
432 case XML_TOK_PERCENT
:
433 state
->handler
= entity1
;
434 return XML_ROLE_ENTITY_NONE
;
436 state
->handler
= entity2
;
437 return XML_ROLE_GENERAL_ENTITY_NAME
;
439 return common(state
, tok
);
443 entity1(PROLOG_STATE
*state
,
450 case XML_TOK_PROLOG_S
:
451 return XML_ROLE_ENTITY_NONE
;
453 state
->handler
= entity7
;
454 return XML_ROLE_PARAM_ENTITY_NAME
;
456 return common(state
, tok
);
460 entity2(PROLOG_STATE
*state
,
467 case XML_TOK_PROLOG_S
:
468 return XML_ROLE_ENTITY_NONE
;
470 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_SYSTEM
)) {
471 state
->handler
= entity4
;
472 return XML_ROLE_ENTITY_NONE
;
474 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_PUBLIC
)) {
475 state
->handler
= entity3
;
476 return XML_ROLE_ENTITY_NONE
;
479 case XML_TOK_LITERAL
:
480 state
->handler
= declClose
;
481 state
->role_none
= XML_ROLE_ENTITY_NONE
;
482 return XML_ROLE_ENTITY_VALUE
;
484 return common(state
, tok
);
488 entity3(PROLOG_STATE
*state
,
495 case XML_TOK_PROLOG_S
:
496 return XML_ROLE_ENTITY_NONE
;
497 case XML_TOK_LITERAL
:
498 state
->handler
= entity4
;
499 return XML_ROLE_ENTITY_PUBLIC_ID
;
501 return common(state
, tok
);
505 entity4(PROLOG_STATE
*state
,
512 case XML_TOK_PROLOG_S
:
513 return XML_ROLE_ENTITY_NONE
;
514 case XML_TOK_LITERAL
:
515 state
->handler
= entity5
;
516 return XML_ROLE_ENTITY_SYSTEM_ID
;
518 return common(state
, tok
);
522 entity5(PROLOG_STATE
*state
,
529 case XML_TOK_PROLOG_S
:
530 return XML_ROLE_ENTITY_NONE
;
531 case XML_TOK_DECL_CLOSE
:
533 return XML_ROLE_ENTITY_COMPLETE
;
535 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_NDATA
)) {
536 state
->handler
= entity6
;
537 return XML_ROLE_ENTITY_NONE
;
541 return common(state
, tok
);
545 entity6(PROLOG_STATE
*state
,
552 case XML_TOK_PROLOG_S
:
553 return XML_ROLE_ENTITY_NONE
;
555 state
->handler
= declClose
;
556 state
->role_none
= XML_ROLE_ENTITY_NONE
;
557 return XML_ROLE_ENTITY_NOTATION_NAME
;
559 return common(state
, tok
);
563 entity7(PROLOG_STATE
*state
,
570 case XML_TOK_PROLOG_S
:
571 return XML_ROLE_ENTITY_NONE
;
573 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_SYSTEM
)) {
574 state
->handler
= entity9
;
575 return XML_ROLE_ENTITY_NONE
;
577 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_PUBLIC
)) {
578 state
->handler
= entity8
;
579 return XML_ROLE_ENTITY_NONE
;
582 case XML_TOK_LITERAL
:
583 state
->handler
= declClose
;
584 state
->role_none
= XML_ROLE_ENTITY_NONE
;
585 return XML_ROLE_ENTITY_VALUE
;
587 return common(state
, tok
);
591 entity8(PROLOG_STATE
*state
,
598 case XML_TOK_PROLOG_S
:
599 return XML_ROLE_ENTITY_NONE
;
600 case XML_TOK_LITERAL
:
601 state
->handler
= entity9
;
602 return XML_ROLE_ENTITY_PUBLIC_ID
;
604 return common(state
, tok
);
608 entity9(PROLOG_STATE
*state
,
615 case XML_TOK_PROLOG_S
:
616 return XML_ROLE_ENTITY_NONE
;
617 case XML_TOK_LITERAL
:
618 state
->handler
= entity10
;
619 return XML_ROLE_ENTITY_SYSTEM_ID
;
621 return common(state
, tok
);
625 entity10(PROLOG_STATE
*state
,
632 case XML_TOK_PROLOG_S
:
633 return XML_ROLE_ENTITY_NONE
;
634 case XML_TOK_DECL_CLOSE
:
636 return XML_ROLE_ENTITY_COMPLETE
;
638 return common(state
, tok
);
642 notation0(PROLOG_STATE
*state
,
649 case XML_TOK_PROLOG_S
:
650 return XML_ROLE_NOTATION_NONE
;
652 state
->handler
= notation1
;
653 return XML_ROLE_NOTATION_NAME
;
655 return common(state
, tok
);
659 notation1(PROLOG_STATE
*state
,
666 case XML_TOK_PROLOG_S
:
667 return XML_ROLE_NOTATION_NONE
;
669 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_SYSTEM
)) {
670 state
->handler
= notation3
;
671 return XML_ROLE_NOTATION_NONE
;
673 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_PUBLIC
)) {
674 state
->handler
= notation2
;
675 return XML_ROLE_NOTATION_NONE
;
679 return common(state
, tok
);
683 notation2(PROLOG_STATE
*state
,
690 case XML_TOK_PROLOG_S
:
691 return XML_ROLE_NOTATION_NONE
;
692 case XML_TOK_LITERAL
:
693 state
->handler
= notation4
;
694 return XML_ROLE_NOTATION_PUBLIC_ID
;
696 return common(state
, tok
);
700 notation3(PROLOG_STATE
*state
,
707 case XML_TOK_PROLOG_S
:
708 return XML_ROLE_NOTATION_NONE
;
709 case XML_TOK_LITERAL
:
710 state
->handler
= declClose
;
711 state
->role_none
= XML_ROLE_NOTATION_NONE
;
712 return XML_ROLE_NOTATION_SYSTEM_ID
;
714 return common(state
, tok
);
718 notation4(PROLOG_STATE
*state
,
725 case XML_TOK_PROLOG_S
:
726 return XML_ROLE_NOTATION_NONE
;
727 case XML_TOK_LITERAL
:
728 state
->handler
= declClose
;
729 state
->role_none
= XML_ROLE_NOTATION_NONE
;
730 return XML_ROLE_NOTATION_SYSTEM_ID
;
731 case XML_TOK_DECL_CLOSE
:
733 return XML_ROLE_NOTATION_NO_SYSTEM_ID
;
735 return common(state
, tok
);
739 attlist0(PROLOG_STATE
*state
,
746 case XML_TOK_PROLOG_S
:
747 return XML_ROLE_ATTLIST_NONE
;
749 case XML_TOK_PREFIXED_NAME
:
750 state
->handler
= attlist1
;
751 return XML_ROLE_ATTLIST_ELEMENT_NAME
;
753 return common(state
, tok
);
757 attlist1(PROLOG_STATE
*state
,
764 case XML_TOK_PROLOG_S
:
765 return XML_ROLE_ATTLIST_NONE
;
766 case XML_TOK_DECL_CLOSE
:
768 return XML_ROLE_ATTLIST_NONE
;
770 case XML_TOK_PREFIXED_NAME
:
771 state
->handler
= attlist2
;
772 return XML_ROLE_ATTRIBUTE_NAME
;
774 return common(state
, tok
);
778 attlist2(PROLOG_STATE
*state
,
785 case XML_TOK_PROLOG_S
:
786 return XML_ROLE_ATTLIST_NONE
;
789 static const char *types
[] = {
800 for (i
= 0; i
< (int)(sizeof(types
)/sizeof(types
[0])); i
++)
801 if (XmlNameMatchesAscii(enc
, ptr
, end
, types
[i
])) {
802 state
->handler
= attlist8
;
803 return XML_ROLE_ATTRIBUTE_TYPE_CDATA
+ i
;
806 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_NOTATION
)) {
807 state
->handler
= attlist5
;
808 return XML_ROLE_ATTLIST_NONE
;
811 case XML_TOK_OPEN_PAREN
:
812 state
->handler
= attlist3
;
813 return XML_ROLE_ATTLIST_NONE
;
815 return common(state
, tok
);
819 attlist3(PROLOG_STATE
*state
,
826 case XML_TOK_PROLOG_S
:
827 return XML_ROLE_ATTLIST_NONE
;
828 case XML_TOK_NMTOKEN
:
830 case XML_TOK_PREFIXED_NAME
:
831 state
->handler
= attlist4
;
832 return XML_ROLE_ATTRIBUTE_ENUM_VALUE
;
834 return common(state
, tok
);
838 attlist4(PROLOG_STATE
*state
,
845 case XML_TOK_PROLOG_S
:
846 return XML_ROLE_ATTLIST_NONE
;
847 case XML_TOK_CLOSE_PAREN
:
848 state
->handler
= attlist8
;
849 return XML_ROLE_ATTLIST_NONE
;
851 state
->handler
= attlist3
;
852 return XML_ROLE_ATTLIST_NONE
;
854 return common(state
, tok
);
858 attlist5(PROLOG_STATE
*state
,
865 case XML_TOK_PROLOG_S
:
866 return XML_ROLE_ATTLIST_NONE
;
867 case XML_TOK_OPEN_PAREN
:
868 state
->handler
= attlist6
;
869 return XML_ROLE_ATTLIST_NONE
;
871 return common(state
, tok
);
875 attlist6(PROLOG_STATE
*state
,
882 case XML_TOK_PROLOG_S
:
883 return XML_ROLE_ATTLIST_NONE
;
885 state
->handler
= attlist7
;
886 return XML_ROLE_ATTRIBUTE_NOTATION_VALUE
;
888 return common(state
, tok
);
892 attlist7(PROLOG_STATE
*state
,
899 case XML_TOK_PROLOG_S
:
900 return XML_ROLE_ATTLIST_NONE
;
901 case XML_TOK_CLOSE_PAREN
:
902 state
->handler
= attlist8
;
903 return XML_ROLE_ATTLIST_NONE
;
905 state
->handler
= attlist6
;
906 return XML_ROLE_ATTLIST_NONE
;
908 return common(state
, tok
);
913 attlist8(PROLOG_STATE
*state
,
920 case XML_TOK_PROLOG_S
:
921 return XML_ROLE_ATTLIST_NONE
;
922 case XML_TOK_POUND_NAME
:
923 if (XmlNameMatchesAscii(enc
,
924 ptr
+ MIN_BYTES_PER_CHAR(enc
),
927 state
->handler
= attlist1
;
928 return XML_ROLE_IMPLIED_ATTRIBUTE_VALUE
;
930 if (XmlNameMatchesAscii(enc
,
931 ptr
+ MIN_BYTES_PER_CHAR(enc
),
934 state
->handler
= attlist1
;
935 return XML_ROLE_REQUIRED_ATTRIBUTE_VALUE
;
937 if (XmlNameMatchesAscii(enc
,
938 ptr
+ MIN_BYTES_PER_CHAR(enc
),
941 state
->handler
= attlist9
;
942 return XML_ROLE_ATTLIST_NONE
;
945 case XML_TOK_LITERAL
:
946 state
->handler
= attlist1
;
947 return XML_ROLE_DEFAULT_ATTRIBUTE_VALUE
;
949 return common(state
, tok
);
953 attlist9(PROLOG_STATE
*state
,
960 case XML_TOK_PROLOG_S
:
961 return XML_ROLE_ATTLIST_NONE
;
962 case XML_TOK_LITERAL
:
963 state
->handler
= attlist1
;
964 return XML_ROLE_FIXED_ATTRIBUTE_VALUE
;
966 return common(state
, tok
);
970 element0(PROLOG_STATE
*state
,
977 case XML_TOK_PROLOG_S
:
978 return XML_ROLE_ELEMENT_NONE
;
980 case XML_TOK_PREFIXED_NAME
:
981 state
->handler
= element1
;
982 return XML_ROLE_ELEMENT_NAME
;
984 return common(state
, tok
);
988 element1(PROLOG_STATE
*state
,
995 case XML_TOK_PROLOG_S
:
996 return XML_ROLE_ELEMENT_NONE
;
998 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_EMPTY
)) {
999 state
->handler
= declClose
;
1000 state
->role_none
= XML_ROLE_ELEMENT_NONE
;
1001 return XML_ROLE_CONTENT_EMPTY
;
1003 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_ANY
)) {
1004 state
->handler
= declClose
;
1005 state
->role_none
= XML_ROLE_ELEMENT_NONE
;
1006 return XML_ROLE_CONTENT_ANY
;
1009 case XML_TOK_OPEN_PAREN
:
1010 state
->handler
= element2
;
1012 return XML_ROLE_GROUP_OPEN
;
1014 return common(state
, tok
);
1018 element2(PROLOG_STATE
*state
,
1022 const ENCODING
*enc
)
1025 case XML_TOK_PROLOG_S
:
1026 return XML_ROLE_ELEMENT_NONE
;
1027 case XML_TOK_POUND_NAME
:
1028 if (XmlNameMatchesAscii(enc
,
1029 ptr
+ MIN_BYTES_PER_CHAR(enc
),
1032 state
->handler
= element3
;
1033 return XML_ROLE_CONTENT_PCDATA
;
1036 case XML_TOK_OPEN_PAREN
:
1038 state
->handler
= element6
;
1039 return XML_ROLE_GROUP_OPEN
;
1041 case XML_TOK_PREFIXED_NAME
:
1042 state
->handler
= element7
;
1043 return XML_ROLE_CONTENT_ELEMENT
;
1044 case XML_TOK_NAME_QUESTION
:
1045 state
->handler
= element7
;
1046 return XML_ROLE_CONTENT_ELEMENT_OPT
;
1047 case XML_TOK_NAME_ASTERISK
:
1048 state
->handler
= element7
;
1049 return XML_ROLE_CONTENT_ELEMENT_REP
;
1050 case XML_TOK_NAME_PLUS
:
1051 state
->handler
= element7
;
1052 return XML_ROLE_CONTENT_ELEMENT_PLUS
;
1054 return common(state
, tok
);
1058 element3(PROLOG_STATE
*state
,
1062 const ENCODING
*enc
)
1065 case XML_TOK_PROLOG_S
:
1066 return XML_ROLE_ELEMENT_NONE
;
1067 case XML_TOK_CLOSE_PAREN
:
1068 state
->handler
= declClose
;
1069 state
->role_none
= XML_ROLE_ELEMENT_NONE
;
1070 return XML_ROLE_GROUP_CLOSE
;
1071 case XML_TOK_CLOSE_PAREN_ASTERISK
:
1072 state
->handler
= declClose
;
1073 state
->role_none
= XML_ROLE_ELEMENT_NONE
;
1074 return XML_ROLE_GROUP_CLOSE_REP
;
1076 state
->handler
= element4
;
1077 return XML_ROLE_ELEMENT_NONE
;
1079 return common(state
, tok
);
1083 element4(PROLOG_STATE
*state
,
1087 const ENCODING
*enc
)
1090 case XML_TOK_PROLOG_S
:
1091 return XML_ROLE_ELEMENT_NONE
;
1093 case XML_TOK_PREFIXED_NAME
:
1094 state
->handler
= element5
;
1095 return XML_ROLE_CONTENT_ELEMENT
;
1097 return common(state
, tok
);
1101 element5(PROLOG_STATE
*state
,
1105 const ENCODING
*enc
)
1108 case XML_TOK_PROLOG_S
:
1109 return XML_ROLE_ELEMENT_NONE
;
1110 case XML_TOK_CLOSE_PAREN_ASTERISK
:
1111 state
->handler
= declClose
;
1112 state
->role_none
= XML_ROLE_ELEMENT_NONE
;
1113 return XML_ROLE_GROUP_CLOSE_REP
;
1115 state
->handler
= element4
;
1116 return XML_ROLE_ELEMENT_NONE
;
1118 return common(state
, tok
);
1122 element6(PROLOG_STATE
*state
,
1126 const ENCODING
*enc
)
1129 case XML_TOK_PROLOG_S
:
1130 return XML_ROLE_ELEMENT_NONE
;
1131 case XML_TOK_OPEN_PAREN
:
1133 return XML_ROLE_GROUP_OPEN
;
1135 case XML_TOK_PREFIXED_NAME
:
1136 state
->handler
= element7
;
1137 return XML_ROLE_CONTENT_ELEMENT
;
1138 case XML_TOK_NAME_QUESTION
:
1139 state
->handler
= element7
;
1140 return XML_ROLE_CONTENT_ELEMENT_OPT
;
1141 case XML_TOK_NAME_ASTERISK
:
1142 state
->handler
= element7
;
1143 return XML_ROLE_CONTENT_ELEMENT_REP
;
1144 case XML_TOK_NAME_PLUS
:
1145 state
->handler
= element7
;
1146 return XML_ROLE_CONTENT_ELEMENT_PLUS
;
1148 return common(state
, tok
);
1152 element7(PROLOG_STATE
*state
,
1156 const ENCODING
*enc
)
1159 case XML_TOK_PROLOG_S
:
1160 return XML_ROLE_ELEMENT_NONE
;
1161 case XML_TOK_CLOSE_PAREN
:
1163 if (state
->level
== 0) {
1164 state
->handler
= declClose
;
1165 state
->role_none
= XML_ROLE_ELEMENT_NONE
;
1167 return XML_ROLE_GROUP_CLOSE
;
1168 case XML_TOK_CLOSE_PAREN_ASTERISK
:
1170 if (state
->level
== 0) {
1171 state
->handler
= declClose
;
1172 state
->role_none
= XML_ROLE_ELEMENT_NONE
;
1174 return XML_ROLE_GROUP_CLOSE_REP
;
1175 case XML_TOK_CLOSE_PAREN_QUESTION
:
1177 if (state
->level
== 0) {
1178 state
->handler
= declClose
;
1179 state
->role_none
= XML_ROLE_ELEMENT_NONE
;
1181 return XML_ROLE_GROUP_CLOSE_OPT
;
1182 case XML_TOK_CLOSE_PAREN_PLUS
:
1184 if (state
->level
== 0) {
1185 state
->handler
= declClose
;
1186 state
->role_none
= XML_ROLE_ELEMENT_NONE
;
1188 return XML_ROLE_GROUP_CLOSE_PLUS
;
1190 state
->handler
= element6
;
1191 return XML_ROLE_GROUP_SEQUENCE
;
1193 state
->handler
= element6
;
1194 return XML_ROLE_GROUP_CHOICE
;
1196 return common(state
, tok
);
1202 condSect0(PROLOG_STATE
*state
,
1206 const ENCODING
*enc
)
1209 case XML_TOK_PROLOG_S
:
1210 return XML_ROLE_NONE
;
1212 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_INCLUDE
)) {
1213 state
->handler
= condSect1
;
1214 return XML_ROLE_NONE
;
1216 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_IGNORE
)) {
1217 state
->handler
= condSect2
;
1218 return XML_ROLE_NONE
;
1222 return common(state
, tok
);
1226 condSect1(PROLOG_STATE
*state
,
1230 const ENCODING
*enc
)
1233 case XML_TOK_PROLOG_S
:
1234 return XML_ROLE_NONE
;
1235 case XML_TOK_OPEN_BRACKET
:
1236 state
->handler
= externalSubset1
;
1237 state
->includeLevel
+= 1;
1238 return XML_ROLE_NONE
;
1240 return common(state
, tok
);
1244 condSect2(PROLOG_STATE
*state
,
1248 const ENCODING
*enc
)
1251 case XML_TOK_PROLOG_S
:
1252 return XML_ROLE_NONE
;
1253 case XML_TOK_OPEN_BRACKET
:
1254 state
->handler
= externalSubset1
;
1255 return XML_ROLE_IGNORE_SECT
;
1257 return common(state
, tok
);
1260 #endif /* XML_DTD */
1263 declClose(PROLOG_STATE
*state
,
1267 const ENCODING
*enc
)
1270 case XML_TOK_PROLOG_S
:
1271 return state
->role_none
;
1272 case XML_TOK_DECL_CLOSE
:
1274 return state
->role_none
;
1276 return common(state
, tok
);
1280 error(PROLOG_STATE
*state
,
1284 const ENCODING
*enc
)
1286 return XML_ROLE_NONE
;
1290 common(PROLOG_STATE
*state
, int tok
)
1293 if (!state
->documentEntity
&& tok
== XML_TOK_PARAM_ENTITY_REF
)
1294 return XML_ROLE_INNER_PARAM_ENTITY_REF
;
1296 state
->handler
= error
;
1297 return XML_ROLE_ERROR
;
1301 XmlPrologStateInit(PROLOG_STATE
*state
)
1303 state
->handler
= prolog0
;
1305 state
->documentEntity
= 1;
1306 state
->includeLevel
= 0;
1307 state
->inEntityValue
= 0;
1308 #endif /* XML_DTD */
1314 XmlPrologStateInitExternalEntity(PROLOG_STATE
*state
)
1316 state
->handler
= externalSubset0
;
1317 state
->documentEntity
= 0;
1318 state
->includeLevel
= 0;
1321 #endif /* XML_DTD */