OSDN Git Service

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