2 * Copyright (C) 2005-2009 QSDN,Inc. All rights reserved.
3 * Copyright (C) 2005 Atsushi Konno All rights reserved.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 tag_handlers chxj_tag_handlers[] = {
21 .type = CHXJ_SPEC_UNKNOWN,
25 .type = CHXJ_SPEC_Chtml_1_0,
26 .handler = chtml10_handler,
29 .type = CHXJ_SPEC_Chtml_2_0,
30 .handler = chtml20_handler,
33 .type = CHXJ_SPEC_Chtml_3_0,
34 .handler = chtml30_handler,
37 .type = CHXJ_SPEC_Chtml_4_0,
38 .handler = chtml40_handler,
41 .type = CHXJ_SPEC_Chtml_5_0,
42 .handler = chtml50_handler,
45 .type = CHXJ_SPEC_Chtml_6_0,
46 .handler = chtml50_handler,
49 .type = CHXJ_SPEC_Chtml_7_0,
50 .handler = chtml50_handler,
53 .type = CHXJ_SPEC_XHtml_Mobile_1_0,
54 .handler = xhtml_handler,
57 .type = CHXJ_SPEC_Hdml,
58 .handler = hdml_handler,
61 .type = CHXJ_SPEC_Jhtml,
62 .handler = jhtml_handler,
65 .type = CHXJ_SPEC_Jxhtml,
66 .handler = jxhtml_handler,
69 .type = CHXJ_SPEC_HTML,
76 * It is main processing of conversion from CHTML to XXML.
80 * @param pdoc [i/o] The pointer to the XXML structure is specified.
81 * @param doc [i/o] The pointer to the XXML structure is specified.
82 * @param node [i] The pointer to a current node is specified.
83 * @param indent [i] The depth of the node processing it now is specified.
85 * @return The character string after it converts it is returned.
98 tag_handler *handlers;
101 handlers = chxj_tag_handlers[spec->html_spec_type].handler;
103 /*--------------------------------------------------------------------------*/
104 /* It is the main loop of the conversion processing. */
105 /*--------------------------------------------------------------------------*/
106 for (child = qs_get_child_node(doc,node);
108 child = qs_get_next_node(doc,child)) {
109 char *name = qs_get_node_name(doc,child);
113 /*----------------------------------------------------------------------*/
115 /*----------------------------------------------------------------------*/
116 if (strcasecmp(name, "html") == 0) {
117 if (handlers[tagHTML].start_tag_handler)
118 handlers[tagHTML].start_tag_handler(pdoc, child);
120 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
122 if (handlers[tagHTML].end_tag_handler)
123 handlers[tagHTML].end_tag_handler(pdoc, child);
125 /*----------------------------------------------------------------------*/
127 /*----------------------------------------------------------------------*/
129 if (strcasecmp(name, "head") == 0) {
130 if (handlers[tagHEAD].start_tag_handler)
131 handlers[tagHEAD].start_tag_handler(pdoc, child);
133 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
135 if (handlers[tagHEAD].end_tag_handler)
136 handlers[tagHEAD].end_tag_handler(pdoc, child);
138 /*----------------------------------------------------------------------*/
140 /*----------------------------------------------------------------------*/
142 if (strcasecmp(name, "hr") == 0) {
143 if (handlers[tagHR].start_tag_handler)
144 handlers[tagHR].start_tag_handler(pdoc, child);
146 if (handlers[tagHR].end_tag_handler)
147 handlers[tagHR].end_tag_handler(pdoc, child);
149 /*----------------------------------------------------------------------*/
151 /*----------------------------------------------------------------------*/
153 if (strcasecmp(name, "h1") == 0) {
154 if (handlers[tagH1].start_tag_handler)
155 handlers[tagH1].start_tag_handler(pdoc, child);
157 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
159 if (handlers[tagH1].end_tag_handler)
160 handlers[tagH1].end_tag_handler(pdoc, child);
162 /*----------------------------------------------------------------------*/
164 /*----------------------------------------------------------------------*/
166 if (strcasecmp(name, "h2") == 0) {
167 if (handlers[tagH2].start_tag_handler)
168 handlers[tagH2].start_tag_handler(pdoc, child);
170 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
172 if (handlers[tagH2].end_tag_handler)
173 handlers[tagH2].end_tag_handler(pdoc, child);
175 /*----------------------------------------------------------------------*/
177 /*----------------------------------------------------------------------*/
179 if (strcasecmp(name, "h3") == 0) {
180 if (handlers[tagH3].start_tag_handler)
181 handlers[tagH3].start_tag_handler(pdoc, child);
183 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
185 if (handlers[tagH3].end_tag_handler)
186 handlers[tagH3].end_tag_handler(pdoc, child);
188 /*----------------------------------------------------------------------*/
190 /*----------------------------------------------------------------------*/
192 if (strcasecmp(name, "h4") == 0) {
193 if (handlers[tagH4].start_tag_handler)
194 handlers[tagH4].start_tag_handler(pdoc, child);
196 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
198 if (handlers[tagH4].end_tag_handler)
199 handlers[tagH4].end_tag_handler(pdoc, child);
201 /*----------------------------------------------------------------------*/
203 /*----------------------------------------------------------------------*/
205 if (strcasecmp(name, "h5") == 0) {
206 if (handlers[tagH5].start_tag_handler)
207 handlers[tagH5].start_tag_handler(pdoc, child);
209 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
211 if (handlers[tagH5].end_tag_handler)
212 handlers[tagH5].end_tag_handler(pdoc, child);
214 /*----------------------------------------------------------------------*/
216 /*----------------------------------------------------------------------*/
218 if (strcasecmp(name, "h6") == 0) {
219 if (handlers[tagH6].start_tag_handler)
220 handlers[tagH6].start_tag_handler(pdoc, child);
222 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
224 if (handlers[tagH6].end_tag_handler)
225 handlers[tagH6].end_tag_handler(pdoc, child);
228 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
235 /*----------------------------------------------------------------------*/
237 /*----------------------------------------------------------------------*/
238 if (strcasecmp(name, "p") == 0) {
239 if (handlers[tagP].start_tag_handler)
240 handlers[tagP].start_tag_handler(pdoc, child);
242 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
244 if (handlers[tagP].end_tag_handler)
245 handlers[tagP].end_tag_handler(pdoc, child);
247 /*----------------------------------------------------------------------*/
249 /*----------------------------------------------------------------------*/
250 else if (strcasecmp(name, "pre") == 0) {
251 if (handlers[tagPRE].start_tag_handler)
252 handlers[tagPRE].start_tag_handler(pdoc, child);
254 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
256 if (handlers[tagPRE].end_tag_handler)
257 handlers[tagPRE].end_tag_handler(pdoc, child);
259 /*----------------------------------------------------------------------*/
261 /*----------------------------------------------------------------------*/
262 else if (strcasecmp(name, "plaintext") == 0) {
263 if (handlers[tagPLAINTEXT].start_tag_handler)
264 handlers[tagPLAINTEXT].start_tag_handler(pdoc, child);
266 if (handlers[tagPLAINTEXT].end_tag_handler)
267 handlers[tagPLAINTEXT].end_tag_handler(pdoc, child);
269 /*----------------------------------------------------------------------*/
271 /*----------------------------------------------------------------------*/
272 else if (strcasecmp(name, "param") == 0) {
273 /* ignore param tag block. */
276 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
282 /*----------------------------------------------------------------------*/
284 /*----------------------------------------------------------------------*/
285 if (strcasecmp(name, "nobr") == 0) {
286 if (handlers[tagNOBR].start_tag_handler)
287 handlers[tagNOBR].start_tag_handler(pdoc, child);
289 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
291 if (handlers[tagNOBR].end_tag_handler)
292 handlers[tagNOBR].end_tag_handler(pdoc, child);
295 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
301 /*----------------------------------------------------------------------*/
303 /*----------------------------------------------------------------------*/
304 if (strcasecmp(name, "ul") == 0) {
305 if (handlers[tagUL].start_tag_handler)
306 handlers[tagUL].start_tag_handler(pdoc, child);
308 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
310 if (handlers[tagUL].end_tag_handler)
311 handlers[tagUL].end_tag_handler(pdoc, child);
314 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
320 /*----------------------------------------------------------------------*/
322 /*----------------------------------------------------------------------*/
323 if (strcasecmp(name, "li") == 0) {
324 if (handlers[tagLI].start_tag_handler)
325 handlers[tagLI].start_tag_handler(pdoc, child);
327 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
329 if (handlers[tagLI].end_tag_handler)
330 handlers[tagLI].end_tag_handler(pdoc, child);
333 /*----------------------------------------------------------------------*/
335 /*----------------------------------------------------------------------*/
336 if (strcasecmp(name, "legend") == 0) {
337 if (handlers[tagLEGEND].start_tag_handler)
338 handlers[tagLEGEND].start_tag_handler(pdoc, child);
340 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
342 if (handlers[tagLEGEND].end_tag_handler)
343 handlers[tagLEGEND].end_tag_handler(pdoc, child);
346 /*----------------------------------------------------------------------*/
348 /*----------------------------------------------------------------------*/
349 if (strcasecmp(name, "label") == 0) {
350 if (handlers[tagLABEL].start_tag_handler)
351 handlers[tagLABEL].start_tag_handler(pdoc, child);
353 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
355 if (handlers[tagLABEL].end_tag_handler)
356 handlers[tagLABEL].end_tag_handler(pdoc, child);
359 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
366 /*----------------------------------------------------------------------*/
368 /*----------------------------------------------------------------------*/
369 if (strcasecmp(name, "ol") == 0) {
370 if (handlers[tagOL].start_tag_handler)
371 handlers[tagOL].start_tag_handler(pdoc, child);
373 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
375 if (handlers[tagOL].end_tag_handler)
376 handlers[tagOL].end_tag_handler(pdoc, child);
379 /*----------------------------------------------------------------------*/
381 /*----------------------------------------------------------------------*/
382 if (strcasecmp(name, "option") == 0) {
383 if (handlers[tagOPTION].start_tag_handler)
384 handlers[tagOPTION].start_tag_handler(pdoc, child);
386 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
388 if (handlers[tagOPTION].end_tag_handler)
389 handlers[tagOPTION].end_tag_handler(pdoc, child);
392 /*----------------------------------------------------------------------*/
394 /*----------------------------------------------------------------------*/
395 if (strcasecmp(name, "object") == 0) {
396 /* ignore object block */
399 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
406 /*----------------------------------------------------------------------*/
408 /*----------------------------------------------------------------------*/
409 if (strcasecmp(name, "meta") == 0) {
410 if (handlers[tagMETA].start_tag_handler)
411 handlers[tagMETA].start_tag_handler(pdoc, child);
413 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
415 if (handlers[tagMETA].end_tag_handler)
416 handlers[tagMETA].end_tag_handler(pdoc, child);
418 /*----------------------------------------------------------------------*/
420 /*----------------------------------------------------------------------*/
421 else if (strcasecmp(name, "menu") == 0) {
422 if (handlers[tagMENU].start_tag_handler)
423 handlers[tagMENU].start_tag_handler(pdoc, child);
425 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
427 if (handlers[tagMENU].end_tag_handler)
428 handlers[tagMENU].end_tag_handler(pdoc, child);
430 /*----------------------------------------------------------------------*/
432 /*----------------------------------------------------------------------*/
433 else if (strcasecmp(name, "marquee") == 0) {
434 if (handlers[tagMARQUEE].start_tag_handler)
435 handlers[tagMARQUEE].start_tag_handler(pdoc, child);
437 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
439 if (handlers[tagMARQUEE].end_tag_handler)
440 handlers[tagMARQUEE].end_tag_handler(pdoc, child);
443 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
449 /*----------------------------------------------------------------------*/
451 /*----------------------------------------------------------------------*/
452 if (strlen(name) == 1) {
453 if (handlers[tagB].start_tag_handler)
454 handlers[tagB].start_tag_handler(pdoc, child);
456 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
458 if (handlers[tagB].end_tag_handler)
459 handlers[tagB].end_tag_handler(pdoc, child);
462 /*----------------------------------------------------------------------*/
464 /*----------------------------------------------------------------------*/
465 if (strcasecmp(name, "base") == 0) {
466 if (handlers[tagBASE].start_tag_handler)
467 handlers[tagBASE].start_tag_handler(pdoc, child);
469 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
471 if (handlers[tagBASE].end_tag_handler)
472 handlers[tagBASE].end_tag_handler(pdoc, child);
474 /*----------------------------------------------------------------------*/
476 /*----------------------------------------------------------------------*/
478 if (strcasecmp(name, "body") == 0) {
479 if (handlers[tagBODY].start_tag_handler)
480 handlers[tagBODY].start_tag_handler(pdoc, child);
482 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
484 if (handlers[tagBODY].end_tag_handler)
485 handlers[tagBODY].end_tag_handler(pdoc, child);
487 /*----------------------------------------------------------------------*/
489 /*----------------------------------------------------------------------*/
490 else if (strcasecmp(name, "br") == 0) {
491 if (handlers[tagBR].start_tag_handler)
492 handlers[tagBR].start_tag_handler(pdoc, child);
494 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
496 if (handlers[tagBR].end_tag_handler)
497 handlers[tagBR].end_tag_handler(pdoc, child);
499 /*----------------------------------------------------------------------*/
501 /*----------------------------------------------------------------------*/
502 else if (strcasecmp(name, "blockquote") == 0) {
503 if (handlers[tagBLOCKQUOTE].start_tag_handler)
504 handlers[tagBLOCKQUOTE].start_tag_handler(pdoc, child);
506 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
508 if (handlers[tagBLOCKQUOTE].end_tag_handler)
509 handlers[tagBLOCKQUOTE].end_tag_handler(pdoc, child);
511 /*----------------------------------------------------------------------*/
513 /*----------------------------------------------------------------------*/
514 else if (strcasecmp(name, "blink") == 0) {
515 if (handlers[tagBLINK].start_tag_handler)
516 handlers[tagBLINK].start_tag_handler(pdoc, child);
518 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
520 if (handlers[tagBLINK].end_tag_handler)
521 handlers[tagBLINK].end_tag_handler(pdoc, child);
524 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
530 /*----------------------------------------------------------------------*/
532 /*----------------------------------------------------------------------*/
533 if (strcasecmp(name, "a") == 0) {
534 if (handlers[tagA].start_tag_handler)
535 handlers[tagA].start_tag_handler(pdoc, child);
537 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
539 if (handlers[tagA].end_tag_handler)
540 handlers[tagA].end_tag_handler(pdoc, child);
543 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
549 /*----------------------------------------------------------------------*/
551 /*----------------------------------------------------------------------*/
552 if (strcasecmp(name, "font") == 0) {
553 if (handlers[tagFONT].start_tag_handler)
554 handlers[tagFONT].start_tag_handler(pdoc, child);
556 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
558 if (handlers[tagFONT].end_tag_handler)
559 handlers[tagFONT].end_tag_handler(pdoc, child);
561 /*----------------------------------------------------------------------*/
563 /*----------------------------------------------------------------------*/
565 if (strcasecmp(name, "form") == 0) {
566 if (handlers[tagFORM].start_tag_handler)
567 handlers[tagFORM].start_tag_handler(pdoc, child);
569 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
571 if (handlers[tagFORM].end_tag_handler)
572 handlers[tagFORM].end_tag_handler(pdoc, child);
574 /*----------------------------------------------------------------------*/
576 /*----------------------------------------------------------------------*/
578 if (strcasecmp(name, "fieldset") == 0) {
579 if (handlers[tagFIELDSET].start_tag_handler)
580 handlers[tagFIELDSET].start_tag_handler(pdoc, child);
582 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
584 if (handlers[tagFIELDSET].end_tag_handler)
585 handlers[tagFIELDSET].end_tag_handler(pdoc, child);
588 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
594 /*----------------------------------------------------------------------*/
596 /*----------------------------------------------------------------------*/
597 if (strcasecmp(name, "input") == 0) {
598 if (handlers[tagINPUT].start_tag_handler)
599 handlers[tagINPUT].start_tag_handler(pdoc, child);
601 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
603 if (handlers[tagINPUT].end_tag_handler)
604 handlers[tagINPUT].end_tag_handler(pdoc, child);
606 /*----------------------------------------------------------------------*/
608 /*----------------------------------------------------------------------*/
610 if (strcasecmp(name, "img") == 0) {
611 if (handlers[tagIMG].start_tag_handler)
612 handlers[tagIMG].start_tag_handler(pdoc, child);
614 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
616 if (handlers[tagIMG].end_tag_handler)
617 handlers[tagIMG].end_tag_handler(pdoc, child);
620 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
626 /*----------------------------------------------------------------------*/
628 /*----------------------------------------------------------------------*/
629 if (strcasecmp(name, "select") == 0) {
630 if (handlers[tagSELECT].start_tag_handler)
631 handlers[tagSELECT].start_tag_handler(pdoc, child);
633 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
635 if (handlers[tagSELECT].end_tag_handler)
636 handlers[tagSELECT].end_tag_handler(pdoc, child);
638 /*----------------------------------------------------------------------*/
640 /*----------------------------------------------------------------------*/
642 if (strcasecmp(name, "style") == 0) {
643 if (handlers[tagSTYLE].start_tag_handler)
644 handlers[tagSTYLE].start_tag_handler(pdoc, child);
646 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
649 if (handlers[tagSTYLE].end_tag_handler)
650 handlers[tagSTYLE].end_tag_handler(pdoc, child);
652 /*----------------------------------------------------------------------*/
654 /*----------------------------------------------------------------------*/
656 if (strcasecmp(name, "span") == 0) {
657 if (handlers[tagSPAN].start_tag_handler)
658 handlers[tagSPAN].start_tag_handler(pdoc, child);
660 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
662 if (handlers[tagSPAN].end_tag_handler)
663 handlers[tagSPAN].end_tag_handler(pdoc, child);
665 /*----------------------------------------------------------------------*/
667 /*----------------------------------------------------------------------*/
669 if (strcasecmp(name, "small") == 0) {
670 if (handlers[tagSMALL].start_tag_handler)
671 handlers[tagSMALL].start_tag_handler(pdoc, child);
673 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
675 if (handlers[tagSMALL].end_tag_handler)
676 handlers[tagSMALL].end_tag_handler(pdoc, child);
678 /*----------------------------------------------------------------------*/
680 /*----------------------------------------------------------------------*/
682 if (strcasecmp(name, "script") == 0) {
683 /* ignore script block */
686 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
692 /*----------------------------------------------------------------------*/
694 /*----------------------------------------------------------------------*/
695 if (strcasecmp(name, "div") == 0) {
696 if (handlers[tagDIV].start_tag_handler)
697 handlers[tagDIV].start_tag_handler(pdoc, child);
699 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
701 if (handlers[tagDIV].end_tag_handler)
702 handlers[tagDIV].end_tag_handler(pdoc, child);
704 /*----------------------------------------------------------------------*/
706 /*----------------------------------------------------------------------*/
707 else if (strcasecmp(name, "dir") == 0) {
708 if (handlers[tagDIR].start_tag_handler)
709 handlers[tagDIR].start_tag_handler(pdoc, child);
711 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
713 if (handlers[tagDIR].end_tag_handler)
714 handlers[tagDIR].end_tag_handler(pdoc, child);
716 /*----------------------------------------------------------------------*/
718 /*----------------------------------------------------------------------*/
719 else if (strcasecmp(name, "dl") == 0) {
720 if (handlers[tagDL].start_tag_handler)
721 handlers[tagDL].start_tag_handler(pdoc, child);
723 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
725 if (handlers[tagDL].end_tag_handler)
726 handlers[tagDL].end_tag_handler(pdoc, child);
728 /*----------------------------------------------------------------------*/
730 /*----------------------------------------------------------------------*/
731 else if (strcasecmp(name, "dt") == 0) {
732 if (handlers[tagDT].start_tag_handler)
733 handlers[tagDT].start_tag_handler(pdoc, child);
735 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
737 if (handlers[tagDT].end_tag_handler)
738 handlers[tagDT].end_tag_handler(pdoc, child);
740 /*----------------------------------------------------------------------*/
742 /*----------------------------------------------------------------------*/
743 else if (strcasecmp(name, "dd") == 0) {
744 if (handlers[tagDD].start_tag_handler)
745 handlers[tagDD].start_tag_handler(pdoc, child);
747 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
749 if (handlers[tagDD].end_tag_handler)
750 handlers[tagDD].end_tag_handler(pdoc, child);
753 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
759 /*----------------------------------------------------------------------*/
761 /*----------------------------------------------------------------------*/
762 if (strcasecmp(name, QS_PARSE_NL_MARK) == 0) {
763 if (handlers[tagNLMARK].start_tag_handler)
764 handlers[tagNLMARK].start_tag_handler(pdoc, child);
767 /*----------------------------------------------------------------------*/
769 /*----------------------------------------------------------------------*/
770 if (strcasecmp(name, "center") == 0) {
771 if (handlers[tagCENTER].start_tag_handler)
772 handlers[tagCENTER].start_tag_handler(pdoc, child);
774 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
776 if (handlers[tagCENTER].end_tag_handler)
777 handlers[tagCENTER].end_tag_handler(pdoc, child);
779 /*----------------------------------------------------------------------*/
781 /*----------------------------------------------------------------------*/
783 if (strcasecmp(name, "chxj:if") == 0) {
784 if (chxj_chxjif_is_mine(spec, doc, child)) {
787 parse_attr = qs_get_parse_attr(doc, child, r->pool);
789 if (parse_attr && strcasecmp(parse_attr, "true") == 0) {
790 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
793 if (handlers[tagCHXJIF].start_tag_handler)
794 handlers[tagCHXJIF].start_tag_handler(pdoc, child);
798 /*----------------------------------------------------------------------*/
800 /*----------------------------------------------------------------------*/
802 if (strcasecmp(name, "chxj:raw") == 0) {
803 if (handlers[tagCHXJRAW].start_tag_handler) {
804 handlers[tagCHXJRAW].start_tag_handler(pdoc, child);
808 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
814 /*----------------------------------------------------------------------*/
816 /*----------------------------------------------------------------------*/
817 if (strcasecmp(name, "textarea") == 0) {
818 if (handlers[tagTEXTAREA].start_tag_handler)
819 handlers[tagTEXTAREA].start_tag_handler(pdoc, child);
821 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
823 if (handlers[tagTEXTAREA].end_tag_handler)
824 handlers[tagTEXTAREA].end_tag_handler(pdoc, child);
827 /*----------------------------------------------------------------------*/
829 /*----------------------------------------------------------------------*/
830 if (strcasecmp(name, "title") == 0) {
831 if (handlers[tagTITLE].start_tag_handler)
832 handlers[tagTITLE].start_tag_handler(pdoc, child);
834 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
836 if (handlers[tagTITLE].end_tag_handler)
837 handlers[tagTITLE].end_tag_handler(pdoc, child);
839 /*----------------------------------------------------------------------*/
841 /*----------------------------------------------------------------------*/
843 if (strcasecmp(name, "table") == 0) {
844 if (handlers[tagTABLE].start_tag_handler)
845 handlers[tagTABLE].start_tag_handler(pdoc, child);
847 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
849 if (handlers[tagTABLE].end_tag_handler)
850 handlers[tagTABLE].end_tag_handler(pdoc, child);
852 /*----------------------------------------------------------------------*/
854 /*----------------------------------------------------------------------*/
856 if (strcasecmp(name, "tbody") == 0) {
857 if (handlers[tagTBODY].start_tag_handler)
858 handlers[tagTBODY].start_tag_handler(pdoc, child);
860 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
862 if (handlers[tagTBODY].end_tag_handler)
863 handlers[tagTBODY].end_tag_handler(pdoc, child);
865 /*----------------------------------------------------------------------*/
867 /*----------------------------------------------------------------------*/
869 if (strcasecmp(name, "th") == 0) {
870 if (handlers[tagTH].start_tag_handler)
871 handlers[tagTH].start_tag_handler(pdoc, child);
873 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
875 if (handlers[tagTH].end_tag_handler)
876 handlers[tagTH].end_tag_handler(pdoc, child);
878 /*----------------------------------------------------------------------*/
880 /*----------------------------------------------------------------------*/
882 if (strcasecmp(name, "tr") == 0) {
883 if (handlers[tagTR].start_tag_handler)
884 handlers[tagTR].start_tag_handler(pdoc, child);
886 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
888 if (handlers[tagTR].end_tag_handler)
889 handlers[tagTR].end_tag_handler(pdoc, child);
891 /*----------------------------------------------------------------------*/
893 /*----------------------------------------------------------------------*/
895 if (strcasecmp(name, "td") == 0) {
896 if (handlers[tagTD].start_tag_handler)
897 handlers[tagTD].start_tag_handler(pdoc, child);
899 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
901 if (handlers[tagTD].end_tag_handler)
902 handlers[tagTD].end_tag_handler(pdoc, child);
904 /*----------------------------------------------------------------------*/
906 /*----------------------------------------------------------------------*/
908 if (strcasecmp(name, "text") == 0) {
909 if (handlers[tagTEXT].start_tag_handler)
910 handlers[tagTEXT].start_tag_handler(pdoc, child);
913 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
918 chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
927 chxj_node_convert_chxjif_only(
937 apr_size_t dst_pos = 0;
940 memset(&doc, 0, sizeof(Doc));
942 apr_pool_create(&doc.pool, r->pool);
945 dst = apr_palloc(doc.pool, *len + 1);
946 memset(dst, 0, *len + 1);
948 for (ii =0; ii<*len; ii++) {
949 if (src[ii + 0] == '<') {
950 apr_size_t endpoint = chxj_cut_tag(&src[ii + 0], *len - ii);
951 Node *node = qs_parse_tag(&doc, &src[ii], endpoint);
952 char *name = qs_get_node_name(&doc,node);
953 if (STRCASEEQ('c','C',"chxj:if", name)) {
954 if (! chxj_chxjif_is_mine(spec, &doc, node)) {
959 else if (STRCASEEQ('/','/', "/chxj:if", name)) {
966 memcpy(&dst[dst_pos], &src[ii], endpoint + 1);
967 dst_pos += (endpoint + 1);
969 dst[dst_pos++] = src[ii];
979 if (is_sjis_kanji(src[ii])) {
980 dst[dst_pos++] = src[ii++];
981 dst[dst_pos++] = src[ii];
984 dst[dst_pos++] = src[ii];