OSDN Git Service

* Added <font size> attribute for au XHTML converter.
[modchxj/mod_chxj.git] / src / chxj_xhtml_mobile_1_0.c
1 /*
2  * Copyright (C) 2005-2008 Atsushi Konno All rights reserved.
3  * Copyright (C) 2005 QSDN,Inc. 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 #include "chxj_encoding.h"
19 #include "chxj_xhtml_mobile_1_0.h"
20 #include "chxj_hdml.h"
21 #include "chxj_dump.h"
22 #include "chxj_img_conv.h"
23 #include "chxj_qr_code.h"
24 #include "chxj_buffered_write.h"
25 #include "chxj_str_util.h"
26
27 #define GET_XHTML(X) ((xhtml_t*)(X))
28 #undef W_L
29 #undef W_V
30 #define W_L(X)          do { xhtml->out = BUFFERED_WRITE_LITERAL(xhtml->out, &doc->buf, (X)); } while(0)
31 #define W_V(X)          do { xhtml->out = (X) ? BUFFERED_WRITE_VALUE(xhtml->out, &doc->buf, (X))  \
32                                                : BUFFERED_WRITE_LITERAL(xhtml->out, &doc->buf, ""); } while(0)
33
34 static char *s_xhtml_1_0_start_html_tag   (void *pdoc, Node *node);
35 static char *s_xhtml_1_0_end_html_tag     (void *pdoc, Node *node);
36 static char *s_xhtml_1_0_start_p_tag      (void *pdoc, Node *node);
37 static char *s_xhtml_1_0_end_p_tag        (void *pdoc, Node *node);
38 static char *s_xhtml_1_0_start_pre_tag    (void *pdoc, Node *node);
39 static char *s_xhtml_1_0_end_pre_tag      (void *pdoc, Node *node);
40 static char *s_xhtml_1_0_start_ul_tag     (void *pdoc, Node *node);
41 static char *s_xhtml_1_0_end_ul_tag       (void *pdoc, Node *node);
42 static char *s_xhtml_1_0_start_h1_tag     (void *pdoc, Node *node);
43 static char *s_xhtml_1_0_end_h1_tag       (void *pdoc, Node *node);
44 static char *s_xhtml_1_0_start_h2_tag     (void *pdoc, Node *node);
45 static char *s_xhtml_1_0_end_h2_tag       (void *pdoc, Node *node);
46 static char *s_xhtml_1_0_start_h3_tag     (void *pdoc, Node *node);
47 static char *s_xhtml_1_0_end_h3_tag       (void *pdoc, Node *node);
48 static char *s_xhtml_1_0_start_h4_tag     (void *pdoc, Node *node);
49 static char *s_xhtml_1_0_end_h4_tag       (void *pdoc, Node *node);
50 static char *s_xhtml_1_0_start_h5_tag     (void *pdoc, Node *node);
51 static char *s_xhtml_1_0_end_h5_tag       (void *pdoc, Node *node);
52 static char *s_xhtml_1_0_start_h6_tag     (void *pdoc, Node *node);
53 static char *s_xhtml_1_0_end_h6_tag       (void *pdoc, Node *node);
54 static char *s_xhtml_1_0_start_ol_tag     (void *pdoc, Node *node);
55 static char *s_xhtml_1_0_end_ol_tag       (void *pdoc, Node *node);
56 static char *s_xhtml_1_0_start_li_tag     (void *pdoc, Node *node);
57 static char *s_xhtml_1_0_end_li_tag       (void *pdoc, Node *node);
58 static char *s_xhtml_1_0_start_meta_tag   (void *pdoc, Node *node);
59 static char *s_xhtml_1_0_end_meta_tag     (void *pdoc, Node *node);
60 static char *s_xhtml_1_0_start_head_tag   (void *pdoc, Node *node);
61 static char *s_xhtml_1_0_end_head_tag     (void *pdoc, Node *node);
62 static char *s_xhtml_1_0_start_title_tag  (void *pdoc, Node *node);
63 static char *s_xhtml_1_0_end_title_tag    (void *pdoc, Node *node);
64 static char *s_xhtml_1_0_start_base_tag   (void *pdoc, Node *node);
65 static char *s_xhtml_1_0_end_base_tag     (void *pdoc, Node *node);
66 static char *s_xhtml_1_0_start_body_tag   (void *pdoc, Node *node);
67 static char *s_xhtml_1_0_end_body_tag     (void *pdoc, Node *node);
68 static char *s_xhtml_1_0_start_a_tag      (void *pdoc, Node *node);
69 static char *s_xhtml_1_0_end_a_tag        (void *pdoc, Node *node);
70 static char *s_xhtml_1_0_start_br_tag     (void *pdoc, Node *node);
71 static char *s_xhtml_1_0_end_br_tag       (void *pdoc, Node *node);
72 static char *s_xhtml_1_0_start_tr_tag     (void *pdoc, Node *node);
73 static char *s_xhtml_1_0_end_tr_tag       (void *pdoc, Node *node);
74 static char *s_xhtml_1_0_start_font_tag   (void *pdoc, Node *node);
75 static char *s_xhtml_1_0_end_font_tag     (void *pdoc, Node *node);
76 static char *s_xhtml_1_0_start_form_tag   (void *pdoc, Node *node);
77 static char *s_xhtml_1_0_end_form_tag     (void *pdoc, Node *node);
78 static char *s_xhtml_1_0_start_input_tag  (void *pdoc, Node *node);
79 static char *s_xhtml_1_0_end_input_tag    (void *pdoc, Node *node);
80 static char *s_xhtml_1_0_start_center_tag (void *pdoc, Node *node);
81 static char *s_xhtml_1_0_end_center_tag   (void *pdoc, Node *node);
82 static char *s_xhtml_1_0_start_hr_tag     (void *pdoc, Node *node);
83 static char *s_xhtml_1_0_end_hr_tag       (void *pdoc, Node *node);
84 static char *s_xhtml_1_0_start_img_tag    (void *pdoc, Node *node);
85 static char *s_xhtml_1_0_end_img_tag      (void *pdoc, Node *node);
86 static char *s_xhtml_1_0_start_select_tag (void *pdoc, Node *node);
87 static char *s_xhtml_1_0_end_select_tag   (void *pdoc, Node *node);
88 static char *s_xhtml_1_0_start_option_tag (void *pdoc, Node *node);
89 static char *s_xhtml_1_0_end_option_tag   (void *pdoc, Node *node);
90 static char *s_xhtml_1_0_start_div_tag       (void *pdoc, Node *node);
91 static char *s_xhtml_1_0_end_div_tag         (void *pdoc, Node *node);
92 static char *s_xhtml_1_0_start_textarea_tag  (void *pdoc, Node *node);
93 static char *s_xhtml_1_0_end_textarea_tag    (void *pdoc, Node *node);
94 static char *s_xhtml_1_0_start_b_tag         (void *pdoc, Node *node);
95 static char *s_xhtml_1_0_end_b_tag           (void *pdoc, Node *node);
96 static char *s_xhtml_1_0_chxjif_tag          (void *pdoc, Node *node);
97 static char *s_xhtml_1_0_start_blockquote_tag(void *pdoc, Node *node);
98 static char *s_xhtml_1_0_end_blockquote_tag  (void *pdoc, Node *node);
99 static char *s_xhtml_1_0_start_dir_tag       (void *pdoc, Node *node);
100 static char *s_xhtml_1_0_end_dir_tag         (void *pdoc, Node *node);
101 static char *s_xhtml_1_0_start_dl_tag        (void *pdoc, Node *node);
102 static char *s_xhtml_1_0_end_dl_tag          (void *pdoc, Node *node);
103 static char *s_xhtml_1_0_start_dt_tag        (void *pdoc, Node *node);
104 static char *s_xhtml_1_0_end_dt_tag          (void *pdoc, Node *node);
105 static char *s_xhtml_1_0_start_dd_tag        (void *pdoc, Node *node);
106 static char *s_xhtml_1_0_end_dd_tag          (void *pdoc, Node *node);
107 static char *s_xhtml_1_0_start_menu_tag      (void *pdoc, Node *node);
108 static char *s_xhtml_1_0_end_menu_tag        (void *pdoc, Node *node);
109 static char *s_xhtml_1_0_start_plaintext_tag       (void *pdoc, Node *node);
110 static char *s_xhtml_1_0_start_plaintext_tag_inner (void *pdoc, Node *node);
111 static char *s_xhtml_1_0_end_plaintext_tag         (void *pdoc, Node *node);
112 static char *s_xhtml_1_0_start_blink_tag     (void *pdoc, Node *node);
113 static char *s_xhtml_1_0_end_blink_tag       (void *pdoc, Node *node);
114 static char *s_xhtml_1_0_start_marquee_tag   (void *pdoc, Node *node);
115 static char *s_xhtml_1_0_end_marquee_tag     (void *pdoc, Node *node);
116
117 static void  s_init_xhtml(xhtml_t *xhtml, Doc *doc, request_rec *r, device_table *spec);
118 static int   s_xhtml_search_emoji(xhtml_t *xhtml, char *txt, char **rslt);
119 static char *s_xhtml_1_0_text_tag(void *pdoc, Node *child);
120
121
122 tag_handler xhtml_handler[] = {
123   /* tagHTML */
124   {
125     s_xhtml_1_0_start_html_tag,
126     s_xhtml_1_0_end_html_tag,
127   },
128   /* tagMETA */
129   {
130     s_xhtml_1_0_start_meta_tag,
131     s_xhtml_1_0_end_meta_tag,
132   },
133   /* tagTEXTAREA */
134   {
135     s_xhtml_1_0_start_textarea_tag,
136     s_xhtml_1_0_end_textarea_tag,
137   },
138   /* tagP */
139   {
140     s_xhtml_1_0_start_p_tag,
141     s_xhtml_1_0_end_p_tag,
142   },
143   /* tagPRE */
144   {
145     s_xhtml_1_0_start_pre_tag,
146     s_xhtml_1_0_end_pre_tag,
147   },
148   /* tagUL */
149   {
150     s_xhtml_1_0_start_ul_tag,
151     s_xhtml_1_0_end_ul_tag,
152   },
153   /* tagLI */
154   {
155     s_xhtml_1_0_start_li_tag,
156     s_xhtml_1_0_end_li_tag,
157   },
158   /* tagOL */
159   {
160     s_xhtml_1_0_start_ol_tag,
161     s_xhtml_1_0_end_ol_tag,
162   },
163   /* tagH1 */
164   {
165     s_xhtml_1_0_start_h1_tag,
166     s_xhtml_1_0_end_h1_tag,
167   },
168   /* tagH2 */
169   {
170     s_xhtml_1_0_start_h2_tag,
171     s_xhtml_1_0_end_h2_tag,
172   },
173   /* tagH3 */
174   {
175     s_xhtml_1_0_start_h3_tag,
176     s_xhtml_1_0_end_h3_tag,
177   },
178   /* tagH4 */
179   {
180     s_xhtml_1_0_start_h4_tag,
181     s_xhtml_1_0_end_h4_tag,
182   },
183   /* tagH5 */
184   {
185     s_xhtml_1_0_start_h5_tag,
186     s_xhtml_1_0_end_h5_tag,
187   },
188   /* tagH6 */
189   {
190     s_xhtml_1_0_start_h6_tag,
191     s_xhtml_1_0_end_h6_tag,
192   },
193   /* tagHEAD */
194   {
195     s_xhtml_1_0_start_head_tag,
196     s_xhtml_1_0_end_head_tag,
197   },
198   /* tagTITLE */
199   {
200     s_xhtml_1_0_start_title_tag,
201     s_xhtml_1_0_end_title_tag,
202   },
203   /* tagBASE */
204   {
205     s_xhtml_1_0_start_base_tag,
206     s_xhtml_1_0_end_base_tag,
207   },
208   /* tagBODY */
209   {
210     s_xhtml_1_0_start_body_tag,
211     s_xhtml_1_0_end_body_tag,
212   },
213   /* tagA */
214   {
215     s_xhtml_1_0_start_a_tag,
216     s_xhtml_1_0_end_a_tag,
217   },
218   /* tagBR */
219   {
220     s_xhtml_1_0_start_br_tag,
221     s_xhtml_1_0_end_br_tag,
222   },
223   /* tagTABLE */
224   {
225     NULL,
226     NULL,
227   },
228   /* tagTR */
229   {
230     s_xhtml_1_0_start_tr_tag,
231     s_xhtml_1_0_end_tr_tag,
232   },
233   /* tagTD */
234   {
235     NULL,
236     NULL,
237   },
238   /* tagTBODY */
239   {
240     NULL,
241     NULL,
242   },
243   /* tagFONT */
244   {
245     s_xhtml_1_0_start_font_tag,
246     s_xhtml_1_0_end_font_tag,
247   },
248   /* tagFORM */
249   {
250     s_xhtml_1_0_start_form_tag,
251     s_xhtml_1_0_end_form_tag,
252   },
253   /* tagINPUT */
254   {
255     s_xhtml_1_0_start_input_tag,
256     s_xhtml_1_0_end_input_tag,
257   },
258   /* tagCENTER */
259   {
260     s_xhtml_1_0_start_center_tag,
261     s_xhtml_1_0_end_center_tag,
262   },
263   /* tagHR */
264   {
265     s_xhtml_1_0_start_hr_tag,
266     s_xhtml_1_0_end_hr_tag,
267   },
268   /* tagIMG */
269   {
270     s_xhtml_1_0_start_img_tag,
271     s_xhtml_1_0_end_img_tag,
272   },
273   /* tagSELECT */
274   {
275     s_xhtml_1_0_start_select_tag,
276     s_xhtml_1_0_end_select_tag,
277   },
278   /* tagOPTION */
279   {
280     s_xhtml_1_0_start_option_tag,
281     s_xhtml_1_0_end_option_tag,
282   },
283   /* tagDIV */
284   {
285     s_xhtml_1_0_start_div_tag,
286     s_xhtml_1_0_end_div_tag,
287   },
288   /* tagCHXJIF */
289   {
290     s_xhtml_1_0_chxjif_tag,
291     NULL,
292   },
293   /* tagNOBR */
294   {
295     NULL,
296     NULL,
297   },
298   /* tagSMALL */
299   {
300     NULL,
301     NULL,
302   },
303   /* tagSTYLE */
304   {
305     NULL,
306     NULL,
307   },
308   /* tagSPAN */
309   {
310     NULL,
311     NULL,
312   },
313   /* tagTEXT */
314   {
315     s_xhtml_1_0_text_tag,
316     NULL,
317   },
318   /* tagTH */
319   {
320     NULL,
321     NULL,
322   },
323   /* tagB */
324   {
325     s_xhtml_1_0_start_b_tag,
326     s_xhtml_1_0_end_b_tag,
327   },
328   /* tagFIELDSET */
329   {
330     NULL,
331     NULL,
332   },
333   /* tagDT */
334   {
335     s_xhtml_1_0_start_dt_tag,
336     s_xhtml_1_0_end_dt_tag,
337   },
338   /* tagLEGEND */
339   {
340     NULL,
341     NULL,
342   },
343   /* tagLABEL */
344   {
345     NULL,
346     NULL,
347   },
348   /* tagBLOCKQUOTE */
349   {
350     s_xhtml_1_0_start_blockquote_tag,
351     s_xhtml_1_0_end_blockquote_tag,
352   },
353   /* tagDIR */
354   {
355     s_xhtml_1_0_start_dir_tag,
356     s_xhtml_1_0_end_dir_tag,
357   },
358   /* tagDL */
359   {
360     s_xhtml_1_0_start_dl_tag,
361     s_xhtml_1_0_end_dl_tag,
362   },
363   /* tagDD */
364   {
365     s_xhtml_1_0_start_dd_tag,
366     s_xhtml_1_0_end_dd_tag,
367   },
368   /* tagMENU */
369   {
370     s_xhtml_1_0_start_menu_tag,
371     s_xhtml_1_0_end_menu_tag,
372   },
373   /* tagPLAINTEXT */
374   {
375     s_xhtml_1_0_start_plaintext_tag,
376     s_xhtml_1_0_end_plaintext_tag,
377   },
378   /* tagBLINK */
379   {
380     s_xhtml_1_0_start_blink_tag,
381     s_xhtml_1_0_end_blink_tag,
382   },
383   /* tagMARQUEE */
384   {
385     s_xhtml_1_0_start_marquee_tag,
386     s_xhtml_1_0_end_marquee_tag,
387   },
388 };
389  
390 /**
391  * converts from CHTML to XHTML.
392  *
393  * @param r     [i]   Requet_rec is appointed.
394  * @param spec  [i]   The result of the device specification processing which 
395  *                    was done in advance is appointed.
396  * @param src   [i]   The character string before the converting is appointed.
397  * @return The character string after the converting is returned.
398  */
399 char *
400 chxj_convert_xhtml_mobile_1_0(
401   request_rec        *r,
402   device_table       *spec,
403   const char         *src,
404   apr_size_t         srclen,
405   apr_size_t         *dstlen,
406   chxjconvrule_entry *entryp,
407   cookie_t           *UNUSED(cookie)
408 )
409 {
410   char      *dst = NULL;
411   char      *ss;
412   xhtml_t   xhtml;
413   Doc       doc;
414
415   DBG(r,"start chxj_convert_xhtml_mobile_1_0()");
416   /*--------------------------------------------------------------------------*/
417   /* If qrcode xml                                                            */
418   /*--------------------------------------------------------------------------*/
419   *dstlen = srclen;
420   dst = chxj_qr_code_blob_handler(r, src, (size_t*)dstlen);
421   if (dst != NULL) {
422     DBG(r,"end chxj_convert_xhtml_mobile_1_0() (found qrcode.xml)");
423     return dst;
424   }
425
426   /*--------------------------------------------------------------------------*/
427   /* The XHTML structure is initialized.                                      */
428   /*--------------------------------------------------------------------------*/
429   s_init_xhtml(&xhtml, &doc, r, spec);
430
431   xhtml.entryp = entryp;
432
433   chxj_set_content_type(r, "text/html; charset=Windows-31J");
434
435   /*--------------------------------------------------------------------------*/
436   /* The character string of the input is analyzed.                           */
437   /*--------------------------------------------------------------------------*/
438   qs_init_malloc(&doc);
439   qs_init_root_node(&doc);
440
441   ss = apr_pcalloc(r->pool, srclen + 1);
442   memset(ss,   0, srclen + 1);
443   memcpy(ss, src, srclen);
444
445 #ifdef DUMP_LOG
446   chxj_dump_out("[src] CHTML->XHTML", ss, srclen);
447 #endif
448   qs_parse_string(&doc,ss, strlen(ss));
449
450   chxj_buffered_write_init(r->pool, &doc.buf);
451   /*--------------------------------------------------------------------------*/
452   /* It converts it from CHTML to XHTML.                                      */
453   /*--------------------------------------------------------------------------*/
454   chxj_node_convert(spec,r,(void *)&xhtml, &doc, qs_get_root(&doc), 0);
455   xhtml.out = chxj_buffered_write_flush(xhtml.out, &doc.buf);
456   dst = apr_pstrdup(r->pool, xhtml.out);
457   chxj_buffered_write_terminate(&doc.buf);
458
459   qs_all_free(&doc,QX_LOGMARK);
460
461   if (! dst) {
462     return apr_pstrdup(r->pool,ss);
463   }
464
465   if (! *dst) {
466     dst = apr_psprintf(r->pool, "\n");
467   }
468   *dstlen = strlen(dst);
469
470 #ifdef DUMP_LOG
471   chxj_dump_out("[dst] CHTML->XHTML", dst, *dstlen);
472 #endif
473
474   DBG(r,"end chxj_convert_xhtml_mobile_1_0()");
475   return dst;
476 }
477
478
479 /**
480  * The XHTML structure is initialized.
481  *
482  * @param xhtml [i/o] The pointer to the HDML structure that wants to be
483  *                   initialized is specified.
484  * @param doc   [i]   The Doc structure that should be set to the initialized
485  *                   HDML structure is specified.
486  * @param r     [i]   To use POOL, the pointer to request_rec is specified.
487  * @param spec  [i]   The pointer to the device_table
488  */
489 static void
490 s_init_xhtml(xhtml_t *xhtml, Doc *doc, request_rec *r, device_table *spec)
491 {
492   memset(doc,   0, sizeof(Doc));
493   memset(xhtml, 0, sizeof(xhtml_t));
494
495   doc->r      = r;
496   xhtml->doc  = doc;
497   xhtml->spec = spec;
498   xhtml->out  = qs_alloc_zero_byte_string(r);
499   xhtml->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
500   xhtml->doc->parse_mode = PARSE_MODE_CHTML;
501 }
502
503
504 /**
505  * Corresponding EMOJI to a current character-code is retrieved. 
506  * The substitution character string is stored in the rslt pointer if agreeing.
507  *
508  * @param xhtml   [i]   The pointer to the XHTML structure is specified. 
509  * @param txt     [i]   The character string to want to examine whether it is 
510  *                      EMOJI is specified. 
511  * @param rslt    [o]   The pointer to the pointer that stores the result is 
512  *                      specified. 
513  * @return When corresponding EMOJI exists, it returns it excluding 0. 
514  */
515 static int
516 s_xhtml_search_emoji(xhtml_t *xhtml, char *txt, char **rslt)
517 {
518   emoji_t       *ee;
519   request_rec   *r;
520   device_table  *spec;
521   int           len;
522
523   spec = xhtml->spec;
524
525   len = strlen(txt);
526   r = xhtml->doc->r;
527
528   if (spec == NULL) {
529     DBG(r,"spec is NULL");
530   }
531
532   for (ee = xhtml->conf->emoji;
533        ee;
534        ee = ee->next) {
535     unsigned char hex1byte;
536     unsigned char hex2byte;
537     if (!ee->imode) {
538       DBG(r,"emoji->imode is NULL");
539       continue;
540     }
541
542     if (ee->imode->string != NULL
543     &&  strlen(ee->imode->string) > 0
544     &&  strncasecmp(ee->imode->string, txt, strlen(ee->imode->string)) == 0) {
545       if (spec == NULL || spec->emoji_type == NULL) {
546         *rslt = apr_psprintf(r->pool,
547                         "<img localsrc=%s>",
548                         ee->ezweb->typeA);
549         return strlen(ee->imode->string);
550       }
551
552       if (strcasecmp(xhtml->spec->emoji_type, "a") == 0) {
553         *rslt = apr_psprintf(r->pool,
554                         "<img localsrc=%s>",
555                         ee->ezweb->typeA);
556         return strlen(ee->imode->string);
557       } 
558       else
559       if (strcasecmp(xhtml->spec->emoji_type, "b") == 0) {
560         *rslt = apr_psprintf(r->pool,
561                         "<img localsrc=%s>",
562                         ee->ezweb->typeB);
563         return strlen(ee->imode->string);
564       }
565       else
566       if (strcasecmp(xhtml->spec->emoji_type, "c") == 0) {
567         *rslt = apr_psprintf(r->pool,
568                         "<img localsrc=%s>",
569                         ee->ezweb->typeC);
570         return strlen(ee->imode->string);
571       }
572       else
573       if (strcasecmp(xhtml->spec->emoji_type, "d") == 0) {
574         *rslt = apr_psprintf(r->pool,
575                         "<img localsrc=%s>",
576                         ee->ezweb->typeD);
577         return strlen(ee->imode->string);
578       }
579       else {
580         *rslt = apr_psprintf(r->pool,
581                         "<img localsrc=%s>",
582                         ee->ezweb->typeA);
583         return strlen(ee->imode->string);
584       }
585       return 0;
586     }
587     hex1byte = ee->imode->hex1byte & 0xff;
588     hex2byte = ee->imode->hex2byte & 0xff;
589     if (len >= 2
590     && ((unsigned char)txt[0] & 0xff) == ((unsigned char)hex1byte)
591     && ((unsigned char)txt[1] & 0xff) == ((unsigned char)hex2byte)) {
592       if (spec == NULL || spec->emoji_type == NULL) {
593         *rslt = apr_psprintf(r->pool,
594                         "<img localsrc=\"%s\">",
595                         ee->ezweb->typeA);
596         return 2;
597       }
598
599       if (strcasecmp(xhtml->spec->emoji_type, "a") == 0) {
600         *rslt = apr_psprintf(r->pool,
601                         "<img localsrc=\"%s\">",
602                         ee->ezweb->typeA);
603         return 2;
604       } 
605       else
606       if (strcasecmp(xhtml->spec->emoji_type, "b") == 0) {
607         *rslt = apr_psprintf(r->pool,
608                         "<img localsrc=\"%s\">",
609                         ee->ezweb->typeB);
610         return 2;
611       }
612       else
613       if (strcasecmp(xhtml->spec->emoji_type, "c") == 0) {
614         *rslt = apr_psprintf(r->pool,
615                         "<img localsrc=\"%s\">",
616                         ee->ezweb->typeC);
617         return 2;
618       }
619       else
620       if (strcasecmp(xhtml->spec->emoji_type, "d") == 0) {
621         *rslt = apr_psprintf(r->pool,
622                         "<img localsrc=\"%s\">",
623                         ee->ezweb->typeD);
624         return 2;
625       }
626       else {
627         *rslt = apr_psprintf(r->pool,
628                         "<img localsrc=\"%s\">",
629                         ee->ezweb->typeD);
630         return 2;
631       }
632       return 0;
633     }
634   }
635   return 0;
636 }
637
638
639 /**
640  * It is a handler who processes the HTML tag.
641  *
642  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
643  *                     destination is specified.
644  * @param node   [i]   The HTML tag node is specified.
645  * @return The conversion result is returned.
646  */
647 static char *
648 s_xhtml_1_0_start_html_tag(void *pdoc, Node *node) 
649 {
650   xhtml_t       *xhtml = GET_XHTML(pdoc);
651   Attr          *attr;
652   Doc           *doc   = xhtml->doc;
653
654   /*--------------------------------------------------------------------------*/
655   /* Add XML Declare                                                          */
656   /*--------------------------------------------------------------------------*/
657   W_L("<?xml version=\"1.0\" encoding=\"Windows-31J\"?>\r\n");
658   /*--------------------------------------------------------------------------*/
659   /* Add DocType                                                              */
660   /*--------------------------------------------------------------------------*/
661   W_L("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML Basic 1.0//EN\"\r\n");
662   W_L(" \"http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd\">\r\n");
663   /*--------------------------------------------------------------------------*/
664   /* start HTML tag                                                           */
665   /*--------------------------------------------------------------------------*/
666   W_L("<html xmlns=\"http://www.w3.org/1999/xhtml\"");
667   /*--------------------------------------------------------------------------*/
668   /* Get Attributes                                                           */
669   /*--------------------------------------------------------------------------*/
670   for (attr = qs_get_attr(doc,node);
671        attr; 
672        attr = qs_get_next_attr(doc,attr)) {
673     char* name  = qs_get_attr_name(doc,attr);
674     char* value = qs_get_attr_value(doc,attr);
675     if (STRCASEEQ('l','L',"lang", name)) {
676       W_L(" xml:lang=\"");
677       W_V(value);
678       W_L("\"");
679     }
680     else if (STRCASEEQ('v','V',"version", name)) {
681       W_L(" version=\"-//OPENWAVE//DTD XHTML Mobile 1.0//EN\"");
682     }
683   }
684   W_L(">\r\n");
685   return xhtml->out;
686 }
687
688
689 /**
690  * It is a handler who processes the HTML tag.
691  *
692  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
693  *                     destination is specified.
694  * @param node   [i]   The HTML tag node is specified.
695  * @return The conversion result is returned.
696  */
697 static char *
698 s_xhtml_1_0_end_html_tag(void *pdoc, Node *UNUSED(child)) 
699 {
700   xhtml_t       *xhtml = GET_XHTML(pdoc);
701   Doc           *doc   = xhtml->doc;
702   W_L("</html>\r\n");
703   return xhtml->out;
704 }
705
706
707 /**
708  * It is a handler who processes the META tag.
709  *
710  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
711  *                     destination is specified.
712  * @param node   [i]   The META tag node is specified.
713  * @return The conversion result is returned.
714  */
715 static char *
716 s_xhtml_1_0_start_meta_tag(void *pdoc, Node *node) 
717 {
718   xhtml_t       *xhtml = GET_XHTML(pdoc);
719   Attr          *attr;
720   Doc           *doc   = xhtml->doc;
721   int           content_type_flag = 0;
722
723   W_L("<meta");
724   /*--------------------------------------------------------------------------*/
725   /* Get Attributes                                                           */
726   /*--------------------------------------------------------------------------*/
727   for (attr = qs_get_attr(doc,node);
728        attr; 
729        attr = qs_get_next_attr(doc,attr)) {
730     char *name  = qs_get_attr_name(doc,attr);
731     char *value = qs_get_attr_value(doc,attr);
732     if (STRCASEEQ('n','N',"name", name) && value && *value) {
733       W_L(" ");
734       W_V(name);
735       W_L("=\"");
736       W_V(value);
737       W_L("\"");
738     }
739     else if (STRCASEEQ('h','H',"http-equiv", name) && value && *value) {
740       W_L(" ");
741       W_V(name);
742       W_L("=\"");
743       W_V(value);
744       W_L("\"");
745       if (STRCASEEQ('c','C', "content-type", value)) {
746         content_type_flag = 1;
747       }
748     }
749     else if (STRCASEEQ('c','C',"content", name) && value && *value) {
750       if (content_type_flag) {
751         W_L(" ");
752         W_V(name);
753         W_L("=\"");
754         W_L("text/html; charset=Windows-31J");
755         W_L("\"");
756       }
757       else {
758         W_L(" ");
759         W_V(name);
760         W_L("=\"");
761         W_V(value);
762         W_L("\"");
763       }
764     }
765   }
766   W_L(" />\r\n");
767   return xhtml->out;
768 }
769
770
771 /**
772  * It is a handler who processes the META tag.
773  *
774  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
775  *                     destination is specified.
776  * @param node   [i]   The META tag node is specified.
777  * @return The conversion result is returned.
778  */
779 static char *
780 s_xhtml_1_0_end_meta_tag(void *pdoc, Node *UNUSED(child)) 
781 {
782   xhtml_t *xhtml = GET_XHTML(pdoc);
783
784   return xhtml->out;
785 }
786
787
788 /**
789  * It is a handler who processes the HEAD tag.
790  *
791  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
792  *                     destination is specified.
793  * @param node   [i]   The HEAD tag node is specified.
794  * @return The conversion result is returned.
795  */
796 static char *
797 s_xhtml_1_0_start_head_tag(void *pdoc, Node *UNUSED(node)) 
798 {
799   xhtml_t       *xhtml = GET_XHTML(pdoc);
800   Doc           *doc   = xhtml->doc;
801
802   W_L("<head>\r\n");
803   return xhtml->out;
804 }
805
806
807 /**
808  * It is a handler who processes the HEAD tag.
809  *
810  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
811  *                     destination is specified.
812  * @param node   [i]   The HEAD tag node is specified.
813  * @return The conversion result is returned.
814  */
815 static char *
816 s_xhtml_1_0_end_head_tag(void *pdoc, Node *UNUSED(child)) 
817 {
818   xhtml_t       *xhtml = GET_XHTML(pdoc);
819   Doc           *doc   = xhtml->doc;
820
821   W_L("</head>\r\n");
822   return xhtml->out;
823 }
824
825
826 /**
827  * It is a handler who processes the TITLE tag.
828  *
829  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
830  *                     destination is specified.
831  * @param node   [i]   The TITLE tag node is specified.
832  * @return The conversion result is returned.
833  */
834 static char *
835 s_xhtml_1_0_start_title_tag(void *pdoc, Node *UNUSED(node)) 
836 {
837   xhtml_t      *xhtml = GET_XHTML(pdoc);
838   Doc          *doc   = xhtml->doc;
839
840   W_L("<title>");
841   return xhtml->out;
842 }
843
844
845 /**
846  * It is a handler who processes the TITLE tag.
847  *
848  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
849  *                     destination is specified.
850  * @param node   [i]   The TITLE tag node is specified.
851  * @return The conversion result is returned.
852  */
853 static char *
854 s_xhtml_1_0_end_title_tag(void *pdoc, Node *UNUSED(child)) 
855 {
856   xhtml_t       *xhtml = GET_XHTML(pdoc);
857   Doc           *doc   = xhtml->doc;
858
859   W_L("</title>\r\n");
860   return xhtml->out;
861 }
862
863
864 /**
865  * It is a handler who processes the BASE tag.
866  *
867  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
868  *                     destination is specified.
869  * @param node   [i]   The BASE tag node is specified.
870  * @return The conversion result is returned.
871  */
872 static char *
873 s_xhtml_1_0_start_base_tag(void *pdoc, Node *node) 
874 {
875   xhtml_t       *xhtml = GET_XHTML(pdoc);
876   Attr          *attr;
877   Doc           *doc   = xhtml->doc;
878
879   W_L("<base");
880   /*--------------------------------------------------------------------------*/
881   /* Get Attributes                                                           */
882   /*--------------------------------------------------------------------------*/
883   for (attr = qs_get_attr(doc,node);
884        attr;
885        attr = qs_get_next_attr(doc,attr)) {
886     char *name = qs_get_attr_name(doc,attr);
887     char *value = qs_get_attr_value(doc,attr);
888     if (STRCASEEQ('h','H',"href",name)) {
889       W_L(" href=\"");
890       W_V(value);
891       W_L("\"");
892       break;
893     }
894   }
895   W_L(" />\r\n");
896   return xhtml->out;
897 }
898
899
900 /**
901  * It is a handler who processes the BASE tag.
902  *
903  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
904  *                     destination is specified.
905  * @param node   [i]   The BASE tag node is specified.
906  * @return The conversion result is returned.
907  */
908 static char *
909 s_xhtml_1_0_end_base_tag(void *pdoc, Node *UNUSED(child)) 
910 {
911   xhtml_t *xhtml = GET_XHTML(pdoc);
912
913   return xhtml->out;
914 }
915
916
917 /**
918  * It is a handler who processes the BODY tag.
919  *
920  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
921  *                     destination is specified.
922  * @param node   [i]   The BODY tag node is specified.
923  * @return The conversion result is returned.
924  */
925 static char *
926 s_xhtml_1_0_start_body_tag(void *pdoc, Node *node) 
927 {
928   xhtml_t      *xhtml = GET_XHTML(pdoc);
929   Doc          *doc   = xhtml->doc;
930   Attr         *attr;
931
932   W_L("<body");
933   /*--------------------------------------------------------------------------*/
934   /* Get Attributes                                                           */
935   /*--------------------------------------------------------------------------*/
936   for (attr = qs_get_attr(doc,node);
937        attr;
938        attr = qs_get_next_attr(doc,attr)) {
939     char *name  = qs_get_attr_name(doc,attr);
940     char *value = qs_get_attr_value(doc,attr);
941     if (STRCASEEQ('b','B',"bgcolor", name) && value && *value) {
942       W_L(" bgcolor=\"");
943       W_V(value);
944       W_L("\"");
945     }
946     else if (STRCASEEQ('t','T',"text",name) && value && *value) {
947       W_L(" text=\"");
948       W_V(value);
949       W_L("\"");
950     }
951     else if (STRCASEEQ('l','L',"link", name) && value && *value) {
952       W_L(" link=\"");
953       W_V(value);
954       W_L("\"");
955     }
956     else if (STRCASEEQ('a','A',"alink", name)) {
957       /* ignore */
958     }
959     else if (STRCASEEQ('v','V',"vlink",name)) {
960       /* ignore */
961     }
962   }
963   W_L(">\r\n");
964   return xhtml->out;
965 }
966
967
968 /**
969  * It is a handler who processes the BODY tag.
970  *
971  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
972  *                     destination is specified.
973  * @param node   [i]   The BODY tag node is specified.
974  * @return The conversion result is returned.
975  */
976 static char *
977 s_xhtml_1_0_end_body_tag(void *pdoc, Node *UNUSED(child)) 
978 {
979   xhtml_t       *xhtml = GET_XHTML(pdoc);
980   Doc           *doc   = xhtml->doc;
981
982   W_L("</body>\r\n");
983   return xhtml->out;
984 }
985
986
987 /**
988  * It is a handler who processes the A tag.
989  *
990  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
991  *                     destination is specified.
992  * @param node   [i]   The A tag node is specified.
993  * @return The conversion result is returned.
994  */
995 static char *
996 s_xhtml_1_0_start_a_tag(void *pdoc, Node *node) 
997 {
998   xhtml_t       *xhtml = GET_XHTML(pdoc);
999   Doc           *doc   = xhtml->doc;
1000   request_rec   *r     = doc->r;
1001   Attr          *attr;
1002
1003   W_L("<a");
1004   /*--------------------------------------------------------------------------*/
1005   /* Get Attributes                                                           */
1006   /*--------------------------------------------------------------------------*/
1007   for (attr = qs_get_attr(doc,node);
1008        attr; 
1009        attr = qs_get_next_attr(doc,attr)) {
1010     char* name  = qs_get_attr_name(doc,attr);
1011     char* value = qs_get_attr_value(doc,attr);
1012     if (STRCASEEQ('n','N',"name",name) && value && *value) {
1013       W_L(" id=\"");
1014       W_V(value);
1015       W_L("\"");
1016     }
1017     else if (STRCASEEQ('h','H',"href", name) && value && *value) {
1018       value = chxj_encoding_parameter(r, value);
1019       W_L(" href=\"");
1020       W_V(value);
1021       W_L("\"");
1022     }
1023     else if (STRCASEEQ('a','A',"accesskey", name)) {
1024       W_L(" accesskey=\"");
1025       W_V(value);
1026       W_L("\"");
1027     }
1028     else if (STRCASEEQ('c','C',"cti",name)) {
1029       /* ignore */
1030     }
1031     else if (STRCASEEQ('i','I',"ijam", name)) {
1032       /* ignore */
1033     }
1034     else if (STRCASEEQ('u','U',"utn", name)) {
1035       /* ignore */
1036     }
1037     else if (STRCASEEQ('t','T',"telbook",name)) {
1038       /* ignore */
1039     }
1040     else if (STRCASEEQ('k','K',"kana",name)) {
1041       /* ignore */
1042     }
1043     else if (STRCASEEQ('e','E',"email",name)) {
1044       /* ignore */
1045     }
1046     else if (STRCASEEQ('i','I',"ista",name)) {
1047       /* ignore */
1048     }
1049     else if (STRCASEEQ('i','I',"ilet",name)) {
1050       /* ignore */
1051     }
1052     else if (STRCASEEQ('i','I',"iswf",name)) {
1053       /* ignore */
1054     }
1055     else if (STRCASEEQ('i','I',"irst",name)) {
1056       /* ignore */
1057     }
1058   }
1059   W_L(">");
1060   return xhtml->out;
1061 }
1062
1063
1064 /**
1065  * It is a handler who processes the A tag.
1066  *
1067  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1068  *                     destination is specified.
1069  * @param node   [i]   The A tag node is specified.
1070  * @return The conversion result is returned.
1071  */
1072 static char *
1073 s_xhtml_1_0_end_a_tag(void *pdoc, Node *UNUSED(child)) 
1074 {
1075   xhtml_t *xhtml = GET_XHTML(pdoc);
1076   Doc     *doc   = xhtml->doc;
1077
1078   W_L("</a>");
1079   return xhtml->out;
1080 }
1081
1082
1083 /**
1084  * It is a handler who processes the BR tag.
1085  *
1086  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1087  *                     destination is specified.
1088  * @param node   [i]   The BR tag node is specified.
1089  * @return The conversion result is returned.
1090  */
1091 static char *
1092 s_xhtml_1_0_start_br_tag(void *pdoc, Node *node) 
1093 {
1094   xhtml_t *xhtml = GET_XHTML(pdoc);
1095   Doc     *doc   = xhtml->doc;
1096   Attr    *attr;
1097
1098   W_L("<br");
1099   /*--------------------------------------------------------------------------*/
1100   /* Get Attributes                                                           */
1101   /*--------------------------------------------------------------------------*/
1102   for (attr = qs_get_attr(doc,node);
1103        attr;
1104        attr = qs_get_next_attr(doc,attr)) {
1105     char *name  = qs_get_attr_name(doc,attr);
1106     char *value = qs_get_attr_value(doc,attr);
1107     if (STRCASEEQ('c','C',"clear",name)) {
1108       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('a','A',"all",value))) {
1109         W_L(" clear=\"");
1110         W_V(value);
1111         W_L("\"");
1112       }
1113     }
1114   }
1115   W_L(" />\r\n");
1116   return xhtml->out;
1117 }
1118
1119
1120 /**
1121  * It is a handler who processes the BR tag.
1122  *
1123  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1124  *                     destination is specified.
1125  * @param node   [i]   The BR tag node is specified.
1126  * @return The conversion result is returned.
1127  */
1128 static char *
1129 s_xhtml_1_0_end_br_tag(void *pdoc, Node *UNUSED(child)) 
1130 {
1131   xhtml_t *xhtml = GET_XHTML(pdoc);
1132
1133   return xhtml->out;
1134 }
1135
1136
1137 /**
1138  * It is a handler who processes the TR tag.
1139  *
1140  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1141  *                     destination is specified.
1142  * @param node   [i]   The TR tag node is specified.
1143  * @return The conversion result is returned.
1144  */
1145 static char *
1146 s_xhtml_1_0_start_tr_tag(void *pdoc, Node *UNUSED(node)) 
1147 {
1148   xhtml_t *xhtml = GET_XHTML(pdoc);
1149   Doc     *doc   = xhtml->doc;
1150
1151   W_L("<br />\r\n");
1152   return xhtml->out;
1153 }
1154
1155
1156 /**
1157  * It is a handler who processes the TR tag.
1158  *
1159  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1160  *                     destination is specified.
1161  * @param node   [i]   The TR tag node is specified.
1162  * @return The conversion result is returned.
1163  */
1164 static char *
1165 s_xhtml_1_0_end_tr_tag(void *pdoc, Node *UNUSED(child)) 
1166 {
1167   xhtml_t *xhtml = GET_XHTML(pdoc);
1168
1169   return xhtml->out;
1170 }
1171
1172
1173 /**
1174  * It is a handler who processes the FONT tag.
1175  *
1176  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1177  *                     destination is specified.
1178  * @param node   [i]   The FONT tag node is specified.
1179  * @return The conversion result is returned.
1180  */
1181 static char *
1182 s_xhtml_1_0_start_font_tag(void *pdoc, Node *node) 
1183 {
1184   xhtml_t *xhtml = GET_XHTML(pdoc);
1185   Doc     *doc   = xhtml->doc;
1186   Attr    *attr;
1187   char    *size = NULL;
1188   char    *color = NULL;
1189
1190   /*=========================================================================*/
1191   /* Get Attributes                                                          */
1192   /*=========================================================================*/
1193   for (attr = qs_get_attr(doc,node);
1194        attr;
1195        attr = qs_get_next_attr(doc,attr)) {
1196     char *name = qs_get_attr_name(doc,attr);
1197     char *value = qs_get_attr_value(doc,attr);
1198     if (STRCASEEQ('c','C',"color",name) && value && *value) {
1199       color = apr_pstrdup(doc->buf.pool, value);
1200     }
1201     else if (STRCASEEQ('s','S',"size",name) && value && *value) {
1202       size = apr_pstrdup(doc->buf.pool, value);
1203     }
1204   }
1205   if (color) {
1206     W_L("<font color=\"");
1207     W_V(color);
1208     W_L("\">");
1209     xhtml->font_color_flag++;
1210   }
1211   if (size) {
1212     xhtml->font_size_flag++;
1213     switch(*size) {
1214     case '1': W_L("<span style=\"font-size: xx-small\">"); break;
1215     case '2': W_L("<span style=\"font-size: x-small\">");  break;
1216     case '3': W_L("<span style=\"font-size: small\">");    break;
1217     case '4': W_L("<span style=\"font-size: medium\">");   break;
1218     case '5': W_L("<span style=\"font-size: large\">");    break;
1219     case '6': W_L("<span style=\"font-size: x-large\">");  break;
1220     case '7': W_L("<span style=\"font-size: xx-large\">"); break;
1221     default:
1222       WRN(doc->r, "invlalid font size. [%s] != (1|2|3|4|5|6|7)", size);
1223       xhtml->font_size_flag--;
1224     }
1225   }
1226   return xhtml->out;
1227 }
1228
1229
1230 /**
1231  * It is a handler who processes the FONT tag.
1232  *
1233  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1234  *                     destination is specified.
1235  * @param node   [i]   The FONT tag node is specified.
1236  * @return The conversion result is returned.
1237  */
1238 static char *
1239 s_xhtml_1_0_end_font_tag(void *pdoc, Node *UNUSED(child)) 
1240 {
1241   xhtml_t *xhtml = GET_XHTML(pdoc);
1242   Doc     *doc   = xhtml->doc;
1243
1244   if (xhtml->font_size_flag) {
1245     W_L("</span>");
1246     xhtml->font_size_flag--;
1247   }
1248   if (xhtml->font_color_flag) {
1249     W_L("</font>");
1250     xhtml->font_color_flag--;
1251   }
1252   return xhtml->out;
1253 }
1254
1255
1256 /**
1257  * It is a handler who processes the FORM tag.
1258  *
1259  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1260  *                     destination is specified.
1261  * @param node   [i]   The FORM tag node is specified.
1262  * @return The conversion result is returned.
1263  */
1264 static char *
1265 s_xhtml_1_0_start_form_tag(void *pdoc, Node *node) 
1266 {
1267   xhtml_t     *xhtml = GET_XHTML(pdoc);
1268   Doc         *doc   = xhtml->doc;
1269   request_rec *r     = doc->r;
1270   Attr        *attr;
1271
1272   W_L("<form");
1273   /*--------------------------------------------------------------------------*/
1274   /* Get Attributes                                                           */
1275   /*--------------------------------------------------------------------------*/
1276   for (attr = qs_get_attr(doc,node);
1277        attr;
1278        attr = qs_get_next_attr(doc,attr)) {
1279     char *name = qs_get_attr_name(doc,attr);
1280     char *value = qs_get_attr_value(doc,attr);
1281     if (STRCASEEQ('a','A',"action",name)) {
1282       value = chxj_encoding_parameter(r, value);
1283       W_L(" action=\"");
1284       W_V(value);
1285       W_L("\"");
1286     }
1287     else if (STRCASEEQ('m','M',"method",name)) {
1288       W_L(" method=\"");
1289       W_V(value);
1290       W_L("\"");
1291     }
1292     else if (STRCASEEQ('u','U',"utn",name)) {
1293       /* ignore */
1294     }
1295   }
1296   W_L(">");
1297   return xhtml->out;
1298 }
1299
1300
1301 /**
1302  * It is a handler who processes the FORM tag.
1303  *
1304  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1305  *                     destination is specified.
1306  * @param node   [i]   The FORM tag node is specified.
1307  * @return The conversion result is returned.
1308  */
1309 static char *
1310 s_xhtml_1_0_end_form_tag(void *pdoc, Node *UNUSED(child)) 
1311 {
1312   xhtml_t *xhtml = GET_XHTML(pdoc);
1313   Doc     *doc   = xhtml->doc;
1314
1315   W_L("</form>");
1316   return xhtml->out;
1317 }
1318
1319
1320 /**
1321  * It is a handler who processes the INPUT tag.
1322  *
1323  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1324  *                     destination is specified.
1325  * @param node   [i]   The INPUT tag node is specified.
1326  * @return The conversion result is returned.
1327  */
1328 static char *
1329 s_xhtml_1_0_start_input_tag(void *pdoc, Node *node) 
1330 {
1331   xhtml_t     *xhtml       = GET_XHTML(pdoc);
1332   Doc         *doc         = xhtml->doc;
1333   request_rec *r           = doc->r;
1334   char        *max_length  = NULL;
1335   char        *type        = NULL;
1336   char        *name        = NULL;
1337   char        *value       = NULL;
1338   char        *istyle      = NULL;
1339   char        *size        = NULL;
1340   char        *checked     = NULL;
1341   char        *accesskey   = NULL;
1342
1343   W_L("<input");
1344   /*--------------------------------------------------------------------------*/
1345   /* Get Attributes                                                           */
1346   /*--------------------------------------------------------------------------*/
1347   type       = qs_get_type_attr(doc, node, r);
1348   name       = qs_get_name_attr(doc, node, r);
1349   value      = qs_get_value_attr(doc,node,r);
1350   istyle     = qs_get_istyle_attr(doc,node,r);
1351   max_length = qs_get_maxlength_attr(doc,node,r);
1352   checked    = qs_get_checked_attr(doc,node,r);
1353   accesskey  = qs_get_accesskey_attr(doc, node, r);
1354   size       = qs_get_size_attr(doc, node, r);
1355
1356   if (type) {
1357     type = qs_trim_string(doc->buf.pool, type);
1358     if (type && (STRCASEEQ('t','T',"text",    type) ||
1359                  STRCASEEQ('p','P',"password",type) ||
1360                  STRCASEEQ('c','C',"checkbox",type) ||
1361                  STRCASEEQ('r','R',"radio",   type) ||
1362                  STRCASEEQ('h','H',"hidden",  type) ||
1363                  STRCASEEQ('s','S',"submit",  type) ||
1364                  STRCASEEQ('r','R',"reset",   type))) {
1365       W_L(" type=\"");
1366       W_V(type);
1367       W_L("\"");
1368     }
1369   }
1370   if (size && *size) {
1371     W_L(" size=\"");
1372     W_V(size);
1373     W_L("\"");
1374   }
1375   if (name && *name) {
1376     W_L(" name=\"");
1377     W_V(name);
1378     W_L("\"");
1379   }
1380   if (value && *value) {
1381     W_L(" value=\"");
1382     W_V(value);
1383     W_L("\"");
1384   }
1385   if (accesskey && *accesskey) {
1386     W_L(" accesskey=\"");
1387     W_V(accesskey);
1388     W_L("\"");
1389   }
1390   if (istyle && *istyle && (*istyle == '1' || *istyle == '2' || *istyle == '3' || *istyle == '4')) {
1391     char *fmt = qs_conv_istyle_to_format(r,istyle);
1392     if (max_length && *max_length) {
1393       int ii;
1394       for (ii=0; (unsigned int)ii<strlen(max_length); ii++) {
1395         if (max_length[ii] < '0' || max_length[ii] > '9') {
1396           max_length = apr_psprintf(r->pool, "0");
1397           break;
1398         }
1399       }
1400
1401       if (strcmp(max_length, "0")) {
1402         char *vv = apr_psprintf(r->pool, " FORMAT=\"%d%s\"", atoi(max_length), fmt);
1403         W_V(vv);
1404       }
1405     }
1406     else {
1407       W_L(" FORMAT=\"");
1408       W_L("*");
1409       W_V(fmt);
1410       W_L("\"");
1411     }
1412   }
1413   else {
1414     if (max_length && *max_length) {
1415       if (chxj_chk_numeric(max_length) != 0) {
1416         max_length = apr_psprintf(r->pool, "0");
1417       }
1418       if (strcmp(max_length, "0")) {
1419         char *vv = apr_psprintf(r->pool, " FORMAT=\"%dm\"", atoi(max_length));
1420         W_V(vv);
1421       }
1422     }
1423   }
1424   /*--------------------------------------------------------------------------*/
1425   /* The figure is default for the password.                                  */
1426   /*--------------------------------------------------------------------------*/
1427   if (type && (istyle == NULL || *istyle == 0) && STRCASEEQ('p','P',"password", type) && ! xhtml->entryp->pc_flag) {
1428     if (max_length) {
1429       W_L(" FORMAT=\"");
1430       W_V(max_length);
1431       W_L("N\"");
1432     }
1433     else {
1434       W_L(" FORMAT=\"*N\"");
1435     }
1436   }
1437   if (checked) {
1438     W_L(" checked=\"checked\"");
1439   }
1440   W_L(" />");
1441   return xhtml->out;
1442 }
1443
1444
1445 /**
1446  * It is a handler who processes the INPUT tag.
1447  *
1448  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1449  *                     destination is specified.
1450  * @param node   [i]   The INPUT tag node is specified.
1451  * @return The conversion result is returned.
1452  */
1453 static char *
1454 s_xhtml_1_0_end_input_tag(void *pdoc, Node *UNUSED(child)) 
1455 {
1456   xhtml_t *xhtml = GET_XHTML(pdoc);
1457
1458   return xhtml->out;
1459 }
1460
1461
1462 /**
1463  * It is a handler who processes the CENTER tag.
1464  *
1465  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1466  *                     destination is specified.
1467  * @param node   [i]   The CENTER tag node is specified.
1468  * @return The conversion result is returned.
1469  */
1470 static char *
1471 s_xhtml_1_0_start_center_tag(void *pdoc, Node *UNUSED(node)) 
1472 {
1473   xhtml_t *xhtml = GET_XHTML(pdoc);
1474   Doc     *doc   = xhtml->doc;
1475
1476   W_L("<center>");
1477   return xhtml->out;
1478 }
1479
1480
1481 /**
1482  * It is a handler who processes the CENTER tag.
1483  *
1484  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1485  *                     destination is specified.
1486  * @param node   [i]   The CENTER tag node is specified.
1487  * @return The conversion result is returned.
1488  */
1489 static char *
1490 s_xhtml_1_0_end_center_tag(void *pdoc, Node *UNUSED(child)) 
1491 {
1492   xhtml_t *xhtml = GET_XHTML(pdoc);
1493   Doc     *doc   = xhtml->doc;
1494
1495   W_L("</center>");
1496   return xhtml->out;
1497 }
1498
1499
1500 /**
1501  * It is a handler who processes the HR tag.
1502  *
1503  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1504  *                     destination is specified.
1505  * @param node   [i]   The HR tag node is specified.
1506  * @return The conversion result is returned.
1507  */
1508 static char *
1509 s_xhtml_1_0_start_hr_tag(void *pdoc, Node *node)
1510 {
1511   xhtml_t *xhtml = GET_XHTML(pdoc);
1512   Doc     *doc   = xhtml->doc;
1513   Attr    *attr;
1514
1515   W_L("<hr");
1516  
1517   for (attr = qs_get_attr(doc,node);
1518        attr; 
1519        attr = qs_get_next_attr(doc,attr)) {
1520     char *name = qs_get_attr_name(doc,attr);
1521     char *value = qs_get_attr_value(doc,attr);
1522     if (STRCASEEQ('a','A',"align", name)) {
1523       /*----------------------------------------------------------------------*/
1524       /* CHTML 1.0                                                            */
1525       /*----------------------------------------------------------------------*/
1526       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
1527         W_L(" align=\"");
1528         W_V(value);
1529         W_L("\"");
1530       }
1531     }
1532     else if (STRCASEEQ('s','S',"size", name)) {
1533       /*----------------------------------------------------------------------*/
1534       /* CHTML 1.0                                                            */
1535       /*----------------------------------------------------------------------*/
1536       if (value && *value) {
1537         W_L(" size=\"");
1538         W_V(value);
1539         W_L("\"");
1540       }
1541     }
1542     else if (STRCASEEQ('w','W',"width", name)) {
1543       /*----------------------------------------------------------------------*/
1544       /* CHTML 1.0                                                            */
1545       /*----------------------------------------------------------------------*/
1546       if (value && *value) {
1547         W_L(" width=\"");
1548         W_V(value);
1549         W_L("\"");
1550       }
1551     }
1552     else if (STRCASEEQ('n','N',"noshade", name)) {
1553       /*----------------------------------------------------------------------*/
1554       /* CHTML 1.0                                                            */
1555       /*----------------------------------------------------------------------*/
1556       /* ignore */
1557     }
1558     else if (STRCASEEQ('c','C',"color", name) && value && *value) {
1559       /*----------------------------------------------------------------------*/
1560       /* CHTML 4.0                                                            */
1561       /*----------------------------------------------------------------------*/
1562       W_L(" color=\"");
1563       W_V(value);
1564       W_L("\"");
1565     }
1566   }
1567   W_L(" />");
1568   return xhtml->out;
1569 }
1570
1571
1572 /**
1573  * It is a handler who processes the HR tag.
1574  *
1575  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1576  *                     destination is specified.
1577  * @param node   [i]   The HR tag node is specified.
1578  * @return The conversion result is returned.
1579  */
1580 static char *
1581 s_xhtml_1_0_end_hr_tag(void *pdoc, Node *UNUSED(child)) 
1582 {
1583   xhtml_t *xhtml = GET_XHTML(pdoc);
1584
1585   return xhtml->out;
1586 }
1587
1588
1589 /**
1590  * It is a handler who processes the PRE tag.
1591  *
1592  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1593  *                     destination is specified.
1594  * @param node   [i]   The PRE tag node is specified.
1595  * @return The conversion result is returned.
1596  */
1597 static char *
1598 s_xhtml_1_0_start_pre_tag(void* pdoc, Node* UNUSED(node)) 
1599 {
1600   xhtml_t *xhtml = GET_XHTML(pdoc);
1601   Doc     *doc   = xhtml->doc;
1602
1603   xhtml->pre_flag++;
1604   W_L("<pre>");
1605   return xhtml->out;
1606 }
1607
1608
1609 /**
1610  * It is a handler who processes the PRE tag.
1611  *
1612  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1613  *                     destination is specified.
1614  * @param node   [i]   The PRE tag node is specified.
1615  * @return The conversion result is returned.
1616  */
1617 static char *
1618 s_xhtml_1_0_end_pre_tag(void *pdoc, Node *UNUSED(child)) 
1619 {
1620   xhtml_t *xhtml = GET_XHTML(pdoc);
1621   Doc     *doc   = xhtml->doc;
1622
1623   W_L("</pre>");
1624   xhtml->pre_flag--;
1625
1626   return xhtml->out;
1627 }
1628
1629
1630 /**
1631  * It is a handler who processes the P tag.
1632  *
1633  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1634  *                     destination is specified.
1635  * @param node   [i]   The P tag node is specified.
1636  * @return The conversion result is returned.
1637  */
1638 static char *
1639 s_xhtml_1_0_start_p_tag(void *pdoc, Node *node) 
1640 {
1641   xhtml_t *xhtml = GET_XHTML(pdoc);
1642   Doc     *doc   = xhtml->doc;
1643   Attr    *attr;
1644   char    *align = NULL;
1645
1646   W_L("<p");
1647   for (attr = qs_get_attr(doc,node);
1648        attr;
1649        attr = qs_get_next_attr(doc,attr)) {
1650     char *nm  = qs_get_attr_name(doc,attr);
1651     char *val = qs_get_attr_value(doc,attr);
1652     if (STRCASEEQ('a','A',"align", nm)) {
1653       /*----------------------------------------------------------------------*/
1654       /* CHTML 1.0 (W3C version 3.2)                                          */
1655       /*----------------------------------------------------------------------*/
1656       if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
1657         align = apr_pstrdup(doc->buf.pool, val);
1658         break;
1659       }
1660     }
1661   }
1662   if (align) {
1663     W_L(" align=\"");
1664     W_V(align);
1665     W_L("\"");
1666   }
1667   W_L(">");
1668   return xhtml->out;
1669 }
1670
1671
1672 /**
1673  * It is a handler who processes the P tag.
1674  *
1675  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1676  *                     destination is specified.
1677  * @param node   [i]   The P tag node is specified.
1678  * @return The conversion result is returned.
1679  */
1680 static char *
1681 s_xhtml_1_0_end_p_tag(void *pdoc, Node *UNUSED(child)) 
1682 {
1683   xhtml_t *xhtml = GET_XHTML(pdoc);
1684   Doc     *doc   = xhtml->doc;
1685
1686   W_L("</p>");
1687   return xhtml->out;
1688 }
1689
1690
1691 /**
1692  * It is a handler who processes the UL tag.
1693  *
1694  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1695  *                     destination is specified.
1696  * @param node   [i]   The UL tag node is specified.
1697  * @return The conversion result is returned.
1698  */
1699 static char *
1700 s_xhtml_1_0_start_ul_tag(void *pdoc, Node *node)
1701 {
1702   xhtml_t *xhtml = GET_XHTML(pdoc);
1703   Doc     *doc   = xhtml->doc;
1704   Attr    *attr;
1705   W_L("<ul");
1706   /*--------------------------------------------------------------------------*/
1707   /* Get Attributes                                                           */
1708   /*--------------------------------------------------------------------------*/
1709   for (attr = qs_get_attr(doc,node);
1710        attr;
1711        attr = qs_get_next_attr(doc,attr)) {
1712     char *name   = qs_get_attr_name(doc,attr);
1713     char *value  = qs_get_attr_value(doc,attr);
1714     if (STRCASEEQ('t','T',"type",name)) {
1715       if (value && (STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
1716         W_L(" type=\"");
1717         W_V(value);
1718         W_L("\"");
1719       }
1720     }
1721   }
1722   W_L(">");
1723   return xhtml->out;
1724 }
1725
1726
1727 /**
1728  * It is a handler who processes the UL tag.
1729  *
1730  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1731  *                     destination is specified.
1732  * @param node   [i]   The UL tag node is specified.
1733  * @return The conversion result is returned.
1734  */
1735 static char *
1736 s_xhtml_1_0_end_ul_tag(void *pdoc, Node *UNUSED(child)) 
1737 {
1738   xhtml_t *xhtml = GET_XHTML(pdoc);
1739   Doc     *doc   = xhtml->doc;
1740
1741   W_L("</ul>");
1742   return xhtml->out;
1743 }
1744
1745
1746 /**
1747  * It is a handler who processes the H1 tag.
1748  *
1749  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1750  *                     destination is specified.
1751  * @param node   [i]   The H1 tag node is specified.
1752  * @return The conversion result is returned.
1753  */
1754 static char *
1755 s_xhtml_1_0_start_h1_tag(void *pdoc, Node *node) 
1756 {
1757   xhtml_t *xhtml = GET_XHTML(pdoc);
1758   Doc     *doc   = xhtml->doc;
1759   Attr    *attr;
1760
1761   W_L("<h1");
1762   for (attr = qs_get_attr(doc,node);
1763        attr;
1764        attr = qs_get_next_attr(doc,attr)) {
1765     char* name;
1766     char* value;
1767     name  = qs_get_attr_name(doc,attr);
1768     value = qs_get_attr_value(doc,attr);
1769     if (STRCASEEQ('a','A',"align", name)) {
1770       if (value) {
1771         if (STRCASEEQ('l','L',"left",value)) {
1772           W_L(" style=\"");
1773           W_L("text-align:left");
1774           W_L("\"");
1775         }
1776         else if (STRCASEEQ('r','R',"right",value)) {
1777           W_L(" style=\"");
1778           W_L("text-align:right");
1779           W_L("\"");
1780         }
1781         else if (STRCASEEQ('c','C',"center",value)) {
1782           W_L(" style=\"");
1783           W_L("text-align:center");
1784           W_L("\"");
1785         }
1786         break;
1787       }
1788     }
1789   }
1790   W_L(">");
1791   return xhtml->out;
1792 }
1793
1794
1795 /**
1796  * It is a handler who processes the H1 tag.
1797  *
1798  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1799  *                     destination is specified.
1800  * @param node   [i]   The H1 tag node is specified.
1801  * @return The conversion result is returned.
1802  */
1803 static char *
1804 s_xhtml_1_0_end_h1_tag(void *pdoc, Node *UNUSED(child)) 
1805 {
1806   xhtml_t *xhtml = GET_XHTML(pdoc);
1807   Doc     *doc   = xhtml->doc;
1808
1809   W_L("</h1>");
1810   return xhtml->out;
1811 }
1812
1813
1814 /**
1815  * It is a handler who processes the H2 tag.
1816  *
1817  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1818  *                     destination is specified.
1819  * @param node   [i]   The H2 tag node is specified.
1820  * @return The conversion result is returned.
1821  */
1822 static char *
1823 s_xhtml_1_0_start_h2_tag(void *pdoc, Node *node)
1824 {
1825   xhtml_t *xhtml = GET_XHTML(pdoc);
1826   Doc     *doc = xhtml->doc;
1827   Attr    *attr;
1828
1829   W_L("<h2");
1830   for (attr = qs_get_attr(doc,node);
1831        attr;
1832        attr = qs_get_next_attr(doc,attr)) {
1833     char* name;
1834     char* value;
1835     name  = qs_get_attr_name(doc,attr);
1836     value = qs_get_attr_value(doc,attr);
1837     if (STRCASEEQ('a','A',"align", name)) {
1838       if (value) {
1839         if (STRCASEEQ('l','L',"left",value)) {
1840           W_L(" style=\"");
1841           W_L("text-align:left");
1842           W_L("\"");
1843         }
1844         else if (STRCASEEQ('r','R',"right",value)) {
1845           W_L(" style=\"");
1846           W_L("text-align:right");
1847           W_L("\"");
1848         }
1849         else if (STRCASEEQ('c','C',"center",value)) {
1850           W_L(" style=\"");
1851           W_L("text-align:center");
1852           W_L("\"");
1853         }
1854         break;
1855       }
1856     }
1857   }
1858   W_L(">");
1859   return xhtml->out;
1860 }
1861
1862
1863 /**
1864  * It is a handler who processes the H2 tag.
1865  *
1866  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1867  *                     destination is specified.
1868  * @param node   [i]   The H2 tag node is specified.
1869  * @return The conversion result is returned.
1870  */
1871 static char *
1872 s_xhtml_1_0_end_h2_tag(void *pdoc, Node *UNUSED(child)) 
1873 {
1874   xhtml_t *xhtml = GET_XHTML(pdoc);
1875   Doc     *doc   = xhtml->doc;
1876
1877   W_L("</h2>");
1878   return xhtml->out;
1879 }
1880
1881
1882 /**
1883  * It is a handler who processes the H3 tag.
1884  *
1885  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1886  *                     destination is specified.
1887  * @param node   [i]   The H3 tag node is specified.
1888  * @return The conversion result is returned.
1889  */
1890 static char *
1891 s_xhtml_1_0_start_h3_tag(void *pdoc, Node *node)
1892 {
1893   xhtml_t *xhtml = GET_XHTML(pdoc);
1894   Doc     *doc   = xhtml->doc;
1895   Attr    *attr;
1896
1897   W_L("<h3");
1898   for (attr = qs_get_attr(doc,node);
1899        attr;
1900        attr = qs_get_next_attr(doc,attr)) {
1901     char* name;
1902     char* value;
1903     name  = qs_get_attr_name(doc,attr);
1904     value = qs_get_attr_value(doc,attr);
1905     if (STRCASEEQ('a','A',"align", name)) {
1906       if (value) {
1907         if (STRCASEEQ('l','L',"left",value)) {
1908           W_L(" style=\"");
1909           W_L("text-align:left");
1910           W_L("\"");
1911         }
1912         else if (STRCASEEQ('r','R',"right",value)) {
1913           W_L(" style=\"");
1914           W_L("text-align:right");
1915           W_L("\"");
1916         }
1917         else if (STRCASEEQ('c','C',"center",value)) {
1918           W_L(" style=\"");
1919           W_L("text-align:center");
1920           W_L("\"");
1921         }
1922         break;
1923       }
1924     }
1925   }
1926   W_L(">");
1927   return xhtml->out;
1928 }
1929
1930
1931 /**
1932  * It is a handler who processes the H3 tag.
1933  *
1934  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1935  *                     destination is specified.
1936  * @param node   [i]   The H3 tag node is specified.
1937  * @return The conversion result is returned.
1938  */
1939 static char *
1940 s_xhtml_1_0_end_h3_tag(void *pdoc, Node *UNUSED(child)) 
1941 {
1942   xhtml_t *xhtml = GET_XHTML(pdoc);
1943   Doc     *doc   = xhtml->doc;
1944
1945   W_L("</h3>");
1946   return xhtml->out;
1947 }
1948
1949
1950 /**
1951  * It is a handler who processes the H4 tag.
1952  *
1953  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1954  *                     destination is specified.
1955  * @param node   [i]   The H4 tag node is specified.
1956  * @return The conversion result is returned.
1957  */
1958 static char *
1959 s_xhtml_1_0_start_h4_tag(void *pdoc, Node *node)
1960 {
1961   xhtml_t *xhtml = GET_XHTML(pdoc);
1962   Doc     *doc   = xhtml->doc;
1963   Attr    *attr;
1964
1965   W_L("<h4");
1966   for (attr = qs_get_attr(doc,node);
1967        attr;
1968        attr = qs_get_next_attr(doc,attr)) {
1969     char* name;
1970     char* value;
1971     name  = qs_get_attr_name(doc,attr);
1972     value = qs_get_attr_value(doc,attr);
1973     if (STRCASEEQ('a','A',"align", name)) {
1974       if (value) {
1975         if (STRCASEEQ('l','L',"left",value)) {
1976           W_L(" style=\"");
1977           W_L("text-align:left");
1978           W_L("\"");
1979         }
1980         else if (STRCASEEQ('r','R',"right",value)) {
1981           W_L(" style=\"");
1982           W_L("text-align:right");
1983           W_L("\"");
1984         }
1985         else if (STRCASEEQ('c','C',"center",value)) {
1986           W_L(" style=\"");
1987           W_L("text-align:center");
1988           W_L("\"");
1989         }
1990         break;
1991       }
1992     }
1993   }
1994   W_L(">");
1995   return xhtml->out;
1996 }
1997
1998
1999 /**
2000  * It is a handler who processes the H4 tag.
2001  *
2002  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2003  *                     destination is specified.
2004  * @param node   [i]   The H4 tag node is specified.
2005  * @return The conversion result is returned.
2006  */
2007 static char *
2008 s_xhtml_1_0_end_h4_tag(void *pdoc, Node *UNUSED(child)) 
2009 {
2010   xhtml_t *xhtml = GET_XHTML(pdoc);
2011   Doc     *doc   = xhtml->doc;
2012
2013   W_L("</h4>");
2014   return xhtml->out;
2015 }
2016
2017
2018 /**
2019  * It is a handler who processes the H5 tag.
2020  *
2021  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2022  *                     destination is specified.
2023  * @param node   [i]   The H5 tag node is specified.
2024  * @return The conversion result is returned.
2025  */
2026 static char *
2027 s_xhtml_1_0_start_h5_tag(void *pdoc, Node *node)
2028 {
2029   xhtml_t *xhtml = GET_XHTML(pdoc);
2030   Doc     *doc   = xhtml->doc;
2031   Attr    *attr;
2032
2033   W_L("<h5");
2034   for (attr = qs_get_attr(doc,node);
2035        attr;
2036        attr = qs_get_next_attr(doc,attr)) {
2037     char* name;
2038     char* value;
2039     name  = qs_get_attr_name(doc,attr);
2040     value = qs_get_attr_value(doc,attr);
2041     if (STRCASEEQ('a','A',"align", name)) {
2042       if (value) {
2043         if (STRCASEEQ('l','L',"left",value)) {
2044           W_L(" style=\"");
2045           W_L("text-align:left");
2046           W_L("\"");
2047         }
2048         else if (STRCASEEQ('r','R',"right",value)) {
2049           W_L(" style=\"");
2050           W_L("text-align:right");
2051           W_L("\"");
2052         }
2053         else if (STRCASEEQ('c','C',"center",value)) {
2054           W_L(" style=\"");
2055           W_L("text-align:center");
2056           W_L("\"");
2057         }
2058         break;
2059       }
2060     }
2061   }
2062   W_L(">");
2063   return xhtml->out;
2064 }
2065
2066
2067 /**
2068  * It is a handler who processes the H5 tag.
2069  *
2070  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2071  *                     destination is specified.
2072  * @param node   [i]   The H5 tag node is specified.
2073  * @return The conversion result is returned.
2074  */
2075 static char *
2076 s_xhtml_1_0_end_h5_tag(void *pdoc, Node *UNUSED(child)) 
2077 {
2078   xhtml_t *xhtml = GET_XHTML(pdoc);
2079   Doc     *doc   = xhtml->doc;
2080
2081   W_L("</h5>");
2082   return xhtml->out;
2083 }
2084
2085
2086 /**
2087  * It is a handler who processes the H6 tag.
2088  *
2089  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2090  *                     destination is specified.
2091  * @param node   [i]   The H6 tag node is specified.
2092  * @return The conversion result is returned.
2093  */
2094 static char *
2095 s_xhtml_1_0_start_h6_tag(void *pdoc, Node *node)
2096 {
2097   xhtml_t *xhtml = GET_XHTML(pdoc);
2098   Doc     *doc   = xhtml->doc;
2099   Attr    *attr;
2100
2101   W_L("<h6");
2102   for (attr = qs_get_attr(doc,node);
2103        attr;
2104        attr = qs_get_next_attr(doc,attr)) {
2105     char* name;
2106     char* value;
2107     name  = qs_get_attr_name(doc,attr);
2108     value = qs_get_attr_value(doc,attr);
2109     if (STRCASEEQ('a','A',"align", name)) {
2110       if (value) {
2111         if (STRCASEEQ('l','L',"left",value)) {
2112           W_L(" style=\"");
2113           W_L("text-align:left");
2114           W_L("\"");
2115         }
2116         else if (STRCASEEQ('r','R',"right",value)) {
2117           W_L(" style=\"");
2118           W_L("text-align:right");
2119           W_L("\"");
2120         }
2121         else if (STRCASEEQ('c','C',"center",value)) {
2122           W_L(" style=\"");
2123           W_L("text-align:center");
2124           W_L("\"");
2125         }
2126         break;
2127       }
2128     }
2129   }
2130   W_L(">");
2131   return xhtml->out;
2132 }
2133
2134
2135 /**
2136  * It is a handler who processes the H6 tag.
2137  *
2138  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2139  *                     destination is specified.
2140  * @param node   [i]   The H6 tag node is specified.
2141  * @return The conversion result is returned.
2142  */
2143 static char *
2144 s_xhtml_1_0_end_h6_tag(void *pdoc, Node *UNUSED(child)) 
2145 {
2146   xhtml_t *xhtml = GET_XHTML(pdoc);
2147   Doc     *doc   = xhtml->doc;
2148
2149   W_L("</h6>");
2150   return xhtml->out;
2151 }
2152
2153
2154 /**
2155  * It is a handler who processes the OL tag.
2156  *
2157  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2158  *                     destination is specified.
2159  * @param node   [i]   The OL tag node is specified.
2160  * @return The conversion result is returned.
2161  */
2162 static char *
2163 s_xhtml_1_0_start_ol_tag(void *pdoc, Node *node)
2164 {
2165   xhtml_t *xhtml = GET_XHTML(pdoc);
2166   Doc     *doc   = xhtml->doc;
2167   Attr    *attr;
2168
2169   W_L("<ol");
2170   /*--------------------------------------------------------------------------*/
2171   /* Get Attributes                                                           */
2172   /*--------------------------------------------------------------------------*/
2173   for (attr = qs_get_attr(doc,node);
2174        attr;
2175        attr = qs_get_next_attr(doc,attr)) {
2176     char *name = qs_get_attr_name(doc,attr);
2177     char *value = qs_get_attr_value(doc,attr);
2178     if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
2179       W_L(" type=\"");
2180       W_V(value);
2181       W_L("\"");
2182     }
2183     else if (STRCASEEQ('s','S',"start",name) && value && *value) {
2184       W_L(" start=\"");
2185       W_V(value);
2186       W_L("\"");
2187     }
2188   }
2189   W_L(">");
2190   return xhtml->out;
2191 }
2192
2193
2194 /**
2195  * It is a handler who processes the OL tag.
2196  *
2197  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2198  *                     destination is specified.
2199  * @param node   [i]   The OL tag node is specified.
2200  * @return The conversion result is returned.
2201  */
2202 static char *
2203 s_xhtml_1_0_end_ol_tag(void *pdoc, Node *UNUSED(child)) 
2204 {
2205   xhtml_t *xhtml = GET_XHTML(pdoc);
2206   Doc     *doc   = xhtml->doc;
2207
2208   W_L("</ol>");
2209   return xhtml->out;
2210 }
2211
2212
2213 /**
2214  * It is a handler who processes the LI tag.
2215  *
2216  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2217  *                     destination is specified.
2218  * @param node   [i]   The LI tag node is specified.
2219  * @return The conversion result is returned.
2220  */
2221 static char *
2222 s_xhtml_1_0_start_li_tag(void *pdoc, Node *node)
2223 {
2224   xhtml_t *xhtml = GET_XHTML(pdoc);
2225   Doc     *doc   = xhtml->doc;
2226   Attr    *attr;
2227
2228   W_L("<li");
2229   /*--------------------------------------------------------------------------*/
2230   /* Get Attributes                                                           */
2231   /*--------------------------------------------------------------------------*/
2232   for (attr = qs_get_attr(doc,node);
2233        attr;
2234        attr = qs_get_next_attr(doc,attr)) {
2235     char *name  = qs_get_attr_name(doc,attr);
2236     char *value = qs_get_attr_value(doc,attr);
2237     if (STRCASEEQ('t','T',"type",name)) {
2238       if (value && (*value == '1' || *value == 'a' || *value == 'A' || STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
2239         W_L(" type=\"");
2240         W_V(value);
2241         W_L("\"");
2242       }
2243     }
2244     else if (STRCASEEQ('v','V',"value", name) && value && *value) {
2245       W_L(" value=\"");
2246       W_V(value);
2247       W_L("\"");
2248     }
2249   }
2250   W_L(">");
2251   return xhtml->out;
2252 }
2253
2254
2255 /**
2256  ** It is a handler who processes the LI tag.
2257  *
2258  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2259  *                     destination is specified.
2260  * @param node   [i]   The LI tag node is specified.
2261  * @return The conversion result is returned.
2262  */
2263 static char *
2264 s_xhtml_1_0_end_li_tag(void *pdoc, Node *UNUSED(child)) 
2265 {
2266   xhtml_t *xhtml = GET_XHTML(pdoc);
2267   Doc     *doc   = xhtml->doc;
2268
2269   W_L("</li>");
2270   return xhtml->out;
2271 }
2272
2273 /**
2274  * It is a handler who processes the IMG tag.
2275  *
2276  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2277  *                     destination is specified.
2278  * @param node   [i]   The IMG tag node is specified.
2279  * @return The conversion result is returned.
2280  */
2281 static char *
2282 s_xhtml_1_0_start_img_tag(void *pdoc, Node *node) 
2283 {
2284   xhtml_t       *xhtml = GET_XHTML(pdoc);
2285   Doc           *doc   = xhtml->doc;
2286   request_rec   *r     = doc->r;
2287   Attr          *attr;
2288
2289 #ifndef IMG_NOT_CONVERT_FILENAME
2290   device_table  *spec = xhtml->spec;
2291 #endif
2292
2293   W_L("<img");
2294   /*--------------------------------------------------------------------------*/
2295   /* Get Attributes                                                           */
2296   /*--------------------------------------------------------------------------*/
2297   for (attr = qs_get_attr(doc,node);
2298        attr;
2299        attr = qs_get_next_attr(doc,attr)) {
2300     char *name  = qs_get_attr_name(doc,attr);
2301     char *value = qs_get_attr_value(doc,attr);
2302
2303     if (STRCASEEQ('s','S',"src",name)) {
2304       value = chxj_encoding_parameter(r, value);
2305 #ifdef IMG_NOT_CONVERT_FILENAME
2306
2307       W_L(" src=\"");
2308       W_V(value);
2309       W_L("\"");
2310
2311 #else
2312
2313       W_L(" src=\"");
2314       {
2315         char *vv = chxj_img_conv(r,spec,value);
2316         W_V(vv);
2317       }
2318       W_L("\"");
2319
2320 #endif
2321     }
2322     else 
2323     if (STRCASEEQ('a','A',"align",name)) {
2324       if (value) {
2325         if (STRCASEEQ('t','T',"top",   value) ||
2326             STRCASEEQ('m','M',"middle",value) ||
2327             STRCASEEQ('b','B',"bottom",value) ||
2328             STRCASEEQ('l','L',"left",  value) ||
2329             STRCASEEQ('r','R',"right", value)) {
2330           W_L(" align=\"");
2331           W_V(value);
2332           W_L("\"");
2333         }
2334         else if (STRCASEEQ('c','C',"center",  value)) {
2335           W_L(" align=\"");
2336           W_L("middle");
2337           W_L("\"");
2338         }
2339       }
2340     }
2341     else if (STRCASEEQ('a','A',"alt",name) && value && *value) {
2342       W_L(" alt=\"");
2343       W_V(value);
2344       W_L("\"");
2345     }
2346     else if (STRCASEEQ('w','W',"width",name) && value && *value) {
2347       W_L(" width=\"");
2348       W_V(value);
2349       W_L("\"");
2350     }
2351     else if (STRCASEEQ('h','H',"height",name) && value && *value) {
2352       W_L(" height=\"");
2353       W_V(value);
2354       W_L("\"");
2355     }
2356     else if (STRCASEEQ('h','H',"hspace",name) && value && *value) {
2357       W_L(" hspace=\"");
2358       W_V(value);
2359       W_L("\"");
2360     }
2361     else if (STRCASEEQ('v','V',"vspace",name) && value && *value) {
2362       W_L(" vspace=\"");
2363       W_V(value);
2364       W_L("\"");
2365     }
2366   }
2367   W_L(" />");
2368   return xhtml->out;
2369 }
2370
2371
2372 /**
2373  * It is a handler who processes the IMG tag.
2374  *
2375  * @param xhtml  [i/o] The pointer to the XHTML structure at the output
2376  *                     destination is specified.
2377  * @param node   [i]   The IMG tag node is specified.
2378  * @return The conversion result is returned.
2379  */
2380 static char *
2381 s_xhtml_1_0_end_img_tag(void *pdoc, Node *UNUSED(child)) 
2382 {
2383   xhtml_t *xhtml = GET_XHTML(pdoc);
2384
2385   return xhtml->out;
2386 }
2387
2388
2389 /**
2390  * It is a handler who processes the SELECT tag.
2391  *
2392  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2393  *                     destination is specified.
2394  * @param node   [i]   The SELECT tag node is specified.
2395  * @return The conversion result is returned.
2396  */
2397 static char *
2398 s_xhtml_1_0_start_select_tag(void *pdoc, Node *child)
2399 {
2400   xhtml_t *xhtml    = GET_XHTML(pdoc);
2401   Doc     *doc      = xhtml->doc;
2402   char    *size     = NULL;
2403   char    *name     = NULL;
2404   char    *multiple = NULL;
2405   Attr    *attr;
2406
2407
2408   W_L("<select");
2409   for (attr = qs_get_attr(doc,child);
2410        attr;
2411        attr = qs_get_next_attr(doc,attr)) {
2412     char *nm  = qs_get_attr_name(doc,attr);
2413     char *val = qs_get_attr_value(doc,attr);
2414     if (STRCASEEQ('s','S',"size",nm)) {
2415       /*----------------------------------------------------------------------*/
2416       /* CHTML 1.0 version 2.0                                                */
2417       /*----------------------------------------------------------------------*/
2418       size = apr_pstrdup(doc->buf.pool, val);
2419     }
2420     else if (STRCASEEQ('n','N',"name",nm)) {
2421       /*----------------------------------------------------------------------*/
2422       /* CHTML 1.0 version 2.0                                                */
2423       /*----------------------------------------------------------------------*/
2424       name = apr_pstrdup(doc->buf.pool, val);
2425     }
2426     else if (STRCASEEQ('m','M',"multiple",nm)) {
2427       /*----------------------------------------------------------------------*/
2428       /* CHTML 1.0 version 2.0                                                */
2429       /*----------------------------------------------------------------------*/
2430       multiple = apr_pstrdup(doc->buf.pool, val);
2431     }
2432   }
2433   if (size && *size) {
2434     W_L(" size=\"");
2435     W_V(size);
2436     W_L("\"");
2437   }
2438   if (name && *name) {
2439     W_L(" name=\"");
2440     W_V(name);
2441     W_L("\"");
2442   }
2443   if (multiple) {
2444     /* "true" is *NOT* W3C. it is specification of WAP2.0 for EZWEB */
2445     W_L(" multiple=\"true\"");
2446   }
2447   W_L(">\r\n");
2448   return xhtml->out;
2449 }
2450
2451
2452 /**
2453  * It is a handler who processes the SELECT tag.
2454  *
2455  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2456  *                     destination is specified.
2457  * @param node   [i]   The SELECT tag node is specified.
2458  * @return The conversion result is returned.
2459  */
2460 static char *
2461 s_xhtml_1_0_end_select_tag(void *pdoc, Node *UNUSED(child))
2462 {
2463   xhtml_t *xhtml = GET_XHTML(pdoc);
2464   Doc     *doc   = xhtml->doc;
2465
2466   W_L("</select>\r\n");
2467   return xhtml->out;
2468 }
2469
2470
2471 /**
2472  * It is a handler who processes the OPTION tag.
2473  *
2474  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2475  *                     destination is specified.
2476  * @param node   [i]   The OPTION tag node is specified.
2477  * @return The conversion result is returned.
2478  */
2479 static char *
2480 s_xhtml_1_0_start_option_tag(void *pdoc, Node *child)
2481 {
2482   xhtml_t *xhtml = GET_XHTML(pdoc);
2483   Doc     *doc   = xhtml->doc;
2484   Attr    *attr;
2485
2486   char *selected   = NULL;
2487   char *value      = NULL;
2488
2489   W_L("<option");
2490   for (attr = qs_get_attr(doc,child);
2491        attr;
2492        attr = qs_get_next_attr(doc,attr)) {
2493     char *nm  = qs_get_attr_name(doc,attr);
2494     char *val = qs_get_attr_value(doc,attr);
2495     if (STRCASEEQ('s','S',"selected",nm)) {
2496       /* CHTML version 2.0 */
2497       selected = apr_pstrdup(doc->buf.pool, val);
2498     }
2499     else if (STRCASEEQ('v','V',"value",nm)) {
2500       /* CHTML version 2.0 */
2501       value = apr_pstrdup(doc->buf.pool, val);
2502     }
2503   }
2504   if (value && *value) {
2505     W_L(" value=\"");
2506     W_V(value);
2507     W_L("\"");
2508   }
2509   if (selected) {
2510     W_L(" selected=\"selected\"");
2511   }
2512   W_L(">");
2513   return xhtml->out;
2514 }
2515
2516
2517 /**
2518  * It is a handler who processes the OPTION tag.
2519  *
2520  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2521  *                     destination is specified.
2522  * @param node   [i]   The OPTION tag node is specified.
2523  * @return The conversion result is returned.
2524  */
2525 static char *
2526 s_xhtml_1_0_end_option_tag(void *pdoc, Node *UNUSED(child))
2527 {
2528   xhtml_t *xhtml = GET_XHTML(pdoc);
2529   Doc     *doc   = xhtml->doc;
2530
2531   W_L("</option>\r\n");
2532   return xhtml->out;
2533 }
2534
2535
2536 /**
2537  * It is a handler who processes the DIV tag.
2538  *
2539  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2540  *                     destination is specified.
2541  * @param node   [i]   The DIV tag node is specified.
2542  * @return The conversion result is returned.
2543  */
2544 static char *
2545 s_xhtml_1_0_start_div_tag(void *pdoc, Node *child)
2546 {
2547   xhtml_t *xhtml = GET_XHTML(pdoc);
2548   Doc     *doc   = xhtml->doc;
2549   Attr    *attr;
2550   char    *align   = NULL;
2551
2552   W_L("<div");
2553   for (attr = qs_get_attr(doc,child);
2554        attr;
2555        attr = qs_get_next_attr(doc,attr)) {
2556     char *nm  = qs_get_attr_name(doc,attr);
2557     char *val = qs_get_attr_value(doc,attr);
2558     if (STRCASEEQ('a','A',"align",nm)) {
2559       /*=====================================================================*/
2560       /* CHTML version 3.2                                                   */
2561       /*=====================================================================*/
2562       if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2563         align = apr_pstrdup(doc->buf.pool, val);
2564       }
2565     }
2566   }
2567   if (align) {
2568     W_L(" align=\"");
2569     W_V(align);
2570     W_L("\"");
2571   }
2572   W_L(">");
2573   return xhtml->out;
2574 }
2575
2576
2577 /**
2578  * It is a handler who processes the DIV tag.
2579  *
2580  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2581  *                     destination is specified.
2582  * @param node   [i]   The DIV tag node is specified.
2583  * @return The conversion result is returned.
2584  */
2585 static char *
2586 s_xhtml_1_0_end_div_tag(void *pdoc, Node *UNUSED(child))
2587 {
2588   xhtml_t *xhtml = GET_XHTML(pdoc);
2589   Doc     *doc   = xhtml->doc;
2590   W_L("</div>\r\n");
2591   return xhtml->out;
2592 }
2593
2594
2595 /**
2596  * It is a handler who processes the B tag.
2597  *
2598  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2599  *                     destination is specified.
2600  * @param node   [i]   The B tag node is specified.
2601  * @return The conversion result is returned.
2602  */
2603 static char *
2604 s_xhtml_1_0_start_b_tag(void *pdoc, Node *UNUSED(child))
2605 {
2606   xhtml_t *xhtml = GET_XHTML(pdoc);
2607   Doc     *doc   = xhtml->doc;
2608
2609   W_L("<div style=\"font-weight:bold\">");
2610   return xhtml->out;
2611 }
2612
2613
2614 /**
2615  * It is a handler who processes the B tag.
2616  *
2617  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2618  *                     destination is specified.
2619  * @param node   [i]   The B tag node is specified.
2620  * @return The conversion result is returned.
2621  */
2622 static char *
2623 s_xhtml_1_0_end_b_tag(void *pdoc, Node *UNUSED(child))
2624 {
2625   xhtml_t *xhtml = GET_XHTML(pdoc);
2626   Doc     *doc   = xhtml->doc;
2627
2628   W_L("</div>\n");
2629   return xhtml->out;
2630 }
2631
2632
2633 /**
2634  * It is a handler who processes the CHXJ:IF tag.
2635  *
2636  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2637  *                     destination is specified.
2638  * @param node   [i]   The CHXJ:IF tag node is specified.
2639  */
2640 static char *
2641 s_xhtml_1_0_chxjif_tag(void *pdoc, Node *node)
2642 {
2643   xhtml_t      *xhtml = GET_XHTML(pdoc);
2644   Doc          *doc   = xhtml->doc;
2645   Node         *child;
2646
2647   for (child = qs_get_child_node(doc, node);
2648        child;
2649        child = qs_get_next_node(doc, child)) {
2650     W_V(child->otext);
2651     s_xhtml_1_0_chxjif_tag(xhtml, child);
2652   }
2653
2654   return NULL;
2655 }
2656
2657
2658 /**
2659  * It is a handler who processes the TEXTARE tag.
2660  *
2661  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2662  *                     destination is specified.
2663  * @param node   [i]   The TEXTAREA tag node is specified.
2664  * @return The conversion result is returned.
2665  */
2666 static char *
2667 s_xhtml_1_0_start_textarea_tag(void *pdoc, Node *node) 
2668 {
2669   xhtml_t *xhtml = GET_XHTML(pdoc);
2670   Doc     *doc   = xhtml->doc;
2671   Attr    *attr;
2672
2673   xhtml->textarea_flag++;
2674   W_L("<textarea");
2675   for (attr = qs_get_attr(doc,node);
2676        attr;
2677        attr = qs_get_next_attr(doc,attr)) {
2678     char *name  = qs_get_attr_name(doc,attr);
2679     char *value = qs_get_attr_value(doc,attr);
2680     if (STRCASEEQ('n','N',"name",name) && value && *value) {
2681       W_L(" name=\"");
2682       W_V(value);
2683       W_L("\"");
2684     }
2685     else if (STRCASEEQ('r','R',"rows",name) && value && *value) {
2686       W_L(" rows=\"");
2687       W_V(value);
2688       W_L("\"");
2689     }
2690     else if (STRCASEEQ('c','C',"cols",name) && value && *value) {
2691       W_L(" cols=\"");
2692       W_V(value);
2693       W_L("\"");
2694     }
2695     else if (STRCASEEQ('i','I',"istyle", name) && value && (*value == '1' || *value == '2' || *value == '3' || *value == '4')) {
2696       char *fmt = qs_conv_istyle_to_format(doc->r,value);
2697       W_L(" FORMAT=\"*");
2698       W_V(fmt);
2699       W_L("\"");
2700     }
2701     else if (STRCASEEQ('a','A',"accesskey",name) && value && *value != 0) {
2702       W_L(" accesskey=\"");
2703       W_V(value);
2704       W_L("\"");
2705     }
2706   }
2707   W_L(">\r\n");
2708   return xhtml->out;
2709 }
2710
2711
2712 /**
2713  * It is a handler who processes the TEXTAREA tag.
2714  *
2715  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2716  *                     destination is specified.
2717  * @param node   [i]   The TEXTAREA tag node is specified.
2718  * @return The conversion result is returned.
2719  */
2720 static char *
2721 s_xhtml_1_0_end_textarea_tag(void *pdoc, Node *UNUSED(child)) 
2722 {
2723   xhtml_t *xhtml = GET_XHTML(pdoc);
2724   Doc     *doc   = xhtml->doc;
2725
2726   W_L("</textarea>\r\n");
2727   xhtml->textarea_flag--;
2728
2729   return xhtml->out;
2730 }
2731
2732 static char *
2733 s_xhtml_1_0_text_tag(void *pdoc, Node *child)
2734 {
2735   xhtml_t     *xhtml   = GET_XHTML(pdoc);
2736   Doc         *doc     = xhtml->doc;
2737   request_rec *r       = doc->r;
2738   char        *textval;
2739   char        *tmp;
2740   char        *tdst;
2741   char        one_byte[2];
2742   int         ii;
2743   int         tdst_len;
2744   
2745   textval = qs_get_node_value(doc,child);
2746   if (strlen(textval) == 0) {
2747     return xhtml->out;
2748   }
2749   
2750   tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
2751   memset(tmp, 0, qs_get_node_size(doc,child)+1);
2752   
2753   tdst     = qs_alloc_zero_byte_string(r);
2754   memset(one_byte, 0, sizeof(one_byte));
2755   tdst_len = 0;
2756   
2757   for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
2758     char *out;
2759     int rtn = s_xhtml_search_emoji(xhtml, &textval[ii], &out);
2760     if (rtn != 0) {
2761       DBG(r,"[%s][%d]", out, rtn);
2762       tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
2763       ii+=(rtn - 1);
2764       continue;
2765     }
2766     if (is_sjis_kanji(textval[ii])) {
2767       one_byte[0] = textval[ii+0];
2768       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2769       one_byte[0] = textval[ii+1];
2770       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2771       ii++;
2772     }
2773     else if (xhtml->pre_flag) {
2774       one_byte[0] = textval[ii+0];
2775       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2776     }
2777     else if (xhtml->textarea_flag) {
2778       one_byte[0] = textval[ii+0];
2779       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2780     }
2781     else if (textval[ii] != '\r' && textval[ii] != '\n') {
2782       one_byte[0] = textval[ii+0];
2783       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2784     }
2785   }
2786   W_V(tdst);
2787   return xhtml->out;
2788 }
2789
2790
2791 /**
2792  * It is a handler who processes the BLOCKQUOTE tag.
2793  *
2794  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2795  *                     destination is specified.
2796  * @param node   [i]   The BLOCKQUOTE tag node is specified.
2797  * @return The conversion result is returned.
2798  */
2799 static char *
2800 s_xhtml_1_0_start_blockquote_tag(void *pdoc, Node *UNUSED(child))
2801 {
2802   xhtml_t *xhtml = GET_XHTML(pdoc);
2803   Doc     *doc   = xhtml->doc;
2804   W_L("<blockquote>");
2805   return xhtml->out;
2806 }
2807
2808
2809 /**
2810  * It is a handler who processes the BLOCKQUOTE tag.
2811  *
2812  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2813  *                     destination is specified.
2814  * @param node   [i]   The BLOCKQUOTE tag node is specified.
2815  * @return The conversion result is returned.
2816  */
2817 static char *
2818 s_xhtml_1_0_end_blockquote_tag(void *pdoc, Node *UNUSED(child))
2819 {
2820   xhtml_t *xhtml = GET_XHTML(pdoc);
2821   Doc     *doc   = xhtml->doc;
2822   W_L("</blockquote>");
2823   return xhtml->out;
2824 }
2825
2826
2827 /**
2828  * It is a handler who processes the DIR tag.
2829  *
2830  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2831  *                     destination is specified.
2832  * @param node   [i]   The DIR tag node is specified.
2833  * @return The conversion result is returned.
2834  */
2835 static char *
2836 s_xhtml_1_0_start_dir_tag(void *pdoc, Node *node)
2837 {
2838   xhtml_t *xhtml = GET_XHTML(pdoc);
2839   Doc     *doc = xhtml->doc;
2840   Attr      *attr;
2841   W_L("<dir");
2842   for (attr = qs_get_attr(doc,node);
2843        attr;
2844        attr = qs_get_next_attr(doc,attr)) {
2845     char *name   = qs_get_attr_name(doc,attr);
2846     char *value  = qs_get_attr_value(doc,attr);
2847     if (STRCASEEQ('t','T',"type",name)) {
2848       if (value && (STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
2849         W_L(" type=\"");
2850         W_V(value);
2851         W_L("\"");
2852       }
2853     }
2854   }
2855   W_L(">");
2856   return xhtml->out;
2857 }
2858
2859
2860 /**
2861  * It is a handler who processes the DIR tag.
2862  *
2863  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2864  *                     destination is specified.
2865  * @param node   [i]   The DIR tag node is specified.
2866  * @return The conversion result is returned.
2867  */
2868 static char *
2869 s_xhtml_1_0_end_dir_tag(void *pdoc, Node *UNUSED(child))
2870 {
2871   xhtml_t *xhtml = GET_XHTML(pdoc);
2872   Doc     *doc = xhtml->doc;
2873   W_L("</dir>");
2874   return xhtml->out;
2875 }
2876
2877
2878 /**
2879  * It is a handler who processes the DL tag.
2880  *
2881  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2882  *                     destination is specified.
2883  * @param node   [i]   The DL tag node is specified.
2884  * @return The conversion result is returned.
2885  */
2886 static char *
2887 s_xhtml_1_0_start_dl_tag(void *pdoc, Node *UNUSED(child))
2888 {
2889   xhtml_t *xhtml = GET_XHTML(pdoc);
2890   Doc *doc = xhtml->doc;
2891   W_L("<dl>");
2892   return xhtml->out;
2893 }
2894
2895
2896 /**
2897  * It is a handler who processes the DL tag.
2898  *
2899  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2900  *                     destination is specified.
2901  * @param node   [i]   The DL tag node is specified.
2902  * @return The conversion result is returned.
2903  */
2904 static char *
2905 s_xhtml_1_0_end_dl_tag(void *pdoc, Node *UNUSED(child))
2906 {
2907   xhtml_t *xhtml = GET_XHTML(pdoc);
2908   Doc *doc = xhtml->doc;
2909   W_L("</dl>");
2910   return xhtml->out;
2911 }
2912
2913
2914 /**
2915  * It is a handter who processes the DT tag.
2916  *
2917  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2918  *                     destination is specified.
2919  * @param node   [i]   The DT tag node is specified.
2920  * @return The conversion result is returned.
2921  */
2922 static char *
2923 s_xhtml_1_0_start_dt_tag(void *pdoc, Node *UNUSED(child))
2924 {
2925   xhtml_t *xhtml = GET_XHTML(pdoc);
2926   Doc     *doc   = xhtml->doc;
2927   W_L("<dt>");
2928   return xhtml->out;
2929 }
2930
2931
2932 /**
2933  * It is a handter who processes the DT tag.
2934  *
2935  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2936  *                     destination is specified.
2937  * @param node   [i]   The DT tag node is specified.
2938  * @return The conversion result is returned.
2939  */
2940 static char *
2941 s_xhtml_1_0_end_dt_tag(void *pdoc, Node *UNUSED(child))
2942 {
2943   xhtml_t *xhtml = GET_XHTML(pdoc);
2944   Doc     *doc   = xhtml->doc;
2945   W_L("</dt>");
2946   return xhtml->out;
2947 }
2948
2949
2950 /**
2951  * It is a handder who processes the DD tag.
2952  *
2953  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2954  *                     destination is specified.
2955  * @param node   [i]   The DD tag node is specified.
2956  * @return The conversion result is returned.
2957  */
2958 static char *
2959 s_xhtml_1_0_start_dd_tag(void *pdoc, Node *UNUSED(child))
2960 {
2961   xhtml_t *xhtml = GET_XHTML(pdoc);
2962   Doc     *doc   = xhtml->doc;
2963   W_L("<dd>");
2964   return xhtml->out;
2965 }
2966
2967
2968 /**
2969  * It is a handder who processes the DD tag.
2970  *
2971  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2972  *                     destination is specified.
2973  * @param node   [i]   The DD tag node is specified.
2974  * @return The conversion result is returned.
2975  */
2976 static char *
2977 s_xhtml_1_0_end_dd_tag(void *pdoc, Node *UNUSED(child))
2978 {
2979   xhtml_t *xhtml = GET_XHTML(pdoc);
2980   Doc     *doc   = xhtml->doc;
2981   W_L("</dd>");
2982   return xhtml->out;
2983 }
2984
2985
2986 /**
2987  * It is a handler who processes the MENU tag.
2988  *
2989  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2990  *                     destination is specified.
2991  * @param node   [i]   The MENU tag node is specified.
2992  * @return The conversion result is returned.
2993  */
2994 static char *
2995 s_xhtml_1_0_start_menu_tag(void *pdoc, Node *node)
2996 {
2997   xhtml_t *xhtml = GET_XHTML(pdoc);
2998   Doc     *doc   = xhtml->doc;
2999   Attr    *attr;
3000   W_L("<menu");
3001   /*--------------------------------------------------------------------------*/
3002   /* Get Attributes                                                           */
3003   /*--------------------------------------------------------------------------*/
3004   for (attr = qs_get_attr(doc,node);
3005        attr;
3006        attr = qs_get_next_attr(doc,attr)) {
3007     char *name   = qs_get_attr_name(doc,attr);
3008     char *value  = qs_get_attr_value(doc,attr);
3009     if (STRCASEEQ('t','T',"type",name)) {
3010       if (value && (STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
3011         W_L(" type=\"");
3012         W_V(value);
3013         W_L("\"");
3014       }
3015     }
3016   }
3017   W_L(">");
3018   return xhtml->out;
3019 }
3020
3021
3022 /**
3023  * It is a hanmenuer who processes the MENU tag.
3024  *
3025  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3026  *                     destination is specified.
3027  * @param node   [i]   The MENU tag node is specified.
3028  * @return The conversion result is returned.
3029  */
3030 static char *
3031 s_xhtml_1_0_end_menu_tag(void *pdoc, Node *UNUSED(child))
3032 {
3033   xhtml_t *xhtml = GET_XHTML(pdoc);
3034   Doc *doc = xhtml->doc;
3035   W_L("</menu>");
3036   return xhtml->out;
3037 }
3038
3039
3040 /**
3041  * It is a handler who processes the PLAINTEXT tag.
3042  *
3043  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3044  *                     destination is specified.
3045  * @param node   [i]   The PLAINTEXT tag node is specified.
3046  * @return The conversion result is returned.
3047  */
3048 static char *
3049 s_xhtml_1_0_start_plaintext_tag(void *pdoc, Node *node)
3050 {
3051   xhtml_t *xhtml = GET_XHTML(pdoc);
3052   Doc     *doc     = xhtml->doc;
3053   W_L("<plaintext>");
3054   s_xhtml_1_0_start_plaintext_tag_inner(pdoc,node);
3055   return xhtml->out;
3056 }
3057
3058 static char *
3059 s_xhtml_1_0_start_plaintext_tag_inner(void *pdoc, Node *node)
3060 {
3061   xhtml_t *xhtml = GET_XHTML(pdoc);
3062   Doc     *doc     = xhtml->doc;
3063   Node    *child;
3064   for (child = qs_get_child_node(doc, node);
3065        child;
3066        child = qs_get_next_node(doc, child)) {
3067     W_V(child->otext);
3068     s_xhtml_1_0_start_plaintext_tag_inner(pdoc, child);
3069   }
3070   return xhtml->out;
3071 }
3072
3073
3074 /**
3075  * It is a handler who processes the PLAINTEXT tag.
3076  *
3077  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3078  *                     destination is specified.
3079  * @param node   [i]   The PLAINTEXT tag node is specified.
3080  * @return The conversion result is returned.
3081  */
3082 static char *
3083 s_xhtml_1_0_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
3084 {
3085   xhtml_t *xhtml = GET_XHTML(pdoc);
3086   Doc     *doc     = xhtml->doc;
3087   W_L("</plaintext>");
3088   return xhtml->out;
3089 }
3090
3091
3092 /**
3093  * It is a hanblinker who processes the BLINK tag.
3094  *
3095  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3096  *                     destination is specified.
3097  * @param node   [i]   The BLINK tag node is specified.
3098  * @return The conversion result is returned.
3099  */
3100 static char *
3101 s_xhtml_1_0_start_blink_tag(void *pdoc, Node *UNUSED(child))
3102 {
3103   xhtml_t *xhtml = GET_XHTML(pdoc);
3104   Doc     *doc = xhtml->doc;
3105   W_L("<blink>");
3106   return xhtml->out;
3107 }
3108
3109
3110 /**
3111  * It is a hanblinker who processes the BLINK tag.
3112  *
3113  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3114  *                     destination is specified.
3115  * @param node   [i]   The BLINK tag node is specified.
3116  * @return The conversion result is returned.
3117  */
3118 static char *
3119 s_xhtml_1_0_end_blink_tag(void *pdoc, Node *UNUSED(child))
3120 {
3121   xhtml_t *xhtml = GET_XHTML(pdoc);
3122   Doc     *doc = xhtml->doc;
3123   W_L("</blink>");
3124   return xhtml->out;
3125 }
3126
3127
3128 /**
3129  * It is a handler who processes the MARQUEE tag.
3130  *
3131  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3132  *                     destination is specified.
3133  * @param node   [i]   The MARQUEE tag node is specified.
3134  * @return The conversion result is returned.
3135  */
3136 static char *
3137 s_xhtml_1_0_start_marquee_tag(void *pdoc, Node *node)
3138 {
3139   xhtml_t *xhtml = GET_XHTML(pdoc);
3140   Doc     *doc = xhtml->doc;
3141   Attr *attr;
3142   W_L("<marquee");
3143   /*--------------------------------------------------------------------------*/
3144   /* Get Attributes                                                           */
3145   /*--------------------------------------------------------------------------*/
3146   for (attr = qs_get_attr(doc,node);
3147        attr;
3148        attr = qs_get_next_attr(doc,attr)) {
3149     char *name   = qs_get_attr_name(doc,attr);
3150     char *value  = qs_get_attr_value(doc,attr);
3151     if (STRCASEEQ('d','D',"direction", name)) {
3152       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value))) {
3153         W_L(" direction=\"");
3154         W_V(value);
3155         W_L("\"");
3156       }
3157     }
3158     else if (STRCASEEQ('b','B',"behavior",name)) {
3159       if (value && (STRCASEEQ('s','S',"scroll",value) || STRCASEEQ('s','S',"slide",value) || STRCASEEQ('a','A',"alternate",value))) {
3160         W_L(" behavior=\""); 
3161         W_V(value);
3162         W_L("\"");
3163       }
3164     }
3165     else if (STRCASEEQ('l','L',"loop",name)) {
3166       if (value && *value) {
3167         W_L(" loop=\"");
3168         W_V(value);
3169         W_L("\"");
3170       }
3171     }
3172     else if (STRCASEEQ('b','B',"bgcolor",name)) {
3173       if (value && *value) {
3174         W_L(" bgcolor=\"");
3175         W_V(value);
3176         W_L("\"");
3177       }
3178     }
3179   }
3180   W_L(">");
3181   return xhtml->out;
3182 }
3183
3184
3185 /**
3186  * It is a handler who processes the MARQUEE tag.
3187  *
3188  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3189  *                     destination is specified.
3190  * @param node   [i]   The MARQUEE tag node is specified.
3191  * @return The conversion result is returned.
3192  */
3193 static char *
3194 s_xhtml_1_0_end_marquee_tag(void *pdoc, Node *UNUSED(child))
3195 {
3196   xhtml_t *xhtml = GET_XHTML(pdoc);
3197   Doc     *doc = xhtml->doc;
3198   W_L("</marquee>");
3199   return xhtml->out;
3200 }
3201 /*
3202  * vim:ts=2 et
3203  */