OSDN Git Service

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