1 /* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
2 See the file COPYING for copying permission.
5 #ifdef COMPILED_FROM_DSP
9 #elif defined(MACOS_CLASSIC)
10 #include "macconfig.h"
12 #include "expat_config.h"
13 #endif /* ndef COMPILED_FROM_DSP */
21 that ,| are not mixed in a model group
26 static const char KW_ANY
[] = {
27 ASCII_A
, ASCII_N
, ASCII_Y
, '\0' };
28 static const char KW_ATTLIST
[] = {
29 ASCII_A
, ASCII_T
, ASCII_T
, ASCII_L
, ASCII_I
, ASCII_S
, ASCII_T
, '\0' };
30 static const char KW_CDATA
[] = {
31 ASCII_C
, ASCII_D
, ASCII_A
, ASCII_T
, ASCII_A
, '\0' };
32 static const char KW_DOCTYPE
[] = {
33 ASCII_D
, ASCII_O
, ASCII_C
, ASCII_T
, ASCII_Y
, ASCII_P
, ASCII_E
, '\0' };
34 static const char KW_ELEMENT
[] = {
35 ASCII_E
, ASCII_L
, ASCII_E
, ASCII_M
, ASCII_E
, ASCII_N
, ASCII_T
, '\0' };
36 static const char KW_EMPTY
[] = {
37 ASCII_E
, ASCII_M
, ASCII_P
, ASCII_T
, ASCII_Y
, '\0' };
38 static const char KW_ENTITIES
[] = {
39 ASCII_E
, ASCII_N
, ASCII_T
, ASCII_I
, ASCII_T
, ASCII_I
, ASCII_E
, ASCII_S
,
41 static const char KW_ENTITY
[] = {
42 ASCII_E
, ASCII_N
, ASCII_T
, ASCII_I
, ASCII_T
, ASCII_Y
, '\0' };
43 static const char KW_FIXED
[] = {
44 ASCII_F
, ASCII_I
, ASCII_X
, ASCII_E
, ASCII_D
, '\0' };
45 static const char KW_ID
[] = {
46 ASCII_I
, ASCII_D
, '\0' };
47 static const char KW_IDREF
[] = {
48 ASCII_I
, ASCII_D
, ASCII_R
, ASCII_E
, ASCII_F
, '\0' };
49 static const char KW_IDREFS
[] = {
50 ASCII_I
, ASCII_D
, ASCII_R
, ASCII_E
, ASCII_F
, ASCII_S
, '\0' };
51 static const char KW_IGNORE
[] = {
52 ASCII_I
, ASCII_G
, ASCII_N
, ASCII_O
, ASCII_R
, ASCII_E
, '\0' };
53 static const char KW_IMPLIED
[] = {
54 ASCII_I
, ASCII_M
, ASCII_P
, ASCII_L
, ASCII_I
, ASCII_E
, ASCII_D
, '\0' };
55 static const char KW_INCLUDE
[] = {
56 ASCII_I
, ASCII_N
, ASCII_C
, ASCII_L
, ASCII_U
, ASCII_D
, ASCII_E
, '\0' };
57 static const char KW_NDATA
[] = {
58 ASCII_N
, ASCII_D
, ASCII_A
, ASCII_T
, ASCII_A
, '\0' };
59 static const char KW_NMTOKEN
[] = {
60 ASCII_N
, ASCII_M
, ASCII_T
, ASCII_O
, ASCII_K
, ASCII_E
, ASCII_N
, '\0' };
61 static const char KW_NMTOKENS
[] = {
62 ASCII_N
, ASCII_M
, ASCII_T
, ASCII_O
, ASCII_K
, ASCII_E
, ASCII_N
, ASCII_S
,
64 static const char KW_NOTATION
[] =
65 { ASCII_N
, ASCII_O
, ASCII_T
, ASCII_A
, ASCII_T
, ASCII_I
, ASCII_O
, ASCII_N
,
67 static const char KW_PCDATA
[] = {
68 ASCII_P
, ASCII_C
, ASCII_D
, ASCII_A
, ASCII_T
, ASCII_A
, '\0' };
69 static const char KW_PUBLIC
[] = {
70 ASCII_P
, ASCII_U
, ASCII_B
, ASCII_L
, ASCII_I
, ASCII_C
, '\0' };
71 static const char KW_REQUIRED
[] = {
72 ASCII_R
, ASCII_E
, ASCII_Q
, ASCII_U
, ASCII_I
, ASCII_R
, ASCII_E
, ASCII_D
,
74 static const char KW_SYSTEM
[] = {
75 ASCII_S
, ASCII_Y
, ASCII_S
, ASCII_T
, ASCII_E
, ASCII_M
, '\0' };
77 #ifndef MIN_BYTES_PER_CHAR
78 #define MIN_BYTES_PER_CHAR(enc) ((enc)->minBytesPerChar)
82 #define setTopLevel(state) \
83 ((state)->handler = ((state)->documentEntity \
86 #else /* not XML_DTD */
87 #define setTopLevel(state) ((state)->handler = internalSubset)
88 #endif /* not XML_DTD */
90 typedef int PTRCALL
PROLOG_HANDLER(PROLOG_STATE
*state
,
97 prolog0
, prolog1
, prolog2
,
98 doctype0
, doctype1
, doctype2
, doctype3
, doctype4
, doctype5
,
100 entity0
, entity1
, entity2
, entity3
, entity4
, entity5
, entity6
,
101 entity7
, entity8
, entity9
, entity10
,
102 notation0
, notation1
, notation2
, notation3
, notation4
,
103 attlist0
, attlist1
, attlist2
, attlist3
, attlist4
, attlist5
, attlist6
,
104 attlist7
, attlist8
, attlist9
,
105 element0
, element1
, element2
, element3
, element4
, element5
, element6
,
108 externalSubset0
, externalSubset1
,
109 condSect0
, condSect1
, condSect2
,
114 static int FASTCALL
common(PROLOG_STATE
*state
, int tok
);
117 prolog0(PROLOG_STATE
*state
,
124 case XML_TOK_PROLOG_S
:
125 state
->handler
= prolog1
;
126 return XML_ROLE_NONE
;
127 case XML_TOK_XML_DECL
:
128 state
->handler
= prolog1
;
129 return XML_ROLE_XML_DECL
;
131 state
->handler
= prolog1
;
133 case XML_TOK_COMMENT
:
134 state
->handler
= prolog1
;
135 return XML_ROLE_COMMENT
;
137 return XML_ROLE_NONE
;
138 case XML_TOK_DECL_OPEN
:
139 if (!XmlNameMatchesAscii(enc
,
140 ptr
+ 2 * MIN_BYTES_PER_CHAR(enc
),
144 state
->handler
= doctype0
;
145 return XML_ROLE_DOCTYPE_NONE
;
146 case XML_TOK_INSTANCE_START
:
147 state
->handler
= error
;
148 return XML_ROLE_INSTANCE_START
;
150 return common(state
, tok
);
154 prolog1(PROLOG_STATE
*state
,
161 case XML_TOK_PROLOG_S
:
162 return XML_ROLE_NONE
;
165 case XML_TOK_COMMENT
:
166 return XML_ROLE_COMMENT
;
168 return XML_ROLE_NONE
;
169 case XML_TOK_DECL_OPEN
:
170 if (!XmlNameMatchesAscii(enc
,
171 ptr
+ 2 * MIN_BYTES_PER_CHAR(enc
),
175 state
->handler
= doctype0
;
176 return XML_ROLE_DOCTYPE_NONE
;
177 case XML_TOK_INSTANCE_START
:
178 state
->handler
= error
;
179 return XML_ROLE_INSTANCE_START
;
181 return common(state
, tok
);
185 prolog2(PROLOG_STATE
*state
,
192 case XML_TOK_PROLOG_S
:
193 return XML_ROLE_NONE
;
196 case XML_TOK_COMMENT
:
197 return XML_ROLE_COMMENT
;
198 case XML_TOK_INSTANCE_START
:
199 state
->handler
= error
;
200 return XML_ROLE_INSTANCE_START
;
202 return common(state
, tok
);
206 doctype0(PROLOG_STATE
*state
,
213 case XML_TOK_PROLOG_S
:
214 return XML_ROLE_DOCTYPE_NONE
;
216 case XML_TOK_PREFIXED_NAME
:
217 state
->handler
= doctype1
;
218 return XML_ROLE_DOCTYPE_NAME
;
220 return common(state
, tok
);
224 doctype1(PROLOG_STATE
*state
,
231 case XML_TOK_PROLOG_S
:
232 return XML_ROLE_DOCTYPE_NONE
;
233 case XML_TOK_OPEN_BRACKET
:
234 state
->handler
= internalSubset
;
235 return XML_ROLE_DOCTYPE_INTERNAL_SUBSET
;
236 case XML_TOK_DECL_CLOSE
:
237 state
->handler
= prolog2
;
238 return XML_ROLE_DOCTYPE_CLOSE
;
240 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_SYSTEM
)) {
241 state
->handler
= doctype3
;
242 return XML_ROLE_DOCTYPE_NONE
;
244 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_PUBLIC
)) {
245 state
->handler
= doctype2
;
246 return XML_ROLE_DOCTYPE_NONE
;
250 return common(state
, tok
);
254 doctype2(PROLOG_STATE
*state
,
261 case XML_TOK_PROLOG_S
:
262 return XML_ROLE_DOCTYPE_NONE
;
263 case XML_TOK_LITERAL
:
264 state
->handler
= doctype3
;
265 return XML_ROLE_DOCTYPE_PUBLIC_ID
;
267 return common(state
, tok
);
271 doctype3(PROLOG_STATE
*state
,
278 case XML_TOK_PROLOG_S
:
279 return XML_ROLE_DOCTYPE_NONE
;
280 case XML_TOK_LITERAL
:
281 state
->handler
= doctype4
;
282 return XML_ROLE_DOCTYPE_SYSTEM_ID
;
284 return common(state
, tok
);
288 doctype4(PROLOG_STATE
*state
,
295 case XML_TOK_PROLOG_S
:
296 return XML_ROLE_DOCTYPE_NONE
;
297 case XML_TOK_OPEN_BRACKET
:
298 state
->handler
= internalSubset
;
299 return XML_ROLE_DOCTYPE_INTERNAL_SUBSET
;
300 case XML_TOK_DECL_CLOSE
:
301 state
->handler
= prolog2
;
302 return XML_ROLE_DOCTYPE_CLOSE
;
304 return common(state
, tok
);
308 doctype5(PROLOG_STATE
*state
,
315 case XML_TOK_PROLOG_S
:
316 return XML_ROLE_DOCTYPE_NONE
;
317 case XML_TOK_DECL_CLOSE
:
318 state
->handler
= prolog2
;
319 return XML_ROLE_DOCTYPE_CLOSE
;
321 return common(state
, tok
);
325 internalSubset(PROLOG_STATE
*state
,
332 case XML_TOK_PROLOG_S
:
333 return XML_ROLE_NONE
;
334 case XML_TOK_DECL_OPEN
:
335 if (XmlNameMatchesAscii(enc
,
336 ptr
+ 2 * MIN_BYTES_PER_CHAR(enc
),
339 state
->handler
= entity0
;
340 return XML_ROLE_ENTITY_NONE
;
342 if (XmlNameMatchesAscii(enc
,
343 ptr
+ 2 * MIN_BYTES_PER_CHAR(enc
),
346 state
->handler
= attlist0
;
347 return XML_ROLE_ATTLIST_NONE
;
349 if (XmlNameMatchesAscii(enc
,
350 ptr
+ 2 * MIN_BYTES_PER_CHAR(enc
),
353 state
->handler
= element0
;
354 return XML_ROLE_ELEMENT_NONE
;
356 if (XmlNameMatchesAscii(enc
,
357 ptr
+ 2 * MIN_BYTES_PER_CHAR(enc
),
360 state
->handler
= notation0
;
361 return XML_ROLE_NOTATION_NONE
;
366 case XML_TOK_COMMENT
:
367 return XML_ROLE_COMMENT
;
368 case XML_TOK_PARAM_ENTITY_REF
:
369 return XML_ROLE_PARAM_ENTITY_REF
;
370 case XML_TOK_CLOSE_BRACKET
:
371 state
->handler
= doctype5
;
372 return XML_ROLE_DOCTYPE_NONE
;
374 return common(state
, tok
);
380 externalSubset0(PROLOG_STATE
*state
,
386 state
->handler
= externalSubset1
;
387 if (tok
== XML_TOK_XML_DECL
)
388 return XML_ROLE_TEXT_DECL
;
389 return externalSubset1(state
, tok
, ptr
, end
, enc
);
393 externalSubset1(PROLOG_STATE
*state
,
400 case XML_TOK_COND_SECT_OPEN
:
401 state
->handler
= condSect0
;
402 return XML_ROLE_NONE
;
403 case XML_TOK_COND_SECT_CLOSE
:
404 if (state
->includeLevel
== 0)
406 state
->includeLevel
-= 1;
407 return XML_ROLE_NONE
;
408 case XML_TOK_PROLOG_S
:
409 return XML_ROLE_NONE
;
410 case XML_TOK_CLOSE_BRACKET
:
413 if (state
->includeLevel
)
415 return XML_ROLE_NONE
;
417 return internalSubset(state
, tok
, ptr
, end
, enc
);
419 return common(state
, tok
);
425 entity0(PROLOG_STATE
*state
,
432 case XML_TOK_PROLOG_S
:
433 return XML_ROLE_ENTITY_NONE
;
434 case XML_TOK_PERCENT
:
435 state
->handler
= entity1
;
436 return XML_ROLE_ENTITY_NONE
;
438 state
->handler
= entity2
;
439 return XML_ROLE_GENERAL_ENTITY_NAME
;
441 return common(state
, tok
);
445 entity1(PROLOG_STATE
*state
,
452 case XML_TOK_PROLOG_S
:
453 return XML_ROLE_ENTITY_NONE
;
455 state
->handler
= entity7
;
456 return XML_ROLE_PARAM_ENTITY_NAME
;
458 return common(state
, tok
);
462 entity2(PROLOG_STATE
*state
,
469 case XML_TOK_PROLOG_S
:
470 return XML_ROLE_ENTITY_NONE
;
472 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_SYSTEM
)) {
473 state
->handler
= entity4
;
474 return XML_ROLE_ENTITY_NONE
;
476 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_PUBLIC
)) {
477 state
->handler
= entity3
;
478 return XML_ROLE_ENTITY_NONE
;
481 case XML_TOK_LITERAL
:
482 state
->handler
= declClose
;
483 state
->role_none
= XML_ROLE_ENTITY_NONE
;
484 return XML_ROLE_ENTITY_VALUE
;
486 return common(state
, tok
);
490 entity3(PROLOG_STATE
*state
,
497 case XML_TOK_PROLOG_S
:
498 return XML_ROLE_ENTITY_NONE
;
499 case XML_TOK_LITERAL
:
500 state
->handler
= entity4
;
501 return XML_ROLE_ENTITY_PUBLIC_ID
;
503 return common(state
, tok
);
507 entity4(PROLOG_STATE
*state
,
514 case XML_TOK_PROLOG_S
:
515 return XML_ROLE_ENTITY_NONE
;
516 case XML_TOK_LITERAL
:
517 state
->handler
= entity5
;
518 return XML_ROLE_ENTITY_SYSTEM_ID
;
520 return common(state
, tok
);
524 entity5(PROLOG_STATE
*state
,
531 case XML_TOK_PROLOG_S
:
532 return XML_ROLE_ENTITY_NONE
;
533 case XML_TOK_DECL_CLOSE
:
535 return XML_ROLE_ENTITY_COMPLETE
;
537 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_NDATA
)) {
538 state
->handler
= entity6
;
539 return XML_ROLE_ENTITY_NONE
;
543 return common(state
, tok
);
547 entity6(PROLOG_STATE
*state
,
554 case XML_TOK_PROLOG_S
:
555 return XML_ROLE_ENTITY_NONE
;
557 state
->handler
= declClose
;
558 state
->role_none
= XML_ROLE_ENTITY_NONE
;
559 return XML_ROLE_ENTITY_NOTATION_NAME
;
561 return common(state
, tok
);
565 entity7(PROLOG_STATE
*state
,
572 case XML_TOK_PROLOG_S
:
573 return XML_ROLE_ENTITY_NONE
;
575 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_SYSTEM
)) {
576 state
->handler
= entity9
;
577 return XML_ROLE_ENTITY_NONE
;
579 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_PUBLIC
)) {
580 state
->handler
= entity8
;
581 return XML_ROLE_ENTITY_NONE
;
584 case XML_TOK_LITERAL
:
585 state
->handler
= declClose
;
586 state
->role_none
= XML_ROLE_ENTITY_NONE
;
587 return XML_ROLE_ENTITY_VALUE
;
589 return common(state
, tok
);
593 entity8(PROLOG_STATE
*state
,
600 case XML_TOK_PROLOG_S
:
601 return XML_ROLE_ENTITY_NONE
;
602 case XML_TOK_LITERAL
:
603 state
->handler
= entity9
;
604 return XML_ROLE_ENTITY_PUBLIC_ID
;
606 return common(state
, tok
);
610 entity9(PROLOG_STATE
*state
,
617 case XML_TOK_PROLOG_S
:
618 return XML_ROLE_ENTITY_NONE
;
619 case XML_TOK_LITERAL
:
620 state
->handler
= entity10
;
621 return XML_ROLE_ENTITY_SYSTEM_ID
;
623 return common(state
, tok
);
627 entity10(PROLOG_STATE
*state
,
634 case XML_TOK_PROLOG_S
:
635 return XML_ROLE_ENTITY_NONE
;
636 case XML_TOK_DECL_CLOSE
:
638 return XML_ROLE_ENTITY_COMPLETE
;
640 return common(state
, tok
);
644 notation0(PROLOG_STATE
*state
,
651 case XML_TOK_PROLOG_S
:
652 return XML_ROLE_NOTATION_NONE
;
654 state
->handler
= notation1
;
655 return XML_ROLE_NOTATION_NAME
;
657 return common(state
, tok
);
661 notation1(PROLOG_STATE
*state
,
668 case XML_TOK_PROLOG_S
:
669 return XML_ROLE_NOTATION_NONE
;
671 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_SYSTEM
)) {
672 state
->handler
= notation3
;
673 return XML_ROLE_NOTATION_NONE
;
675 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_PUBLIC
)) {
676 state
->handler
= notation2
;
677 return XML_ROLE_NOTATION_NONE
;
681 return common(state
, tok
);
685 notation2(PROLOG_STATE
*state
,
692 case XML_TOK_PROLOG_S
:
693 return XML_ROLE_NOTATION_NONE
;
694 case XML_TOK_LITERAL
:
695 state
->handler
= notation4
;
696 return XML_ROLE_NOTATION_PUBLIC_ID
;
698 return common(state
, tok
);
702 notation3(PROLOG_STATE
*state
,
709 case XML_TOK_PROLOG_S
:
710 return XML_ROLE_NOTATION_NONE
;
711 case XML_TOK_LITERAL
:
712 state
->handler
= declClose
;
713 state
->role_none
= XML_ROLE_NOTATION_NONE
;
714 return XML_ROLE_NOTATION_SYSTEM_ID
;
716 return common(state
, tok
);
720 notation4(PROLOG_STATE
*state
,
727 case XML_TOK_PROLOG_S
:
728 return XML_ROLE_NOTATION_NONE
;
729 case XML_TOK_LITERAL
:
730 state
->handler
= declClose
;
731 state
->role_none
= XML_ROLE_NOTATION_NONE
;
732 return XML_ROLE_NOTATION_SYSTEM_ID
;
733 case XML_TOK_DECL_CLOSE
:
735 return XML_ROLE_NOTATION_NO_SYSTEM_ID
;
737 return common(state
, tok
);
741 attlist0(PROLOG_STATE
*state
,
748 case XML_TOK_PROLOG_S
:
749 return XML_ROLE_ATTLIST_NONE
;
751 case XML_TOK_PREFIXED_NAME
:
752 state
->handler
= attlist1
;
753 return XML_ROLE_ATTLIST_ELEMENT_NAME
;
755 return common(state
, tok
);
759 attlist1(PROLOG_STATE
*state
,
766 case XML_TOK_PROLOG_S
:
767 return XML_ROLE_ATTLIST_NONE
;
768 case XML_TOK_DECL_CLOSE
:
770 return XML_ROLE_ATTLIST_NONE
;
772 case XML_TOK_PREFIXED_NAME
:
773 state
->handler
= attlist2
;
774 return XML_ROLE_ATTRIBUTE_NAME
;
776 return common(state
, tok
);
780 attlist2(PROLOG_STATE
*state
,
787 case XML_TOK_PROLOG_S
:
788 return XML_ROLE_ATTLIST_NONE
;
791 static const char *types
[] = {
802 for (i
= 0; i
< (int)(sizeof(types
)/sizeof(types
[0])); i
++)
803 if (XmlNameMatchesAscii(enc
, ptr
, end
, types
[i
])) {
804 state
->handler
= attlist8
;
805 return XML_ROLE_ATTRIBUTE_TYPE_CDATA
+ i
;
808 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_NOTATION
)) {
809 state
->handler
= attlist5
;
810 return XML_ROLE_ATTLIST_NONE
;
813 case XML_TOK_OPEN_PAREN
:
814 state
->handler
= attlist3
;
815 return XML_ROLE_ATTLIST_NONE
;
817 return common(state
, tok
);
821 attlist3(PROLOG_STATE
*state
,
828 case XML_TOK_PROLOG_S
:
829 return XML_ROLE_ATTLIST_NONE
;
830 case XML_TOK_NMTOKEN
:
832 case XML_TOK_PREFIXED_NAME
:
833 state
->handler
= attlist4
;
834 return XML_ROLE_ATTRIBUTE_ENUM_VALUE
;
836 return common(state
, tok
);
840 attlist4(PROLOG_STATE
*state
,
847 case XML_TOK_PROLOG_S
:
848 return XML_ROLE_ATTLIST_NONE
;
849 case XML_TOK_CLOSE_PAREN
:
850 state
->handler
= attlist8
;
851 return XML_ROLE_ATTLIST_NONE
;
853 state
->handler
= attlist3
;
854 return XML_ROLE_ATTLIST_NONE
;
856 return common(state
, tok
);
860 attlist5(PROLOG_STATE
*state
,
867 case XML_TOK_PROLOG_S
:
868 return XML_ROLE_ATTLIST_NONE
;
869 case XML_TOK_OPEN_PAREN
:
870 state
->handler
= attlist6
;
871 return XML_ROLE_ATTLIST_NONE
;
873 return common(state
, tok
);
877 attlist6(PROLOG_STATE
*state
,
884 case XML_TOK_PROLOG_S
:
885 return XML_ROLE_ATTLIST_NONE
;
887 state
->handler
= attlist7
;
888 return XML_ROLE_ATTRIBUTE_NOTATION_VALUE
;
890 return common(state
, tok
);
894 attlist7(PROLOG_STATE
*state
,
901 case XML_TOK_PROLOG_S
:
902 return XML_ROLE_ATTLIST_NONE
;
903 case XML_TOK_CLOSE_PAREN
:
904 state
->handler
= attlist8
;
905 return XML_ROLE_ATTLIST_NONE
;
907 state
->handler
= attlist6
;
908 return XML_ROLE_ATTLIST_NONE
;
910 return common(state
, tok
);
915 attlist8(PROLOG_STATE
*state
,
922 case XML_TOK_PROLOG_S
:
923 return XML_ROLE_ATTLIST_NONE
;
924 case XML_TOK_POUND_NAME
:
925 if (XmlNameMatchesAscii(enc
,
926 ptr
+ MIN_BYTES_PER_CHAR(enc
),
929 state
->handler
= attlist1
;
930 return XML_ROLE_IMPLIED_ATTRIBUTE_VALUE
;
932 if (XmlNameMatchesAscii(enc
,
933 ptr
+ MIN_BYTES_PER_CHAR(enc
),
936 state
->handler
= attlist1
;
937 return XML_ROLE_REQUIRED_ATTRIBUTE_VALUE
;
939 if (XmlNameMatchesAscii(enc
,
940 ptr
+ MIN_BYTES_PER_CHAR(enc
),
943 state
->handler
= attlist9
;
944 return XML_ROLE_ATTLIST_NONE
;
947 case XML_TOK_LITERAL
:
948 state
->handler
= attlist1
;
949 return XML_ROLE_DEFAULT_ATTRIBUTE_VALUE
;
951 return common(state
, tok
);
955 attlist9(PROLOG_STATE
*state
,
962 case XML_TOK_PROLOG_S
:
963 return XML_ROLE_ATTLIST_NONE
;
964 case XML_TOK_LITERAL
:
965 state
->handler
= attlist1
;
966 return XML_ROLE_FIXED_ATTRIBUTE_VALUE
;
968 return common(state
, tok
);
972 element0(PROLOG_STATE
*state
,
979 case XML_TOK_PROLOG_S
:
980 return XML_ROLE_ELEMENT_NONE
;
982 case XML_TOK_PREFIXED_NAME
:
983 state
->handler
= element1
;
984 return XML_ROLE_ELEMENT_NAME
;
986 return common(state
, tok
);
990 element1(PROLOG_STATE
*state
,
997 case XML_TOK_PROLOG_S
:
998 return XML_ROLE_ELEMENT_NONE
;
1000 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_EMPTY
)) {
1001 state
->handler
= declClose
;
1002 state
->role_none
= XML_ROLE_ELEMENT_NONE
;
1003 return XML_ROLE_CONTENT_EMPTY
;
1005 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_ANY
)) {
1006 state
->handler
= declClose
;
1007 state
->role_none
= XML_ROLE_ELEMENT_NONE
;
1008 return XML_ROLE_CONTENT_ANY
;
1011 case XML_TOK_OPEN_PAREN
:
1012 state
->handler
= element2
;
1014 return XML_ROLE_GROUP_OPEN
;
1016 return common(state
, tok
);
1020 element2(PROLOG_STATE
*state
,
1024 const ENCODING
*enc
)
1027 case XML_TOK_PROLOG_S
:
1028 return XML_ROLE_ELEMENT_NONE
;
1029 case XML_TOK_POUND_NAME
:
1030 if (XmlNameMatchesAscii(enc
,
1031 ptr
+ MIN_BYTES_PER_CHAR(enc
),
1034 state
->handler
= element3
;
1035 return XML_ROLE_CONTENT_PCDATA
;
1038 case XML_TOK_OPEN_PAREN
:
1040 state
->handler
= element6
;
1041 return XML_ROLE_GROUP_OPEN
;
1043 case XML_TOK_PREFIXED_NAME
:
1044 state
->handler
= element7
;
1045 return XML_ROLE_CONTENT_ELEMENT
;
1046 case XML_TOK_NAME_QUESTION
:
1047 state
->handler
= element7
;
1048 return XML_ROLE_CONTENT_ELEMENT_OPT
;
1049 case XML_TOK_NAME_ASTERISK
:
1050 state
->handler
= element7
;
1051 return XML_ROLE_CONTENT_ELEMENT_REP
;
1052 case XML_TOK_NAME_PLUS
:
1053 state
->handler
= element7
;
1054 return XML_ROLE_CONTENT_ELEMENT_PLUS
;
1056 return common(state
, tok
);
1060 element3(PROLOG_STATE
*state
,
1064 const ENCODING
*enc
)
1067 case XML_TOK_PROLOG_S
:
1068 return XML_ROLE_ELEMENT_NONE
;
1069 case XML_TOK_CLOSE_PAREN
:
1070 state
->handler
= declClose
;
1071 state
->role_none
= XML_ROLE_ELEMENT_NONE
;
1072 return XML_ROLE_GROUP_CLOSE
;
1073 case XML_TOK_CLOSE_PAREN_ASTERISK
:
1074 state
->handler
= declClose
;
1075 state
->role_none
= XML_ROLE_ELEMENT_NONE
;
1076 return XML_ROLE_GROUP_CLOSE_REP
;
1078 state
->handler
= element4
;
1079 return XML_ROLE_ELEMENT_NONE
;
1081 return common(state
, tok
);
1085 element4(PROLOG_STATE
*state
,
1089 const ENCODING
*enc
)
1092 case XML_TOK_PROLOG_S
:
1093 return XML_ROLE_ELEMENT_NONE
;
1095 case XML_TOK_PREFIXED_NAME
:
1096 state
->handler
= element5
;
1097 return XML_ROLE_CONTENT_ELEMENT
;
1099 return common(state
, tok
);
1103 element5(PROLOG_STATE
*state
,
1107 const ENCODING
*enc
)
1110 case XML_TOK_PROLOG_S
:
1111 return XML_ROLE_ELEMENT_NONE
;
1112 case XML_TOK_CLOSE_PAREN_ASTERISK
:
1113 state
->handler
= declClose
;
1114 state
->role_none
= XML_ROLE_ELEMENT_NONE
;
1115 return XML_ROLE_GROUP_CLOSE_REP
;
1117 state
->handler
= element4
;
1118 return XML_ROLE_ELEMENT_NONE
;
1120 return common(state
, tok
);
1124 element6(PROLOG_STATE
*state
,
1128 const ENCODING
*enc
)
1131 case XML_TOK_PROLOG_S
:
1132 return XML_ROLE_ELEMENT_NONE
;
1133 case XML_TOK_OPEN_PAREN
:
1135 return XML_ROLE_GROUP_OPEN
;
1137 case XML_TOK_PREFIXED_NAME
:
1138 state
->handler
= element7
;
1139 return XML_ROLE_CONTENT_ELEMENT
;
1140 case XML_TOK_NAME_QUESTION
:
1141 state
->handler
= element7
;
1142 return XML_ROLE_CONTENT_ELEMENT_OPT
;
1143 case XML_TOK_NAME_ASTERISK
:
1144 state
->handler
= element7
;
1145 return XML_ROLE_CONTENT_ELEMENT_REP
;
1146 case XML_TOK_NAME_PLUS
:
1147 state
->handler
= element7
;
1148 return XML_ROLE_CONTENT_ELEMENT_PLUS
;
1150 return common(state
, tok
);
1154 element7(PROLOG_STATE
*state
,
1158 const ENCODING
*enc
)
1161 case XML_TOK_PROLOG_S
:
1162 return XML_ROLE_ELEMENT_NONE
;
1163 case XML_TOK_CLOSE_PAREN
:
1165 if (state
->level
== 0) {
1166 state
->handler
= declClose
;
1167 state
->role_none
= XML_ROLE_ELEMENT_NONE
;
1169 return XML_ROLE_GROUP_CLOSE
;
1170 case XML_TOK_CLOSE_PAREN_ASTERISK
:
1172 if (state
->level
== 0) {
1173 state
->handler
= declClose
;
1174 state
->role_none
= XML_ROLE_ELEMENT_NONE
;
1176 return XML_ROLE_GROUP_CLOSE_REP
;
1177 case XML_TOK_CLOSE_PAREN_QUESTION
:
1179 if (state
->level
== 0) {
1180 state
->handler
= declClose
;
1181 state
->role_none
= XML_ROLE_ELEMENT_NONE
;
1183 return XML_ROLE_GROUP_CLOSE_OPT
;
1184 case XML_TOK_CLOSE_PAREN_PLUS
:
1186 if (state
->level
== 0) {
1187 state
->handler
= declClose
;
1188 state
->role_none
= XML_ROLE_ELEMENT_NONE
;
1190 return XML_ROLE_GROUP_CLOSE_PLUS
;
1192 state
->handler
= element6
;
1193 return XML_ROLE_GROUP_SEQUENCE
;
1195 state
->handler
= element6
;
1196 return XML_ROLE_GROUP_CHOICE
;
1198 return common(state
, tok
);
1204 condSect0(PROLOG_STATE
*state
,
1208 const ENCODING
*enc
)
1211 case XML_TOK_PROLOG_S
:
1212 return XML_ROLE_NONE
;
1214 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_INCLUDE
)) {
1215 state
->handler
= condSect1
;
1216 return XML_ROLE_NONE
;
1218 if (XmlNameMatchesAscii(enc
, ptr
, end
, KW_IGNORE
)) {
1219 state
->handler
= condSect2
;
1220 return XML_ROLE_NONE
;
1224 return common(state
, tok
);
1228 condSect1(PROLOG_STATE
*state
,
1232 const ENCODING
*enc
)
1235 case XML_TOK_PROLOG_S
:
1236 return XML_ROLE_NONE
;
1237 case XML_TOK_OPEN_BRACKET
:
1238 state
->handler
= externalSubset1
;
1239 state
->includeLevel
+= 1;
1240 return XML_ROLE_NONE
;
1242 return common(state
, tok
);
1246 condSect2(PROLOG_STATE
*state
,
1250 const ENCODING
*enc
)
1253 case XML_TOK_PROLOG_S
:
1254 return XML_ROLE_NONE
;
1255 case XML_TOK_OPEN_BRACKET
:
1256 state
->handler
= externalSubset1
;
1257 return XML_ROLE_IGNORE_SECT
;
1259 return common(state
, tok
);
1262 #endif /* XML_DTD */
1265 declClose(PROLOG_STATE
*state
,
1269 const ENCODING
*enc
)
1272 case XML_TOK_PROLOG_S
:
1273 return state
->role_none
;
1274 case XML_TOK_DECL_CLOSE
:
1276 return state
->role_none
;
1278 return common(state
, tok
);
1282 error(PROLOG_STATE
*state
,
1286 const ENCODING
*enc
)
1288 return XML_ROLE_NONE
;
1292 common(PROLOG_STATE
*state
, int tok
)
1295 if (!state
->documentEntity
&& tok
== XML_TOK_PARAM_ENTITY_REF
)
1296 return XML_ROLE_INNER_PARAM_ENTITY_REF
;
1298 state
->handler
= error
;
1299 return XML_ROLE_ERROR
;
1303 XmlPrologStateInit(PROLOG_STATE
*state
)
1305 state
->handler
= prolog0
;
1307 state
->documentEntity
= 1;
1308 state
->includeLevel
= 0;
1309 state
->inEntityValue
= 0;
1310 #endif /* XML_DTD */
1316 XmlPrologStateInitExternalEntity(PROLOG_STATE
*state
)
1318 state
->handler
= externalSubset0
;
1319 state
->documentEntity
= 0;
1320 state
->includeLevel
= 0;
1323 #endif /* XML_DTD */