OSDN Git Service

* Merge branch 'branch_0.10.0' into branch_0.11.0
[modchxj/mod_chxj.git] / src / chxj_node_exchange.c
1 /*
2  * Copyright (C) 2005-2008 QSDN,Inc. All rights reserved.
3  * Copyright (C) 2005 Atsushi Konno All rights reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #include "mod_chxj.h"
18
19 tag_handlers chxj_tag_handlers[] = {
20   {
21     .type    = CHXJ_SPEC_UNKNOWN,
22     .handler = NULL,
23   },
24   {
25     .type    = CHXJ_SPEC_Chtml_1_0,
26     .handler = chtml10_handler,
27   },
28   {
29     .type    = CHXJ_SPEC_Chtml_2_0,
30     .handler = chtml20_handler,
31   },
32   {
33     .type    = CHXJ_SPEC_Chtml_3_0,
34     .handler = chtml30_handler,
35   },
36   {
37     .type    = CHXJ_SPEC_Chtml_4_0,
38     .handler = chtml30_handler,
39   },
40   {
41     .type    = CHXJ_SPEC_Chtml_5_0,
42     .handler = chtml30_handler,
43   },
44   {
45     .type    = CHXJ_SPEC_XHtml_Mobile_1_0,
46     .handler = xhtml_handler,
47   },
48   {
49     .type    = CHXJ_SPEC_Hdml,
50     .handler = hdml_handler,
51   },
52   {
53     .type    = CHXJ_SPEC_Jhtml,
54     .handler = jhtml_handler,
55   },
56   {
57     .type    = CHXJ_SPEC_HTML,
58     .handler = NULL,
59   },
60 };
61
62
63 /**
64  * It is main processing of conversion from CHTML to XXML. 
65  *
66  * @param spec    [i]   
67  * @param r       [i]   
68  * @param pdoc    [i/o] The pointer to the XXML structure is specified. 
69  * @param doc     [i/o] The pointer to the XXML structure is specified. 
70  * @param node    [i]   The pointer to a current node is specified. 
71  * @param indent  [i]   The depth of the node processing it now is specified. 
72  *
73  * @return The character string after it converts it is returned. 
74  */
75 char*
76 chxj_node_exchange(
77   device_table* spec,
78   request_rec*  r,
79   void*         pdoc, 
80   Doc*          doc, 
81   Node*         node, 
82   int           indent
83 )
84 {
85   Node*         child;
86   tag_handler*  handlers;
87
88
89   handlers = chxj_tag_handlers[spec->html_spec_type].handler;
90
91   /*--------------------------------------------------------------------------*/
92   /* It is the main loop of the conversion processing.                        */
93   /*--------------------------------------------------------------------------*/
94   for (child = qs_get_child_node(doc,node);
95        child;
96        child = qs_get_next_node(doc,child)) {
97
98     char* name;
99
100     name = qs_get_node_name(doc,child);
101
102     switch(*name) {
103     case 'h':
104     case 'H':
105       /*----------------------------------------------------------------------*/
106       /* <HTML>                                                               */
107       /*----------------------------------------------------------------------*/
108       if (strcasecmp(name, "html") == 0) {
109         if (handlers[tagHTML].start_tag_handler) 
110           handlers[tagHTML].start_tag_handler(pdoc, child);
111
112         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
113
114         if (handlers[tagHTML].end_tag_handler)
115           handlers[tagHTML].end_tag_handler(pdoc, child);
116       }
117       /*----------------------------------------------------------------------*/
118       /* <HEAD>                                                               */
119       /*----------------------------------------------------------------------*/
120       else 
121       if (strcasecmp(name, "head") == 0) {
122         if (handlers[tagHEAD].start_tag_handler) 
123           handlers[tagHEAD].start_tag_handler(pdoc, child);
124
125         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
126
127         if (handlers[tagHEAD].end_tag_handler)
128           handlers[tagHEAD].end_tag_handler(pdoc, child);
129       }
130       /*----------------------------------------------------------------------*/
131       /* <HR>                                                                 */
132       /*----------------------------------------------------------------------*/
133       else 
134       if (strcasecmp(name, "hr") == 0) {
135         if (handlers[tagHR].start_tag_handler) 
136           handlers[tagHR].start_tag_handler(pdoc, child);
137
138         if (handlers[tagHR].end_tag_handler)
139           handlers[tagHR].end_tag_handler(pdoc, child);
140       }
141       /*----------------------------------------------------------------------*/
142       /* <H1>                                                                 */
143       /*----------------------------------------------------------------------*/
144       else
145       if (strcasecmp(name, "h1") == 0) {
146         if (handlers[tagH1].start_tag_handler) 
147           handlers[tagH1].start_tag_handler(pdoc, child);
148
149         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
150
151         if (handlers[tagH1].end_tag_handler)
152           handlers[tagH1].end_tag_handler(pdoc, child);
153       }
154       /*----------------------------------------------------------------------*/
155       /* <H2>                                                                 */
156       /*----------------------------------------------------------------------*/
157       else
158       if (strcasecmp(name, "h2") == 0) {
159         if (handlers[tagH2].start_tag_handler) 
160           handlers[tagH2].start_tag_handler(pdoc, child);
161
162         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
163
164         if (handlers[tagH2].end_tag_handler)
165           handlers[tagH2].end_tag_handler(pdoc, child);
166       }
167       /*----------------------------------------------------------------------*/
168       /* <H3>                                                                 */
169       /*----------------------------------------------------------------------*/
170       else
171       if (strcasecmp(name, "h3") == 0) {
172         if (handlers[tagH3].start_tag_handler) 
173           handlers[tagH3].start_tag_handler(pdoc, child);
174
175         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
176
177         if (handlers[tagH3].end_tag_handler)
178           handlers[tagH3].end_tag_handler(pdoc, child);
179       }
180       /*----------------------------------------------------------------------*/
181       /* <H4>                                                                 */
182       /*----------------------------------------------------------------------*/
183       else
184       if (strcasecmp(name, "h4") == 0) {
185         if (handlers[tagH4].start_tag_handler) 
186           handlers[tagH4].start_tag_handler(pdoc, child);
187
188         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
189
190         if (handlers[tagH4].end_tag_handler)
191           handlers[tagH4].end_tag_handler(pdoc, child);
192       }
193       /*----------------------------------------------------------------------*/
194       /* <H5>                                                                 */
195       /*----------------------------------------------------------------------*/
196       else
197       if (strcasecmp(name, "h5") == 0) {
198         if (handlers[tagH5].start_tag_handler) 
199           handlers[tagH5].start_tag_handler(pdoc, child);
200
201         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
202
203         if (handlers[tagH5].end_tag_handler)
204           handlers[tagH5].end_tag_handler(pdoc, child);
205       }
206       /*----------------------------------------------------------------------*/
207       /* <H6>                                                                 */
208       /*----------------------------------------------------------------------*/
209       else
210       if (strcasecmp(name, "h6") == 0) {
211         if (handlers[tagH6].start_tag_handler) 
212           handlers[tagH6].start_tag_handler(pdoc, child);
213
214         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
215
216         if (handlers[tagH6].end_tag_handler)
217           handlers[tagH6].end_tag_handler(pdoc, child);
218       }
219       else {
220         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
221       }
222       break;
223
224
225     case 'p':
226     case 'P':
227       /*----------------------------------------------------------------------*/
228       /* <P>                                                                  */
229       /*----------------------------------------------------------------------*/
230       if (strcasecmp(name, "p") == 0) {
231         if (handlers[tagP].start_tag_handler) 
232           handlers[tagP].start_tag_handler(pdoc, child);
233
234         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
235
236         if (handlers[tagP].end_tag_handler)
237           handlers[tagP].end_tag_handler(pdoc, child);
238       }
239       /*----------------------------------------------------------------------*/
240       /* <PRE>                                                                */
241       /*----------------------------------------------------------------------*/
242       else if (strcasecmp(name, "pre") == 0) {
243         if (handlers[tagPRE].start_tag_handler) 
244           handlers[tagPRE].start_tag_handler(pdoc, child);
245
246         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
247
248         if (handlers[tagPRE].end_tag_handler)
249           handlers[tagPRE].end_tag_handler(pdoc, child);
250       }
251       /*----------------------------------------------------------------------*/
252       /* <PLAINTEXT>                                                          */
253       /*----------------------------------------------------------------------*/
254       else if (strcasecmp(name, "plaintext") == 0) {
255         if (handlers[tagPLAINTEXT].start_tag_handler) 
256           handlers[tagPLAINTEXT].start_tag_handler(pdoc, child);
257
258         if (handlers[tagPLAINTEXT].end_tag_handler)
259           handlers[tagPLAINTEXT].end_tag_handler(pdoc, child);
260       }
261       else {
262         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
263       }
264       break;
265
266     case 'n':
267     case 'N':
268       /*----------------------------------------------------------------------*/
269       /* <NOBR>                                                               */
270       /*----------------------------------------------------------------------*/
271       if (strcasecmp(name, "nobr") == 0) {
272         if (handlers[tagNOBR].start_tag_handler) 
273           handlers[tagNOBR].start_tag_handler(pdoc, child);
274
275         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
276
277         if (handlers[tagNOBR].end_tag_handler)
278           handlers[tagNOBR].end_tag_handler(pdoc, child);
279       }
280       else {
281         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
282       }
283       break;
284
285     case 'u':
286     case 'U':
287       /*----------------------------------------------------------------------*/
288       /* <UL>                                                                 */
289       /*----------------------------------------------------------------------*/
290       if (strcasecmp(name, "ul") == 0) {
291         if (handlers[tagUL].start_tag_handler) 
292           handlers[tagUL].start_tag_handler(pdoc, child);
293
294         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
295
296         if (handlers[tagUL].end_tag_handler)
297           handlers[tagUL].end_tag_handler(pdoc, child);
298       }
299       else {
300         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
301       }
302       break;
303
304     case 'l':
305     case 'L':
306       /*----------------------------------------------------------------------*/
307       /* <LI>                                                                 */
308       /*----------------------------------------------------------------------*/
309       if (strcasecmp(name, "li") == 0) {
310         if (handlers[tagLI].start_tag_handler) 
311           handlers[tagLI].start_tag_handler(pdoc, child);
312
313         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
314
315         if (handlers[tagLI].end_tag_handler)
316           handlers[tagLI].end_tag_handler(pdoc, child);
317       }
318       else
319       /*----------------------------------------------------------------------*/
320       /* <LEGEND>                                                             */
321       /*----------------------------------------------------------------------*/
322       if (strcasecmp(name, "legend") == 0) {
323         if (handlers[tagLEGEND].start_tag_handler) 
324           handlers[tagLEGEND].start_tag_handler(pdoc, child);
325
326         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
327
328         if (handlers[tagLEGEND].end_tag_handler)
329           handlers[tagLEGEND].end_tag_handler(pdoc, child);
330       }
331       else
332       /*----------------------------------------------------------------------*/
333       /* <LABEL>                                                              */
334       /*----------------------------------------------------------------------*/
335       if (strcasecmp(name, "label") == 0) {
336         if (handlers[tagLABEL].start_tag_handler) 
337           handlers[tagLABEL].start_tag_handler(pdoc, child);
338
339         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
340
341         if (handlers[tagLABEL].end_tag_handler)
342           handlers[tagLABEL].end_tag_handler(pdoc, child);
343       }
344       else {
345         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
346       }
347       
348       break;
349
350     case 'o':
351     case 'O':
352       /*----------------------------------------------------------------------*/
353       /* <OL>                                                                 */
354       /*----------------------------------------------------------------------*/
355       if (strcasecmp(name, "ol") == 0) {
356         if (handlers[tagOL].start_tag_handler) 
357           handlers[tagOL].start_tag_handler(pdoc, child);
358
359         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
360
361         if (handlers[tagOL].end_tag_handler)
362           handlers[tagOL].end_tag_handler(pdoc, child);
363       }
364       else
365       /*----------------------------------------------------------------------*/
366       /* <OPTION>                                                             */
367       /*----------------------------------------------------------------------*/
368       if (strcasecmp(name, "option") == 0) {
369         if (handlers[tagOPTION].start_tag_handler) 
370           handlers[tagOPTION].start_tag_handler(pdoc, child);
371
372         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
373
374         if (handlers[tagOPTION].end_tag_handler)
375           handlers[tagOPTION].end_tag_handler(pdoc, child);
376       }
377       else
378       /*----------------------------------------------------------------------*/
379       /* <OBJECT>                                                             */
380       /*----------------------------------------------------------------------*/
381       if (strcasecmp(name, "object") == 0) {
382         /* ignore object block */
383       }
384       else {
385         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
386       }
387
388       break;
389
390     case 'm':
391     case 'M':
392       /*----------------------------------------------------------------------*/
393       /* <META>                                                               */
394       /*----------------------------------------------------------------------*/
395       if (strcasecmp(name, "meta") == 0) {
396         if (handlers[tagMETA].start_tag_handler) 
397           handlers[tagMETA].start_tag_handler(pdoc, child);
398
399         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
400
401         if (handlers[tagMETA].end_tag_handler)
402           handlers[tagMETA].end_tag_handler(pdoc, child);
403       }
404       /*----------------------------------------------------------------------*/
405       /* <MENU>                                                               */
406       /*----------------------------------------------------------------------*/
407       else if (strcasecmp(name, "menu") == 0) {
408         if (handlers[tagMENU].start_tag_handler) 
409           handlers[tagMENU].start_tag_handler(pdoc, child);
410
411         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
412
413         if (handlers[tagMENU].end_tag_handler)
414           handlers[tagMENU].end_tag_handler(pdoc, child);
415       }
416       /*----------------------------------------------------------------------*/
417       /* <MARQUEE>                                                            */
418       /*----------------------------------------------------------------------*/
419       else if (strcasecmp(name, "marquee") == 0) {
420         if (handlers[tagMARQUEE].start_tag_handler) 
421           handlers[tagMARQUEE].start_tag_handler(pdoc, child);
422
423         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
424
425         if (handlers[tagMARQUEE].end_tag_handler)
426           handlers[tagMARQUEE].end_tag_handler(pdoc, child);
427       }
428       else {
429         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
430       }
431       break;
432
433     case 'b':
434     case 'B':
435       /*----------------------------------------------------------------------*/
436       /* <B>                                                                  */
437       /*----------------------------------------------------------------------*/
438       if (strlen(name) == 1) {
439         if (handlers[tagB].start_tag_handler) 
440           handlers[tagB].start_tag_handler(pdoc, child);
441
442         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
443
444         if (handlers[tagB].end_tag_handler)
445           handlers[tagB].end_tag_handler(pdoc, child);
446       }
447       else
448       /*----------------------------------------------------------------------*/
449       /* <BASE>                                                               */
450       /*----------------------------------------------------------------------*/
451       if (strcasecmp(name, "base") == 0) {
452         if (handlers[tagBASE].start_tag_handler) 
453           handlers[tagBASE].start_tag_handler(pdoc, child);
454
455         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
456
457         if (handlers[tagBASE].end_tag_handler)
458           handlers[tagBASE].end_tag_handler(pdoc, child);
459       }
460       /*----------------------------------------------------------------------*/
461       /* <BODY>                                                               */
462       /*----------------------------------------------------------------------*/
463       else
464       if (strcasecmp(name, "body") == 0) {
465         if (handlers[tagBODY].start_tag_handler) 
466           handlers[tagBODY].start_tag_handler(pdoc, child);
467
468         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
469
470         if (handlers[tagBODY].end_tag_handler)
471           handlers[tagBODY].end_tag_handler(pdoc, child);
472       }
473       /*----------------------------------------------------------------------*/
474       /* <BR>                                                                 */
475       /*----------------------------------------------------------------------*/
476       else if (strcasecmp(name, "br") == 0) {
477         if (handlers[tagBR].start_tag_handler) 
478           handlers[tagBR].start_tag_handler(pdoc, child);
479
480         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
481
482         if (handlers[tagBR].end_tag_handler)
483           handlers[tagBR].end_tag_handler(pdoc, child);
484       }
485       /*----------------------------------------------------------------------*/
486       /* <BLOCKQUOTE>                                                         */
487       /*----------------------------------------------------------------------*/
488       else if (strcasecmp(name, "blockquote") == 0) {
489         if (handlers[tagBLOCKQUOTE].start_tag_handler) 
490           handlers[tagBLOCKQUOTE].start_tag_handler(pdoc, child);
491
492         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
493
494         if (handlers[tagBLOCKQUOTE].end_tag_handler)
495           handlers[tagBLOCKQUOTE].end_tag_handler(pdoc, child);
496       }
497       /*----------------------------------------------------------------------*/
498       /* <BLINK>                                                              */
499       /*----------------------------------------------------------------------*/
500       else if (strcasecmp(name, "blink") == 0) {
501         if (handlers[tagBLINK].start_tag_handler) 
502           handlers[tagBLINK].start_tag_handler(pdoc, child);
503
504         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
505
506         if (handlers[tagBLINK].end_tag_handler)
507           handlers[tagBLINK].end_tag_handler(pdoc, child);
508       }
509       else {
510         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
511       }
512       break;
513
514     case 'a':
515     case 'A':
516       /*----------------------------------------------------------------------*/
517       /* <A>                                                                  */
518       /*----------------------------------------------------------------------*/
519       if (strcasecmp(name, "a") == 0) {
520         if (handlers[tagA].start_tag_handler) 
521           handlers[tagA].start_tag_handler(pdoc, child);
522
523         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
524
525         if (handlers[tagA].end_tag_handler)
526           handlers[tagA].end_tag_handler(pdoc, child);
527       }
528       else {
529         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
530       }
531       break;
532
533     case 'f':
534     case 'F':
535       /*----------------------------------------------------------------------*/
536       /* <FONT>                                                               */
537       /*----------------------------------------------------------------------*/
538       if (strcasecmp(name, "font") == 0) {
539         if (handlers[tagFONT].start_tag_handler) 
540           handlers[tagFONT].start_tag_handler(pdoc, child);
541
542         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
543
544         if (handlers[tagFONT].end_tag_handler)
545           handlers[tagFONT].end_tag_handler(pdoc, child);
546       }
547       /*----------------------------------------------------------------------*/
548       /* <FORM>                                                               */
549       /*----------------------------------------------------------------------*/
550       else
551       if (strcasecmp(name, "form") == 0) {
552         if (handlers[tagFORM].start_tag_handler) 
553           handlers[tagFORM].start_tag_handler(pdoc, child);
554
555         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
556
557         if (handlers[tagFORM].end_tag_handler)
558           handlers[tagFORM].end_tag_handler(pdoc, child);
559       }
560       /*----------------------------------------------------------------------*/
561       /* <FIELDSET>                                                           */
562       /*----------------------------------------------------------------------*/
563       else
564       if (strcasecmp(name, "fieldset") == 0) {
565         if (handlers[tagFIELDSET].start_tag_handler) 
566           handlers[tagFIELDSET].start_tag_handler(pdoc, child);
567
568         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
569
570         if (handlers[tagFIELDSET].end_tag_handler)
571           handlers[tagFIELDSET].end_tag_handler(pdoc, child);
572       }
573       else {
574         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
575       }
576       break;
577
578     case 'i':
579     case 'I':
580       /*----------------------------------------------------------------------*/
581       /* <INPUT>                                                              */
582       /*----------------------------------------------------------------------*/
583       if (strcasecmp(name, "input") == 0) {
584         if (handlers[tagINPUT].start_tag_handler) 
585           handlers[tagINPUT].start_tag_handler(pdoc, child);
586
587         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
588
589         if (handlers[tagINPUT].end_tag_handler)
590           handlers[tagINPUT].end_tag_handler(pdoc, child);
591       }
592       /*----------------------------------------------------------------------*/
593       /* <IMG>                                                                */
594       /*----------------------------------------------------------------------*/
595       else
596       if (strcasecmp(name, "img") == 0) {
597         if (handlers[tagIMG].start_tag_handler) 
598           handlers[tagIMG].start_tag_handler(pdoc, child);
599
600         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
601
602         if (handlers[tagIMG].end_tag_handler)
603           handlers[tagIMG].end_tag_handler(pdoc, child);
604       }
605       else {
606         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
607       }
608       break;
609
610     case 's':
611     case 'S':
612       /*----------------------------------------------------------------------*/
613       /* <SELECT>                                                             */
614       /*----------------------------------------------------------------------*/
615       if (strcasecmp(name, "select") == 0) {
616         if (handlers[tagSELECT].start_tag_handler) 
617           handlers[tagSELECT].start_tag_handler(pdoc, child);
618
619         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
620
621         if (handlers[tagSELECT].end_tag_handler)
622           handlers[tagSELECT].end_tag_handler(pdoc, child);
623       }
624       /*----------------------------------------------------------------------*/
625       /* <STYLE>                                                              */
626       /*----------------------------------------------------------------------*/
627       else
628       if (strcasecmp(name, "style") == 0) {
629         if (handlers[tagSTYLE].start_tag_handler) 
630           handlers[tagSTYLE].start_tag_handler(pdoc, child);
631 #if 0
632         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
633 #endif
634
635         if (handlers[tagSTYLE].end_tag_handler)
636           handlers[tagSTYLE].end_tag_handler(pdoc, child);
637       }
638       /*----------------------------------------------------------------------*/
639       /* <SPAN>                                                               */
640       /*----------------------------------------------------------------------*/
641       else
642       if (strcasecmp(name, "span") == 0) {
643         if (handlers[tagSPAN].start_tag_handler) 
644           handlers[tagSPAN].start_tag_handler(pdoc, child);
645
646         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
647
648         if (handlers[tagSPAN].end_tag_handler)
649           handlers[tagSPAN].end_tag_handler(pdoc, child);
650       }
651       /*----------------------------------------------------------------------*/
652       /* <SMALL>                                                              */
653       /*----------------------------------------------------------------------*/
654       else
655       if (strcasecmp(name, "small") == 0) {
656         if (handlers[tagSMALL].start_tag_handler) 
657           handlers[tagSMALL].start_tag_handler(pdoc, child);
658
659         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
660
661         if (handlers[tagSMALL].end_tag_handler)
662           handlers[tagSMALL].end_tag_handler(pdoc, child);
663       }
664       /*----------------------------------------------------------------------*/
665       /* <SCRIPT>                                                             */
666       /*----------------------------------------------------------------------*/
667       else 
668       if (strcasecmp(name, "script") == 0) {
669         /* ignore script block */
670       }
671       else {
672         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
673       }
674       break;
675   
676     case 'd':
677     case 'D':
678       /*----------------------------------------------------------------------*/
679       /* <DIV>                                                                */
680       /*----------------------------------------------------------------------*/
681       if (strcasecmp(name, "div") == 0) {
682         if (handlers[tagDIV].start_tag_handler) 
683           handlers[tagDIV].start_tag_handler(pdoc, child);
684
685         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
686
687         if (handlers[tagDIV].end_tag_handler)
688           handlers[tagDIV].end_tag_handler(pdoc, child);
689       }
690       /*----------------------------------------------------------------------*/
691       /* <DIR>                                                                */
692       /*----------------------------------------------------------------------*/
693       else if (strcasecmp(name, "dir") == 0) {
694         if (handlers[tagDIR].start_tag_handler) 
695           handlers[tagDIR].start_tag_handler(pdoc, child);
696
697         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
698
699         if (handlers[tagDIR].end_tag_handler)
700           handlers[tagDIR].end_tag_handler(pdoc, child);
701       }
702       /*----------------------------------------------------------------------*/
703       /* <DL>                                                                 */
704       /*----------------------------------------------------------------------*/
705       else if (strcasecmp(name, "dl") == 0) {
706         if (handlers[tagDL].start_tag_handler) 
707           handlers[tagDL].start_tag_handler(pdoc, child);
708
709         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
710
711         if (handlers[tagDL].end_tag_handler)
712           handlers[tagDL].end_tag_handler(pdoc, child);
713       }
714       /*----------------------------------------------------------------------*/
715       /* <DT>                                                                 */
716       /*----------------------------------------------------------------------*/
717       else if (strcasecmp(name, "dt") == 0) {
718         if (handlers[tagDT].start_tag_handler) 
719           handlers[tagDT].start_tag_handler(pdoc, child);
720
721         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
722
723         if (handlers[tagDT].end_tag_handler)
724           handlers[tagDT].end_tag_handler(pdoc, child);
725       }
726       /*----------------------------------------------------------------------*/
727       /* <DD>                                                                 */
728       /*----------------------------------------------------------------------*/
729       else if (strcasecmp(name, "dd") == 0) {
730         if (handlers[tagDD].start_tag_handler) 
731           handlers[tagDD].start_tag_handler(pdoc, child);
732
733         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
734
735         if (handlers[tagDD].end_tag_handler)
736           handlers[tagDD].end_tag_handler(pdoc, child);
737       }
738       else {
739         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
740       }
741       break;
742
743     case 'c':
744     case 'C':
745       /*----------------------------------------------------------------------*/
746       /* <CENTER>                                                             */
747       /*----------------------------------------------------------------------*/
748       if (strcasecmp(name, "center") == 0) {
749         if (handlers[tagCENTER].start_tag_handler) 
750           handlers[tagCENTER].start_tag_handler(pdoc, child);
751
752         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
753
754         if (handlers[tagCENTER].end_tag_handler)
755           handlers[tagCENTER].end_tag_handler(pdoc, child);
756       }
757       /*----------------------------------------------------------------------*/
758       /* <CHXJ:IF>                                                            */
759       /*----------------------------------------------------------------------*/
760       else
761       if (strcasecmp(name, "chxj:if") == 0) {
762         if (chxj_chxjif_is_mine(spec, doc, child)) {
763           char* parse_attr;
764
765           parse_attr = qs_get_parse_attr(doc, child, r);
766
767           if (parse_attr && strcasecmp(parse_attr, "true") == 0) {
768             chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
769           }
770           else {
771             if (handlers[tagCHXJIF].start_tag_handler)
772               handlers[tagCHXJIF].start_tag_handler(pdoc, child);
773           }
774         }
775       }
776       else {
777         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
778       }
779       break;
780
781     case 't':
782     case 'T':
783       /*----------------------------------------------------------------------*/
784       /* <TEXTAREA>                                                           */
785       /*----------------------------------------------------------------------*/
786       if (strcasecmp(name, "textarea") == 0) {
787         if (handlers[tagTEXTAREA].start_tag_handler) 
788           handlers[tagTEXTAREA].start_tag_handler(pdoc, child);
789
790         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
791
792         if (handlers[tagTEXTAREA].end_tag_handler)
793           handlers[tagTEXTAREA].end_tag_handler(pdoc, child);
794       }
795       else
796       /*----------------------------------------------------------------------*/
797       /* <TITLE>                                                              */
798       /*----------------------------------------------------------------------*/
799       if (strcasecmp(name, "title") == 0) {
800         if (handlers[tagTITLE].start_tag_handler) 
801           handlers[tagTITLE].start_tag_handler(pdoc, child);
802
803         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
804
805         if (handlers[tagTITLE].end_tag_handler)
806           handlers[tagTITLE].end_tag_handler(pdoc, child);
807       }
808       /*----------------------------------------------------------------------*/
809       /* <TABLE>                                                              */
810       /*----------------------------------------------------------------------*/
811       else
812       if (strcasecmp(name, "table") == 0) {
813         if (handlers[tagTABLE].start_tag_handler) 
814           handlers[tagTABLE].start_tag_handler(pdoc, child);
815
816         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
817
818         if (handlers[tagTABLE].end_tag_handler)
819           handlers[tagTABLE].end_tag_handler(pdoc, child);
820       }
821       /*----------------------------------------------------------------------*/
822       /* <TBODY>                                                              */
823       /*----------------------------------------------------------------------*/
824       else
825       if (strcasecmp(name, "tbody") == 0) {
826         if (handlers[tagTBODY].start_tag_handler) 
827           handlers[tagTBODY].start_tag_handler(pdoc, child);
828
829         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
830
831         if (handlers[tagTBODY].end_tag_handler)
832           handlers[tagTBODY].end_tag_handler(pdoc, child);
833       }
834       /*----------------------------------------------------------------------*/
835       /* <TH>                                                                 */
836       /*----------------------------------------------------------------------*/
837       else
838       if (strcasecmp(name, "th") == 0) {
839         if (handlers[tagTH].start_tag_handler) 
840           handlers[tagTH].start_tag_handler(pdoc, child);
841
842         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
843
844         if (handlers[tagTH].end_tag_handler)
845           handlers[tagTH].end_tag_handler(pdoc, child);
846       }
847       /*----------------------------------------------------------------------*/
848       /* <TR>                                                                 */
849       /*----------------------------------------------------------------------*/
850       else
851       if (strcasecmp(name, "tr") == 0) {
852         if (handlers[tagTR].start_tag_handler) 
853           handlers[tagTR].start_tag_handler(pdoc, child);
854
855         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
856
857         if (handlers[tagTR].end_tag_handler)
858           handlers[tagTR].end_tag_handler(pdoc, child);
859       }
860       /*----------------------------------------------------------------------*/
861       /* <TD>                                                                 */
862       /*----------------------------------------------------------------------*/
863       else
864       if (strcasecmp(name, "td") == 0) {
865         if (handlers[tagTD].start_tag_handler) 
866           handlers[tagTD].start_tag_handler(pdoc, child);
867
868         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
869
870         if (handlers[tagTD].end_tag_handler)
871           handlers[tagTD].end_tag_handler(pdoc, child);
872       }
873       /*----------------------------------------------------------------------*/
874       /* NORMAL TEXT                                                          */
875       /*----------------------------------------------------------------------*/
876       else
877       if (strcasecmp(name, "text") == 0) {
878         if (handlers[tagTEXT].start_tag_handler)
879           handlers[tagTEXT].start_tag_handler(pdoc, child);
880       }
881       else {
882         chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
883       }
884       break;
885
886     default:
887       chxj_node_exchange(spec, r, pdoc, doc, child, indent+1);
888     }
889   }
890
891   return NULL;
892 }
893 /*
894  * vim:ts=2 et
895  */