OSDN Git Service

1fb40557839428419c4d2e748202ded92cc365f9
[modchxj/mod_chxj.git] / src / chxj_xhtml_mobile_1_0.c
1 /*
2  * Copyright (C) 2005-2009 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 #include "chxj_header_inf.h"
27 #include "chxj_conv_z2h.h"
28
29 #define GET_XHTML(X) ((xhtml_t*)(X))
30 #undef W_L
31 #undef W_V
32 #define W_L(X)          do { xhtml->out = BUFFERED_WRITE_LITERAL(xhtml->out, &doc->buf, (X)); } while(0)
33 #define W_V(X)          do { xhtml->out = (X) ? BUFFERED_WRITE_VALUE(xhtml->out, &doc->buf, (X))  \
34                                                : BUFFERED_WRITE_LITERAL(xhtml->out, &doc->buf, ""); } while(0)
35 #undef W_NLCODE
36 #define W_NLCODE()     do { char *nlcode = TO_NLCODE(xhtml->conf); W_V(nlcode); } while (0)
37
38 static char *s_xhtml_1_0_start_html_tag   (void *pdoc, Node *node);
39 static char *s_xhtml_1_0_end_html_tag     (void *pdoc, Node *node);
40 static char *s_xhtml_1_0_start_p_tag      (void *pdoc, Node *node);
41 static char *s_xhtml_1_0_end_p_tag        (void *pdoc, Node *node);
42 static char *s_xhtml_1_0_start_pre_tag    (void *pdoc, Node *node);
43 static char *s_xhtml_1_0_end_pre_tag      (void *pdoc, Node *node);
44 static char *s_xhtml_1_0_start_ul_tag     (void *pdoc, Node *node);
45 static char *s_xhtml_1_0_end_ul_tag       (void *pdoc, Node *node);
46 static char *s_xhtml_1_0_start_h1_tag     (void *pdoc, Node *node);
47 static char *s_xhtml_1_0_end_h1_tag       (void *pdoc, Node *node);
48 static char *s_xhtml_1_0_start_h2_tag     (void *pdoc, Node *node);
49 static char *s_xhtml_1_0_end_h2_tag       (void *pdoc, Node *node);
50 static char *s_xhtml_1_0_start_h3_tag     (void *pdoc, Node *node);
51 static char *s_xhtml_1_0_end_h3_tag       (void *pdoc, Node *node);
52 static char *s_xhtml_1_0_start_h4_tag     (void *pdoc, Node *node);
53 static char *s_xhtml_1_0_end_h4_tag       (void *pdoc, Node *node);
54 static char *s_xhtml_1_0_start_h5_tag     (void *pdoc, Node *node);
55 static char *s_xhtml_1_0_end_h5_tag       (void *pdoc, Node *node);
56 static char *s_xhtml_1_0_start_h6_tag     (void *pdoc, Node *node);
57 static char *s_xhtml_1_0_end_h6_tag       (void *pdoc, Node *node);
58 static char *s_xhtml_1_0_start_ol_tag     (void *pdoc, Node *node);
59 static char *s_xhtml_1_0_end_ol_tag       (void *pdoc, Node *node);
60 static char *s_xhtml_1_0_start_li_tag     (void *pdoc, Node *node);
61 static char *s_xhtml_1_0_end_li_tag       (void *pdoc, Node *node);
62 static char *s_xhtml_1_0_start_meta_tag   (void *pdoc, Node *node);
63 static char *s_xhtml_1_0_end_meta_tag     (void *pdoc, Node *node);
64 static char *s_xhtml_1_0_start_head_tag   (void *pdoc, Node *node);
65 static char *s_xhtml_1_0_end_head_tag     (void *pdoc, Node *node);
66 static char *s_xhtml_1_0_start_title_tag  (void *pdoc, Node *node);
67 static char *s_xhtml_1_0_end_title_tag    (void *pdoc, Node *node);
68 static char *s_xhtml_1_0_start_base_tag   (void *pdoc, Node *node);
69 static char *s_xhtml_1_0_end_base_tag     (void *pdoc, Node *node);
70 static char *s_xhtml_1_0_start_body_tag   (void *pdoc, Node *node);
71 static char *s_xhtml_1_0_end_body_tag     (void *pdoc, Node *node);
72 static char *s_xhtml_1_0_start_a_tag      (void *pdoc, Node *node);
73 static char *s_xhtml_1_0_end_a_tag        (void *pdoc, Node *node);
74 static char *s_xhtml_1_0_start_br_tag     (void *pdoc, Node *node);
75 static char *s_xhtml_1_0_end_br_tag       (void *pdoc, Node *node);
76 static char *s_xhtml_1_0_start_tr_tag     (void *pdoc, Node *node);
77 static char *s_xhtml_1_0_end_tr_tag       (void *pdoc, Node *node);
78 static char *s_xhtml_1_0_start_font_tag   (void *pdoc, Node *node);
79 static char *s_xhtml_1_0_end_font_tag     (void *pdoc, Node *node);
80 static char *s_xhtml_1_0_start_form_tag   (void *pdoc, Node *node);
81 static char *s_xhtml_1_0_end_form_tag     (void *pdoc, Node *node);
82 static char *s_xhtml_1_0_start_input_tag  (void *pdoc, Node *node);
83 static char *s_xhtml_1_0_end_input_tag    (void *pdoc, Node *node);
84 static char *s_xhtml_1_0_start_center_tag (void *pdoc, Node *node);
85 static char *s_xhtml_1_0_end_center_tag   (void *pdoc, Node *node);
86 static char *s_xhtml_1_0_start_hr_tag     (void *pdoc, Node *node);
87 static char *s_xhtml_1_0_end_hr_tag       (void *pdoc, Node *node);
88 static char *s_xhtml_1_0_start_img_tag    (void *pdoc, Node *node);
89 static char *s_xhtml_1_0_end_img_tag      (void *pdoc, Node *node);
90 static char *s_xhtml_1_0_start_select_tag (void *pdoc, Node *node);
91 static char *s_xhtml_1_0_end_select_tag   (void *pdoc, Node *node);
92 static char *s_xhtml_1_0_start_option_tag (void *pdoc, Node *node);
93 static char *s_xhtml_1_0_end_option_tag   (void *pdoc, Node *node);
94 static char *s_xhtml_1_0_start_div_tag       (void *pdoc, Node *node);
95 static char *s_xhtml_1_0_end_div_tag         (void *pdoc, Node *node);
96 static char *s_xhtml_1_0_start_textarea_tag  (void *pdoc, Node *node);
97 static char *s_xhtml_1_0_end_textarea_tag    (void *pdoc, Node *node);
98 static char *s_xhtml_1_0_start_b_tag         (void *pdoc, Node *node);
99 static char *s_xhtml_1_0_end_b_tag           (void *pdoc, Node *node);
100 static char *s_xhtml_1_0_chxjif_tag          (void *pdoc, Node *node);
101 static char *s_xhtml_1_0_start_blockquote_tag (void *pdoc, Node *node);
102 static char *s_xhtml_1_0_end_blockquote_tag  (void *pdoc, Node *node);
103 static char *s_xhtml_1_0_start_dir_tag       (void *pdoc, Node *node);
104 static char *s_xhtml_1_0_end_dir_tag         (void *pdoc, Node *node);
105 static char *s_xhtml_1_0_start_dl_tag        (void *pdoc, Node *node);
106 static char *s_xhtml_1_0_end_dl_tag          (void *pdoc, Node *node);
107 static char *s_xhtml_1_0_start_dt_tag        (void *pdoc, Node *node);
108 static char *s_xhtml_1_0_end_dt_tag          (void *pdoc, Node *node);
109 static char *s_xhtml_1_0_start_dd_tag        (void *pdoc, Node *node);
110 static char *s_xhtml_1_0_end_dd_tag          (void *pdoc, Node *node);
111 static char *s_xhtml_1_0_start_menu_tag      (void *pdoc, Node *node);
112 static char *s_xhtml_1_0_end_menu_tag        (void *pdoc, Node *node);
113 static char *s_xhtml_1_0_start_plaintext_tag       (void *pdoc, Node *node);
114 static char *s_xhtml_1_0_start_plaintext_tag_inner (void *pdoc, Node *node);
115 static char *s_xhtml_1_0_end_plaintext_tag         (void *pdoc, Node *node);
116 static char *s_xhtml_1_0_start_blink_tag     (void *pdoc, Node *node);
117 static char *s_xhtml_1_0_end_blink_tag       (void *pdoc, Node *node);
118 static char *s_xhtml_1_0_start_marquee_tag   (void *pdoc, Node *node);
119 static char *s_xhtml_1_0_end_marquee_tag     (void *pdoc, Node *node);
120 static char *s_xhtml_1_0_newline_mark       (void *pdoc, Node *node);
121 static char *s_xhtml_1_0_link_tag           (void *pdoc, Node *node);
122 static char *s_xhtml_1_0_start_span_tag      (void *pdoc, Node *node);
123 static char *s_xhtml_1_0_end_span_tag        (void *pdoc, Node *node);
124 static char *s_xhtml_1_0_style_tag        (void *pdoc, Node *node);
125
126 static void  s_init_xhtml(xhtml_t *xhtml, Doc *doc, request_rec *r, device_table *spec);
127 static int   s_xhtml_search_emoji(xhtml_t *xhtml, char *txt, char **rslt);
128 static char *s_xhtml_1_0_text_tag(void *pdoc, Node *child);
129 static css_prop_list_t *s_xhtml_1_0_nopush_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value);
130 static css_prop_list_t *s_xhtml_1_0_push_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value);
131 /* pend */
132
133
134 tag_handler xhtml_handler[] = {
135   /* tagHTML */
136   {
137     s_xhtml_1_0_start_html_tag,
138     s_xhtml_1_0_end_html_tag,
139   },
140   /* tagMETA */
141   {
142     s_xhtml_1_0_start_meta_tag,
143     s_xhtml_1_0_end_meta_tag,
144   },
145   /* tagTEXTAREA */
146   {
147     s_xhtml_1_0_start_textarea_tag,
148     s_xhtml_1_0_end_textarea_tag,
149   },
150   /* tagP */
151   {
152     s_xhtml_1_0_start_p_tag,
153     s_xhtml_1_0_end_p_tag,
154   },
155   /* tagPRE */
156   {
157     s_xhtml_1_0_start_pre_tag,
158     s_xhtml_1_0_end_pre_tag,
159   },
160   /* tagUL */
161   {
162     s_xhtml_1_0_start_ul_tag,
163     s_xhtml_1_0_end_ul_tag,
164   },
165   /* tagLI */
166   {
167     s_xhtml_1_0_start_li_tag,
168     s_xhtml_1_0_end_li_tag,
169   },
170   /* tagOL */
171   {
172     s_xhtml_1_0_start_ol_tag,
173     s_xhtml_1_0_end_ol_tag,
174   },
175   /* tagH1 */
176   {
177     s_xhtml_1_0_start_h1_tag,
178     s_xhtml_1_0_end_h1_tag,
179   },
180   /* tagH2 */
181   {
182     s_xhtml_1_0_start_h2_tag,
183     s_xhtml_1_0_end_h2_tag,
184   },
185   /* tagH3 */
186   {
187     s_xhtml_1_0_start_h3_tag,
188     s_xhtml_1_0_end_h3_tag,
189   },
190   /* tagH4 */
191   {
192     s_xhtml_1_0_start_h4_tag,
193     s_xhtml_1_0_end_h4_tag,
194   },
195   /* tagH5 */
196   {
197     s_xhtml_1_0_start_h5_tag,
198     s_xhtml_1_0_end_h5_tag,
199   },
200   /* tagH6 */
201   {
202     s_xhtml_1_0_start_h6_tag,
203     s_xhtml_1_0_end_h6_tag,
204   },
205   /* tagHEAD */
206   {
207     s_xhtml_1_0_start_head_tag,
208     s_xhtml_1_0_end_head_tag,
209   },
210   /* tagTITLE */
211   {
212     s_xhtml_1_0_start_title_tag,
213     s_xhtml_1_0_end_title_tag,
214   },
215   /* tagBASE */
216   {
217     s_xhtml_1_0_start_base_tag,
218     s_xhtml_1_0_end_base_tag,
219   },
220   /* tagBODY */
221   {
222     s_xhtml_1_0_start_body_tag,
223     s_xhtml_1_0_end_body_tag,
224   },
225   /* tagA */
226   {
227     s_xhtml_1_0_start_a_tag,
228     s_xhtml_1_0_end_a_tag,
229   },
230   /* tagBR */
231   {
232     s_xhtml_1_0_start_br_tag,
233     s_xhtml_1_0_end_br_tag,
234   },
235   /* tagTABLE */
236   {
237     NULL,
238     NULL,
239   },
240   /* tagTR */
241   {
242     s_xhtml_1_0_start_tr_tag,
243     s_xhtml_1_0_end_tr_tag,
244   },
245   /* tagTD */
246   {
247     NULL,
248     NULL,
249   },
250   /* tagTBODY */
251   {
252     NULL,
253     NULL,
254   },
255   /* tagFONT */
256   {
257     s_xhtml_1_0_start_font_tag,
258     s_xhtml_1_0_end_font_tag,
259   },
260   /* tagFORM */
261   {
262     s_xhtml_1_0_start_form_tag,
263     s_xhtml_1_0_end_form_tag,
264   },
265   /* tagINPUT */
266   {
267     s_xhtml_1_0_start_input_tag,
268     s_xhtml_1_0_end_input_tag,
269   },
270   /* tagCENTER */
271   {
272     s_xhtml_1_0_start_center_tag,
273     s_xhtml_1_0_end_center_tag,
274   },
275   /* tagHR */
276   {
277     s_xhtml_1_0_start_hr_tag,
278     s_xhtml_1_0_end_hr_tag,
279   },
280   /* tagIMG */
281   {
282     s_xhtml_1_0_start_img_tag,
283     s_xhtml_1_0_end_img_tag,
284   },
285   /* tagSELECT */
286   {
287     s_xhtml_1_0_start_select_tag,
288     s_xhtml_1_0_end_select_tag,
289   },
290   /* tagOPTION */
291   {
292     s_xhtml_1_0_start_option_tag,
293     s_xhtml_1_0_end_option_tag,
294   },
295   /* tagDIV */
296   {
297     s_xhtml_1_0_start_div_tag,
298     s_xhtml_1_0_end_div_tag,
299   },
300   /* tagCHXJIF */
301   {
302     s_xhtml_1_0_chxjif_tag,
303     NULL,
304   },
305   /* tagNOBR */
306   {
307     NULL,
308     NULL,
309   },
310   /* tagSMALL */
311   {
312     NULL,
313     NULL,
314   },
315   /* tagSTYLE */
316   {
317     s_xhtml_1_0_style_tag,
318     NULL,
319   },
320   /* tagSPAN */
321   {
322     s_xhtml_1_0_start_span_tag,
323     s_xhtml_1_0_end_span_tag,
324   },
325   /* tagTEXT */
326   {
327     s_xhtml_1_0_text_tag,
328     NULL,
329   },
330   /* tagTH */
331   {
332     NULL,
333     NULL,
334   },
335   /* tagB */
336   {
337     s_xhtml_1_0_start_b_tag,
338     s_xhtml_1_0_end_b_tag,
339   },
340   /* tagFIELDSET */
341   {
342     NULL,
343     NULL,
344   },
345   /* tagDT */
346   {
347     s_xhtml_1_0_start_dt_tag,
348     s_xhtml_1_0_end_dt_tag,
349   },
350   /* tagLEGEND */
351   {
352     NULL,
353     NULL,
354   },
355   /* tagLABEL */
356   {
357     NULL,
358     NULL,
359   },
360   /* tagBLOCKQUOTE */
361   {
362     s_xhtml_1_0_start_blockquote_tag,
363     s_xhtml_1_0_end_blockquote_tag,
364   },
365   /* tagDIR */
366   {
367     s_xhtml_1_0_start_dir_tag,
368     s_xhtml_1_0_end_dir_tag,
369   },
370   /* tagDL */
371   {
372     s_xhtml_1_0_start_dl_tag,
373     s_xhtml_1_0_end_dl_tag,
374   },
375   /* tagDD */
376   {
377     s_xhtml_1_0_start_dd_tag,
378     s_xhtml_1_0_end_dd_tag,
379   },
380   /* tagMENU */
381   {
382     s_xhtml_1_0_start_menu_tag,
383     s_xhtml_1_0_end_menu_tag,
384   },
385   /* tagPLAINTEXT */
386   {
387     s_xhtml_1_0_start_plaintext_tag,
388     s_xhtml_1_0_end_plaintext_tag,
389   },
390   /* tagBLINK */
391   {
392     s_xhtml_1_0_start_blink_tag,
393     s_xhtml_1_0_end_blink_tag,
394   },
395   /* tagMARQUEE */
396   {
397     s_xhtml_1_0_start_marquee_tag,
398     s_xhtml_1_0_end_marquee_tag,
399   },
400   /* tagLINK */
401   {
402     s_xhtml_1_0_link_tag,
403     NULL,
404   },
405   /* tagNLMARK */
406   {
407     s_xhtml_1_0_newline_mark,
408     NULL,
409   },
410 };
411  
412 /**
413  * converts from CHTML to XHTML.
414  *
415  * @param r     [i]   Requet_rec is appointed.
416  * @param spec  [i]   The result of the device specification processing which 
417  *                    was done in advance is appointed.
418  * @param src   [i]   The character string before the converting is appointed.
419  * @return The character string after the converting is returned.
420  */
421 char *
422 chxj_convert_xhtml_mobile_1_0(
423   request_rec        *r,
424   device_table       *spec,
425   const char         *src,
426   apr_size_t         srclen,
427   apr_size_t         *dstlen,
428   chxjconvrule_entry *entryp,
429   cookie_t           *cookie
430 )
431 {
432   char      *dst = NULL;
433   char      *ss;
434   xhtml_t   xhtml;
435   Doc       doc;
436
437   DBG(r,"start chxj_convert_xhtml_mobile_1_0()");
438   /*--------------------------------------------------------------------------*/
439   /* If qrcode xml                                                            */
440   /*--------------------------------------------------------------------------*/
441   *dstlen = srclen;
442   dst = chxj_qr_code_blob_handler(r, src, (size_t*)dstlen);
443   if (dst != NULL) {
444     DBG(r,"end chxj_convert_xhtml_mobile_1_0() (found qrcode.xml)");
445     return dst;
446   }
447
448   /*--------------------------------------------------------------------------*/
449   /* The XHTML structure is initialized.                                      */
450   /*--------------------------------------------------------------------------*/
451   s_init_xhtml(&xhtml, &doc, r, spec);
452
453   xhtml.entryp = entryp;
454   xhtml.cookie = cookie;
455
456   chxj_set_content_type(r, chxj_header_inf_set_content_type(r, "text/html; charset=Windows-31J"));
457
458   /*--------------------------------------------------------------------------*/
459   /* The character string of the input is analyzed.                           */
460   /*--------------------------------------------------------------------------*/
461   qs_init_malloc(&doc);
462   qs_init_root_node(&doc);
463
464   ss = apr_pcalloc(r->pool, srclen + 1);
465   memset(ss,   0, srclen + 1);
466   memcpy(ss, src, srclen);
467
468   if (IS_CSS_ON(xhtml.entryp)) {
469     /* current property list */
470     xhtml.css_prop_stack = chxj_new_prop_list_stack(&doc);
471   }
472 #ifdef DUMP_LOG
473   chxj_dump_out("[src] CHTML->XHTML", ss, srclen);
474 #endif
475   qs_parse_string(&doc,ss, strlen(ss));
476
477   chxj_buffered_write_init(r->pool, &doc.buf);
478   /*--------------------------------------------------------------------------*/
479   /* It converts it from CHTML to XHTML.                                      */
480   /*--------------------------------------------------------------------------*/
481   chxj_node_convert(spec,r,(void *)&xhtml, &doc, qs_get_root(&doc), 0);
482   xhtml.out = chxj_buffered_write_flush(xhtml.out, &doc.buf);
483   dst = apr_pstrdup(r->pool, xhtml.out);
484   chxj_buffered_write_terminate(&doc.buf);
485
486   qs_all_free(&doc,QX_LOGMARK);
487
488   if (! dst) {
489     return apr_pstrdup(r->pool,ss);
490   }
491
492   if (! *dst) {
493     dst = apr_psprintf(r->pool, "\n");
494   }
495   *dstlen = strlen(dst);
496
497 #ifdef DUMP_LOG
498   chxj_dump_out("[dst] CHTML->XHTML", dst, *dstlen);
499 #endif
500
501   DBG(r,"end chxj_convert_xhtml_mobile_1_0()");
502   return dst;
503 }
504
505
506 /**
507  * The XHTML structure is initialized.
508  *
509  * @param xhtml [i/o] The pointer to the HDML structure that wants to be
510  *                   initialized is specified.
511  * @param doc   [i]   The Doc structure that should be set to the initialized
512  *                   HDML structure is specified.
513  * @param r     [i]   To use POOL, the pointer to request_rec is specified.
514  * @param spec  [i]   The pointer to the device_table
515  */
516 static void
517 s_init_xhtml(xhtml_t *xhtml, Doc *doc, request_rec *r, device_table *spec)
518 {
519   memset(doc,   0, sizeof(Doc));
520   memset(xhtml, 0, sizeof(xhtml_t));
521
522   doc->r      = r;
523   xhtml->doc  = doc;
524   xhtml->spec = spec;
525   xhtml->out  = qs_alloc_zero_byte_string(r->pool);
526   xhtml->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
527   xhtml->doc->parse_mode = PARSE_MODE_CHTML;
528 }
529
530
531 /**
532  * Corresponding EMOJI to a current character-code is retrieved. 
533  * The substitution character string is stored in the rslt pointer if agreeing.
534  *
535  * @param xhtml   [i]   The pointer to the XHTML structure is specified. 
536  * @param txt     [i]   The character string to want to examine whether it is 
537  *                      EMOJI is specified. 
538  * @param rslt    [o]   The pointer to the pointer that stores the result is 
539  *                      specified. 
540  * @return When corresponding EMOJI exists, it returns it excluding 0. 
541  */
542 static int
543 s_xhtml_search_emoji(xhtml_t *xhtml, char *txt, char **rslt)
544 {
545   emoji_t       *ee;
546   request_rec   *r;
547   device_table  *spec;
548   int           len;
549
550   spec = xhtml->spec;
551
552   len = strlen(txt);
553   r = xhtml->doc->r;
554
555   if (spec == NULL) {
556     DBG(r,"spec is NULL");
557   }
558
559   for (ee = xhtml->conf->emoji;
560        ee;
561        ee = ee->next) {
562     unsigned char hex1byte;
563     unsigned char hex2byte;
564     if (!ee->imode) {
565       DBG(r,"emoji->imode is NULL");
566       continue;
567     }
568
569     if (ee->imode->string != NULL
570     &&  strlen(ee->imode->string) > 0
571     &&  strncasecmp(ee->imode->string, txt, strlen(ee->imode->string)) == 0) {
572       if (spec == NULL || spec->emoji_type == NULL) {
573         *rslt = apr_psprintf(r->pool,
574                         "<img localsrc=%s>",
575                         ee->ezweb->typeA);
576         return strlen(ee->imode->string);
577       }
578
579       if (strcasecmp(xhtml->spec->emoji_type, "a") == 0) {
580         *rslt = apr_psprintf(r->pool,
581                         "<img localsrc=%s>",
582                         ee->ezweb->typeA);
583         return strlen(ee->imode->string);
584       } 
585       else
586       if (strcasecmp(xhtml->spec->emoji_type, "b") == 0) {
587         *rslt = apr_psprintf(r->pool,
588                         "<img localsrc=%s>",
589                         ee->ezweb->typeB);
590         return strlen(ee->imode->string);
591       }
592       else
593       if (strcasecmp(xhtml->spec->emoji_type, "c") == 0) {
594         *rslt = apr_psprintf(r->pool,
595                         "<img localsrc=%s>",
596                         ee->ezweb->typeC);
597         return strlen(ee->imode->string);
598       }
599       else
600       if (strcasecmp(xhtml->spec->emoji_type, "d") == 0) {
601         *rslt = apr_psprintf(r->pool,
602                         "<img localsrc=%s>",
603                         ee->ezweb->typeD);
604         return strlen(ee->imode->string);
605       }
606       else {
607         *rslt = apr_psprintf(r->pool,
608                         "<img localsrc=%s>",
609                         ee->ezweb->typeA);
610         return strlen(ee->imode->string);
611       }
612       return 0;
613     }
614     hex1byte = ee->imode->hex1byte & 0xff;
615     hex2byte = ee->imode->hex2byte & 0xff;
616     if (len >= 2
617     && ((unsigned char)txt[0] & 0xff) == ((unsigned char)hex1byte)
618     && ((unsigned char)txt[1] & 0xff) == ((unsigned char)hex2byte)) {
619       if (spec == NULL || spec->emoji_type == NULL) {
620         *rslt = apr_psprintf(r->pool,
621                         "<img localsrc=\"%s\">",
622                         ee->ezweb->typeA);
623         return 2;
624       }
625
626       if (strcasecmp(xhtml->spec->emoji_type, "a") == 0) {
627         *rslt = apr_psprintf(r->pool,
628                         "<img localsrc=\"%s\">",
629                         ee->ezweb->typeA);
630         return 2;
631       } 
632       else
633       if (strcasecmp(xhtml->spec->emoji_type, "b") == 0) {
634         *rslt = apr_psprintf(r->pool,
635                         "<img localsrc=\"%s\">",
636                         ee->ezweb->typeB);
637         return 2;
638       }
639       else
640       if (strcasecmp(xhtml->spec->emoji_type, "c") == 0) {
641         *rslt = apr_psprintf(r->pool,
642                         "<img localsrc=\"%s\">",
643                         ee->ezweb->typeC);
644         return 2;
645       }
646       else
647       if (strcasecmp(xhtml->spec->emoji_type, "d") == 0) {
648         *rslt = apr_psprintf(r->pool,
649                         "<img localsrc=\"%s\">",
650                         ee->ezweb->typeD);
651         return 2;
652       }
653       else {
654         *rslt = apr_psprintf(r->pool,
655                         "<img localsrc=\"%s\">",
656                         ee->ezweb->typeD);
657         return 2;
658       }
659       return 0;
660     }
661   }
662   return 0;
663 }
664
665
666 char *
667 chxj_xhtml_emoji_only_converter(request_rec *r, device_table *spec, const char *src, apr_size_t len)
668 {
669   apr_size_t ii;
670   Doc __doc;
671   Doc *doc;
672   xhtml_t __xhtml;
673   xhtml_t *xhtml;
674   char one_byte[2];
675   char two_byte[3];
676   apr_pool_t *pool;
677
678   xhtml = &__xhtml;
679   doc   = &__doc;
680
681   DBG(r, "REQ[%X] start chxj_xhtml_emoji_eonly_converter()", (unsigned int)(apr_size_t)r);
682   memset(doc,     0, sizeof(Doc));
683   memset(xhtml, 0, sizeof(xhtml_t));
684
685   doc->r        = r;
686   xhtml->doc  = doc;
687   xhtml->spec = spec;
688   xhtml->out  = qs_alloc_zero_byte_string(r->pool);
689   xhtml->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
690   xhtml->doc->parse_mode = PARSE_MODE_CHTML;
691
692   apr_pool_create(&pool, r->pool);
693
694   chxj_buffered_write_init(pool, &doc->buf);
695
696   for (ii=0; ii<len; ii++) {
697     char *out;
698     int   rtn;
699
700     rtn = s_xhtml_search_emoji(xhtml, (char *)&src[ii], &out);
701     if (rtn) {
702       W_V(out);
703       ii+=(rtn - 1);
704       continue;
705     }
706
707     if (is_sjis_kanji(src[ii])) {
708       two_byte[0] = src[ii+0];
709       two_byte[1] = src[ii+1];
710       two_byte[2] = 0;
711       W_V(two_byte);
712       ii++;
713     }
714     else {
715       one_byte[0] = src[ii+0];
716       one_byte[1] = 0;
717       W_V(one_byte);
718     }
719   }
720   xhtml->out = chxj_buffered_write_flush(xhtml->out, &doc->buf);
721
722   DBG(r, "REQ[%X] end chxj_xhtml_emoji_eonly_converter()", (unsigned int)(apr_size_t)r);
723   return xhtml->out;
724 }
725
726
727 /**
728  * It is a handler who processes the HTML tag.
729  *
730  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
731  *                     destination is specified.
732  * @param node   [i]   The HTML tag node is specified.
733  * @return The conversion result is returned.
734  */
735 static char *
736 s_xhtml_1_0_start_html_tag(void *pdoc, Node *UNUSED(node)) 
737 {
738   xhtml_t       *xhtml = GET_XHTML(pdoc);
739   Doc           *doc   = xhtml->doc;
740
741   /*--------------------------------------------------------------------------*/
742   /* Add XML Declare                                                          */
743   /*--------------------------------------------------------------------------*/
744   W_L("<?xml version=\"1.0\" encoding=\"Shift_JIS\"?>");
745   W_NLCODE();
746   /*--------------------------------------------------------------------------*/
747   /* Add DocType                                                              */
748   /*--------------------------------------------------------------------------*/
749   W_L("<!DOCTYPE html PUBLIC \"-//OPENWAVE//DTD XHTML 1.0//EN\"");
750   W_NLCODE();
751   W_L(" \"http://www.openwave.com/DTD/xhtml-basic.dtd\">");
752   W_NLCODE();
753   /*--------------------------------------------------------------------------*/
754   /* start HTML tag                                                           */
755   /*--------------------------------------------------------------------------*/
756   W_L("<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"ja\" xml:lang=\"ja\">");
757
758   xhtml->start_html_flag = 1;
759   return xhtml->out;
760 }
761
762
763 /**
764  * It is a handler who processes the HTML tag.
765  *
766  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
767  *                     destination is specified.
768  * @param node   [i]   The HTML tag node is specified.
769  * @return The conversion result is returned.
770  */
771 static char *
772 s_xhtml_1_0_end_html_tag(void *pdoc, Node *UNUSED(child)) 
773 {
774   xhtml_t       *xhtml = GET_XHTML(pdoc);
775   Doc           *doc   = xhtml->doc;
776   W_L("</html>");
777   return xhtml->out;
778 }
779
780
781 /**
782  * It is a handler who processes the META tag.
783  *
784  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
785  *                     destination is specified.
786  * @param node   [i]   The META tag node is specified.
787  * @return The conversion result is returned.
788  */
789 static char *
790 s_xhtml_1_0_start_meta_tag(void *pdoc, Node *node) 
791 {
792   xhtml_t       *xhtml = GET_XHTML(pdoc);
793   Attr          *attr;
794   Doc           *doc   = xhtml->doc;
795   int           content_type_flag = 0;
796   request_rec   *r = doc->r;
797
798   W_L("<meta");
799   /*--------------------------------------------------------------------------*/
800   /* Get Attributes                                                           */
801   /*--------------------------------------------------------------------------*/
802   for (attr = qs_get_attr(doc,node);
803        attr; 
804        attr = qs_get_next_attr(doc,attr)) {
805     char *name  = qs_get_attr_name(doc,attr);
806     char *value = qs_get_attr_value(doc,attr);
807     if (STRCASEEQ('n','N',"name", name) && value && *value) {
808       W_L(" ");
809       W_V(name);
810       W_L("=\"");
811       W_V(value);
812       W_L("\"");
813     }
814     else if (STRCASEEQ('h','H',"http-equiv", name) && value && *value) {
815       W_L(" ");
816       W_V(name);
817       W_L("=\"");
818       W_V(value);
819       W_L("\"");
820       if (STRCASEEQ('c','C', "content-type", value)) {
821         content_type_flag = 1;
822       }
823     }
824     else if (STRCASEEQ('c','C',"content", name) && value && *value) {
825       if (content_type_flag) {
826         W_L(" ");
827         W_V(name);
828         W_L("=\"");
829         W_V(chxj_header_inf_set_content_type(r, "text/html; charset=Windows-31J"));
830         W_L("\"");
831       }
832       else {
833         W_L(" ");
834         W_V(name);
835         W_L("=\"");
836         W_V(value);
837         W_L("\"");
838       }
839     }
840   }
841   W_L(" />");
842   return xhtml->out;
843 }
844
845
846 /**
847  * It is a handler who processes the META tag.
848  *
849  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
850  *                     destination is specified.
851  * @param node   [i]   The META tag node is specified.
852  * @return The conversion result is returned.
853  */
854 static char *
855 s_xhtml_1_0_end_meta_tag(void *pdoc, Node *UNUSED(child)) 
856 {
857   xhtml_t *xhtml = GET_XHTML(pdoc);
858
859   return xhtml->out;
860 }
861
862
863 /**
864  * It is a handler who processes the HEAD tag.
865  *
866  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
867  *                     destination is specified.
868  * @param node   [i]   The HEAD tag node is specified.
869  * @return The conversion result is returned.
870  */
871 static char *
872 s_xhtml_1_0_start_head_tag(void *pdoc, Node *UNUSED(node)) 
873 {
874   xhtml_t       *xhtml = GET_XHTML(pdoc);
875   Doc           *doc   = xhtml->doc;
876
877   W_L("<head>");
878   return xhtml->out;
879 }
880
881
882 /**
883  * It is a handler who processes the HEAD tag.
884  *
885  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
886  *                     destination is specified.
887  * @param node   [i]   The HEAD tag node is specified.
888  * @return The conversion result is returned.
889  */
890 static char *
891 s_xhtml_1_0_end_head_tag(void *pdoc, Node *UNUSED(child)) 
892 {
893   xhtml_t       *xhtml = GET_XHTML(pdoc);
894   Doc           *doc   = xhtml->doc;
895
896   W_L("</head>");
897   return xhtml->out;
898 }
899
900
901 /**
902  * It is a handler who processes the TITLE tag.
903  *
904  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
905  *                     destination is specified.
906  * @param node   [i]   The TITLE tag node is specified.
907  * @return The conversion result is returned.
908  */
909 static char *
910 s_xhtml_1_0_start_title_tag(void *pdoc, Node *UNUSED(node)) 
911 {
912   xhtml_t      *xhtml = GET_XHTML(pdoc);
913   Doc          *doc   = xhtml->doc;
914
915   W_L("<title>");
916   return xhtml->out;
917 }
918
919
920 /**
921  * It is a handler who processes the TITLE tag.
922  *
923  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
924  *                     destination is specified.
925  * @param node   [i]   The TITLE tag node is specified.
926  * @return The conversion result is returned.
927  */
928 static char *
929 s_xhtml_1_0_end_title_tag(void *pdoc, Node *UNUSED(child)) 
930 {
931   xhtml_t       *xhtml = GET_XHTML(pdoc);
932   Doc           *doc   = xhtml->doc;
933
934   W_L("</title>");
935
936   return xhtml->out;
937 }
938
939
940 /**
941  * It is a handler who processes the BASE tag.
942  *
943  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
944  *                     destination is specified.
945  * @param node   [i]   The BASE tag node is specified.
946  * @return The conversion result is returned.
947  */
948 static char *
949 s_xhtml_1_0_start_base_tag(void *pdoc, Node *node) 
950 {
951   xhtml_t       *xhtml = GET_XHTML(pdoc);
952   Attr          *attr;
953   Doc           *doc   = xhtml->doc;
954
955   W_L("<base");
956   /*--------------------------------------------------------------------------*/
957   /* Get Attributes                                                           */
958   /*--------------------------------------------------------------------------*/
959   for (attr = qs_get_attr(doc,node);
960        attr;
961        attr = qs_get_next_attr(doc,attr)) {
962     char *name = qs_get_attr_name(doc,attr);
963     char *value = qs_get_attr_value(doc,attr);
964     if (STRCASEEQ('h','H',"href",name)) {
965       W_L(" href=\"");
966       W_V(value);
967       W_L("\"");
968       break;
969     }
970   }
971   W_L(" />");
972
973   return xhtml->out;
974 }
975
976
977 /**
978  * It is a handler who processes the BASE tag.
979  *
980  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
981  *                     destination is specified.
982  * @param node   [i]   The BASE tag node is specified.
983  * @return The conversion result is returned.
984  */
985 static char *
986 s_xhtml_1_0_end_base_tag(void *pdoc, Node *UNUSED(child)) 
987 {
988   xhtml_t *xhtml = GET_XHTML(pdoc);
989
990   return xhtml->out;
991 }
992
993
994 /**
995  * It is a handler who processes the BODY tag.
996  *
997  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
998  *                     destination is specified.
999  * @param node   [i]   The BODY tag node is specified.
1000  * @return The conversion result is returned.
1001  */
1002 static char *
1003 s_xhtml_1_0_start_body_tag(void *pdoc, Node *node) 
1004 {
1005   xhtml_t     *xhtml = GET_XHTML(pdoc);
1006   Doc         *doc   = xhtml->doc;
1007   Attr        *attr;
1008   char        *attr_bgcolor = NULL;
1009   char        *attr_text    = NULL;
1010   char        *attr_link    = NULL;
1011   char        *attr_style   = NULL;
1012
1013   /*--------------------------------------------------------------------------*/
1014   /* Get Attributes                                                           */
1015   /*--------------------------------------------------------------------------*/
1016   for (attr = qs_get_attr(doc,node);
1017        attr;
1018        attr = qs_get_next_attr(doc,attr)) {
1019     char *name  = qs_get_attr_name(doc,attr);
1020     char *value = qs_get_attr_value(doc,attr);
1021     if (STRCASEEQ('b','B',"bgcolor", name) && value && *value) {
1022       attr_bgcolor = value;
1023     }
1024     else if (STRCASEEQ('t','T',"text",name) && value && *value) {
1025       attr_text = value;
1026     }
1027     else if (STRCASEEQ('l','L',"link", name) && value && *value) {
1028       attr_link = value;
1029     }
1030     else if (STRCASEEQ('a','A',"alink", name)) {
1031       /* ignore */
1032     }
1033     else if (STRCASEEQ('v','V',"vlink",name)) {
1034       /* ignore */
1035     }
1036     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
1037       attr_style = value;
1038     }
1039   }
1040
1041   if (IS_CSS_ON(xhtml->entryp)) {
1042     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
1043     if (style) {
1044       css_property_t *color_prop      = chxj_css_get_property_value(doc, style, "color");
1045       css_property_t *bgcolor_prop    = chxj_css_get_property_value(doc, style, "background-color");
1046       css_property_t *cur;
1047       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
1048         if (cur->value && *cur->value) {
1049           attr_text = apr_pstrdup(doc->pool, cur->value);
1050         }
1051       }
1052       for (cur = bgcolor_prop->next; cur != bgcolor_prop; cur = cur->next) {
1053         if (cur->value && *cur->value) {
1054           attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
1055         }
1056       }
1057     }
1058     if (xhtml->style) {
1059       css_stylesheet_t *pseudos = chxj_find_pseudo_selectors(doc, xhtml->style);
1060       css_selector_t *cur_sel;
1061       for (cur_sel = pseudos->selector_head.next; cur_sel != &pseudos->selector_head; cur_sel = cur_sel->next) {
1062         if (cur_sel->name && strcasecmp(cur_sel->name, "a:link") == 0) {
1063           css_property_t *cur;
1064           for (cur = cur_sel->property_head.next; cur != &cur_sel->property_head; cur = cur->next) {
1065             if (cur->name && strcasecmp(cur->name, "color") == 0) {
1066               attr_link = apr_pstrdup(doc->pool, cur->value);
1067             }
1068           }
1069         }
1070       }
1071     }
1072   }
1073
1074   W_L("<body");
1075   if (attr_bgcolor || attr_text) {
1076     W_L(" style=\"");
1077     if (attr_bgcolor) {
1078       attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
1079       W_L("background-color:");
1080       W_V(attr_bgcolor);
1081       W_L(";");
1082     }
1083     if (attr_text) {
1084       attr_text = chxj_css_rgb_func_to_value(doc->pool, attr_text);
1085       W_L("color:");
1086       W_V(attr_text);
1087       W_L(";");
1088     }
1089     W_L("\"");
1090   }
1091   if (attr_link) {
1092     attr_link = chxj_css_rgb_func_to_value(doc->pool, attr_link);
1093     W_L(" link=\"");
1094     W_V(attr_link);
1095     W_L("\"");
1096   }
1097   W_L(">");
1098
1099   return xhtml->out;
1100 }
1101
1102
1103 /**
1104  * It is a handler who processes the BODY tag.
1105  *
1106  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1107  *                     destination is specified.
1108  * @param node   [i]   The BODY tag node is specified.
1109  * @return The conversion result is returned.
1110  */
1111 static char *
1112 s_xhtml_1_0_end_body_tag(void *pdoc, Node *UNUSED(child)) 
1113 {
1114   xhtml_t       *xhtml = GET_XHTML(pdoc);
1115   Doc           *doc   = xhtml->doc;
1116
1117   W_L("</body>");
1118   if (IS_CSS_ON(xhtml->entryp)) {
1119     chxj_css_pop_prop_list(xhtml->css_prop_stack);
1120   }
1121
1122   return xhtml->out;
1123 }
1124
1125
1126 /**
1127  * It is a handler who processes the A tag.
1128  *
1129  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1130  *                     destination is specified.
1131  * @param node   [i]   The A tag node is specified.
1132  * @return The conversion result is returned.
1133  */
1134 static char *
1135 s_xhtml_1_0_start_a_tag(void *pdoc, Node *node) 
1136 {
1137   xhtml_t     *xhtml = GET_XHTML(pdoc);
1138   Doc         *doc   = xhtml->doc;
1139   request_rec *r     = doc->r;
1140   Attr        *attr;
1141   char        *attr_style = NULL;
1142
1143   W_L("<a");
1144   /*--------------------------------------------------------------------------*/
1145   /* Get Attributes                                                           */
1146   /*--------------------------------------------------------------------------*/
1147   for (attr = qs_get_attr(doc,node);
1148        attr; 
1149        attr = qs_get_next_attr(doc,attr)) {
1150     char* name  = qs_get_attr_name(doc,attr);
1151     char* value = qs_get_attr_value(doc,attr);
1152     if (STRCASEEQ('n','N',"name",name) && value && *value) {
1153       W_L(" id=\"");
1154       W_V(value);
1155       W_L("\"");
1156     }
1157     else if (STRCASEEQ('h','H',"href", name) && value && *value) {
1158       value = chxj_encoding_parameter(r, value, 1);
1159       if (! chxj_starts_with(value, "mailto:") && ! chxj_starts_with(value, "tel:")) {
1160         value = chxj_add_cookie_parameter(r, value, xhtml->cookie);
1161       }
1162       W_L(" href=\"");
1163       W_V(value);
1164       W_L("\"");
1165     }
1166     else if (STRCASEEQ('a','A',"accesskey", name)) {
1167       W_L(" accesskey=\"");
1168       W_V(value);
1169       W_L("\"");
1170     }
1171     else if (STRCASEEQ('c','C',"cti",name)) {
1172       /* ignore */
1173     }
1174     else if (STRCASEEQ('i','I',"ijam", name)) {
1175       /* ignore */
1176     }
1177     else if (STRCASEEQ('u','U',"utn", name)) {
1178       /* ignore */
1179     }
1180     else if (STRCASEEQ('t','T',"telbook",name)) {
1181       /* ignore */
1182     }
1183     else if (STRCASEEQ('k','K',"kana",name)) {
1184       /* ignore */
1185     }
1186     else if (STRCASEEQ('e','E',"email",name)) {
1187       /* ignore */
1188     }
1189     else if (STRCASEEQ('i','I',"ista",name)) {
1190       /* ignore */
1191     }
1192     else if (STRCASEEQ('i','I',"ilet",name)) {
1193       /* ignore */
1194     }
1195     else if (STRCASEEQ('i','I',"iswf",name)) {
1196       /* ignore */
1197     }
1198     else if (STRCASEEQ('i','I',"irst",name)) {
1199       /* ignore */
1200     }
1201     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
1202       attr_style = value;
1203     }
1204   }
1205   W_L(">");
1206
1207   if (IS_CSS_ON(xhtml->entryp)) {
1208     s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
1209   }
1210
1211   return xhtml->out;
1212 }
1213
1214
1215 /**
1216  * It is a handler who processes the A tag.
1217  *
1218  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1219  *                     destination is specified.
1220  * @param node   [i]   The A tag node is specified.
1221  * @return The conversion result is returned.
1222  */
1223 static char *
1224 s_xhtml_1_0_end_a_tag(void *pdoc, Node *UNUSED(child)) 
1225 {
1226   xhtml_t *xhtml = GET_XHTML(pdoc);
1227   Doc     *doc   = xhtml->doc;
1228
1229   W_L("</a>");
1230
1231   if (IS_CSS_ON(xhtml->entryp)) {
1232     chxj_css_pop_prop_list(xhtml->css_prop_stack);
1233   }
1234
1235   return xhtml->out;
1236 }
1237
1238
1239 /**
1240  * It is a handler who processes the BR tag.
1241  *
1242  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1243  *                     destination is specified.
1244  * @param node   [i]   The BR tag node is specified.
1245  * @return The conversion result is returned.
1246  */
1247 static char *
1248 s_xhtml_1_0_start_br_tag(void *pdoc, Node *node) 
1249 {
1250   xhtml_t *xhtml = GET_XHTML(pdoc);
1251   Doc     *doc   = xhtml->doc;
1252   Attr    *attr;
1253
1254   W_L("<br");
1255   /*--------------------------------------------------------------------------*/
1256   /* Get Attributes                                                           */
1257   /*--------------------------------------------------------------------------*/
1258   for (attr = qs_get_attr(doc,node);
1259        attr;
1260        attr = qs_get_next_attr(doc,attr)) {
1261     char *name  = qs_get_attr_name(doc,attr);
1262     char *value = qs_get_attr_value(doc,attr);
1263     if (STRCASEEQ('c','C',"clear",name)) {
1264       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('a','A',"all",value))) {
1265         W_L(" clear=\"");
1266         W_V(value);
1267         W_L("\"");
1268       }
1269     }
1270   }
1271   W_L(" />");
1272
1273   return xhtml->out;
1274 }
1275
1276
1277 /**
1278  * It is a handler who processes the BR tag.
1279  *
1280  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1281  *                     destination is specified.
1282  * @param node   [i]   The BR tag node is specified.
1283  * @return The conversion result is returned.
1284  */
1285 static char *
1286 s_xhtml_1_0_end_br_tag(void *pdoc, Node *UNUSED(child)) 
1287 {
1288   xhtml_t *xhtml = GET_XHTML(pdoc);
1289
1290   return xhtml->out;
1291 }
1292
1293
1294 /**
1295  * It is a handler who processes the TR tag.
1296  *
1297  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1298  *                     destination is specified.
1299  * @param node   [i]   The TR tag node is specified.
1300  * @return The conversion result is returned.
1301  */
1302 static char *
1303 s_xhtml_1_0_start_tr_tag(void *pdoc, Node *UNUSED(node)) 
1304 {
1305   xhtml_t *xhtml = GET_XHTML(pdoc);
1306   Doc     *doc   = xhtml->doc;
1307
1308   W_L("<br />");
1309
1310   return xhtml->out;
1311 }
1312
1313
1314 /**
1315  * It is a handler who processes the TR tag.
1316  *
1317  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1318  *                     destination is specified.
1319  * @param node   [i]   The TR tag node is specified.
1320  * @return The conversion result is returned.
1321  */
1322 static char *
1323 s_xhtml_1_0_end_tr_tag(void *pdoc, Node *UNUSED(child)) 
1324 {
1325   xhtml_t *xhtml = GET_XHTML(pdoc);
1326
1327   return xhtml->out;
1328 }
1329
1330
1331 /**
1332  * It is a handler who processes the FONT tag.
1333  *
1334  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1335  *                     destination is specified.
1336  * @param node   [i]   The FONT tag node is specified.
1337  * @return The conversion result is returned.
1338  */
1339 static char *
1340 s_xhtml_1_0_start_font_tag(void *pdoc, Node *node) 
1341 {
1342   xhtml_t *xhtml = GET_XHTML(pdoc);
1343   Doc     *doc   = xhtml->doc;
1344   Attr    *attr;
1345   char    *attr_color = NULL;
1346   char    *attr_size  = NULL;
1347   char    *attr_style = NULL;
1348
1349   /*--------------------------------------------------------------------------*/
1350   /* Get Attributes                                                           */
1351   /*--------------------------------------------------------------------------*/
1352   for (attr = qs_get_attr(doc,node);
1353        attr;
1354        attr = qs_get_next_attr(doc,attr)) {
1355     char *name  = qs_get_attr_name(doc,attr);
1356     char *value = qs_get_attr_value(doc,attr);
1357     if (STRCASEEQ('c','C',"color",name) && value && *value) {
1358       attr_color = apr_pstrdup(doc->buf.pool, value);
1359     }
1360     else if (STRCASEEQ('s','S',"size",name) && value && *value) {
1361       /*----------------------------------------------------------------------*/
1362       /* CHTML 5.0                                                            */
1363       /*----------------------------------------------------------------------*/
1364       attr_size = apr_pstrdup(doc->buf.pool, value);
1365     }
1366     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
1367       attr_style = apr_pstrdup(doc->buf.pool, value);
1368     }
1369   }
1370   if (IS_CSS_ON(xhtml->entryp)) {
1371     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
1372     if (style) {
1373       css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
1374       css_property_t *size_prop  = chxj_css_get_property_value(doc, style, "font-size");
1375       css_property_t *cur;
1376       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
1377         if (cur->value && *cur->value) {
1378           attr_color = apr_pstrdup(doc->pool, cur->value);
1379         }
1380       }
1381       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
1382         if (cur->value && *cur->value) {
1383           attr_size = apr_pstrdup(doc->pool, cur->value);
1384           if (STRCASEEQ('x','X',"xx-small",attr_size)) {
1385             attr_size = apr_pstrdup(doc->pool, "1");
1386           }
1387           else if (STRCASEEQ('x','X',"x-small",attr_size)) {
1388             attr_size = apr_pstrdup(doc->pool, "2");
1389           }
1390           else if (STRCASEEQ('s','S',"small",attr_size)) {
1391             attr_size = apr_pstrdup(doc->pool, "3");
1392           }
1393           else if (STRCASEEQ('m','M',"medium",attr_size)) {
1394             attr_size = apr_pstrdup(doc->pool, "4");
1395           }
1396           else if (STRCASEEQ('l','L',"large",attr_size)) {
1397             attr_size = apr_pstrdup(doc->pool, "5");
1398           }
1399           else if (STRCASEEQ('x','X',"x-large",attr_size)) {
1400             attr_size = apr_pstrdup(doc->pool, "6");
1401           }
1402           else if (STRCASEEQ('x','X',"xx-large",attr_size)) {
1403             attr_size = apr_pstrdup(doc->pool, "7");
1404           }
1405         }
1406       }
1407     }
1408   }
1409
1410   xhtml_flags_t *flg = (xhtml_flags_t *)apr_palloc(doc->pool, sizeof(*flg));
1411   memset(flg, 0, sizeof(*flg));
1412   if (attr_color) {
1413     W_L("<font color=\"");
1414     W_V(attr_color);
1415     W_L("\">");
1416     flg->font_color_flag = 1;
1417   }
1418   if (attr_size) {
1419     flg->font_size_flag = 1;
1420     switch(*attr_size) {
1421     case '1': W_L("<span style=\"font-size: xx-small\">"); break;
1422     case '2': W_L("<span style=\"font-size: x-small\">");  break;
1423     case '3': W_L("<span style=\"font-size: small\">");    break;
1424     case '4': W_L("<span style=\"font-size: medium\">");   break;
1425     case '5': W_L("<span style=\"font-size: large\">");    break;
1426     case '6': W_L("<span style=\"font-size: x-large\">");  break;
1427     case '7': W_L("<span style=\"font-size: xx-large\">"); break;
1428     case '-':
1429       if (*(attr_size + 1) == '1') {
1430         W_L("<span style=\"font-size: small\">");
1431         break;
1432       }
1433       if (*(attr_size + 1) == '2') {
1434         W_L("<span style=\"font-size: x-small\">");
1435         break;
1436       }
1437       if (*(attr_size + 1) == '3') {
1438         W_L("<span style=\"font-size: xx-small\">");
1439         break;
1440       }
1441       flg->font_size_flag = 0;
1442       break;
1443
1444     case '+':
1445       if (*(attr_size + 1) == '1') {
1446         W_L("<span style=\"font-size: large\">");
1447         break;
1448       }
1449       if (*(attr_size + 1) == '2') {
1450         W_L("<span style=\"font-size: x-large\">");
1451         break;
1452       }
1453       if (*(attr_size + 1) == '3') {
1454         W_L("<span style=\"font-size: xx-large\">");
1455         break;
1456       }
1457       flg->font_size_flag = 0;
1458       break;
1459
1460     default:
1461       WRN(doc->r, "invlalid font size. [%s] != (1|2|3|4|5|6|7|+1|+2|+3|-1|-2|-3)", attr_size);
1462       flg->font_size_flag = 0;
1463     }
1464   }
1465   node->userData = flg;
1466
1467   return xhtml->out;
1468 }
1469
1470
1471 /**
1472  * It is a handler who processes the FONT tag.
1473  *
1474  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1475  *                     destination is specified.
1476  * @param node   [i]   The FONT tag node is specified.
1477  * @return The conversion result is returned.
1478  */
1479 static char *
1480 s_xhtml_1_0_end_font_tag(void *pdoc, Node *node)
1481 {
1482   xhtml_t *xhtml = GET_XHTML(pdoc);
1483   Doc     *doc   = xhtml->doc;
1484
1485   xhtml_flags_t *flg = (xhtml_flags_t *)node->userData;
1486   if (flg && flg->font_size_flag) {
1487     W_L("</span>");
1488   }
1489   if (flg && flg->font_color_flag) {
1490     W_L("</font>");
1491   }
1492   if (IS_CSS_ON(xhtml->entryp)) {
1493     chxj_css_pop_prop_list(xhtml->css_prop_stack);
1494   }
1495   return xhtml->out;
1496 }
1497
1498
1499 /**
1500  * It is a handler who processes the FORM tag.
1501  *
1502  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1503  *                     destination is specified.
1504  * @param node   [i]   The FORM tag node is specified.
1505  * @return The conversion result is returned.
1506  */
1507 static char *
1508 s_xhtml_1_0_start_form_tag(void *pdoc, Node *node) 
1509 {
1510   xhtml_t     *xhtml = GET_XHTML(pdoc);
1511   Doc         *doc   = xhtml->doc;
1512   request_rec *r     = doc->r;
1513   Attr        *attr;
1514   char        *attr_action = NULL;
1515   char        *attr_method = NULL;
1516   char        *attr_style  = NULL;
1517   char        *attr_color  = NULL;
1518   char        *attr_align  = NULL;
1519   char        *attr_name   = NULL;
1520   char        *new_hidden_tag = NULL;
1521
1522   /*--------------------------------------------------------------------------*/
1523   /* Get Attributes                                                           */
1524   /*--------------------------------------------------------------------------*/
1525   for (attr = qs_get_attr(doc,node);
1526        attr;
1527        attr = qs_get_next_attr(doc,attr)) {
1528     char *name  = qs_get_attr_name(doc,attr);
1529     char *value = qs_get_attr_value(doc,attr);
1530     switch(*name) {
1531     case 'a':
1532     case 'A':
1533       if (strcasecmp(name, "action") == 0) {
1534         /*--------------------------------------------------------------------*/
1535         /* CHTML 1.0                                                          */
1536         /*--------------------------------------------------------------------*/
1537         attr_action = value;
1538       }
1539       break;
1540
1541     case 'm':
1542     case 'M':
1543       if (strcasecmp(name, "method") == 0) {
1544         /*--------------------------------------------------------------------*/
1545         /* CHTML 1.0                                                          */
1546         /*--------------------------------------------------------------------*/
1547         attr_method = value;
1548       }
1549       break;
1550
1551     case 'n':
1552     case 'N':
1553       if (strcasecmp(name, "name") == 0) {
1554         /*--------------------------------------------------------------------*/
1555         /* CHTML 1.0                                                          */
1556         /*--------------------------------------------------------------------*/
1557         attr_name = value;
1558       }
1559       break;
1560
1561     case 's':
1562     case 'S':
1563       if (strcasecmp(name, "style") == 0) {
1564         attr_style = value;
1565       }
1566       break;
1567
1568     default:
1569       break;
1570     }
1571   }
1572   if (IS_CSS_ON(xhtml->entryp)) {
1573     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
1574     if (style) {
1575       css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
1576       css_property_t *color_prop      = chxj_css_get_property_value(doc, style, "color");
1577       css_property_t *cur;
1578       for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
1579         if (STRCASEEQ('l','L',"left", cur->value)) {
1580           attr_align = apr_pstrdup(doc->pool, "left");
1581         }
1582         else if (STRCASEEQ('c','C',"center",cur->value)) {
1583           attr_align = apr_pstrdup(doc->pool, "center");
1584         }
1585         else if (STRCASEEQ('r','R',"right",cur->value)) {
1586           attr_align = apr_pstrdup(doc->pool, "right");
1587         }
1588       }
1589       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
1590         attr_color = apr_pstrdup(doc->pool, cur->value);
1591       }
1592     }
1593   }
1594
1595   int post_flag = (attr_method && strcasecmp(attr_method, "post") == 0) ? 1 : 0;
1596
1597   W_L("<form");
1598   if (attr_action) {
1599     attr_action = chxj_encoding_parameter(r, attr_action, 1);
1600     attr_action = chxj_add_cookie_parameter(r, attr_action, xhtml->cookie);
1601     char *q;
1602     char *old_qs = NULL;
1603     q = strchr(attr_action, '?');
1604     if (q) {
1605       new_hidden_tag = chxj_form_action_to_hidden_tag(r, doc->pool, attr_action, 1, post_flag, &old_qs, CHXJ_FALSE, CHXJ_FALSE, xhtml->entryp);
1606       if (new_hidden_tag || old_qs) {
1607         *q = 0;
1608       }
1609     }
1610     W_L(" action=\"");
1611     W_V(attr_action);
1612     if (old_qs) {
1613       W_L("?");
1614       W_V(old_qs);
1615     }
1616     W_L("\"");
1617   }
1618   if (attr_method) {
1619     W_L(" method=\"");
1620     W_V(attr_method);
1621     W_L("\"");
1622   }
1623   if (attr_name) {
1624     W_L(" name=\"");
1625     W_V(attr_name);
1626     W_L("\"");
1627   }
1628   W_L(">");
1629
1630   xhtml_flags_t *flg = (xhtml_flags_t *)apr_palloc(doc->pool, sizeof(xhtml_flags_t));
1631   memset(flg, 0, sizeof(*flg));
1632   if (attr_color) {
1633     attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
1634     W_L("<font color=\"");
1635     W_V(attr_color);
1636     W_L("\">");
1637     flg->with_font_flag = 1;
1638   }
1639   if (attr_align) {
1640     W_L("<div align=\"");
1641     W_V(attr_align);
1642     W_L("\">");
1643     flg->with_div_flag = 1;
1644   }
1645   node->userData = flg;
1646   if (new_hidden_tag) {
1647     W_V(new_hidden_tag);
1648   }
1649   return xhtml->out;
1650 }
1651
1652
1653 /**
1654  * It is a handler who processes the FORM tag.
1655  *
1656  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1657  *                     destination is specified.
1658  * @param node   [i]   The FORM tag node is specified.
1659  * @return The conversion result is returned.
1660  */
1661 static char *
1662 s_xhtml_1_0_end_form_tag(void *pdoc, Node *node)
1663 {
1664   xhtml_t *xhtml = GET_XHTML(pdoc);
1665   Doc     *doc   = xhtml->doc;
1666
1667   xhtml_flags_t *flg = (xhtml_flags_t *)node->userData;
1668   if (flg && flg->with_div_flag) {
1669     W_L("</div>");
1670   }
1671   if (flg && flg->with_font_flag) {
1672     W_L("</font>");
1673   }
1674   W_L("</form>");
1675   if (IS_CSS_ON(xhtml->entryp)) {
1676     chxj_css_pop_prop_list(xhtml->css_prop_stack);
1677   }
1678
1679   return xhtml->out;
1680 }
1681
1682
1683 /**
1684  * It is a handler who processes the INPUT tag.
1685  *
1686  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1687  *                     destination is specified.
1688  * @param node   [i]   The INPUT tag node is specified.
1689  * @return The conversion result is returned.
1690  */
1691 static char *
1692 s_xhtml_1_0_start_input_tag(void *pdoc, Node *node) 
1693 {
1694   xhtml_t     *xhtml       = GET_XHTML(pdoc);
1695   Doc         *doc         = xhtml->doc;
1696   request_rec *r           = doc->r;
1697   Attr        *attr;
1698   char        *attr_max_length  = NULL;
1699   char        *attr_type        = NULL;
1700   char        *attr_name        = NULL;
1701   char        *attr_value       = NULL;
1702   char        *attr_istyle      = NULL;
1703   char        *attr_size        = NULL;
1704   char        *attr_checked     = NULL;
1705   char        *attr_accesskey   = NULL;
1706   char        *attr_style       = NULL;
1707
1708   /*--------------------------------------------------------------------------*/
1709   /* Get Attributes                                                           */
1710   /*--------------------------------------------------------------------------*/
1711   for (attr = qs_get_attr(doc,node);
1712        attr;
1713        attr = qs_get_next_attr(doc,attr)) {
1714     char *name  = qs_get_attr_name(doc,attr);
1715     char *value = qs_get_attr_value(doc,attr);
1716     if (STRCASEEQ('t','T',"type",name) && value && *value) {
1717       char *tmp_type = qs_trim_string(doc->buf.pool, value);
1718       if (tmp_type && (STRCASEEQ('t','T',"text",    tmp_type) ||
1719                        STRCASEEQ('p','P',"password",tmp_type) ||
1720                        STRCASEEQ('c','C',"checkbox",tmp_type) ||
1721                        STRCASEEQ('r','R',"radio",   tmp_type) ||
1722                        STRCASEEQ('h','H',"hidden",  tmp_type) ||
1723                        STRCASEEQ('s','S',"submit",  tmp_type) ||
1724                        STRCASEEQ('r','R',"reset",   tmp_type))) {
1725         attr_type = tmp_type;
1726       }
1727     }
1728     else if (STRCASEEQ('n','N',"name",name) && value && *value) {
1729       attr_name = value;
1730     }
1731     else if (STRCASEEQ('v','V',"value",name) && value && *value) {
1732       attr_value = value;
1733     }
1734     else if (STRCASEEQ('i','I',"istyle",name) && value && *value) {
1735       attr_istyle = value;
1736     }
1737     else if (STRCASEEQ('m','M',"maxlength",name) && value && *value) {
1738       attr_max_length = value;
1739     }
1740     else if (STRCASEEQ('c','C',"checked", name)) {
1741       attr_checked = value;
1742     }
1743     else if (STRCASEEQ('a','A',"accesskey", name) && value && *value) {
1744       attr_accesskey = value;
1745     }
1746     else if (STRCASEEQ('s','S',"size", name) && value && *value) {
1747       attr_size = value;
1748     }
1749     else if (STRCASEEQ('s','S',"style", name) && value && *value) {
1750       attr_style = value;
1751     }
1752   }
1753
1754   if (IS_CSS_ON(xhtml->entryp)) {
1755     css_prop_list_t *style = s_xhtml_1_0_nopush_and_get_now_style(pdoc, node, attr_style);
1756     if (style) {
1757       css_property_t *wap_input_format = chxj_css_get_property_value(doc, style, "-wap-input-format");
1758       css_property_t *cur;
1759       for (cur = wap_input_format->next; cur != wap_input_format; cur = cur->next) {
1760         if (strcasestr(cur->value, "<ja:n>")) {
1761           attr_istyle = "4";
1762         }
1763         else if (strcasestr(cur->value, "<ja:en>")) {
1764           attr_istyle = "3";
1765         }
1766         else if (strcasestr(cur->value, "<ja:hk>")) {
1767           attr_istyle = "2";
1768         }
1769         else if (strcasestr(cur->value, "<ja:h>")) {
1770           attr_istyle = "1";
1771         }
1772       }
1773     }
1774   }
1775   W_L("<input");
1776   if (attr_type) {
1777     attr_type = qs_trim_string(doc->buf.pool, attr_type);
1778     if (attr_type && (STRCASEEQ('t','T',"text",    attr_type) ||
1779                       STRCASEEQ('p','P',"password",attr_type) ||
1780                       STRCASEEQ('c','C',"checkbox",attr_type) ||
1781                       STRCASEEQ('r','R',"radio",   attr_type) ||
1782                       STRCASEEQ('h','H',"hidden",  attr_type) ||
1783                       STRCASEEQ('s','S',"submit",  attr_type) ||
1784                       STRCASEEQ('r','R',"reset",   attr_type))) {
1785       W_L(" type=\"");
1786       W_V(attr_type);
1787       W_L("\"");
1788     }
1789   }
1790   if (attr_size && *attr_size) {
1791     W_L(" size=\"");
1792     W_V(attr_size);
1793     W_L("\"");
1794   }
1795   if (attr_name && *attr_name) {
1796     W_L(" name=\"");
1797     W_V(attr_name);
1798     W_L("\"");
1799   }
1800   if (attr_value && *attr_value) {
1801     W_L(" value=\"");
1802     W_V(chxj_add_slash_to_doublequote(doc->pool, attr_value));
1803     W_L("\"");
1804   }
1805   if (attr_accesskey && *attr_accesskey) {
1806     W_L(" accesskey=\"");
1807     W_V(attr_accesskey);
1808     W_L("\"");
1809   }
1810   if (attr_istyle && *attr_istyle && (*attr_istyle == '1' || *attr_istyle == '2' || *attr_istyle == '3' || *attr_istyle == '4')) {
1811     char *fmt = qs_conv_istyle_to_format(r->pool,attr_istyle);
1812     if (attr_max_length && *attr_max_length) {
1813       int ii;
1814       for (ii=0; (unsigned int)ii<strlen(attr_max_length); ii++) {
1815         if (attr_max_length[ii] < '0' || attr_max_length[ii] > '9') {
1816           attr_max_length = apr_psprintf(r->pool, "0");
1817           break;
1818         }
1819       }
1820
1821       if (strcmp(attr_max_length, "0")) {
1822         char *vv = apr_psprintf(r->pool, " FORMAT=\"%d%s\"", atoi(attr_max_length), fmt);
1823         W_V(vv);
1824       }
1825     }
1826     else {
1827       W_L(" FORMAT=\"");
1828       W_L("*");
1829       W_V(fmt);
1830       W_L("\"");
1831     }
1832   }
1833   else {
1834     if (attr_max_length && *attr_max_length) {
1835       if (chxj_chk_numeric(attr_max_length) != 0) {
1836         attr_max_length = apr_psprintf(r->pool, "0");
1837       }
1838       if (strcmp(attr_max_length, "0")) {
1839         char *vv = apr_psprintf(r->pool, " FORMAT=\"%dm\"", atoi(attr_max_length));
1840         W_V(vv);
1841       }
1842     }
1843   }
1844   /*--------------------------------------------------------------------------*/
1845   /* The figure is default for the password.                                  */
1846   /*--------------------------------------------------------------------------*/
1847   if (attr_type && (attr_istyle == NULL || *attr_istyle == 0) && STRCASEEQ('p','P',"password", attr_type) && ! xhtml->entryp->pc_flag) {
1848     if (attr_max_length) {
1849       W_L(" FORMAT=\"");
1850       W_V(attr_max_length);
1851       W_L("N\"");
1852     }
1853     else {
1854       W_L(" FORMAT=\"*N\"");
1855     }
1856   }
1857   if (attr_checked) {
1858     W_L(" checked=\"checked\"");
1859   }
1860   W_L(" />");
1861 #if 0
1862   W_L("<input");
1863   /*--------------------------------------------------------------------------*/
1864   /* Get Attributes                                                           */
1865   /*--------------------------------------------------------------------------*/
1866   type       = qs_get_type_attr(doc, node, doc->buf.pool);
1867   name       = qs_get_name_attr(doc, node, doc->buf.pool);
1868   value      = qs_get_value_attr(doc,node, doc->buf.pool);
1869   istyle     = qs_get_istyle_attr(doc,node,doc->buf.pool);
1870   max_length = qs_get_maxlength_attr(doc,node,doc->buf.pool);
1871   checked    = qs_get_checked_attr(doc,node, doc->buf.pool);
1872   accesskey  = qs_get_accesskey_attr(doc, node, doc->buf.pool);
1873   size       = qs_get_size_attr(doc, node, doc->buf.pool);
1874
1875   if (type) {
1876     type = qs_trim_string(doc->buf.pool, type);
1877     if (type && (STRCASEEQ('t','T',"text",    type) ||
1878                  STRCASEEQ('p','P',"password",type) ||
1879                  STRCASEEQ('c','C',"checkbox",type) ||
1880                  STRCASEEQ('r','R',"radio",   type) ||
1881                  STRCASEEQ('h','H',"hidden",  type) ||
1882                  STRCASEEQ('s','S',"submit",  type) ||
1883                  STRCASEEQ('r','R',"reset",   type))) {
1884       W_L(" type=\"");
1885       W_V(type);
1886       W_L("\"");
1887     }
1888   }
1889   if (size && *size) {
1890     W_L(" size=\"");
1891     W_V(size);
1892     W_L("\"");
1893   }
1894   if (name && *name) {
1895     W_L(" name=\"");
1896     W_V(name);
1897     W_L("\"");
1898   }
1899   if (value && *value) {
1900     if (type && (STRCASEEQ('s','S',"submit",type) || STRCASEEQ('r','R',"reset",type))) {
1901       apr_size_t value_len = strlen(value);
1902       value = chxj_conv_z2h(r, value, &value_len, xhtml->entryp);
1903     }
1904
1905     W_L(" value=\"");
1906     W_V(chxj_add_slash_to_doublequote(doc->pool, value));
1907     W_L("\"");
1908   }
1909   if (accesskey && *accesskey) {
1910     W_L(" accesskey=\"");
1911     W_V(accesskey);
1912     W_L("\"");
1913   }
1914   if (istyle && *istyle && (*istyle == '1' || *istyle == '2' || *istyle == '3' || *istyle == '4')) {
1915     char *fmt = qs_conv_istyle_to_format(r->pool,istyle);
1916     if (max_length && *max_length) {
1917       int ii;
1918       for (ii=0; (unsigned int)ii<strlen(max_length); ii++) {
1919         if (max_length[ii] < '0' || max_length[ii] > '9') {
1920           max_length = apr_psprintf(r->pool, "0");
1921           break;
1922         }
1923       }
1924
1925       if (strcmp(max_length, "0")) {
1926         char *vv = apr_psprintf(r->pool, " FORMAT=\"%d%s\"", atoi(max_length), fmt);
1927         W_V(vv);
1928       }
1929     }
1930     else {
1931       W_L(" FORMAT=\"");
1932       W_L("*");
1933       W_V(fmt);
1934       W_L("\"");
1935     }
1936   }
1937   else {
1938     if (max_length && *max_length) {
1939       if (chxj_chk_numeric(max_length) != 0) {
1940         max_length = apr_psprintf(r->pool, "0");
1941       }
1942       if (strcmp(max_length, "0")) {
1943         char *vv = apr_psprintf(r->pool, " FORMAT=\"%dm\"", atoi(max_length));
1944         W_V(vv);
1945       }
1946     }
1947   }
1948   /*--------------------------------------------------------------------------*/
1949   /* The figure is default for the password.                                  */
1950   /*--------------------------------------------------------------------------*/
1951   if (type && (istyle == NULL || *istyle == 0) && STRCASEEQ('p','P',"password", type) && ! xhtml->entryp->pc_flag) {
1952     if (max_length) {
1953       W_L(" FORMAT=\"");
1954       W_V(max_length);
1955       W_L("N\"");
1956     }
1957     else {
1958       W_L(" FORMAT=\"*N\"");
1959     }
1960   }
1961   if (checked) {
1962     W_L(" checked=\"checked\"");
1963   }
1964   W_L(" />");
1965 #endif
1966
1967   return xhtml->out;
1968 }
1969
1970
1971 /**
1972  * It is a handler who processes the INPUT tag.
1973  *
1974  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1975  *                     destination is specified.
1976  * @param node   [i]   The INPUT tag node is specified.
1977  * @return The conversion result is returned.
1978  */
1979 static char *
1980 s_xhtml_1_0_end_input_tag(void *pdoc, Node *UNUSED(child)) 
1981 {
1982   xhtml_t *xhtml = GET_XHTML(pdoc);
1983
1984   return xhtml->out;
1985 }
1986
1987
1988 /**
1989  * It is a handler who processes the CENTER tag.
1990  *
1991  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1992  *                     destination is specified.
1993  * @param node   [i]   The CENTER tag node is specified.
1994  * @return The conversion result is returned.
1995  */
1996 static char *
1997 s_xhtml_1_0_start_center_tag(void *pdoc, Node *node)
1998 {
1999   xhtml_t *xhtml;
2000   Doc     *doc;
2001   Attr    *attr;
2002   char    *attr_style = NULL;
2003   char    *attr_color = NULL;
2004   char    *attr_size  = NULL;
2005
2006   xhtml = GET_XHTML(pdoc);
2007   doc    = xhtml->doc;
2008
2009   for (attr = qs_get_attr(doc,node);
2010        attr;
2011        attr = qs_get_next_attr(doc,attr)) {
2012     char *name  = qs_get_attr_name(doc,attr);
2013     char *value = qs_get_attr_value(doc,attr);
2014     if (STRCASEEQ('s','S',"style",name) && value && *value) {
2015       attr_style = value;
2016     }
2017   }
2018   if (IS_CSS_ON(xhtml->entryp)) {
2019     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
2020     if (style) {
2021       css_property_t *color_prop      = chxj_css_get_property_value(doc, style, "color");
2022       css_property_t *size_prop       = chxj_css_get_property_value(doc, style, "font-size");
2023       css_property_t *cur;
2024       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
2025         if (cur->value && *cur->value) {
2026           attr_color = apr_pstrdup(doc->pool, cur->value);
2027         }
2028       }
2029       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
2030         if (cur->value && *cur->value) {
2031           attr_size = apr_pstrdup(doc->pool, cur->value);
2032         }
2033       }
2034     }
2035   }
2036
2037   W_L("<center");
2038   if (attr_size || attr_color) {
2039     W_L(" style=\"");
2040     if (attr_size) {
2041       W_L("font-size:");
2042       W_V(attr_size);
2043       W_L(";");
2044     }
2045     if (attr_color) {
2046       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
2047       W_L("color:");
2048       W_V(attr_color);
2049       W_L(";");
2050     }
2051     W_L("\"");
2052   }
2053   W_L(">");
2054   
2055   return xhtml->out;
2056 }
2057
2058
2059 /**
2060  * It is a handler who processes the CENTER tag.
2061  *
2062  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2063  *                     destination is specified.
2064  * @param node   [i]   The CENTER tag node is specified.
2065  * @return The conversion result is returned.
2066  */
2067 static char *
2068 s_xhtml_1_0_end_center_tag(void *pdoc, Node *UNUSED(node))
2069 {
2070   xhtml_t *xhtml = GET_XHTML(pdoc);
2071   Doc     *doc   = xhtml->doc;
2072
2073   W_L("</center>");
2074   if (IS_CSS_ON(xhtml->entryp)) {
2075     chxj_css_pop_prop_list(xhtml->css_prop_stack);
2076   }
2077   return xhtml->out;
2078 }
2079
2080
2081 /**
2082  * It is a handler who processes the HR tag.
2083  *
2084  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2085  *                     destination is specified.
2086  * @param node   [i]   The HR tag node is specified.
2087  * @return The conversion result is returned.
2088  */
2089 static char *
2090 s_xhtml_1_0_start_hr_tag(void *pdoc, Node *node)
2091 {
2092   Attr        *attr;
2093   xhtml_t     *xhtml;
2094   Doc         *doc;
2095   request_rec *r;
2096   char        *attr_align   = NULL;
2097   char        *attr_size    = NULL;
2098   char        *attr_width   = NULL;
2099   char        *attr_noshade = NULL;
2100   char        *attr_style   = NULL;
2101   char        *attr_color   = NULL;
2102
2103   xhtml   = GET_XHTML(pdoc);
2104   doc     = xhtml->doc;
2105   r       = doc->r;
2106
2107   for (attr = qs_get_attr(doc,node);
2108        attr; 
2109        attr = qs_get_next_attr(doc,attr)) {
2110     char *name  = qs_get_attr_name (doc,attr);
2111     char *value = qs_get_attr_value(doc,attr);
2112     switch(*name) {
2113     case 'a':
2114     case 'A':
2115       if (strcasecmp(name, "align") == 0) {
2116         /*--------------------------------------------------------------------*/
2117         /* CHTML 1.0                                                          */
2118         /*--------------------------------------------------------------------*/
2119         if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2120           attr_align = value;
2121         }
2122       }
2123       break;
2124
2125     case 's':
2126     case 'S':
2127       if (strcasecmp(name, "size") == 0) {
2128         /*--------------------------------------------------------------------*/
2129         /* CHTML 1.0                                                          */
2130         /*--------------------------------------------------------------------*/
2131         if (value && *value) {
2132           attr_size = value;
2133         }
2134       }
2135       else if (strcasecmp(name, "style") == 0) {
2136         if (value && *value) {
2137           attr_style = value;
2138         }
2139       }
2140       break;
2141
2142     case 'w':
2143     case 'W':
2144       if (strcasecmp(name, "width") == 0) {
2145         /*--------------------------------------------------------------------*/
2146         /* CHTML 1.0                                                          */
2147         /*--------------------------------------------------------------------*/
2148         if (value && *value) {
2149           attr_width = value;
2150         }
2151       }
2152       break;
2153
2154     case 'n':
2155     case 'N':
2156       if (strcasecmp(name, "noshade") == 0) {
2157         /*--------------------------------------------------------------------*/
2158         /* CHTML 1.0                                                          */
2159         /*--------------------------------------------------------------------*/
2160         attr_noshade = apr_pstrdup(doc->pool, "noshade");
2161       }
2162       break;
2163
2164     case 'c':
2165     case 'C':
2166       if (strcasecmp(name, "color") == 0 && value && *value) {
2167         /*--------------------------------------------------------------------*/
2168         /* CHTML 4.0                                                          */
2169         /*--------------------------------------------------------------------*/
2170         attr_color = value;
2171       }
2172       break;
2173
2174     default:
2175       break;
2176     }
2177   }
2178   if (IS_CSS_ON(xhtml->entryp)) {
2179     css_prop_list_t *style = s_xhtml_1_0_nopush_and_get_now_style(pdoc, node, attr_style);
2180     if (style) {
2181       css_property_t *border_style_prop = chxj_css_get_property_value(doc, style, "border-style");
2182       css_property_t *height_prop       = chxj_css_get_property_value(doc, style, "height");
2183       css_property_t *width_prop        = chxj_css_get_property_value(doc, style, "width");
2184       css_property_t *cur;
2185       for (cur = border_style_prop->next; cur != border_style_prop; cur = cur->next) {
2186         if (STRCASEEQ('s','S',"solid",cur->value)) {
2187           attr_noshade = "noshade";
2188         }
2189       }
2190       for (cur = height_prop->next; cur != height_prop; cur = cur->next) {
2191         char *tmp = apr_pstrdup(doc->pool, cur->value);
2192         char *tmpp = strstr(tmp, "px");
2193         if (tmpp) { 
2194           attr_size = apr_pstrdup(doc->pool, tmp);
2195         }
2196       }
2197       for (cur = width_prop->next; cur != width_prop; cur = cur->next) {
2198         char *tmp = apr_pstrdup(doc->pool, cur->value);
2199         char *tmpp = strstr(tmp, "px");
2200         if (tmpp) {
2201           attr_width = apr_pstrdup(doc->pool, tmp);
2202         }
2203         else {
2204           tmpp = strstr(tmp, "%");
2205           if (tmpp) {
2206             attr_width = apr_pstrdup(doc->pool, tmp);
2207           }
2208         }
2209       }
2210     }
2211   }
2212   W_L("<hr");
2213   if (attr_align) {
2214     W_L(" align=\"");
2215     W_V(attr_align);
2216     W_L("\"");
2217   }
2218   if (attr_size || attr_width || attr_noshade) {
2219     W_L(" style=\"");
2220     if (attr_size) {
2221       W_L("height:");
2222       W_V(attr_size);
2223       if (!strstr(attr_size, "px")) {
2224         W_L("px");
2225       }
2226       W_L(";");
2227     }
2228     if (attr_width) {
2229       W_L("width:");
2230       W_V(attr_width);
2231       if (!strstr(attr_width, "px") && !strstr(attr_width, "%")) {
2232         W_L("px");
2233       }
2234       W_L(";");
2235     }
2236     if (attr_noshade) {
2237       W_L("border-style:solid;");
2238     }
2239     W_L("\"");
2240   }
2241   if (attr_color) {
2242     W_L(" color=\"");
2243     W_V(attr_color);
2244     W_L("\"");
2245   }
2246   W_L(" />");
2247
2248   return xhtml->out;
2249 }
2250
2251
2252 /**
2253  * It is a handler who processes the HR tag.
2254  *
2255  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2256  *                     destination is specified.
2257  * @param node   [i]   The HR tag node is specified.
2258  * @return The conversion result is returned.
2259  */
2260 static char *
2261 s_xhtml_1_0_end_hr_tag(void *pdoc, Node *UNUSED(child)) 
2262 {
2263   xhtml_t *xhtml = GET_XHTML(pdoc);
2264
2265   return xhtml->out;
2266 }
2267
2268
2269 /**
2270  * It is a handler who processes the PRE tag.
2271  *
2272  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2273  *                     destination is specified.
2274  * @param node   [i]   The PRE tag node is specified.
2275  * @return The conversion result is returned.
2276  */
2277 static char *
2278 s_xhtml_1_0_start_pre_tag(void *pdoc, Node *node)
2279 {
2280   xhtml_t *xhtml = GET_XHTML(pdoc);
2281   Doc     *doc   = xhtml->doc;
2282   Attr    *attr;
2283   char    *attr_style = NULL;
2284
2285   for (attr = qs_get_attr(doc,node);
2286        attr;
2287        attr = qs_get_next_attr(doc,attr)) {
2288     char *nm  = qs_get_attr_name(doc,attr);
2289     char *val = qs_get_attr_value(doc,attr);
2290     if (val && STRCASEEQ('s','S',"style", nm)) {
2291       attr_style = val;
2292     }
2293   }
2294
2295   if (IS_CSS_ON(xhtml->entryp)) {
2296     s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
2297   }
2298
2299   xhtml->pre_flag++;
2300   W_L("<pre>");
2301   return xhtml->out;
2302 }
2303
2304
2305 /**
2306  * It is a handler who processes the PRE tag.
2307  *
2308  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2309  *                     destination is specified.
2310  * @param node   [i]   The PRE tag node is specified.
2311  * @return The conversion result is returned.
2312  */
2313 static char *
2314 s_xhtml_1_0_end_pre_tag(void *pdoc, Node *UNUSED(child)) 
2315 {
2316   xhtml_t *xhtml = GET_XHTML(pdoc);
2317   Doc     *doc   = xhtml->doc;
2318
2319   W_L("</pre>");
2320   xhtml->pre_flag--;
2321   if (IS_CSS_ON(xhtml->entryp)) {
2322     chxj_css_pop_prop_list(xhtml->css_prop_stack);
2323   }
2324
2325   return xhtml->out;
2326 }
2327
2328
2329 /**
2330  * It is a handler who processes the P tag.
2331  *
2332  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2333  *                     destination is specified.
2334  * @param node   [i]   The P tag node is specified.
2335  * @return The conversion result is returned.
2336  */
2337 static char *
2338 s_xhtml_1_0_start_p_tag(void *pdoc, Node *node) 
2339 {
2340   xhtml_t *xhtml = GET_XHTML(pdoc);
2341   Doc     *doc   = xhtml->doc;
2342   Attr    *attr;
2343   char    *attr_align = NULL;
2344   char    *attr_style = NULL;
2345   char    *attr_color = NULL;
2346   char    *attr_blink = NULL;
2347
2348   for (attr = qs_get_attr(doc,node);
2349        attr;
2350        attr = qs_get_next_attr(doc,attr)) {
2351     char *nm  = qs_get_attr_name(doc,attr);
2352     char *val = qs_get_attr_value(doc,attr);
2353     if (STRCASEEQ('a','A',"align", nm)) {
2354       /*----------------------------------------------------------------------*/
2355       /* CHTML 1.0 (W3C version 3.2)                                          */
2356       /*----------------------------------------------------------------------*/
2357       if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2358         attr_align = apr_pstrdup(doc->buf.pool, val);
2359         break;
2360       }
2361     }
2362     else if (STRCASEEQ('s','S',"style", nm) && val && *val) {
2363       attr_style = apr_pstrdup(doc->buf.pool, val);
2364     }
2365   }
2366   if (IS_CSS_ON(xhtml->entryp)) {
2367     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
2368     if (style) {
2369       css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
2370       css_property_t *color_prop      = chxj_css_get_property_value(doc, style, "color");
2371       css_property_t *text_deco_prop  = chxj_css_get_property_value(doc, style, "text-decoration");
2372       css_property_t *cur;
2373       for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
2374         if (STRCASEEQ('l','L',"left",cur->value)) {
2375           attr_align = apr_pstrdup(doc->pool, "left");
2376         }
2377         else if (STRCASEEQ('c','C',"center",cur->value)) {
2378           attr_align = apr_pstrdup(doc->pool, "center");
2379         }
2380         else if (STRCASEEQ('r','R',"right",cur->value)) {
2381           attr_align = apr_pstrdup(doc->pool, "right");
2382         }
2383       }
2384       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
2385         if (cur->value && *cur->value) {
2386           attr_color = apr_pstrdup(doc->pool, cur->value);
2387         }
2388       }
2389       for (cur = text_deco_prop->next; cur != text_deco_prop; cur = cur->next) {
2390         if (cur->value && *cur->value && STRCASEEQ('b','B',"blink",cur->value)) {
2391           attr_blink = apr_pstrdup(doc->pool, cur->value);
2392         }
2393       }
2394     }
2395   }
2396   W_L("<p");
2397   if ((attr_align && *attr_align) || (attr_color && *attr_color) || (attr_blink && *attr_blink)) {
2398     W_L(" style=\"");
2399     if (attr_align) {
2400       W_L("text-align:");
2401       W_V(attr_align);
2402       W_L(";");
2403     }
2404     if (attr_color) {
2405       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
2406       W_L("color:");
2407       W_V(attr_color);
2408       W_L(";");
2409     }
2410     if (attr_blink) {
2411       W_L("text-decoration:");
2412       W_V(attr_blink);
2413       W_L(";");
2414     }
2415     W_L("\"");
2416   }
2417   W_L(">");
2418   return xhtml->out;
2419 }
2420
2421
2422 /**
2423  * It is a handler who processes the P tag.
2424  *
2425  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2426  *                     destination is specified.
2427  * @param node   [i]   The P tag node is specified.
2428  * @return The conversion result is returned.
2429  */
2430 static char *
2431 s_xhtml_1_0_end_p_tag(void *pdoc, Node *UNUSED(child)) 
2432 {
2433   xhtml_t *xhtml = GET_XHTML(pdoc);
2434   Doc     *doc   = xhtml->doc;
2435
2436   W_L("</p>");
2437   if (IS_CSS_ON(xhtml->entryp)) {
2438     chxj_css_pop_prop_list(xhtml->css_prop_stack);
2439   }
2440   return xhtml->out;
2441 }
2442
2443
2444 /**
2445  * It is a handler who processes the UL tag.
2446  *
2447  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2448  *                     destination is specified.
2449  * @param node   [i]   The UL tag node is specified.
2450  * @return The conversion result is returned.
2451  */
2452 static char *
2453 s_xhtml_1_0_start_ul_tag(void *pdoc, Node *node)
2454 {
2455   xhtml_t *xhtml = GET_XHTML(pdoc);
2456   Doc     *doc   = xhtml->doc;
2457   Attr    *attr;
2458   char        *attr_type = NULL;
2459   char        *attr_style = NULL;
2460   /*--------------------------------------------------------------------------*/
2461   /* Get Attributes                                                           */
2462   /*--------------------------------------------------------------------------*/
2463   for (attr = qs_get_attr(doc,node);
2464        attr;
2465        attr = qs_get_next_attr(doc,attr)) {
2466     char *name   = qs_get_attr_name(doc,attr);
2467     char *value  = qs_get_attr_value(doc,attr);
2468     if (STRCASEEQ('t','T',"type",name)) {
2469       if (value && (STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
2470         attr_type = value;
2471       }
2472     }
2473     else if (value && *value && STRCASEEQ('s','S',"style", name)) {
2474       attr_style = value;
2475     }
2476   }
2477   if (IS_CSS_ON(xhtml->entryp)) {
2478     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
2479     if (style) {
2480       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
2481       css_property_t *cur;
2482       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
2483         if (STRCASEEQ('d','D',"disc",cur->value)) {
2484           attr_type = apr_pstrdup(doc->pool, "disc");
2485         }
2486         else if (STRCASEEQ('c','C',"circle",cur->value)) {
2487           attr_type = apr_pstrdup(doc->pool, "circle");
2488         }
2489         else if (STRCASEEQ('s','S',"square",cur->value)) {
2490           attr_type = apr_pstrdup(doc->pool, "square");
2491         }
2492       }
2493     }
2494   }
2495   W_L("<ul");
2496   if (attr_type) {
2497     W_L(" style=\"");
2498     W_L("list-style-type:");
2499     W_V(attr_type);
2500     W_L(";");
2501     W_L("\"");
2502   }
2503   W_L(">");
2504   return xhtml->out;
2505 }
2506
2507
2508 /**
2509  * It is a handler who processes the UL tag.
2510  *
2511  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2512  *                     destination is specified.
2513  * @param node   [i]   The UL tag node is specified.
2514  * @return The conversion result is returned.
2515  */
2516 static char *
2517 s_xhtml_1_0_end_ul_tag(void *pdoc, Node *UNUSED(child)) 
2518 {
2519   xhtml_t *xhtml = GET_XHTML(pdoc);
2520   Doc     *doc   = xhtml->doc;
2521
2522   W_L("</ul>");
2523   if (IS_CSS_ON(xhtml->entryp)) {
2524     chxj_css_pop_prop_list(xhtml->css_prop_stack);
2525   }
2526   return xhtml->out;
2527 }
2528
2529
2530 /**
2531  * It is a handler who processes the H1 tag.
2532  *
2533  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2534  *                     destination is specified.
2535  * @param node   [i]   The H1 tag node is specified.
2536  * @return The conversion result is returned.
2537  */
2538 static char *
2539 s_xhtml_1_0_start_h1_tag(void *pdoc, Node *node) 
2540 {
2541   xhtml_t *xhtml = GET_XHTML(pdoc);
2542   Doc     *doc   = xhtml->doc;
2543   Attr    *attr;
2544   char    *attr_style = NULL;
2545   char    *attr_align = NULL;
2546
2547   for (attr = qs_get_attr(doc,node);
2548        attr;
2549        attr = qs_get_next_attr(doc,attr)) {
2550     char *name  = qs_get_attr_name(doc,attr);
2551     char *value = qs_get_attr_value(doc,attr);
2552     if (STRCASEEQ('a','A',"align", name)) {
2553       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2554         attr_align = value;
2555       }
2556     }
2557     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
2558       attr_style = value;
2559     }
2560   }
2561   if (IS_CSS_ON(xhtml->entryp)) {
2562     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
2563     if (style) {
2564       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
2565       css_property_t *cur;
2566       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
2567         if (STRCASEEQ('l','L',"left", cur->value)) {
2568           attr_align = apr_pstrdup(doc->pool, "left");
2569         }
2570         else if (STRCASEEQ('c','C',"center",cur->value)) {
2571           attr_align = apr_pstrdup(doc->pool, "center");
2572         }
2573         else if (STRCASEEQ('r','R',"right",cur->value)) {
2574           attr_align = apr_pstrdup(doc->pool, "right");
2575         }
2576       }
2577     }
2578   }
2579   W_L("<h1");
2580   if (attr_align) {
2581     W_L(" style=\"");
2582     W_L("text-align:");
2583     W_V(attr_align);
2584     W_L(";");
2585     W_L("\"");
2586   }
2587   W_L(">");
2588
2589   return xhtml->out;
2590 }
2591
2592
2593 /**
2594  * It is a handler who processes the H1 tag.
2595  *
2596  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2597  *                     destination is specified.
2598  * @param node   [i]   The H1 tag node is specified.
2599  * @return The conversion result is returned.
2600  */
2601 static char *
2602 s_xhtml_1_0_end_h1_tag(void *pdoc, Node *UNUSED(child)) 
2603 {
2604   xhtml_t *xhtml = GET_XHTML(pdoc);
2605   Doc     *doc   = xhtml->doc;
2606
2607   W_L("</h1>");
2608   if (IS_CSS_ON(xhtml->entryp)) {
2609     chxj_css_pop_prop_list(xhtml->css_prop_stack);
2610   }
2611   return xhtml->out;
2612 }
2613
2614
2615 /**
2616  * It is a handler who processes the H2 tag.
2617  *
2618  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2619  *                     destination is specified.
2620  * @param node   [i]   The H2 tag node is specified.
2621  * @return The conversion result is returned.
2622  */
2623 static char *
2624 s_xhtml_1_0_start_h2_tag(void *pdoc, Node *node)
2625 {
2626   xhtml_t *xhtml = GET_XHTML(pdoc);
2627   Doc     *doc = xhtml->doc;
2628   Attr    *attr;
2629   char    *attr_style = NULL;
2630   char    *attr_align = NULL;
2631
2632   for (attr = qs_get_attr(doc,node);
2633        attr;
2634        attr = qs_get_next_attr(doc,attr)) {
2635     char *name  = qs_get_attr_name(doc,attr);
2636     char *value = qs_get_attr_value(doc,attr);
2637     if (STRCASEEQ('a','A',"align", name)) {
2638       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2639         attr_align = value;
2640       }
2641     }
2642     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
2643       attr_style = value;
2644     }
2645   }
2646   if (IS_CSS_ON(xhtml->entryp)) {
2647     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
2648     if (style) {
2649       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
2650       css_property_t *cur;
2651       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
2652         if (STRCASEEQ('l','L',"left", cur->value)) {
2653           attr_align = apr_pstrdup(doc->pool, "left");
2654         }
2655         else if (STRCASEEQ('c','C',"center",cur->value)) {
2656           attr_align = apr_pstrdup(doc->pool, "center");
2657         }
2658         else if (STRCASEEQ('r','R',"right",cur->value)) {
2659           attr_align = apr_pstrdup(doc->pool, "right");
2660         }
2661       }
2662     }
2663   }
2664   W_L("<h2");
2665   if (attr_align) {
2666     W_L(" style=\"");
2667     W_L("text-align:");
2668     W_V(attr_align);
2669     W_L(";");
2670     W_L("\"");
2671   }
2672   W_L(">");
2673
2674   return xhtml->out;
2675 }
2676
2677
2678 /**
2679  * It is a handler who processes the H2 tag.
2680  *
2681  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2682  *                     destination is specified.
2683  * @param node   [i]   The H2 tag node is specified.
2684  * @return The conversion result is returned.
2685  */
2686 static char *
2687 s_xhtml_1_0_end_h2_tag(void *pdoc, Node *UNUSED(child)) 
2688 {
2689   xhtml_t *xhtml = GET_XHTML(pdoc);
2690   Doc     *doc   = xhtml->doc;
2691
2692   W_L("</h2>");
2693   if (IS_CSS_ON(xhtml->entryp)) {
2694     chxj_css_pop_prop_list(xhtml->css_prop_stack);
2695   }
2696   return xhtml->out;
2697 }
2698
2699
2700 /**
2701  * It is a handler who processes the H3 tag.
2702  *
2703  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2704  *                     destination is specified.
2705  * @param node   [i]   The H3 tag node is specified.
2706  * @return The conversion result is returned.
2707  */
2708 static char *
2709 s_xhtml_1_0_start_h3_tag(void *pdoc, Node *node)
2710 {
2711   xhtml_t *xhtml = GET_XHTML(pdoc);
2712   Doc     *doc = xhtml->doc;
2713   Attr    *attr;
2714   char    *attr_style = NULL;
2715   char    *attr_align = NULL;
2716
2717   for (attr = qs_get_attr(doc,node);
2718        attr;
2719        attr = qs_get_next_attr(doc,attr)) {
2720     char *name  = qs_get_attr_name(doc,attr);
2721     char *value = qs_get_attr_value(doc,attr);
2722     if (STRCASEEQ('a','A',"align", name)) {
2723       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2724         attr_align = value;
2725       }
2726     }
2727     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
2728       attr_style = value;
2729     }
2730   }
2731   if (IS_CSS_ON(xhtml->entryp)) {
2732     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
2733     if (style) {
2734       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
2735       css_property_t *cur;
2736       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
2737         if (STRCASEEQ('l','L',"left", cur->value)) {
2738           attr_align = apr_pstrdup(doc->pool, "left");
2739         }
2740         else if (STRCASEEQ('c','C',"center",cur->value)) {
2741           attr_align = apr_pstrdup(doc->pool, "center");
2742         }
2743         else if (STRCASEEQ('r','R',"right",cur->value)) {
2744           attr_align = apr_pstrdup(doc->pool, "right");
2745         }
2746       }
2747     }
2748   }
2749   W_L("<h3");
2750   if (attr_align) {
2751     W_L(" style=\"");
2752     W_L("text-align:");
2753     W_V(attr_align);
2754     W_L(";");
2755     W_L("\"");
2756   }
2757   W_L(">");
2758
2759   return xhtml->out;
2760 }
2761
2762
2763 /**
2764  * It is a handler who processes the H3 tag.
2765  *
2766  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2767  *                     destination is specified.
2768  * @param node   [i]   The H3 tag node is specified.
2769  * @return The conversion result is returned.
2770  */
2771 static char *
2772 s_xhtml_1_0_end_h3_tag(void *pdoc, Node *UNUSED(child)) 
2773 {
2774   xhtml_t *xhtml = GET_XHTML(pdoc);
2775   Doc     *doc   = xhtml->doc;
2776
2777   W_L("</h3>");
2778   if (IS_CSS_ON(xhtml->entryp)) {
2779     chxj_css_pop_prop_list(xhtml->css_prop_stack);
2780   }
2781
2782   return xhtml->out;
2783 }
2784
2785
2786 /**
2787  * It is a handler who processes the H4 tag.
2788  *
2789  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2790  *                     destination is specified.
2791  * @param node   [i]   The H4 tag node is specified.
2792  * @return The conversion result is returned.
2793  */
2794 static char *
2795 s_xhtml_1_0_start_h4_tag(void *pdoc, Node *node)
2796 {
2797   xhtml_t *xhtml = GET_XHTML(pdoc);
2798   Doc     *doc = xhtml->doc;
2799   Attr    *attr;
2800   char    *attr_style = NULL;
2801   char    *attr_align = NULL;
2802
2803   for (attr = qs_get_attr(doc,node);
2804        attr;
2805        attr = qs_get_next_attr(doc,attr)) {
2806     char *name  = qs_get_attr_name(doc,attr);
2807     char *value = qs_get_attr_value(doc,attr);
2808     if (STRCASEEQ('a','A',"align", name)) {
2809       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2810         attr_align = value;
2811       }
2812     }
2813     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
2814       attr_style = value;
2815     }
2816   }
2817   if (IS_CSS_ON(xhtml->entryp)) {
2818     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
2819     if (style) {
2820       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
2821       css_property_t *cur;
2822       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
2823         if (STRCASEEQ('l','L',"left", cur->value)) {
2824           attr_align = apr_pstrdup(doc->pool, "left");
2825         }
2826         else if (STRCASEEQ('c','C',"center",cur->value)) {
2827           attr_align = apr_pstrdup(doc->pool, "center");
2828         }
2829         else if (STRCASEEQ('r','R',"right",cur->value)) {
2830           attr_align = apr_pstrdup(doc->pool, "right");
2831         }
2832       }
2833     }
2834   }
2835   W_L("<h4");
2836   if (attr_align) {
2837     W_L(" style=\"");
2838     W_L("text-align:");
2839     W_V(attr_align);
2840     W_L(";");
2841     W_L("\"");
2842   }
2843   W_L(">");
2844
2845   return xhtml->out;
2846 }
2847
2848
2849 /**
2850  * It is a handler who processes the H4 tag.
2851  *
2852  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2853  *                     destination is specified.
2854  * @param node   [i]   The H4 tag node is specified.
2855  * @return The conversion result is returned.
2856  */
2857 static char *
2858 s_xhtml_1_0_end_h4_tag(void *pdoc, Node *UNUSED(child)) 
2859 {
2860   xhtml_t *xhtml = GET_XHTML(pdoc);
2861   Doc     *doc   = xhtml->doc;
2862
2863   W_L("</h4>");
2864   if (IS_CSS_ON(xhtml->entryp)) {
2865     chxj_css_pop_prop_list(xhtml->css_prop_stack);
2866   }
2867
2868   return xhtml->out;
2869 }
2870
2871
2872 /**
2873  * It is a handler who processes the H5 tag.
2874  *
2875  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2876  *                     destination is specified.
2877  * @param node   [i]   The H5 tag node is specified.
2878  * @return The conversion result is returned.
2879  */
2880 static char *
2881 s_xhtml_1_0_start_h5_tag(void *pdoc, Node *node)
2882 {
2883   xhtml_t *xhtml = GET_XHTML(pdoc);
2884   Doc     *doc = xhtml->doc;
2885   Attr    *attr;
2886   char    *attr_style = NULL;
2887   char    *attr_align = NULL;
2888
2889   for (attr = qs_get_attr(doc,node);
2890        attr;
2891        attr = qs_get_next_attr(doc,attr)) {
2892     char *name  = qs_get_attr_name(doc,attr);
2893     char *value = qs_get_attr_value(doc,attr);
2894     if (STRCASEEQ('a','A',"align", name)) {
2895       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2896         attr_align = value;
2897       }
2898     }
2899     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
2900       attr_style = value;
2901     }
2902   }
2903   if (IS_CSS_ON(xhtml->entryp)) {
2904     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
2905     if (style) {
2906       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
2907       css_property_t *cur;
2908       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
2909         if (STRCASEEQ('l','L',"left", cur->value)) {
2910           attr_align = apr_pstrdup(doc->pool, "left");
2911         }
2912         else if (STRCASEEQ('c','C',"center",cur->value)) {
2913           attr_align = apr_pstrdup(doc->pool, "center");
2914         }
2915         else if (STRCASEEQ('r','R',"right",cur->value)) {
2916           attr_align = apr_pstrdup(doc->pool, "right");
2917         }
2918       }
2919     }
2920   }
2921   W_L("<h5");
2922   if (attr_align) {
2923     W_L(" style=\"");
2924     W_L("text-align:");
2925     W_V(attr_align);
2926     W_L(";");
2927     W_L("\"");
2928   }
2929   W_L(">");
2930
2931   return xhtml->out;
2932 }
2933
2934
2935 /**
2936  * It is a handler who processes the H5 tag.
2937  *
2938  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2939  *                     destination is specified.
2940  * @param node   [i]   The H5 tag node is specified.
2941  * @return The conversion result is returned.
2942  */
2943 static char *
2944 s_xhtml_1_0_end_h5_tag(void *pdoc, Node *UNUSED(child)) 
2945 {
2946   xhtml_t *xhtml = GET_XHTML(pdoc);
2947   Doc     *doc   = xhtml->doc;
2948
2949   W_L("</h5>");
2950   if (IS_CSS_ON(xhtml->entryp)) {
2951     chxj_css_pop_prop_list(xhtml->css_prop_stack);
2952   }
2953
2954   return xhtml->out;
2955 }
2956
2957
2958 /**
2959  * It is a handler who processes the H6 tag.
2960  *
2961  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2962  *                     destination is specified.
2963  * @param node   [i]   The H6 tag node is specified.
2964  * @return The conversion result is returned.
2965  */
2966 static char *
2967 s_xhtml_1_0_start_h6_tag(void *pdoc, Node *node)
2968 {
2969   xhtml_t *xhtml = GET_XHTML(pdoc);
2970   Doc     *doc = xhtml->doc;
2971   Attr    *attr;
2972   char    *attr_style = NULL;
2973   char    *attr_align = NULL;
2974
2975   for (attr = qs_get_attr(doc,node);
2976        attr;
2977        attr = qs_get_next_attr(doc,attr)) {
2978     char *name  = qs_get_attr_name(doc,attr);
2979     char *value = qs_get_attr_value(doc,attr);
2980     if (STRCASEEQ('a','A',"align", name)) {
2981       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2982         attr_align = value;
2983       }
2984     }
2985     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
2986       attr_style = value;
2987     }
2988   }
2989   if (IS_CSS_ON(xhtml->entryp)) {
2990     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
2991     if (style) {
2992       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
2993       css_property_t *cur;
2994       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
2995         if (STRCASEEQ('l','L',"left", cur->value)) {
2996           attr_align = apr_pstrdup(doc->pool, "left");
2997         }
2998         else if (STRCASEEQ('c','C',"center",cur->value)) {
2999           attr_align = apr_pstrdup(doc->pool, "center");
3000         }
3001         else if (STRCASEEQ('r','R',"right",cur->value)) {
3002           attr_align = apr_pstrdup(doc->pool, "right");
3003         }
3004       }
3005     }
3006   }
3007   W_L("<h6");
3008   if (attr_align) {
3009     W_L(" style=\"");
3010     W_L("text-align:");
3011     W_V(attr_align);
3012     W_L(";");
3013     W_L("\"");
3014   }
3015   W_L(">");
3016
3017   return xhtml->out;
3018 }
3019
3020
3021 /**
3022  * It is a handler who processes the H6 tag.
3023  *
3024  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3025  *                     destination is specified.
3026  * @param node   [i]   The H6 tag node is specified.
3027  * @return The conversion result is returned.
3028  */
3029 static char *
3030 s_xhtml_1_0_end_h6_tag(void *pdoc, Node *UNUSED(child)) 
3031 {
3032   xhtml_t *xhtml = GET_XHTML(pdoc);
3033   Doc     *doc   = xhtml->doc;
3034
3035   W_L("</h6>");
3036   if (IS_CSS_ON(xhtml->entryp)) {
3037     chxj_css_pop_prop_list(xhtml->css_prop_stack);
3038   }
3039
3040   return xhtml->out;
3041 }
3042
3043
3044 /**
3045  * It is a handler who processes the OL tag.
3046  *
3047  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3048  *                     destination is specified.
3049  * @param node   [i]   The OL tag node is specified.
3050  * @return The conversion result is returned.
3051  */
3052 static char *
3053 s_xhtml_1_0_start_ol_tag(void *pdoc, Node *node)
3054 {
3055   xhtml_t *xhtml = GET_XHTML(pdoc);
3056   Doc     *doc   = xhtml->doc;
3057   Attr    *attr;
3058   char    *attr_style = NULL;
3059   char    *attr_start = NULL;
3060   char    *attr_type  = NULL;
3061
3062   /*--------------------------------------------------------------------------*/
3063   /* Get Attributes                                                           */
3064   /*--------------------------------------------------------------------------*/
3065   for (attr = qs_get_attr(doc,node);
3066        attr;
3067        attr = qs_get_next_attr(doc,attr)) {
3068     char *name = qs_get_attr_name(doc,attr);
3069     char *value = qs_get_attr_value(doc,attr);
3070     if (STRCASEEQ('t','T',"type",name) && value) {
3071       if (*value == '1') {
3072         attr_type = apr_pstrdup(doc->pool, "decimal");
3073       }
3074       else if (*value == 'a') {
3075         attr_type = apr_pstrdup(doc->pool, "lower-alpha");
3076       }
3077       else if (*value == 'A') {
3078         attr_type = apr_pstrdup(doc->pool, "upper-alpha");
3079       }
3080     }
3081     else if (STRCASEEQ('s','S',"start",name) && value && *value) {
3082       attr_start = value;
3083     }
3084     else if (STRCASEEQ('s','S',"style", name) && value && *value) {
3085       attr_style = value;
3086     }
3087   }
3088   if (IS_CSS_ON(xhtml->entryp)) {
3089     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
3090     if (style) {
3091       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
3092       css_property_t *cur;
3093       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3094         if (STRCASEEQ('d','D',"decimal", cur->value)) {
3095           attr_type = apr_pstrdup(doc->pool, "decimal");
3096         }
3097         else if (STRCASEEQ('u','U',"upper-alpha", cur->value)) {
3098           attr_type = apr_pstrdup(doc->pool, "upper-alpha");
3099         }
3100         else if (STRCASEEQ('l','L',"lower-alpha", cur->value)) {
3101           attr_type = apr_pstrdup(doc->pool, "lower-alpha");
3102         }
3103       }
3104     }
3105   }
3106   W_L("<ol");
3107   if (attr_type) {
3108     W_L(" style=\"");
3109     W_L("list-style-type:");
3110     W_V(attr_type);
3111     W_L(";");
3112     W_L("\"");
3113   }
3114   if (attr_start) {
3115     W_L(" start=\"");
3116     W_V(attr_start);
3117     W_L("\"");
3118   }
3119   W_L(">");
3120
3121   return xhtml->out;
3122 }
3123
3124
3125 /**
3126  * It is a handler who processes the OL tag.
3127  *
3128  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3129  *                     destination is specified.
3130  * @param node   [i]   The OL tag node is specified.
3131  * @return The conversion result is returned.
3132  */
3133 static char *
3134 s_xhtml_1_0_end_ol_tag(void *pdoc, Node *UNUSED(child)) 
3135 {
3136   xhtml_t *xhtml = GET_XHTML(pdoc);
3137   Doc     *doc   = xhtml->doc;
3138
3139   W_L("</ol>");
3140   if (IS_CSS_ON(xhtml->entryp)) {
3141     chxj_css_pop_prop_list(xhtml->css_prop_stack);
3142   }
3143
3144   return xhtml->out;
3145 }
3146
3147
3148 /**
3149  * It is a handler who processes the LI tag.
3150  *
3151  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3152  *                     destination is specified.
3153  * @param node   [i]   The LI tag node is specified.
3154  * @return The conversion result is returned.
3155  */
3156 static char *
3157 s_xhtml_1_0_start_li_tag(void *pdoc, Node *node)
3158 {
3159   xhtml_t *xhtml = GET_XHTML(pdoc);
3160   Doc     *doc   = xhtml->doc;
3161   Attr    *attr;
3162   char    *attr_type  = NULL;
3163   char    *attr_value = NULL;
3164   char    *attr_style = NULL;
3165
3166   for (attr = qs_get_attr(doc,node);
3167        attr;
3168        attr = qs_get_next_attr(doc,attr)) {
3169     char *name  = qs_get_attr_name(doc,attr);
3170     char *value = qs_get_attr_value(doc,attr);
3171     if (STRCASEEQ('t','T',"type",name)) {
3172       if (value && (*value == '1' || *value == 'a' || *value == 'A' || STRCASEEQ('d','D',"disc",value) || STRCASEEQ('s','S',"square",value) || STRCASEEQ('c','C',"circle",value))) {
3173         if (*value == '1') {
3174           attr_type = apr_pstrdup(doc->pool, "decimal");
3175         }
3176         else if (*value == 'a') {
3177           attr_type = apr_pstrdup(doc->pool, "lower-alpha");
3178         }
3179         else if (*value == 'A') {
3180           attr_type = apr_pstrdup(doc->pool, "upper-alpha");
3181         }
3182         else {
3183           attr_type = value;
3184         }
3185       }
3186     }
3187     else if (STRCASEEQ('v','V',"value", name) && value && *value) {
3188       attr_value = value;
3189     }
3190     else if (STRCASEEQ('s','S',"style", name) && value && *value) {
3191       attr_style = value;
3192     }
3193   }
3194   if (IS_CSS_ON(xhtml->entryp)) {
3195     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
3196     if (style) {
3197       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
3198       css_property_t *cur;
3199       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3200         if (STRCASEEQ('d','D',"decimal", cur->value)) {
3201           attr_type = apr_pstrdup(doc->pool, "decimal");
3202         }
3203         else if (STRCASEEQ('u','U',"upper-alpha", cur->value)) {
3204           attr_type = apr_pstrdup(doc->pool, "upper-alpha");
3205         }
3206         else if (STRCASEEQ('l','L',"lower-alpha", cur->value)) {
3207           attr_type = apr_pstrdup(doc->pool, "lower-alpha");
3208         }
3209         else if (STRCASEEQ('d','D',"disc", cur->value)) {
3210           attr_type = apr_pstrdup(doc->pool, "disc");
3211         }
3212         else if (STRCASEEQ('s','S',"square", cur->value)) {
3213           attr_type = apr_pstrdup(doc->pool, "square");
3214         }
3215         else if (STRCASEEQ('c','C',"circle", cur->value)) {
3216           attr_type = apr_pstrdup(doc->pool, "circle");
3217         }
3218       }
3219     }
3220   }
3221
3222
3223   W_L("<li");
3224   if (attr_type) {
3225     W_L(" style=\"");
3226     W_L("list-style-type:");
3227     W_V(attr_type);
3228     W_L(";");
3229     W_L("\"");
3230   }
3231   if (attr_value) {
3232     W_L(" value=\"");
3233     W_V(attr_value);
3234     W_L("\"");
3235   }
3236   W_L(">");
3237   return xhtml->out;
3238 }
3239
3240
3241 /**
3242  ** It is a handler who processes the LI tag.
3243  *
3244  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3245  *                     destination is specified.
3246  * @param node   [i]   The LI tag node is specified.
3247  * @return The conversion result is returned.
3248  */
3249 static char *
3250 s_xhtml_1_0_end_li_tag(void *pdoc, Node *UNUSED(child)) 
3251 {
3252   xhtml_t *xhtml = GET_XHTML(pdoc);
3253   Doc     *doc   = xhtml->doc;
3254
3255   W_L("</li>");
3256   if (IS_CSS_ON(xhtml->entryp)) {
3257     chxj_css_pop_prop_list(xhtml->css_prop_stack);
3258   }
3259   return xhtml->out;
3260 }
3261
3262 /**
3263  * It is a handler who processes the IMG tag.
3264  *
3265  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3266  *                     destination is specified.
3267  * @param node   [i]   The IMG tag node is specified.
3268  * @return The conversion result is returned.
3269  */
3270 static char *
3271 s_xhtml_1_0_start_img_tag(void *pdoc, Node *node) 
3272 {
3273   xhtml_t       *xhtml = GET_XHTML(pdoc);
3274   Doc           *doc   = xhtml->doc;
3275   request_rec   *r     = doc->r;
3276   Attr          *attr;
3277   char          *attr_src    = NULL;
3278   char          *attr_alt    = NULL;
3279   char          *attr_height = NULL;
3280   char          *attr_width  = NULL;
3281   char          *attr_align  = NULL;
3282   char          *attr_style  = NULL;
3283   char          *attr_hspace = NULL;
3284   char          *attr_vspace = NULL;
3285
3286 #ifndef IMG_NOT_CONVERT_FILENAME
3287   device_table  *spec = xhtml->spec;
3288 #endif
3289
3290   /*--------------------------------------------------------------------------*/
3291   /* Get Attributes                                                           */
3292   /*--------------------------------------------------------------------------*/
3293   for (attr = qs_get_attr(doc,node);
3294        attr;
3295        attr = qs_get_next_attr(doc,attr)) {
3296     char *name  = qs_get_attr_name(doc,attr);
3297     char *value = qs_get_attr_value(doc,attr);
3298
3299     if (STRCASEEQ('s','S',"src",name)) {
3300       value = chxj_encoding_parameter(r, value, 1);
3301       value = chxj_add_cookie_parameter(r, value, xhtml->cookie);
3302       value = chxj_add_cookie_no_update_parameter(r, value);
3303 #ifdef IMG_NOT_CONVERT_FILENAME
3304       attr_src = value;
3305
3306 #else
3307
3308       {
3309         attr_src = chxj_img_conv(r,spec,value);
3310       }
3311
3312 #endif
3313     }
3314     else 
3315     if (STRCASEEQ('a','A',"align",name)) {
3316       if (value) {
3317         if (STRCASEEQ('t','T',"top",   value) ||
3318             STRCASEEQ('m','M',"middle",value) ||
3319             STRCASEEQ('b','B',"bottom",value) ||
3320             STRCASEEQ('l','L',"left",  value) ||
3321             STRCASEEQ('r','R',"right", value)) {
3322           attr_align = value;
3323         }
3324         else if (STRCASEEQ('c','C',"center",  value)) {
3325           attr_align = apr_pstrdup(doc->pool, "middle");
3326         }
3327       }
3328     }
3329     else if (STRCASEEQ('a','A',"alt",name) && value && *value) {
3330       attr_alt = value;
3331     }
3332     else if (STRCASEEQ('w','W',"width",name) && value && *value) {
3333       attr_width = value;
3334     }
3335     else if (STRCASEEQ('h','H',"height",name) && value && *value) {
3336       attr_height = value;
3337     }
3338     else if (STRCASEEQ('h','H',"hspace",name) && value && *value) {
3339       attr_hspace = value;
3340     }
3341     else if (STRCASEEQ('v','V',"vspace",name) && value && *value) {
3342       attr_vspace = value;
3343     }
3344     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3345       attr_style = value;
3346     }
3347   }
3348
3349   if (IS_CSS_ON(xhtml->entryp)) {
3350     css_prop_list_t *style = s_xhtml_1_0_nopush_and_get_now_style(pdoc, node, attr_style);
3351     if (style) {
3352       css_property_t *height_prop = chxj_css_get_property_value(doc, style, "height");
3353       css_property_t *width_prop  = chxj_css_get_property_value(doc, style, "width");
3354       css_property_t *valign_prop = chxj_css_get_property_value(doc, style, "vertical-align");
3355       css_property_t *cur;
3356       for (cur = height_prop->next; cur != height_prop; cur = cur->next) {
3357         attr_height = apr_pstrdup(doc->pool, cur->value);
3358       }
3359       for (cur = width_prop->next; cur != width_prop; cur = cur->next) {
3360         attr_width = apr_pstrdup(doc->pool, cur->value);
3361       }
3362       for (cur = valign_prop->next; cur != valign_prop; cur = cur->next) {
3363         attr_align = apr_pstrdup(doc->pool, cur->value);
3364       }
3365     }
3366   }
3367
3368   W_L("<img");
3369   if (attr_src) {
3370     W_L(" src=\"");
3371     W_V(attr_src);
3372     W_L("\"");
3373   }
3374   if (attr_align) {
3375     W_L(" align=\"");
3376     W_V(attr_align);
3377     W_L("\"");
3378   }
3379   if (attr_width) {
3380     W_L(" width=\"");
3381     W_V(attr_width);
3382     W_L("\"");
3383   }
3384   if (attr_height) {
3385     W_L(" height=\"");
3386     W_V(attr_height);
3387     W_L("\"");
3388   }
3389   if (attr_hspace) {
3390     W_L(" hspace=\"");
3391     W_V(attr_hspace);
3392     W_L("\"");
3393   }
3394   if (attr_vspace) {
3395     W_L(" vspace=\"");
3396     W_V(attr_vspace);
3397     W_L("\"");
3398   }
3399   if (attr_alt) {
3400     W_L(" alt=\"");
3401     W_V(attr_alt);
3402     W_L("\"");
3403   }
3404   else {
3405     W_L(" alt=\"\"");
3406   }
3407   W_L(" />");
3408   return xhtml->out;
3409 }
3410
3411
3412 /**
3413  * It is a handler who processes the IMG tag.
3414  *
3415  * @param xhtml  [i/o] The pointer to the XHTML structure at the output
3416  *                     destination is specified.
3417  * @param node   [i]   The IMG tag node is specified.
3418  * @return The conversion result is returned.
3419  */
3420 static char *
3421 s_xhtml_1_0_end_img_tag(void *pdoc, Node *UNUSED(child)) 
3422 {
3423   xhtml_t *xhtml = GET_XHTML(pdoc);
3424
3425   return xhtml->out;
3426 }
3427
3428
3429 /**
3430  * It is a handler who processes the SELECT tag.
3431  *
3432  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3433  *                     destination is specified.
3434  * @param node   [i]   The SELECT tag node is specified.
3435  * @return The conversion result is returned.
3436  */
3437 static char *
3438 s_xhtml_1_0_start_select_tag(void *pdoc, Node *node)
3439 {
3440   xhtml_t *xhtml    = GET_XHTML(pdoc);
3441   Doc     *doc      = xhtml->doc;
3442   char    *size     = NULL;
3443   char    *name     = NULL;
3444   char    *multiple = NULL;
3445   Attr    *attr;
3446   char    *attr_style = NULL;
3447
3448   W_L("<select");
3449   for (attr = qs_get_attr(doc,node);
3450        attr;
3451        attr = qs_get_next_attr(doc,attr)) {
3452     char *nm  = qs_get_attr_name(doc,attr);
3453     char *val = qs_get_attr_value(doc,attr);
3454     if (STRCASEEQ('s','S',"size",nm)) {
3455       /*----------------------------------------------------------------------*/
3456       /* CHTML 1.0 version 2.0                                                */
3457       /*----------------------------------------------------------------------*/
3458       size = apr_pstrdup(doc->buf.pool, val);
3459     }
3460     else if (STRCASEEQ('s','S',"style",nm) && val && *val) {
3461       /*----------------------------------------------------------------------*/
3462       /* CHTML 1.0 version 2.0                                                */
3463       /*----------------------------------------------------------------------*/
3464       attr_style = apr_pstrdup(doc->buf.pool, val);
3465     }
3466     else if (STRCASEEQ('n','N',"name",nm)) {
3467       /*----------------------------------------------------------------------*/
3468       /* CHTML 1.0 version 2.0                                                */
3469       /*----------------------------------------------------------------------*/
3470       name = apr_pstrdup(doc->buf.pool, val);
3471     }
3472     else if (STRCASEEQ('m','M',"multiple",nm)) {
3473       /*----------------------------------------------------------------------*/
3474       /* CHTML 1.0 version 2.0                                                */
3475       /*----------------------------------------------------------------------*/
3476       multiple = apr_pstrdup(doc->buf.pool, val);
3477     }
3478   }
3479   if (size && *size) {
3480     W_L(" size=\"");
3481     W_V(size);
3482     W_L("\"");
3483   }
3484   if (name && *name) {
3485     W_L(" name=\"");
3486     W_V(name);
3487     W_L("\"");
3488   }
3489   if (multiple) {
3490     /* "true" is *NOT* W3C. it is specification of WAP2.0 for EZWEB */
3491     W_L(" multiple=\"true\"");
3492   }
3493   W_L(">");
3494   if (IS_CSS_ON(xhtml->entryp)) {
3495     s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
3496   }
3497
3498   return xhtml->out;
3499 }
3500
3501
3502 /**
3503  * It is a handler who processes the SELECT tag.
3504  *
3505  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3506  *                     destination is specified.
3507  * @param node   [i]   The SELECT tag node is specified.
3508  * @return The conversion result is returned.
3509  */
3510 static char *
3511 s_xhtml_1_0_end_select_tag(void *pdoc, Node *UNUSED(child))
3512 {
3513   xhtml_t *xhtml = GET_XHTML(pdoc);
3514   Doc     *doc   = xhtml->doc;
3515
3516   W_L("</select>");
3517   if (IS_CSS_ON(xhtml->entryp)) {
3518     chxj_css_pop_prop_list(xhtml->css_prop_stack);
3519   }
3520   return xhtml->out;
3521 }
3522
3523
3524 /**
3525  * It is a handler who processes the OPTION tag.
3526  *
3527  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3528  *                     destination is specified.
3529  * @param node   [i]   The OPTION tag node is specified.
3530  * @return The conversion result is returned.
3531  */
3532 static char *
3533 s_xhtml_1_0_start_option_tag(void *pdoc, Node *node)
3534 {
3535   xhtml_t *xhtml = GET_XHTML(pdoc);
3536   Doc     *doc   = xhtml->doc;
3537   Attr    *attr;
3538   char    *attr_style = NULL;
3539
3540   char *selected   = NULL;
3541   char *value      = NULL;
3542
3543   W_L("<option");
3544   for (attr = qs_get_attr(doc,node);
3545        attr;
3546        attr = qs_get_next_attr(doc,attr)) {
3547     char *nm  = qs_get_attr_name(doc,attr);
3548     char *val = qs_get_attr_value(doc,attr);
3549     if (STRCASEEQ('s','S',"selected",nm)) {
3550       /* CHTML version 2.0 */
3551       selected = apr_pstrdup(doc->buf.pool, val);
3552     }
3553     else if (STRCASEEQ('s','S',"style",nm) && val && *val) {
3554       /* CHTML version 2.0 */
3555       attr_style = apr_pstrdup(doc->buf.pool, val);
3556     }
3557     else if (STRCASEEQ('v','V',"value",nm)) {
3558       /* CHTML version 2.0 */
3559       value = apr_pstrdup(doc->buf.pool, val);
3560     }
3561   }
3562   if (value) {
3563     W_L(" value=\"");
3564     W_V(value);
3565     W_L("\"");
3566   }
3567   if (selected) {
3568     W_L(" selected=\"selected\"");
3569   }
3570   W_L(">");
3571   if (IS_CSS_ON(xhtml->entryp)) {
3572     s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
3573   }
3574   return xhtml->out;
3575 }
3576
3577
3578 /**
3579  * It is a handler who processes the OPTION tag.
3580  *
3581  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3582  *                     destination is specified.
3583  * @param node   [i]   The OPTION tag node is specified.
3584  * @return The conversion result is returned.
3585  */
3586 static char *
3587 s_xhtml_1_0_end_option_tag(void *pdoc, Node *UNUSED(child))
3588 {
3589   xhtml_t *xhtml = GET_XHTML(pdoc);
3590   Doc     *doc   = xhtml->doc;
3591
3592   W_L("</option>");
3593   if (IS_CSS_ON(xhtml->entryp)) {
3594     chxj_css_pop_prop_list(xhtml->css_prop_stack);
3595   }
3596
3597   return xhtml->out;
3598 }
3599
3600
3601 /**
3602  * It is a handler who processes the DIV tag.
3603  *
3604  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3605  *                     destination is specified.
3606  * @param node   [i]   The DIV tag node is specified.
3607  * @return The conversion result is returned.
3608  */
3609 static char *
3610 s_xhtml_1_0_start_div_tag(void *pdoc, Node *node)
3611 {
3612   xhtml_t     *xhtml = GET_XHTML(pdoc);
3613   Doc         *doc   = xhtml->doc;
3614   Attr        *attr;
3615   char        *attr_style             = NULL;
3616   char        *attr_align             = NULL;
3617   char        *attr_display           = NULL;
3618   char        *attr_decoration        = NULL;
3619   char        *attr_wap_marquee_style = NULL;
3620   char        *attr_wap_marquee_dir   = NULL;
3621   char        *attr_wap_marquee_loop  = NULL;
3622   char        *attr_color             = NULL;
3623   char        *attr_bgcolor           = NULL;
3624   char        *attr_font_size         = NULL;
3625
3626   for (attr = qs_get_attr(doc,node);
3627        attr;
3628        attr = qs_get_next_attr(doc,attr)) {
3629     char *nm  = qs_get_attr_name(doc,attr);
3630     char *val = qs_get_attr_value(doc,attr);
3631     if (STRCASEEQ('a','A',"align",nm)) {
3632       /*----------------------------------------------------------------------*/
3633       /* CHTML 1.0 (W3C version 3.2)                                          */
3634       /*----------------------------------------------------------------------*/
3635       if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
3636         attr_align = apr_pstrdup(doc->buf.pool, val);
3637       }
3638     }
3639     else if (STRCASEEQ('s','S',"style",nm) && val && *val) {
3640       attr_style = apr_pstrdup(doc->buf.pool, val);
3641     }
3642   }
3643
3644   if (IS_CSS_ON(xhtml->entryp)) {
3645     css_prop_list_t *style = s_xhtml_1_0_nopush_and_get_now_style(pdoc, node, attr_style);
3646     if (style) {
3647       css_property_t *display_prop           = chxj_css_get_property_value(doc, style, "display");
3648       css_property_t *text_decoration_prop   = chxj_css_get_property_value(doc, style, "text-decoration");
3649       css_property_t *color_prop             = chxj_css_get_property_value(doc, style, "color");
3650       css_property_t *text_align_prop        = chxj_css_get_property_value(doc, style, "text-align");
3651       css_property_t *font_size_prop         = chxj_css_get_property_value(doc, style, "font-size");
3652       css_property_t *background_color_prop  = chxj_css_get_property_value(doc, style, "background-color");
3653       css_property_t *background_prop        = chxj_css_get_property_value(doc, style, "background");
3654
3655       css_property_t *cur;
3656       for (cur = display_prop->next; cur != display_prop; cur = cur->next) {
3657         if (strcasecmp("-wap-marquee", cur->value) == 0) {
3658           attr_display = apr_pstrdup(doc->pool, cur->value);
3659         }
3660       }
3661       for (cur = text_decoration_prop->next; cur != text_decoration_prop; cur = cur->next) {
3662         if (STRCASEEQ('b','B',"blink", cur->value)) {
3663           attr_decoration = apr_pstrdup(doc->pool, cur->value);
3664         }
3665       }
3666       for (cur = background_color_prop->next; cur != background_color_prop; cur = cur->next) {
3667         attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
3668         attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
3669       }
3670       for (cur = background_prop->next; cur != background_prop; cur = cur->next) {
3671         char *ss = strchr(cur->value, '#');
3672         if (ss) {
3673           attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
3674           attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
3675         }
3676       }
3677       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
3678         attr_color = apr_pstrdup(doc->pool, cur->value);
3679       }
3680       for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
3681         attr_align = apr_pstrdup(doc->pool, cur->value);
3682       }
3683       for (cur = font_size_prop->next; cur != font_size_prop; cur = cur->next) {
3684         if (   STRCASEEQ('x','X',"xx-small",cur->value)
3685             || STRCASEEQ('x','X',"x-small",cur->value)
3686             || STRCASEEQ('s','S',"small",cur->value)
3687             || STRCASEEQ('m','M',"medium",cur->value)
3688             || STRCASEEQ('l','L',"large",cur->value)
3689             || STRCASEEQ('x','X',"x-large",cur->value)
3690             || STRCASEEQ('x','X',"xx-large",cur->value)) {
3691           attr_font_size = apr_pstrdup(doc->pool, cur->value);
3692         }
3693       }
3694       if (attr_display) {
3695         css_property_t *wap_marquee_style_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-style");
3696         css_property_t *wap_marquee_dir_prop   = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
3697         css_property_t *wap_marquee_loop_prop  = chxj_css_get_property_value(doc, style, "-wap-marquee-loop");
3698         for (cur = wap_marquee_style_prop->next; cur != wap_marquee_style_prop; cur = cur->next) {
3699           if (STRCASEEQ('s','S',"scroll", cur->value) || STRCASEEQ('s','S',"slide",cur->value) || STRCASEEQ('a','A',"alternate",cur->value)) {
3700             attr_wap_marquee_style = apr_pstrdup(doc->pool, cur->value);
3701           }
3702         }
3703         for (cur = wap_marquee_dir_prop->next; cur != wap_marquee_dir_prop; cur = cur->next) {
3704           if (STRCASEEQ('l','L',"ltr",cur->value)) {
3705             attr_wap_marquee_dir = apr_pstrdup(doc->pool, cur->value);
3706           }
3707           else if (STRCASEEQ('r','R',"rtl",cur->value)) {
3708             attr_wap_marquee_dir = apr_pstrdup(doc->pool, cur->value);
3709           }
3710         }
3711         for (cur = wap_marquee_loop_prop->next; cur != wap_marquee_loop_prop; cur = cur->next) {
3712           attr_wap_marquee_loop = apr_pstrdup(doc->pool, cur->value);
3713         }
3714       }
3715     }
3716   }  
3717   W_L("<div");
3718   if (attr_align
3719       || attr_display
3720       || attr_decoration
3721       || attr_wap_marquee_style
3722       || attr_wap_marquee_dir
3723       || attr_wap_marquee_loop
3724       || attr_color
3725       || attr_bgcolor
3726       || attr_font_size) {
3727     W_L(" style=\"");
3728     if (attr_align) {
3729       W_L("text-align:");
3730       W_V(attr_align);
3731       W_L(";");
3732     }
3733     if (attr_display) {
3734       W_L("display:");
3735       W_V(attr_display);
3736       W_L(";");
3737     }
3738     if (attr_decoration) {
3739       W_L("text-decoration:");
3740       W_V(attr_decoration);
3741       W_L(";");
3742     }
3743     if (attr_wap_marquee_style) {
3744       W_L("-wap-marquee-style:");
3745       W_V(attr_wap_marquee_style);
3746       W_L(";");
3747     }
3748     if (attr_wap_marquee_dir) {
3749       W_L("-wap-marquee-dir:");
3750       W_V(attr_wap_marquee_dir);
3751       W_L(";");
3752     }
3753     if (attr_wap_marquee_loop) {
3754       W_L("-wap-marquee-loop:");
3755       W_V(attr_wap_marquee_loop);
3756       W_L(";");
3757     }
3758     if (attr_color) {
3759       W_L("color:");
3760       W_V(attr_color);
3761       W_L(";");
3762     }
3763     if (attr_bgcolor) {
3764       W_L("background-color:");
3765       W_V(attr_bgcolor);
3766       W_L(";");
3767     }
3768     if (attr_font_size) {
3769       W_L("font-size:");
3770       W_V(attr_font_size);
3771       W_L(";");
3772     }
3773     W_L("\"");
3774   }
3775   W_L(">");
3776   return xhtml->out;
3777 }
3778
3779
3780 /**
3781  * It is a handler who processes the DIV tag.
3782  *
3783  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3784  *                     destination is specified.
3785  * @param node   [i]   The DIV tag node is specified.
3786  * @return The conversion result is returned.
3787  */
3788 static char *
3789 s_xhtml_1_0_end_div_tag(void *pdoc, Node *UNUSED(child))
3790 {
3791   xhtml_t *xhtml = GET_XHTML(pdoc);
3792   Doc     *doc   = xhtml->doc;
3793   W_L("</div>");
3794   if (IS_CSS_ON(xhtml->entryp)) {
3795     chxj_css_pop_prop_list(xhtml->css_prop_stack);
3796   }
3797   return xhtml->out;
3798 }
3799
3800
3801 /**
3802  * It is a handler who processes the B tag.
3803  *
3804  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3805  *                     destination is specified.
3806  * @param node   [i]   The B tag node is specified.
3807  * @return The conversion result is returned.
3808  */
3809 static char *
3810 s_xhtml_1_0_start_b_tag(void *pdoc, Node *UNUSED(child))
3811 {
3812   xhtml_t *xhtml = GET_XHTML(pdoc);
3813   Doc     *doc   = xhtml->doc;
3814
3815   W_L("<div style=\"font-weight:bold\">");
3816   return xhtml->out;
3817 }
3818
3819
3820 /**
3821  * It is a handler who processes the B tag.
3822  *
3823  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3824  *                     destination is specified.
3825  * @param node   [i]   The B tag node is specified.
3826  * @return The conversion result is returned.
3827  */
3828 static char *
3829 s_xhtml_1_0_end_b_tag(void *pdoc, Node *UNUSED(child))
3830 {
3831   xhtml_t *xhtml = GET_XHTML(pdoc);
3832   Doc     *doc   = xhtml->doc;
3833
3834   W_L("</div>");
3835   return xhtml->out;
3836 }
3837
3838
3839 /**
3840  * It is a handler who processes the CHXJ:IF tag.
3841  *
3842  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3843  *                     destination is specified.
3844  * @param node   [i]   The CHXJ:IF tag node is specified.
3845  */
3846 static char *
3847 s_xhtml_1_0_chxjif_tag(void *pdoc, Node *node)
3848 {
3849   xhtml_t      *xhtml = GET_XHTML(pdoc);
3850   Doc          *doc   = xhtml->doc;
3851   Node         *child;
3852
3853   for (child = qs_get_child_node(doc, node);
3854        child;
3855        child = qs_get_next_node(doc, child)) {
3856     W_V(child->otext);
3857     s_xhtml_1_0_chxjif_tag(xhtml, child);
3858   }
3859
3860   return NULL;
3861 }
3862
3863
3864 /**
3865  * It is a handler who processes the TEXTARE tag.
3866  *
3867  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3868  *                     destination is specified.
3869  * @param node   [i]   The TEXTAREA tag node is specified.
3870  * @return The conversion result is returned.
3871  */
3872 static char *
3873 s_xhtml_1_0_start_textarea_tag(void *pdoc, Node *node) 
3874 {
3875   xhtml_t *xhtml = GET_XHTML(pdoc);
3876   Doc     *doc   = xhtml->doc;
3877   Attr    *attr;
3878   char    *attr_accesskey = NULL;
3879   char    *attr_name      = NULL;
3880   char    *attr_rows      = NULL;
3881   char    *attr_cols      = NULL;
3882   char    *attr_istyle    = NULL;
3883   char    *attr_style     = NULL;
3884
3885   xhtml->textarea_flag++;
3886   for (attr = qs_get_attr(doc,node);
3887        attr;
3888        attr = qs_get_next_attr(doc,attr)) {
3889     char *name  = qs_get_attr_name(doc,attr);
3890     char *value = qs_get_attr_value(doc,attr);
3891     if (STRCASEEQ('n','N',"name",name) && value && *value) {
3892       attr_name = value;
3893     }
3894     else if (STRCASEEQ('r','R',"rows",name) && value && *value) {
3895       attr_rows = value;
3896     }
3897     else if (STRCASEEQ('c','C',"cols",name) && value && *value) {
3898       attr_cols = value;
3899     }
3900     else if (STRCASEEQ('i','I',"istyle", name) && value && (*value == '1' || *value == '2' || *value == '3' || *value == '4')) {
3901       attr_istyle = value;
3902 #if 0
3903       char *fmt = qs_conv_istyle_to_format(doc->r->pool,value);
3904       W_L(" FORMAT=\"*");
3905       W_V(fmt);
3906       W_L("\"");
3907 #endif
3908     }
3909     else if (STRCASEEQ('a','A',"accesskey",name) && value && *value != 0) {
3910       attr_accesskey = value;
3911     }
3912     else if (STRCASEEQ('s','S',"style",name) && value && *value != 0) {
3913       attr_style = value;
3914     }
3915   }
3916   if (IS_CSS_ON(xhtml->entryp)) {
3917     css_prop_list_t *style = s_xhtml_1_0_nopush_and_get_now_style(pdoc, node, attr_style);
3918     if (style) {
3919       css_property_t *wap_input_format = chxj_css_get_property_value(doc, style, "-wap-input-format");
3920       css_property_t *cur;
3921       for (cur = wap_input_format->next; cur != wap_input_format; cur = cur->next) {
3922         if (strcasestr(cur->value, "<ja:n>")) {
3923           attr_istyle = "4";
3924         }
3925         else if (strcasestr(cur->value, "<ja:en>")) {
3926           attr_istyle = "3";
3927         }
3928         else if (strcasestr(cur->value, "<ja:hk>")) {
3929           attr_istyle = "2";
3930         }
3931         else if (strcasestr(cur->value, "<ja:h>")) {
3932           attr_istyle = "1";
3933         }
3934       }
3935     }
3936   }
3937   W_L("<textarea");
3938   if (attr_accesskey) {
3939     W_L(" accesskey=\"");
3940     W_V(attr_accesskey);
3941     W_L("\"");
3942   }
3943   if (attr_name) {
3944     W_L(" name=\"");
3945     W_V(attr_name);
3946     W_L("\"");
3947   }
3948   if (attr_rows) {
3949     W_L(" rows=\"");
3950     W_V(attr_rows);
3951     W_L("\"");
3952   }
3953   if (attr_cols) {
3954     W_L(" cols=\"");
3955     W_V(attr_cols);
3956     W_L("\"");
3957   }
3958   if (attr_istyle) {
3959     char *fmt = qs_conv_istyle_to_format(doc->r->pool, attr_istyle);
3960     W_L(" FORMAT=\"*");
3961     W_V(fmt);
3962     W_L("\"");
3963   }
3964   W_L(">");
3965   return xhtml->out;
3966 }
3967
3968
3969 /**
3970  * It is a handler who processes the TEXTAREA tag.
3971  *
3972  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3973  *                     destination is specified.
3974  * @param node   [i]   The TEXTAREA tag node is specified.
3975  * @return The conversion result is returned.
3976  */
3977 static char *
3978 s_xhtml_1_0_end_textarea_tag(void *pdoc, Node *UNUSED(child)) 
3979 {
3980   xhtml_t *xhtml = GET_XHTML(pdoc);
3981   Doc     *doc   = xhtml->doc;
3982
3983   W_L("</textarea>");
3984   xhtml->textarea_flag--;
3985
3986   return xhtml->out;
3987 }
3988
3989 static char *
3990 s_xhtml_1_0_text_tag(void *pdoc, Node *child)
3991 {
3992   xhtml_t     *xhtml   = GET_XHTML(pdoc);
3993   Doc         *doc     = xhtml->doc;
3994   request_rec *r       = doc->r;
3995   char        *textval;
3996   char        *tmp;
3997   char        *tdst;
3998   char        one_byte[2];
3999   int         ii;
4000   int         tdst_len;
4001   apr_size_t  z2h_input_len;
4002   
4003   textval = qs_get_node_value(doc,child);
4004   if (strlen(textval) == 0) {
4005     return xhtml->out;
4006   }
4007   
4008   tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
4009   memset(tmp, 0, qs_get_node_size(doc,child)+1);
4010   
4011   tdst     = qs_alloc_zero_byte_string(doc->buf.pool);
4012   memset(one_byte, 0, sizeof(one_byte));
4013   tdst_len = 0;
4014   
4015   for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
4016     char *out;
4017     int rtn = s_xhtml_search_emoji(xhtml, &textval[ii], &out);
4018     if (rtn != 0) {
4019       DBG(r,"[%s][%d]", out, rtn);
4020       tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
4021       ii+=(rtn - 1);
4022       continue;
4023     }
4024     if (is_sjis_kanji(textval[ii])) {
4025       one_byte[0] = textval[ii+0];
4026       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
4027       one_byte[0] = textval[ii+1];
4028       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
4029       ii++;
4030     }
4031     else if (xhtml->pre_flag) {
4032       one_byte[0] = textval[ii+0];
4033       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
4034     }
4035     else if (xhtml->textarea_flag) {
4036       one_byte[0] = textval[ii+0];
4037       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
4038     }
4039     else if (textval[ii] != '\r' && textval[ii] != '\n') {
4040       one_byte[0] = textval[ii+0];
4041       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
4042     }
4043   }
4044   z2h_input_len = strlen(tdst);
4045   tdst = chxj_conv_z2h(r, tdst, &z2h_input_len, xhtml->entryp);
4046
4047   W_V(tdst);
4048   return xhtml->out;
4049 }
4050
4051
4052 /**
4053  * It is a handler who processes the BLOCKQUOTE tag.
4054  *
4055  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4056  *                     destination is specified.
4057  * @param node   [i]   The BLOCKQUOTE tag node is specified.
4058  * @return The conversion result is returned.
4059  */
4060 static char *
4061 s_xhtml_1_0_start_blockquote_tag(void *pdoc, Node *node)
4062 {
4063   xhtml_t *xhtml;
4064   Doc      *doc;
4065   Attr     *attr;
4066   char     *attr_style = NULL;
4067   char     *attr_color = NULL;
4068   char     *attr_size  = NULL;
4069
4070   xhtml  = GET_XHTML(pdoc);
4071   doc     = xhtml->doc;
4072   for (attr = qs_get_attr(doc,node);
4073        attr;
4074        attr = qs_get_next_attr(doc,attr)) {
4075     char *nm  = qs_get_attr_name(doc,attr);
4076     char *val = qs_get_attr_value(doc,attr);
4077     if (val && STRCASEEQ('s','S',"style", nm)) {
4078       attr_style = val;
4079     }
4080   }
4081   if (IS_CSS_ON(xhtml->entryp)) {
4082     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
4083     if (style) {
4084       css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4085       css_property_t *font_size_prop = chxj_css_get_property_value(doc, style, "font-size");
4086       css_property_t *cur;
4087       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4088         if (cur->value && *cur->value) {
4089           attr_color = apr_pstrdup(doc->pool, cur->value);
4090         }
4091       }
4092       for (cur = font_size_prop->next; cur != font_size_prop; cur = cur->next) {
4093         if (cur->value && *cur->value) {
4094           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
4095             attr_size = apr_pstrdup(doc->pool, cur->value);
4096           }
4097           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
4098             attr_size = apr_pstrdup(doc->pool, cur->value);
4099           }
4100           else if (STRCASEEQ('s','S',"small",cur->value)) {
4101             attr_size = apr_pstrdup(doc->pool, cur->value);
4102           }
4103           else if (STRCASEEQ('m','M',"medium",cur->value)) {
4104             attr_size = apr_pstrdup(doc->pool, cur->value);
4105           }
4106           else if (STRCASEEQ('l','L',"large",cur->value)) {
4107             attr_size = apr_pstrdup(doc->pool, cur->value);
4108           }
4109           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
4110             attr_size = apr_pstrdup(doc->pool, cur->value);
4111           }
4112           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
4113             attr_size = apr_pstrdup(doc->pool, cur->value);
4114           }
4115         }
4116       }
4117     }
4118   }
4119   W_L("<blockquote");
4120   if (attr_color || attr_size) {
4121     W_L(" style=\"");
4122     if (attr_color) {
4123       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4124       W_L("color:");
4125       W_V(attr_color);
4126       W_L(";");
4127     }
4128     if (attr_size) {
4129       W_L("font-size:");
4130       W_V(attr_size);
4131       W_L(";");
4132     }
4133     W_L("\"");
4134   }
4135   W_L(">");
4136   return xhtml->out;
4137 }
4138
4139
4140 /**
4141  * It is a handler who processes the BLOCKQUOTE tag.
4142  *
4143  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4144  *                     destination is specified.
4145  * @param node   [i]   The BLOCKQUOTE tag node is specified.
4146  * @return The conversion result is returned.
4147  */
4148 static char *
4149 s_xhtml_1_0_end_blockquote_tag(void *pdoc, Node *UNUSED(child))
4150 {
4151   xhtml_t *xhtml = GET_XHTML(pdoc);
4152   Doc     *doc   = xhtml->doc;
4153   W_L("</blockquote>");
4154   if (IS_CSS_ON(xhtml->entryp)) {
4155     chxj_css_pop_prop_list(xhtml->css_prop_stack);
4156   }
4157   return xhtml->out;
4158 }
4159
4160
4161 /**
4162  * It is a handler who processes the DIR tag.
4163  *
4164  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4165  *                     destination is specified.
4166  * @param node   [i]   The DIR tag node is specified.
4167  * @return The conversion result is returned.
4168  */
4169 static char *
4170 s_xhtml_1_0_start_dir_tag(void *pdoc, Node *node)
4171 {
4172   xhtml_t *xhtml      = GET_XHTML(pdoc);
4173   Doc       *doc        = xhtml->doc;
4174   Attr      *attr;
4175   char      *attr_style = NULL;
4176   char      *attr_color = NULL;
4177   char      *attr_type  = NULL;
4178   char      *attr_size  = NULL;
4179   for (attr = qs_get_attr(doc,node);
4180        attr;
4181        attr = qs_get_next_attr(doc,attr)) {
4182     char *name   = qs_get_attr_name(doc,attr);
4183     char *value  = qs_get_attr_value(doc,attr);
4184     if (STRCASEEQ('t','T',"type",name)) {
4185       if (value && (STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
4186         attr_type = value;
4187       }
4188     }
4189     else if (STRCASEEQ('s','S',"style", name) && value && *value) {
4190       attr_style = value;
4191     }
4192   }
4193   if (IS_CSS_ON(xhtml->entryp)) {
4194     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
4195     if (style) {
4196       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
4197       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
4198       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
4199       css_property_t *cur;
4200       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4201         if (cur->value && *cur->value) {
4202           attr_color = apr_pstrdup(doc->pool, cur->value);
4203         }
4204       }
4205       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
4206         if (cur->value && *cur->value) {
4207           attr_type = apr_pstrdup(doc->pool, cur->value);
4208         }
4209       }
4210       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
4211         if (cur->value && *cur->value) {
4212           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
4213             attr_size = apr_pstrdup(doc->pool, cur->value);
4214           }
4215           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
4216             attr_size = apr_pstrdup(doc->pool, cur->value);
4217           }
4218           else if (STRCASEEQ('s','S',"small",cur->value)) {
4219             attr_size = apr_pstrdup(doc->pool, cur->value);
4220           }
4221           else if (STRCASEEQ('m','M',"medium",cur->value)) {
4222             attr_size = apr_pstrdup(doc->pool, cur->value);
4223           }
4224           else if (STRCASEEQ('l','L',"large",cur->value)) {
4225             attr_size = apr_pstrdup(doc->pool, cur->value);
4226           }
4227           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
4228             attr_size = apr_pstrdup(doc->pool, cur->value);
4229           }
4230           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
4231             attr_size = apr_pstrdup(doc->pool, cur->value);
4232           }
4233         }
4234       }
4235     }
4236   }
4237   W_L("<dir");
4238   if (attr_type || attr_color || attr_size) {
4239     W_L(" style=\"");
4240     if (attr_type) {
4241       W_L("list-style-type:");
4242       W_V(attr_type);
4243       W_L(";");
4244     }
4245     if (attr_color) {
4246       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4247       W_L("color:");
4248       W_V(attr_color);
4249       W_L(";");
4250     }
4251     if (attr_size) {
4252       W_L("font-size:");
4253       W_V(attr_size);
4254       W_L(";");
4255     }
4256     W_L("\"");
4257   }
4258   W_L("<dir");
4259   if (attr_type || attr_color || attr_size) {
4260     W_L(" style=\"");
4261     if (attr_type) {
4262       W_L("list-style-type:");
4263       W_V(attr_type);
4264       W_L(";");
4265     }
4266     if (attr_color) {
4267       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4268       W_L("color:");
4269       W_V(attr_color);
4270       W_L(";");
4271     }
4272     if (attr_size) {
4273       W_L("font-size:");
4274       W_V(attr_size);
4275       W_L(";");
4276     }
4277     W_L("\"");
4278   }
4279   W_L(">");
4280   return xhtml->out;
4281 }
4282
4283
4284 /**
4285  * It is a handler who processes the DIR tag.
4286  *
4287  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4288  *                     destination is specified.
4289  * @param node   [i]   The DIR tag node is specified.
4290  * @return The conversion result is returned.
4291  */
4292 static char *
4293 s_xhtml_1_0_end_dir_tag(void *pdoc, Node *UNUSED(child))
4294 {
4295   xhtml_t *xhtml = GET_XHTML(pdoc);
4296   Doc     *doc = xhtml->doc;
4297   W_L("</dir>");
4298   if (IS_CSS_ON(xhtml->entryp)) {
4299     chxj_css_pop_prop_list(xhtml->css_prop_stack);
4300   }
4301   return xhtml->out;
4302 }
4303
4304
4305 /**
4306  * It is a handler who processes the DL tag.
4307  *
4308  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4309  *                     destination is specified.
4310  * @param node   [i]   The DL tag node is specified.
4311  * @return The conversion result is returned.
4312  */
4313 static char *
4314 s_xhtml_1_0_start_dl_tag(void *pdoc, Node *node)
4315 {
4316   xhtml_t *xhtml      = GET_XHTML(pdoc);
4317   Doc     *doc        = xhtml->doc;
4318   Attr    *attr;
4319   char    *attr_style = NULL;
4320   char    *attr_color = NULL;
4321   char    *attr_size  = NULL;
4322
4323   for (attr = qs_get_attr(doc,node);
4324        attr;
4325        attr = qs_get_next_attr(doc,attr)) {
4326     char *name   = qs_get_attr_name(doc,attr);
4327     char *value  = qs_get_attr_value(doc,attr);
4328     if (STRCASEEQ('s','S',"style", name) && value && *value) {
4329       attr_style = value;
4330     }
4331   }
4332   if (IS_CSS_ON(xhtml->entryp)) {
4333     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
4334     if (style) {
4335       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
4336       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
4337       css_property_t *cur;
4338       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4339         if (cur->value && *cur->value) {
4340           attr_color = apr_pstrdup(doc->pool, cur->value);
4341         }
4342       }
4343       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
4344         if (cur->value && *cur->value) {
4345           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
4346             attr_size = apr_pstrdup(doc->pool, cur->value);
4347           }
4348           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
4349             attr_size = apr_pstrdup(doc->pool, cur->value);
4350           }
4351           else if (STRCASEEQ('s','S',"small",cur->value)) {
4352             attr_size = apr_pstrdup(doc->pool, cur->value);
4353           }
4354           else if (STRCASEEQ('m','M',"medium",cur->value)) {
4355             attr_size = apr_pstrdup(doc->pool, cur->value);
4356           }
4357           else if (STRCASEEQ('l','L',"large",cur->value)) {
4358             attr_size = apr_pstrdup(doc->pool, cur->value);
4359           }
4360           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
4361             attr_size = apr_pstrdup(doc->pool, cur->value);
4362           }
4363           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
4364             attr_size = apr_pstrdup(doc->pool, cur->value);
4365           }
4366         }
4367       }
4368     }
4369   }
4370   W_L("<dl");
4371   if (attr_color || attr_size) {
4372     W_L(" style=\"");
4373     if (attr_color) {
4374       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4375       W_L("color:");
4376       W_V(attr_color);
4377       W_L(";");
4378     }
4379     if (attr_size) {
4380       W_L("font-size:");
4381       W_V(attr_size);
4382       W_L(";");
4383     }
4384     W_L("\"");
4385   }
4386   W_L(">");
4387   return xhtml->out;
4388 }
4389
4390
4391 /**
4392  * It is a handler who processes the DL tag.
4393  *
4394  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4395  *                     destination is specified.
4396  * @param node   [i]   The DL tag node is specified.
4397  * @return The conversion result is returned.
4398  */
4399 static char *
4400 s_xhtml_1_0_end_dl_tag(void *pdoc, Node *UNUSED(child))
4401 {
4402   xhtml_t *xhtml = GET_XHTML(pdoc);
4403   Doc *doc = xhtml->doc;
4404   W_L("</dl>");
4405   if (IS_CSS_ON(xhtml->entryp)) {
4406     chxj_css_pop_prop_list(xhtml->css_prop_stack);
4407   }
4408   return xhtml->out;
4409 }
4410
4411
4412 /**
4413  * It is a handter who processes the DT tag.
4414  *
4415  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4416  *                     destination is specified.
4417  * @param node   [i]   The DT tag node is specified.
4418  * @return The conversion result is returned.
4419  */
4420 static char *
4421 s_xhtml_1_0_start_dt_tag(void *pdoc, Node *node)
4422 {
4423   xhtml_t *xhtml      = GET_XHTML(pdoc);
4424   Doc     *doc        = xhtml->doc;
4425   Attr    *attr;
4426   char    *attr_style = NULL;
4427   char    *attr_color = NULL;
4428   char    *attr_size  = NULL;
4429
4430   for (attr = qs_get_attr(doc,node);
4431        attr;
4432        attr = qs_get_next_attr(doc,attr)) {
4433     char *name   = qs_get_attr_name(doc,attr);
4434     char *value  = qs_get_attr_value(doc,attr);
4435     if (STRCASEEQ('s','S',"style", name) && value && *value) {
4436       attr_style = value;
4437     }
4438   }
4439   if (IS_CSS_ON(xhtml->entryp)) {
4440     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
4441     if (style) {
4442       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
4443       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
4444       css_property_t *cur;
4445       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4446         if (cur->value && *cur->value) {
4447           attr_color = apr_pstrdup(doc->pool, cur->value);
4448         }
4449       }
4450       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
4451         if (cur->value && *cur->value) {
4452           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
4453             attr_size = apr_pstrdup(doc->pool, cur->value);
4454           }
4455           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
4456             attr_size = apr_pstrdup(doc->pool, cur->value);
4457           }
4458           else if (STRCASEEQ('s','S',"small",cur->value)) {
4459             attr_size = apr_pstrdup(doc->pool, cur->value);
4460           }
4461           else if (STRCASEEQ('m','M',"medium",cur->value)) {
4462             attr_size = apr_pstrdup(doc->pool, cur->value);
4463           }
4464           else if (STRCASEEQ('l','L',"large",cur->value)) {
4465             attr_size = apr_pstrdup(doc->pool, cur->value);
4466           }
4467           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
4468             attr_size = apr_pstrdup(doc->pool, cur->value);
4469           }
4470           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
4471             attr_size = apr_pstrdup(doc->pool, cur->value);
4472           }
4473         }
4474       }
4475     }
4476   }
4477   W_L("<dt");
4478   if (attr_color || attr_size) {
4479     W_L(" style=\"");
4480     if (attr_color) {
4481       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4482       W_L("color:");
4483       W_V(attr_color);
4484       W_L(";");
4485     }
4486     if (attr_size) {
4487       W_L("font-size:");
4488       W_V(attr_size);
4489       W_L(";");
4490     }
4491     W_L("\"");
4492   }
4493   W_L(">");
4494   return xhtml->out;
4495 }
4496
4497
4498 /**
4499  * It is a handter who processes the DT tag.
4500  *
4501  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4502  *                     destination is specified.
4503  * @param node   [i]   The DT tag node is specified.
4504  * @return The conversion result is returned.
4505  */
4506 static char *
4507 s_xhtml_1_0_end_dt_tag(void *pdoc, Node *UNUSED(child))
4508 {
4509   xhtml_t *xhtml = GET_XHTML(pdoc);
4510   Doc     *doc   = xhtml->doc;
4511   W_L("</dt>");
4512   if (IS_CSS_ON(xhtml->entryp)) {
4513     chxj_css_pop_prop_list(xhtml->css_prop_stack);
4514   }
4515   return xhtml->out;
4516 }
4517
4518
4519 /**
4520  * It is a handder who processes the DD tag.
4521  *
4522  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4523  *                     destination is specified.
4524  * @param node   [i]   The DD tag node is specified.
4525  * @return The conversion result is returned.
4526  */
4527 static char *
4528 s_xhtml_1_0_start_dd_tag(void *pdoc, Node *node)
4529 {
4530   xhtml_t *xhtml      = GET_XHTML(pdoc);
4531   Doc     *doc        = xhtml->doc;
4532   Attr    *attr;
4533   char    *attr_style = NULL;
4534   char    *attr_color = NULL;
4535   char    *attr_size  = NULL;
4536
4537   for (attr = qs_get_attr(doc,node);
4538        attr;
4539        attr = qs_get_next_attr(doc,attr)) {
4540     char *name   = qs_get_attr_name(doc,attr);
4541     char *value  = qs_get_attr_value(doc,attr);
4542     if (STRCASEEQ('s','S',"style", name) && value && *value) {
4543       attr_style = value;
4544     }
4545   }
4546   if (IS_CSS_ON(xhtml->entryp)) {
4547     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
4548     if (style) {
4549       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
4550       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
4551       css_property_t *cur;
4552       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4553         if (cur->value && *cur->value) {
4554           attr_color = apr_pstrdup(doc->pool, cur->value);
4555         }
4556       }
4557       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
4558         if (cur->value && *cur->value) {
4559           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
4560             attr_size = apr_pstrdup(doc->pool, cur->value);
4561           }
4562           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
4563             attr_size = apr_pstrdup(doc->pool, cur->value);
4564           }
4565           else if (STRCASEEQ('s','S',"small",cur->value)) {
4566             attr_size = apr_pstrdup(doc->pool, cur->value);
4567           }
4568           else if (STRCASEEQ('m','M',"medium",cur->value)) {
4569             attr_size = apr_pstrdup(doc->pool, cur->value);
4570           }
4571           else if (STRCASEEQ('l','L',"large",cur->value)) {
4572             attr_size = apr_pstrdup(doc->pool, cur->value);
4573           }
4574           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
4575             attr_size = apr_pstrdup(doc->pool, cur->value);
4576           }
4577           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
4578             attr_size = apr_pstrdup(doc->pool, cur->value);
4579           }
4580         }
4581       }
4582     }
4583   }
4584   W_L("<dd");
4585   if (attr_color || attr_size) {
4586     W_L(" style=\"");
4587     if (attr_color) {
4588       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4589       W_L("color:");
4590       W_V(attr_color);
4591       W_L(";");
4592     }
4593     if (attr_size) {
4594       W_L("font-size:");
4595       W_V(attr_size);
4596       W_L(";");
4597     }
4598     W_L("\"");
4599   }
4600   W_L(">");
4601   return xhtml->out;
4602 }
4603
4604
4605 /**
4606  * It is a handler who processes the DD tag.
4607  *
4608  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4609  *                     destination is specified.
4610  * @param node   [i]   The DD tag node is specified.
4611  * @return The conversion result is returned.
4612  */
4613 static char *
4614 s_xhtml_1_0_end_dd_tag(void *pdoc, Node *UNUSED(child))
4615 {
4616   xhtml_t *xhtml = GET_XHTML(pdoc);
4617   Doc     *doc   = xhtml->doc;
4618   W_L("</dd>");
4619   if (IS_CSS_ON(xhtml->entryp)) {
4620     chxj_css_pop_prop_list(xhtml->css_prop_stack);
4621   }
4622   return xhtml->out;
4623 }
4624
4625
4626 /**
4627  * It is a handler who processes the MENU tag.
4628  *
4629  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4630  *                     destination is specified.
4631  * @param node   [i]   The MENU tag node is specified.
4632  * @return The conversion result is returned.
4633  */
4634 static char *
4635 s_xhtml_1_0_start_menu_tag(void *pdoc, Node *node)
4636 {
4637   xhtml_t *xhtml      = GET_XHTML(pdoc);
4638   Doc       *doc        = xhtml->doc;
4639   Attr      *attr;
4640   char      *attr_style = NULL;
4641   char      *attr_color = NULL;
4642   char      *attr_type  = NULL;
4643   char      *attr_size  = NULL;
4644   for (attr = qs_get_attr(doc,node);
4645        attr;
4646        attr = qs_get_next_attr(doc,attr)) {
4647     char *name   = qs_get_attr_name(doc,attr);
4648     char *value  = qs_get_attr_value(doc,attr);
4649     if (STRCASEEQ('t','T',"type",name)) {
4650       if (value && (STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
4651         attr_type = value;
4652       }
4653     }
4654     else if (STRCASEEQ('s','S',"style", name) && value && *value) {
4655       attr_style = value;
4656     }
4657   }
4658   if (IS_CSS_ON(xhtml->entryp)) {
4659     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
4660     if (style) {
4661       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
4662       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
4663       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
4664       css_property_t *cur;
4665       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4666         if (cur->value && *cur->value) {
4667           attr_color = apr_pstrdup(doc->pool, cur->value);
4668         }
4669       }
4670       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
4671         if (cur->value && *cur->value) {
4672           attr_type = apr_pstrdup(doc->pool, cur->value);
4673         }
4674       }
4675       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
4676         if (cur->value && *cur->value) {
4677           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
4678             attr_size = apr_pstrdup(doc->pool, cur->value);
4679           }
4680           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
4681             attr_size = apr_pstrdup(doc->pool, cur->value);
4682           }
4683           else if (STRCASEEQ('s','S',"small",cur->value)) {
4684             attr_size = apr_pstrdup(doc->pool, cur->value);
4685           }
4686           else if (STRCASEEQ('m','M',"medium",cur->value)) {
4687             attr_size = apr_pstrdup(doc->pool, cur->value);
4688           }
4689           else if (STRCASEEQ('l','L',"large",cur->value)) {
4690             attr_size = apr_pstrdup(doc->pool, cur->value);
4691           }
4692           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
4693             attr_size = apr_pstrdup(doc->pool, cur->value);
4694           }
4695           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
4696             attr_size = apr_pstrdup(doc->pool, cur->value);
4697           }
4698         }
4699       }
4700       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
4701         if (cur->value && *cur->value) {
4702           attr_type = apr_pstrdup(doc->pool, cur->value);
4703         }
4704       }
4705       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
4706         if (cur->value && *cur->value) {
4707           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
4708             attr_size = apr_pstrdup(doc->pool, cur->value);
4709           }
4710           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
4711             attr_size = apr_pstrdup(doc->pool, cur->value);
4712           }
4713           else if (STRCASEEQ('s','S',"small",cur->value)) {
4714             attr_size = apr_pstrdup(doc->pool, cur->value);
4715           }
4716           else if (STRCASEEQ('m','M',"medium",cur->value)) {
4717             attr_size = apr_pstrdup(doc->pool, cur->value);
4718           }
4719           else if (STRCASEEQ('l','L',"large",cur->value)) {
4720             attr_size = apr_pstrdup(doc->pool, cur->value);
4721           }
4722           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
4723             attr_size = apr_pstrdup(doc->pool, cur->value);
4724           }
4725           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
4726             attr_size = apr_pstrdup(doc->pool, cur->value);
4727           }
4728         }
4729       }
4730     }
4731   }
4732   W_L("<menu");
4733   if (attr_type || attr_color || attr_size) {
4734     W_L(" style=\"");
4735     if (attr_type) {
4736       W_L("list-style-type:");
4737       W_V(attr_type);
4738       W_L(";");
4739     }
4740     if (attr_color) {
4741       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4742       W_L("color:");
4743       W_V(attr_color);
4744       W_L(";");
4745     }
4746     if (attr_size) {
4747       W_L("font-size:");
4748       W_V(attr_size);
4749       W_L(";");
4750     }
4751     W_L("\"");
4752   }
4753   W_L("<menu");
4754   if (attr_type || attr_color || attr_size) {
4755     W_L(" style=\"");
4756     if (attr_type) {
4757       W_L("list-style-type:");
4758       W_V(attr_type);
4759       W_L(";");
4760     }
4761     if (attr_color) {
4762       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4763       W_L("color:");
4764       W_V(attr_color);
4765       W_L(";");
4766     }
4767     if (attr_size) {
4768       W_L("font-size:");
4769       W_V(attr_size);
4770       W_L(";");
4771     }
4772     W_L("\"");
4773   }
4774   W_L(">");
4775   return xhtml->out;
4776 }
4777
4778
4779 /**
4780  * It is a hanmenuer who processes the MENU tag.
4781  *
4782  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4783  *                     destination is specified.
4784  * @param node   [i]   The MENU tag node is specified.
4785  * @return The conversion result is returned.
4786  */
4787 static char *
4788 s_xhtml_1_0_end_menu_tag(void *pdoc, Node *UNUSED(child))
4789 {
4790   xhtml_t *xhtml = GET_XHTML(pdoc);
4791   Doc     *doc = xhtml->doc;
4792   W_L("</menu>");
4793   if (IS_CSS_ON(xhtml->entryp)) {
4794     chxj_css_pop_prop_list(xhtml->css_prop_stack);
4795   }
4796   return xhtml->out;
4797 }
4798
4799
4800 /**
4801  * It is a handler who processes the PLAINTEXT tag.
4802  *
4803  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4804  *                     destination is specified.
4805  * @param node   [i]   The PLAINTEXT tag node is specified.
4806  * @return The conversion result is returned.
4807  */
4808 static char *
4809 s_xhtml_1_0_start_plaintext_tag(void *pdoc, Node *node)
4810 {
4811   xhtml_t *xhtml = GET_XHTML(pdoc);
4812   Doc     *doc     = xhtml->doc;
4813   W_L("<plaintext>");
4814   s_xhtml_1_0_start_plaintext_tag_inner(pdoc,node);
4815   return xhtml->out;
4816 }
4817
4818 static char *
4819 s_xhtml_1_0_start_plaintext_tag_inner(void *pdoc, Node *node)
4820 {
4821   xhtml_t *xhtml = GET_XHTML(pdoc);
4822   Doc     *doc     = xhtml->doc;
4823   Node    *child;
4824   for (child = qs_get_child_node(doc, node);
4825        child;
4826        child = qs_get_next_node(doc, child)) {
4827     W_V(child->otext);
4828     s_xhtml_1_0_start_plaintext_tag_inner(pdoc, child);
4829   }
4830   return xhtml->out;
4831 }
4832
4833
4834 /**
4835  * It is a handler who processes the PLAINTEXT tag.
4836  *
4837  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4838  *                     destination is specified.
4839  * @param node   [i]   The PLAINTEXT tag node is specified.
4840  * @return The conversion result is returned.
4841  */
4842 static char *
4843 s_xhtml_1_0_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
4844 {
4845   xhtml_t *xhtml = GET_XHTML(pdoc);
4846   Doc     *doc     = xhtml->doc;
4847   W_L("</plaintext>");
4848   return xhtml->out;
4849 }
4850
4851
4852 /**
4853  * It is a handler who processes the BLINK tag.
4854  *
4855  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4856  *                     destination is specified.
4857  * @param node   [i]   The BLINK tag node is specified.
4858  * @return The conversion result is returned.
4859  */
4860 static char *
4861 s_xhtml_1_0_start_blink_tag(void *pdoc, Node *node)
4862 {
4863   xhtml_t *xhtml      = GET_XHTML(pdoc);
4864   Doc     *doc        = xhtml->doc;
4865   Attr    *attr;
4866   char    *attr_style = NULL;
4867   char    *attr_color = NULL;
4868   char    *attr_size  = NULL;
4869
4870   for (attr = qs_get_attr(doc,node);
4871        attr;
4872        attr = qs_get_next_attr(doc,attr)) {
4873     char *name   = qs_get_attr_name(doc,attr);
4874     char *value  = qs_get_attr_value(doc,attr);
4875     if (STRCASEEQ('s','S',"style", name) && value && *value) {
4876       attr_style = value;
4877     }
4878   }
4879   if (IS_CSS_ON(xhtml->entryp)) {
4880     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
4881     if (style) {
4882       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
4883       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
4884       css_property_t *cur;
4885       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4886         if (cur->value && *cur->value) {
4887           attr_color = apr_pstrdup(doc->pool, cur->value);
4888         }
4889       }
4890       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
4891         if (cur->value && *cur->value) {
4892           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
4893             attr_size = apr_pstrdup(doc->pool, cur->value);
4894           }
4895           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
4896             attr_size = apr_pstrdup(doc->pool, cur->value);
4897           }
4898           else if (STRCASEEQ('s','S',"small",cur->value)) {
4899             attr_size = apr_pstrdup(doc->pool, cur->value);
4900           }
4901           else if (STRCASEEQ('m','M',"medium",cur->value)) {
4902             attr_size = apr_pstrdup(doc->pool, cur->value);
4903           }
4904           else if (STRCASEEQ('l','L',"large",cur->value)) {
4905             attr_size = apr_pstrdup(doc->pool, cur->value);
4906           }
4907           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
4908             attr_size = apr_pstrdup(doc->pool, cur->value);
4909           }
4910           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
4911             attr_size = apr_pstrdup(doc->pool, cur->value);
4912           }
4913         }
4914       }
4915     }
4916   }
4917   W_L("<blink");
4918   if (attr_color || attr_size) {
4919     W_L(" style=\"");
4920     if (attr_color) {
4921       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4922       W_L("color:");
4923       W_V(attr_color);
4924       W_L(";");
4925     }
4926     if (attr_size) {
4927       W_L("font-size:");
4928       W_V(attr_size);
4929       W_L(";");
4930     }
4931     W_L("\"");
4932   }
4933   W_L(">");
4934   return xhtml->out;
4935 }
4936
4937
4938 /**
4939  * It is a handler who processes the BLINK tag.
4940  *
4941  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4942  *                     destination is specified.
4943  * @param node   [i]   The BLINK tag node is specified.
4944  * @return The conversion result is returned.
4945  */
4946 static char *
4947 s_xhtml_1_0_end_blink_tag(void *pdoc, Node *UNUSED(node))
4948 {
4949   xhtml_t *xhtml = GET_XHTML(pdoc);
4950   Doc     *doc   = xhtml->doc;
4951   W_L("</blink>");
4952   if (IS_CSS_ON(xhtml->entryp)) {
4953     chxj_css_pop_prop_list(xhtml->css_prop_stack);
4954   }
4955   return xhtml->out;
4956 }
4957
4958
4959 /**
4960  * It is a handler who processes the MARQUEE tag.
4961  *
4962  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4963  *                     destination is specified.
4964  * @param node   [i]   The MARQUEE tag node is specified.
4965  * @return The conversion result is returned.
4966  */
4967 static char *
4968 s_xhtml_1_0_start_marquee_tag(void *pdoc, Node *node)
4969 {
4970   xhtml_t   *xhtml = GET_XHTML(pdoc);
4971   Doc       *doc = xhtml->doc;
4972   Attr      *attr;
4973   char      *attr_direction = NULL;
4974   char      *attr_behavior  = NULL;
4975   char      *attr_loop      = NULL;
4976   char      *attr_style     = NULL;
4977   char      *attr_color     = NULL;
4978   char      *attr_size      = NULL;
4979   char      *attr_bgcolor   = NULL;
4980   /*--------------------------------------------------------------------------*/
4981   /* Get Attributes                                                           */
4982   /*--------------------------------------------------------------------------*/
4983   for (attr = qs_get_attr(doc,node);
4984        attr;
4985        attr = qs_get_next_attr(doc,attr)) {
4986     char *name   = qs_get_attr_name(doc,attr);
4987     char *value  = qs_get_attr_value(doc,attr);
4988     if (STRCASEEQ('d','D',"direction", name)) {
4989       if (value) {
4990         if (STRCASEEQ('l','L',"left",value)) {
4991           attr_direction = "rtl";
4992         }
4993         else if (STRCASEEQ('r','R',"right",value)) {
4994           attr_direction = "ltr";
4995         }
4996       }
4997     }
4998     else if (STRCASEEQ('b','B',"behavior",name) && value && *value) {
4999       if (STRCASEEQ('s','S',"scroll",value) || STRCASEEQ('s','S',"slide",value) || STRCASEEQ('a','A',"alternate",value)) {
5000         attr_behavior = value;
5001       }
5002     }
5003     else if (STRCASEEQ('l','L',"loop",name) && value && *value) {
5004       attr_loop = value;
5005     }
5006     else if (STRCASEEQ('b','B',"bgcolor",name)) {
5007       if (value && *value) {
5008         attr_bgcolor = value;
5009       }
5010     }
5011     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
5012       attr_style = value;
5013     }
5014   }
5015   if (IS_CSS_ON(xhtml->entryp)) {
5016     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
5017     if (style) {
5018       css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
5019       css_property_t *size_prop  = chxj_css_get_property_value(doc, style, "font-size");
5020       css_property_t *bgcolor_prop  = chxj_css_get_property_value(doc, style, "background-color");
5021       css_property_t *direction_prop  = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
5022       css_property_t *behavior_prop  = chxj_css_get_property_value(doc, style, "-wap-marquee-style");
5023       css_property_t *loop_prop  = chxj_css_get_property_value(doc, style, "-wap-marquee-loop");
5024       css_property_t *cur;
5025       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
5026         if (cur->value && *cur->value) {
5027           attr_color = apr_pstrdup(doc->pool, cur->value);
5028         }
5029       }
5030       for (cur = bgcolor_prop->next; cur != bgcolor_prop; cur = cur->next) {
5031         if (cur->value && *cur->value) {
5032           attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
5033         }
5034       }
5035       for (cur = direction_prop->next; cur != direction_prop; cur = cur->next) {
5036         if (cur->value && *cur->value) {
5037           attr_direction = apr_pstrdup(doc->pool, cur->value);
5038         }
5039       }
5040       for (cur = behavior_prop->next; cur != behavior_prop; cur = cur->next) {
5041         if (cur->value && *cur->value) {
5042           if (STRCASEEQ('s','S',"scroll",cur->value) || STRCASEEQ('s','S',"slide",cur->value) || STRCASEEQ('a','A',"alternate",cur->value)) {
5043             attr_behavior = apr_pstrdup(doc->pool, cur->value);
5044           }
5045         }
5046       }
5047       for (cur = loop_prop->next; cur != loop_prop; cur = cur->next) {
5048         if (cur->value && *cur->value) {
5049           attr_loop = apr_pstrdup(doc->pool, cur->value);
5050         }
5051       }
5052       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
5053         if (cur->value && *cur->value) {
5054           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
5055             attr_size = apr_pstrdup(doc->pool, cur->value);
5056           }
5057           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
5058             attr_size = apr_pstrdup(doc->pool, cur->value);
5059           }
5060           else if (STRCASEEQ('s','S',"small",cur->value)) {
5061             attr_size = apr_pstrdup(doc->pool, cur->value);
5062           }
5063           else if (STRCASEEQ('m','M',"medium",cur->value)) {
5064             attr_size = apr_pstrdup(doc->pool, cur->value);
5065           }
5066           else if (STRCASEEQ('l','L',"large",cur->value)) {
5067             attr_size = apr_pstrdup(doc->pool, cur->value);
5068           }
5069           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
5070             attr_size = apr_pstrdup(doc->pool, cur->value);
5071           }
5072           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
5073             attr_size = apr_pstrdup(doc->pool, cur->value);
5074           }
5075         }
5076       }
5077     }
5078   }
5079   W_L("<marquee");
5080   if (attr_color || attr_size || attr_direction || attr_bgcolor || attr_behavior || attr_loop) {
5081     W_L(" style=\"");
5082     if (attr_direction) {
5083       W_L("-wap-marquee-dir:");
5084       W_V(attr_direction);
5085       W_L(";");
5086     }
5087     if (attr_behavior) {
5088       W_L("-wap-marquee-style:");
5089       W_V(attr_behavior);
5090       W_L(";");
5091     }
5092     if (attr_loop) {
5093       W_L("-wap-marquee-loop:");
5094       W_V(attr_loop);
5095       W_L(";");
5096     }
5097     if (attr_bgcolor) {
5098       attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
5099       W_L("background-color:");
5100       W_V(attr_bgcolor);
5101       W_L(";");
5102     }
5103     if (attr_color) {
5104       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
5105       W_L("color:");
5106       W_V(attr_color);
5107       W_L(";");
5108     }
5109     if (attr_size) {
5110       W_L("font-size:");
5111       W_V(attr_size);
5112       W_L(";");
5113     }
5114     W_L("\"");
5115   }
5116   W_L("<marquee");
5117   if (attr_color || attr_size || attr_direction || attr_bgcolor || attr_behavior || attr_loop) {
5118     W_L(" style=\"");
5119     if (attr_direction) {
5120       W_L("-wap-marquee-dir:");
5121       W_V(attr_direction);
5122       W_L(";");
5123     }
5124     if (attr_behavior) {
5125       W_L("-wap-marquee-style:");
5126       W_V(attr_behavior);
5127       W_L(";");
5128     }
5129     if (attr_loop) {
5130       W_L("-wap-marquee-loop:");
5131       W_V(attr_loop);
5132       W_L(";");
5133     }
5134     if (attr_bgcolor) {
5135       attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
5136       W_L("background-color:");
5137       W_V(attr_bgcolor);
5138       W_L(";");
5139     }
5140     if (attr_color) {
5141       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
5142       W_L("color:");
5143       W_V(attr_color);
5144       W_L(";");
5145     }
5146     if (attr_size) {
5147       W_L("font-size:");
5148       W_V(attr_size);
5149       W_L(";");
5150     }
5151     W_L("\"");
5152   }
5153   W_L(">");
5154
5155   return xhtml->out;
5156 }
5157
5158
5159 /**
5160  * It is a handler who processes the MARQUEE tag.
5161  *
5162  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
5163  *                     destination is specified.
5164  * @param node   [i]   The MARQUEE tag node is specified.
5165  * @return The conversion result is returned.
5166  */
5167 static char *
5168 s_xhtml_1_0_end_marquee_tag(void *pdoc, Node *UNUSED(child))
5169 {
5170   xhtml_t *xhtml = GET_XHTML(pdoc);
5171   Doc     *doc = xhtml->doc;
5172   W_L("</marquee>");
5173   if (IS_CSS_ON(xhtml->entryp)) {
5174     chxj_css_pop_prop_list(xhtml->css_prop_stack);
5175   }
5176   return xhtml->out;
5177 }
5178
5179
5180 /**
5181  * It is handler who processes the New Line Code.
5182  */
5183 static char *
5184 s_xhtml_1_0_newline_mark(void *pdoc, Node *UNUSED(node))
5185 {
5186   xhtml_t *xhtml = GET_XHTML(pdoc);
5187   Doc *doc = xhtml->doc;
5188   if (xhtml->start_html_flag) {
5189     W_NLCODE();
5190   }
5191   return xhtml->out;
5192 }
5193
5194
5195 /**
5196  * It is a handler who processes the LINK tag.
5197  *
5198  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
5199  *                     destination is specified.
5200  * @param node   [i]   The LINK tag node is specified.
5201  * @return The conversion result is returned.
5202  */
5203 static char *
5204 s_xhtml_1_0_link_tag(void *pdoc, Node *node)
5205 {
5206   xhtml_t       *xhtml;
5207   Doc           *doc;
5208   Attr          *attr;
5209   char          *rel  = NULL;
5210   char          *href = NULL;
5211   char          *type = NULL;
5212
5213   xhtml = GET_XHTML(pdoc);
5214   doc   = xhtml->doc;
5215
5216   if (! IS_CSS_ON(xhtml->entryp)) {
5217     return xhtml->out;
5218   }
5219
5220   for (attr = qs_get_attr(doc,node);
5221        attr;
5222        attr = qs_get_next_attr(doc,attr)) {
5223     char *name  = qs_get_attr_name(doc,attr);
5224     char *value = qs_get_attr_value(doc,attr);
5225     if (STRCASEEQ('r','R',"rel", name)) {
5226       if (value && *value && STRCASEEQ('s','S',"stylesheet", value)) {
5227         rel = value;
5228       }
5229     }
5230     else if (STRCASEEQ('h','H',"href", name)) {
5231       if (value && *value) {
5232         href = value;
5233       }
5234     }
5235     else if (STRCASEEQ('t','T',"type", name)) {
5236       if (value && *value && STRCASEEQ('t','T',"text/css",value)) {
5237         type = value;
5238       }
5239     }
5240   }
5241
5242   if (rel && href && type) {
5243     DBG(doc->r, "start load CSS. url:[%s]", href);
5244     xhtml->style = chxj_css_parse_from_uri(doc->r, doc->pool, xhtml->style, href);
5245     DBG(doc->r, "end load CSS. url:[%s]", href);
5246   }
5247
5248   return xhtml->out;
5249 }
5250
5251 static css_prop_list_t *
5252 s_xhtml_1_0_push_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value)
5253 {
5254   xhtml_t *xhtml = GET_XHTML(pdoc);
5255   Doc *doc = xhtml->doc;
5256   css_prop_list_t *last_css = NULL;
5257   if (IS_CSS_ON(xhtml->entryp)) {
5258     css_prop_list_t *dup_css;
5259     css_selector_t  *selector;
5260
5261     last_css = chxj_css_get_last_prop_list(xhtml->css_prop_stack);
5262     dup_css  = chxj_dup_css_prop_list(doc, last_css);
5263     selector = chxj_css_find_selector(doc, xhtml->style, node);
5264     if (selector) {
5265       chxj_css_prop_list_merge_property(doc, dup_css, selector);
5266     }
5267     chxj_css_push_prop_list(xhtml->css_prop_stack, dup_css);
5268     last_css = chxj_css_get_last_prop_list(xhtml->css_prop_stack);
5269
5270     if (style_attr_value) {
5271       css_stylesheet_t *ssheet = chxj_css_parse_style_attr(doc, NULL, apr_pstrdup(doc->pool, node->name), NULL, NULL, apr_pstrdup(doc->pool, style_attr_value));
5272       if (ssheet) {
5273         chxj_css_prop_list_merge_property(doc, last_css, ssheet->selector_head.next);
5274       }
5275     }
5276   }
5277   return last_css;
5278 }
5279
5280
5281 static css_prop_list_t *
5282 s_xhtml_1_0_nopush_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value)
5283 {
5284   xhtml_t *xhtml = GET_XHTML(pdoc);
5285   Doc *doc = xhtml->doc;
5286   css_prop_list_t *last_css = NULL;
5287   if (IS_CSS_ON(xhtml->entryp)) {
5288     css_prop_list_t *dup_css;
5289     css_selector_t  *selector;
5290
5291     last_css = chxj_css_get_last_prop_list(xhtml->css_prop_stack);
5292     dup_css  = chxj_dup_css_prop_list(doc, last_css);
5293     selector = chxj_css_find_selector(doc, xhtml->style, node);
5294     if (selector) {
5295       chxj_css_prop_list_merge_property(doc, dup_css, selector);
5296     }
5297     last_css = dup_css;
5298
5299     if (style_attr_value) {
5300       css_stylesheet_t *ssheet = chxj_css_parse_style_attr(doc, NULL, apr_pstrdup(doc->pool, node->name), NULL, NULL, apr_pstrdup(doc->pool, style_attr_value));
5301       if (ssheet) {
5302         chxj_css_prop_list_merge_property(doc, last_css, ssheet->selector_head.next);
5303       }
5304     }
5305   }
5306   return last_css;
5307 }
5308
5309
5310 /**
5311  * It is a handler who processes the SPAN tag.
5312  *
5313  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
5314  *                     destination is specified.
5315  * @param node   [i]   The SPAN tag node is specified.
5316  * @return The conversion result is returned.
5317  */
5318 static char *
5319 s_xhtml_1_0_start_span_tag(void *pdoc, Node *node)
5320 {
5321   xhtml_t *xhtml;
5322   Doc *doc;
5323   Attr *attr;
5324   char *attr_style = NULL;
5325   char *attr_color = NULL;
5326   char *attr_size = NULL;
5327   char *attr_align = NULL;
5328   char *attr_blink = NULL;
5329   char *attr_marquee = NULL;
5330   char *attr_marquee_dir = NULL;
5331   char *attr_marquee_style = NULL;
5332   char *attr_marquee_loop = NULL;
5333
5334   xhtml = GET_XHTML(pdoc);
5335   doc     = xhtml->doc;
5336
5337   for (attr = qs_get_attr(doc,node);
5338        attr;
5339        attr = qs_get_next_attr(doc,attr)) {
5340     char *nm  = qs_get_attr_name(doc,attr);
5341     char *val = qs_get_attr_value(doc,attr);
5342     if (val && STRCASEEQ('s','S',"style", nm)) {
5343       attr_style = val;
5344     }
5345   }
5346   if (IS_CSS_ON(xhtml->entryp)) {
5347     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
5348     if (style) {
5349       css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
5350       css_property_t *size_prop = chxj_css_get_property_value(doc, style, "font-size");
5351       css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
5352       css_property_t *decoration_prop = chxj_css_get_property_value(doc, style, "text-decoration");
5353       css_property_t *display_prop = chxj_css_get_property_value(doc, style, "display");
5354       css_property_t *marquee_dir_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
5355       css_property_t *marquee_style_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-style");
5356       css_property_t *marquee_loop_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-loop");
5357       css_property_t *cur;
5358       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
5359         attr_color = apr_pstrdup(doc->pool, cur->value);
5360       }
5361       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
5362         if (cur->value && *cur->value) {
5363           if ( STRCASEEQ('x','X',"xx-small",cur->value)
5364             || STRCASEEQ('x','X',"x-small", cur->value)
5365             || STRCASEEQ('s','S',"small",   cur->value)
5366             || STRCASEEQ('m','M',"medium",  cur->value)
5367             || STRCASEEQ('l','L',"large",   cur->value)
5368             || STRCASEEQ('x','X',"x-large", cur->value)
5369             || STRCASEEQ('x','X',"xx-large",cur->value)) {
5370             attr_size = apr_pstrdup(doc->pool, cur->value);
5371           }
5372         }
5373       }
5374       for (cur = decoration_prop->next; cur != decoration_prop; cur = cur->next) {
5375         if (cur->value && STRCASEEQ('b','B',"blink",cur->value)) {
5376           attr_blink = apr_pstrdup(doc->pool, cur->value);
5377         }
5378       }
5379       for (cur = display_prop->next; cur != display_prop; cur = cur->next) {
5380         if (cur->value && strcasecmp("-wap-marquee",cur->value) == 0) {
5381           attr_marquee = apr_pstrdup(doc->pool, cur->value);
5382         }
5383       }
5384       for (cur = marquee_dir_prop->next; cur != marquee_dir_prop; cur = cur->next) {
5385         if (cur->value && *cur->value) {
5386           if ( STRCASEEQ('l','L',"ltr",cur->value)
5387             || STRCASEEQ('r','R',"rtl",cur->value)) {
5388             attr_marquee_dir = apr_pstrdup(doc->pool, cur->value);
5389           }
5390         }
5391       }
5392       for (cur = marquee_style_prop->next; cur != marquee_style_prop; cur = cur->next) {
5393         if (cur->value && *cur->value) {
5394           if ( STRCASEEQ('s','S',"scroll",cur->value)
5395             || STRCASEEQ('s','S',"slide",cur->value)
5396             || STRCASEEQ('a','A',"alternate",cur->value)) {
5397             attr_marquee_style = apr_pstrdup(doc->pool, cur->value);
5398           }
5399         }
5400       }
5401       for (cur = marquee_loop_prop->next; cur != marquee_loop_prop; cur = cur->next) {
5402         if (cur->value && *cur->value) {
5403           attr_marquee_loop = apr_pstrdup(doc->pool, cur->value);
5404         }
5405       }
5406       for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
5407         if (STRCASEEQ('l','L',"left", cur->value)) {
5408           attr_align = apr_pstrdup(doc->pool, "left");
5409         }
5410         else if (STRCASEEQ('c','C',"center",cur->value)) {
5411           attr_align = apr_pstrdup(doc->pool, "center");
5412         }
5413         else if (STRCASEEQ('r','R',"right",cur->value)) {
5414           attr_align = apr_pstrdup(doc->pool, "right");
5415         }
5416       }
5417     }
5418   }
5419
5420   W_L("<span");
5421   if (attr_color || attr_size || attr_align || attr_blink || attr_marquee) {
5422     W_L(" style=\"");
5423     if (attr_color) {
5424       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
5425       W_L("color:");
5426       W_V(attr_color);
5427       W_L(";");
5428     }
5429     if (attr_size) {
5430       W_L("font-size:");
5431       W_V(attr_size);
5432       W_L(";");
5433     }
5434     if (attr_align) {
5435       W_L("text-align:");
5436       W_V(attr_align);
5437       W_L(";");
5438     }
5439     if (attr_blink) {
5440       W_L("text-decoration:");
5441       W_V("blink");
5442       W_L(";");
5443     }
5444     if (attr_marquee) {
5445       W_L("display:-wap-marquee;");
5446       if (attr_marquee_dir) {
5447         W_L("-wap-marquee-dir:");
5448         W_V(attr_marquee_dir);
5449         W_L(";");
5450       }
5451       if (attr_marquee_style) {
5452         W_L("-wap-marquee-style:");
5453         W_V(attr_marquee_style);
5454         W_L(";");
5455       }
5456       if (attr_marquee_loop) {
5457         W_L("-wap-marquee-loop:");
5458         W_V(attr_marquee_loop);
5459         W_L(";");
5460       }
5461     }
5462     W_L("\"");
5463   }
5464   W_L(">");
5465   return xhtml->out;
5466 }
5467
5468
5469 /**
5470  * It is a handler who processes the SPAN tag.
5471  *
5472  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
5473  *                     destination is specified.
5474  * @param node   [i]   The SPAN tag node is specified.
5475  * @return The conversion result is returned.
5476  */
5477 static char *
5478 s_xhtml_1_0_end_span_tag(void *pdoc, Node *UNUSED(node))
5479 {
5480   xhtml_t *xhtml = GET_XHTML(pdoc);
5481   Doc *doc = xhtml->doc;
5482
5483   W_L("</span>");
5484   if (IS_CSS_ON(xhtml->entryp)) {
5485     chxj_css_pop_prop_list(xhtml->css_prop_stack);
5486   }
5487   return xhtml->out;
5488 }
5489
5490
5491 /**
5492  * It is a handler who processes the STYLE tag.
5493  *
5494  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
5495  *                     destination is specified.
5496  * @param node   [i]   The STYLE tag node is specified.
5497  * @return The conversion result is returned.
5498  */
5499 static char *
5500 s_xhtml_1_0_style_tag(void *pdoc, Node *node)
5501 {
5502   xhtml_t     *xhtml;
5503   Doc           *doc;
5504   Attr          *attr;
5505   char          *type = NULL;
5506
5507   xhtml = GET_XHTML(pdoc);
5508   doc     = xhtml->doc;
5509
5510   if (! IS_CSS_ON(xhtml->entryp)) {
5511     return xhtml->out;
5512   }
5513
5514   for (attr = qs_get_attr(doc,node);
5515        attr;
5516        attr = qs_get_next_attr(doc,attr)) {
5517     char *name  = qs_get_attr_name(doc,attr);
5518     char *value = qs_get_attr_value(doc,attr);
5519     if (STRCASEEQ('t','T',"type", name)) {
5520       if (value && *value && STRCASEEQ('t','T',"text/css",value)) {
5521         type = value;
5522       }
5523     }
5524   }
5525
5526   Node *child = qs_get_child_node(doc, node);
5527   if (type && child) {
5528     char *name  = qs_get_node_name(doc, child);
5529     if (STRCASEEQ('t','T',"text", name)) {
5530       char *value = qs_get_node_value(doc, child);
5531       DBG(doc->r, "start load CSS. buf:[%s]", value);
5532       xhtml->style = chxj_css_parse_style_value(doc, xhtml->style, value);
5533       DBG(doc->r, "end load CSS. value:[%s]", value);
5534     }
5535   }
5536   return xhtml->out;
5537 }
5538 /*
5539  * vim:ts=2 et
5540  */