OSDN Git Service

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