OSDN Git Service

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