OSDN Git Service

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