OSDN Git Service

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