OSDN Git Service

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