OSDN Git Service

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