OSDN Git Service

* typo
[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     char *vv = s_jxhtml_istyle_to_wap_input_format(doc->buf.pool,attr_istyle);
2615     W_L(" style=\"");
2616     W_L("-wap-input-format:");
2617     W_V(vv);
2618     W_L(";");
2619     W_L("\"");
2620   }
2621   else if(attr_type && STRCASEEQ('p','P',"password",attr_type)) {
2622     W_L(" istyle=\"4\"");
2623
2624     char *vv = s_jxhtml_istyle_to_wap_input_format(doc->buf.pool,"4");
2625     W_L(" style=\"");
2626     W_L("-wap-input-format:");
2627     W_V(vv);
2628     W_L(";");
2629     W_L("\"");
2630   }
2631   /*--------------------------------------------------------------------------*/
2632   /* The figure is default for the password.                                  */
2633   /*--------------------------------------------------------------------------*/
2634   if (attr_max_length && *attr_max_length) {
2635     if (chxj_chk_numeric(attr_max_length) == 0) {
2636       W_L(" maxlength=\"");
2637       W_V(attr_max_length);
2638       W_L("\"");
2639     }
2640   }
2641   if (attr_checked) {
2642     W_L(" checked=\"checked\"");
2643   }
2644   W_L(" />");
2645 #if 0
2646   jxhtml_t       *jxhtml;
2647   Doc           *doc;
2648   request_rec   *r;
2649   char          *max_length;
2650   char          *type;
2651   char          *name;
2652   char          *value;
2653   char          *istyle;
2654   char          *size;
2655   char          *checked;
2656   char          *accesskey;
2657
2658   jxhtml       = GET_JXHTML(pdoc);
2659   doc         = jxhtml->doc;
2660   r           = doc->r;
2661   max_length  = NULL;
2662   type        = NULL;
2663   name        = NULL;
2664   value       = NULL;
2665   istyle      = NULL;
2666   size        = NULL;
2667   checked     = NULL;
2668   accesskey   = NULL;
2669
2670   W_L("<input");
2671   /*--------------------------------------------------------------------------*/
2672   /* Get Attributes                                                           */
2673   /*--------------------------------------------------------------------------*/
2674   type       = qs_get_type_attr(doc, node, doc->buf.pool);
2675   name       = qs_get_name_attr(doc, node, doc->buf.pool);
2676   value      = qs_get_value_attr(doc,node, doc->buf.pool);
2677   istyle     = qs_get_istyle_attr(doc,node,doc->buf.pool);
2678   max_length = qs_get_maxlength_attr(doc,node,doc->buf.pool);
2679   checked    = qs_get_checked_attr(doc,node,doc->buf.pool);
2680   accesskey  = qs_get_accesskey_attr(doc, node, doc->buf.pool);
2681   size       = qs_get_size_attr(doc, node, doc->buf.pool);
2682
2683   if (type) {
2684     if (type && (STRCASEEQ('t','T',"text",    type) ||
2685                  STRCASEEQ('p','P',"password",type) ||
2686                  STRCASEEQ('c','C',"checkbox",type) ||
2687                  STRCASEEQ('r','R',"radio",   type) ||
2688                  STRCASEEQ('h','H',"hidden",  type) ||
2689                  STRCASEEQ('s','S',"submit",  type) ||
2690                  STRCASEEQ('r','R',"reset",   type))) {
2691       W_L(" type=\"");
2692       W_V(type);
2693       W_L("\"");
2694     }
2695   }
2696   if (size && *size) {
2697     W_L(" size=\"");
2698     W_V(size);
2699     W_L("\"");
2700   }
2701   if (name && *name) {
2702     W_L(" name=\"");
2703     W_V(chxj_jreserved_to_safe_tag(r, name, jxhtml->entryp));
2704     W_L("\"");
2705   }
2706   if (value && *value) {
2707     if (type && (STRCASEEQ('s','S',"submit",type) || STRCASEEQ('r','R',"reset",type))) {
2708       apr_size_t value_len = strlen(value);
2709       value = chxj_conv_z2h(r, value, &value_len, jxhtml->entryp);
2710     }
2711
2712     W_L(" value=\"");
2713     W_V(chxj_add_slash_to_doublequote(doc->pool, value));
2714     W_L("\"");
2715   }
2716   if (accesskey && *accesskey) {
2717     W_L(" accesskey=\"");
2718     W_V(accesskey);
2719     W_L("\"");
2720   }
2721   if (istyle && (*istyle == '1' || *istyle == '2' || *istyle == '3' || *istyle == '4')) {
2722     /*------------------------------------------------------------------------*/
2723     /* CHTML 2.0                                                              */
2724     /*------------------------------------------------------------------------*/
2725     if (type && STRCASEEQ('p','P',"password", type) && ! jxhtml->entryp->pc_flag ) {
2726       W_L(" style=\"-wap-input-format: &quot;*&lt;ja:n&gt;&quot;;\"");
2727     }
2728     else {
2729       char *vv = qs_conv_istyle_to_format(doc->buf.pool, istyle);
2730       W_L(" style=\"");
2731       W_L("-wap-input-format:'*");
2732       W_V(vv);
2733       W_L("';");
2734       W_L("\"");
2735     }
2736   }
2737   else if (type && STRCASEEQ('p','P',"password",type)) {
2738     W_L(" style=\"-wap-input-format: &quot;*&lt;ja:n&gt;&quot;;\"");
2739   }
2740   /*--------------------------------------------------------------------------*/
2741   /* The figure is default for the password.                                  */
2742   /*--------------------------------------------------------------------------*/
2743   if (max_length && *max_length) {
2744     if (chxj_chk_numeric(max_length) == 0) {
2745       W_L(" maxlength=\"");
2746       W_V(max_length);
2747       W_L("\"");
2748     }
2749   }
2750
2751   if (checked) {
2752     W_L(" checked=\"checked\"");
2753   }
2754   W_L(" />");
2755 #endif
2756   return jxhtml->out;
2757 }
2758
2759
2760 /**
2761  * It is a handler who processes the INPUT tag.
2762  *
2763  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
2764  *                     destination is specified.
2765  * @param node   [i]   The INPUT tag node is specified.
2766  * @return The conversion result is returned.
2767  */
2768 static char *
2769 s_jxhtml_end_input_tag(void *pdoc, Node *UNUSED(child)) 
2770 {
2771   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
2772   return jxhtml->out;
2773 }
2774
2775
2776 /**
2777  * It is a handler who processes the CENTER tag.
2778  *
2779  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
2780  *                     destination is specified.
2781  * @param node   [i]   The CENTER tag node is specified.
2782  * @return The conversion result is returned.
2783  */
2784 static char *
2785 s_jxhtml_start_center_tag(void *pdoc, Node *node)
2786 {
2787   jxhtml_t *jxhtml;
2788   Doc       *doc;
2789   Attr      *attr;
2790   char      *attr_style = NULL;
2791   char      *attr_color = NULL;
2792   char      *attr_size  = NULL;
2793
2794   jxhtml = GET_JXHTML(pdoc);
2795   doc    = jxhtml->doc;
2796
2797   for (attr = qs_get_attr(doc,node);
2798        attr;
2799        attr = qs_get_next_attr(doc,attr)) {
2800     char *name  = qs_get_attr_name(doc,attr);
2801     char *value = qs_get_attr_value(doc,attr);
2802     if (STRCASEEQ('s','S',"style",name) && value && *value) {
2803       attr_style = value;
2804     }
2805   }
2806   if (IS_CSS_ON(jxhtml->entryp)) {
2807     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
2808     if (style) {
2809       css_property_t *color_prop      = chxj_css_get_property_value(doc, style, "color");
2810       css_property_t *size_prop       = chxj_css_get_property_value(doc, style, "font-size");
2811       css_property_t *cur;
2812       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
2813         if (cur->value && *cur->value) {
2814           attr_color = apr_pstrdup(doc->pool, cur->value);
2815         }
2816       }
2817       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
2818         if (cur->value && *cur->value) {
2819           attr_size = apr_pstrdup(doc->pool, cur->value);
2820         }
2821       }
2822     }
2823   }
2824
2825   W_L("<center");
2826   if (attr_size || attr_color) {
2827     W_L(" style=\"");
2828     if (attr_size) {
2829       W_L("font-size:");
2830       W_V(attr_size);
2831       W_L(";");
2832     }
2833     if (attr_color) {
2834       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
2835       W_L("color:");
2836       W_V(attr_color);
2837       W_L(";");
2838     }
2839     W_L("\"");
2840   }
2841   W_L(">");
2842   
2843   return jxhtml->out;
2844 }
2845
2846
2847 /**
2848  * It is a handler who processes the CENTER tag.
2849  *
2850  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
2851  *                     destination is specified.
2852  * @param node   [i]   The CENTER tag node is specified.
2853  * @return The conversion result is returned.
2854  */
2855 static char *
2856 s_jxhtml_end_center_tag(void *pdoc, Node *UNUSED(node))
2857 {
2858   jxhtml_t    *jxhtml;
2859   Doc         *doc;
2860   request_rec *r;
2861
2862   jxhtml = GET_JXHTML(pdoc);
2863   doc    = jxhtml->doc;
2864   r      = doc->r;
2865
2866   W_L("</center>");
2867   if (IS_CSS_ON(jxhtml->entryp)) {
2868     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
2869   }
2870   return jxhtml->out;
2871 }
2872
2873
2874 /**
2875  * It is a handler who processes the li tag.
2876  *
2877  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
2878  *                     destination is specified.
2879  * @param node   [i]   The li tag node is specified.
2880  * @return The conversion result is returned.
2881  */
2882 static char *
2883 s_jxhtml_start_li_tag(void *pdoc, Node *node)
2884 {
2885   jxhtml_t    *jxhtml;
2886   Doc         *doc;
2887   request_rec *r;
2888   Attr        *attr;
2889   char        *attr_type  = NULL;
2890   char        *attr_value = NULL;
2891   char        *attr_style = NULL;
2892
2893   jxhtml = GET_JXHTML(pdoc);
2894   doc   = jxhtml->doc;
2895   r     = doc->r;
2896
2897   for (attr = qs_get_attr(doc,node);
2898        attr;
2899        attr = qs_get_next_attr(doc,attr)) {
2900     char *name  = qs_get_attr_name(doc,attr);
2901     char *value = qs_get_attr_value(doc,attr);
2902     if (STRCASEEQ('t','T',"type",name)) {
2903       if (value && (*value == '1' || *value == 'a' || *value == 'A' || STRCASEEQ('d','D',"disc",value) || STRCASEEQ('s','S',"square",value) || STRCASEEQ('c','C',"circle",value))) {
2904         if (*value == '1') {
2905           attr_type = apr_pstrdup(doc->pool, "decimal");
2906         }
2907         else if (*value == 'a') {
2908           attr_type = apr_pstrdup(doc->pool, "lower-alpha");
2909         }
2910         else if (*value == 'A') {
2911           attr_type = apr_pstrdup(doc->pool, "upper-alpha");
2912         }
2913         else {
2914           attr_type = value;
2915         }
2916       }
2917     }
2918     else if (STRCASEEQ('v','V',"value", name) && value && *value) {
2919       attr_value = value;
2920     }
2921     else if (STRCASEEQ('s','S',"style", name) && value && *value) {
2922       attr_style = value;
2923     }
2924   }
2925   if (IS_CSS_ON(jxhtml->entryp)) {
2926     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
2927     if (style) {
2928       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
2929       css_property_t *cur;
2930       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
2931         if (STRCASEEQ('d','D',"decimal", cur->value)) {
2932           attr_type = apr_pstrdup(doc->pool, "decimal");
2933         }
2934         else if (STRCASEEQ('u','U',"upper-alpha", cur->value)) {
2935           attr_type = apr_pstrdup(doc->pool, "upper-alpha");
2936         }
2937         else if (STRCASEEQ('l','L',"lower-alpha", cur->value)) {
2938           attr_type = apr_pstrdup(doc->pool, "lower-alpha");
2939         }
2940         else if (STRCASEEQ('d','D',"disc", cur->value)) {
2941           attr_type = apr_pstrdup(doc->pool, "disc");
2942         }
2943         else if (STRCASEEQ('s','S',"square", cur->value)) {
2944           attr_type = apr_pstrdup(doc->pool, "square");
2945         }
2946         else if (STRCASEEQ('c','C',"circle", cur->value)) {
2947           attr_type = apr_pstrdup(doc->pool, "circle");
2948         }
2949       }
2950     }
2951   }
2952
2953
2954   W_L("<li");
2955   if (attr_type) {
2956     W_L(" style=\"");
2957     W_L("list-style-type:");
2958     W_V(attr_type);
2959     W_L(";");
2960     W_L("\"");
2961   }
2962   if (attr_value) {
2963     W_L(" value=\"");
2964     W_V(attr_value);
2965     W_L("\"");
2966   }
2967   W_L(">");
2968   return jxhtml->out;
2969 }
2970
2971
2972 /**
2973  * It is a handler who processes the li tag.
2974  *
2975  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
2976  *                     destination is specified.
2977  * @param node   [i]   The li tag node is specified.
2978  * @return The conversion result is returned.
2979  */
2980 static char *
2981 s_jxhtml_end_li_tag(void *pdoc, Node *UNUSED(child)) 
2982 {
2983   jxhtml_t     *jxhtml;
2984   Doc         *doc;
2985   request_rec *r;
2986
2987   jxhtml = GET_JXHTML(pdoc);
2988   doc   = jxhtml->doc;
2989   r     = doc->r;
2990
2991   if (IS_CSS_ON(jxhtml->entryp)) {
2992     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
2993   }
2994   W_L("</li>");
2995   return jxhtml->out;
2996 }
2997
2998
2999 /**
3000  * It is a handler who processes the OL tag.
3001  *
3002  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
3003  *                     destination is specified.
3004  * @param node   [i]   The OL tag node is specified.
3005  * @return The conversion result is returned.
3006  */
3007 static char *
3008 s_jxhtml_start_ol_tag(void *pdoc, Node *node)
3009 {
3010   jxhtml_t    *jxhtml;
3011   Doc         *doc;
3012   request_rec *r;
3013   Attr        *attr;
3014   char        *attr_style = NULL;
3015   char        *attr_start = NULL;
3016   char        *attr_type  = NULL;
3017   char        *css_clear  = NULL;
3018
3019   jxhtml = GET_JXHTML(pdoc);
3020   doc   = jxhtml->doc;
3021   r     = doc->r;
3022
3023   /*--------------------------------------------------------------------------*/
3024   /* Get Attributes                                                           */
3025   /*--------------------------------------------------------------------------*/
3026   for (attr = qs_get_attr(doc,node);
3027        attr;
3028        attr = qs_get_next_attr(doc,attr)) {
3029     char *name = qs_get_attr_name(doc,attr);
3030     char *value = qs_get_attr_value(doc,attr);
3031     if (STRCASEEQ('t','T',"type",name) && value) {
3032       if (*value == '1') {
3033         attr_type = apr_pstrdup(doc->pool, "decimal");
3034       }
3035       else if (*value == 'a') {
3036         attr_type = apr_pstrdup(doc->pool, "lower-alpha");
3037       }
3038       else if (*value == 'A') {
3039         attr_type = apr_pstrdup(doc->pool, "upper-alpha");
3040       }
3041     }
3042     else if (STRCASEEQ('s','S',"start",name) && value && *value) {
3043       attr_start = value;
3044     }
3045     else if (STRCASEEQ('s','S',"style", name) && value && *value) {
3046       attr_style = value;
3047     }
3048   }
3049   if (IS_CSS_ON(jxhtml->entryp)) {
3050     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
3051     if (style) {
3052       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
3053       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
3054       
3055       css_property_t *cur;
3056       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3057         if (STRCASEEQ('d','D',"decimal", cur->value)) {
3058           attr_type = apr_pstrdup(doc->pool, "decimal");
3059         }
3060         else if (STRCASEEQ('u','U',"upper-alpha", cur->value)) {
3061           attr_type = apr_pstrdup(doc->pool, "upper-alpha");
3062         }
3063         else if (STRCASEEQ('l','L',"lower-alpha", cur->value)) {
3064           attr_type = apr_pstrdup(doc->pool, "lower-alpha");
3065         }
3066       }
3067       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
3068         css_clear = apr_pstrdup(doc->pool, cur->value);
3069       }
3070     }
3071   }
3072   W_L("<ol");
3073   if (attr_type || css_clear) {
3074     W_L(" style=\"");
3075     if (attr_type) {
3076       W_L("list-style-type:");
3077       W_V(attr_type);
3078       W_L(";");
3079     }
3080     if (css_clear){
3081       W_L("clear:");
3082       W_V(css_clear);
3083       W_L(";");
3084     }
3085     W_L("\"");
3086   }
3087   if (attr_start) {
3088     W_L(" start=\"");
3089     W_V(attr_start);
3090     W_L("\"");
3091   }
3092   W_L(">");
3093
3094   return jxhtml->out;
3095 }
3096
3097
3098 /**
3099  * It is a handler who processes the OL tag.
3100  *
3101  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
3102  *                     destination is specified.
3103  * @param node   [i]   The OL tag node is specified.
3104  * @return The conversion result is returned.
3105  */
3106 static char *
3107 s_jxhtml_end_ol_tag(void *pdoc, Node *UNUSED(child)) 
3108 {
3109   jxhtml_t     *jxhtml;
3110   Doc         *doc;
3111   request_rec *r;
3112
3113   jxhtml = GET_JXHTML(pdoc);
3114   doc   = jxhtml->doc;
3115   r     = doc->r;
3116
3117   W_L("</ol>");
3118   if (IS_CSS_ON(jxhtml->entryp)) {
3119     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
3120   }
3121   return jxhtml->out;
3122 }
3123
3124
3125 /**
3126  * It is a handler who processes the P tag.
3127  *
3128  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
3129  *                     destination is specified.
3130  * @param node   [i]   The P tag node is specified.
3131  * @return The conversion result is returned.
3132  */
3133 static char *
3134 s_jxhtml_start_p_tag(void *pdoc, Node *node)
3135 {
3136   jxhtml_t    *jxhtml;
3137   Doc         *doc;
3138   request_rec *r;
3139   Attr        *attr;
3140   char        *attr_align = NULL;
3141   char        *attr_style = NULL;
3142   char        *attr_color = NULL;
3143   char        *attr_blink = NULL;
3144   char        *css_clear  = NULL;
3145
3146   jxhtml = GET_JXHTML(pdoc);
3147   doc   = jxhtml->doc;
3148   r     = doc->r;
3149
3150   for (attr = qs_get_attr(doc,node);
3151        attr;
3152        attr = qs_get_next_attr(doc,attr)) {
3153     char *nm  = qs_get_attr_name(doc,attr);
3154     char *val = qs_get_attr_value(doc,attr);
3155     if (STRCASEEQ('a','A',"align", nm)) {
3156       /*----------------------------------------------------------------------*/
3157       /* CHTML 1.0 (W3C version 3.2)                                          */
3158       /*----------------------------------------------------------------------*/
3159       if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
3160         attr_align = apr_pstrdup(doc->buf.pool, val);
3161         break;
3162       }
3163     }
3164     else if (STRCASEEQ('s','S',"style", nm) && val && *val) {
3165       attr_style = apr_pstrdup(doc->buf.pool, val);
3166     }
3167   }
3168   if (IS_CSS_ON(jxhtml->entryp)) {
3169     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
3170     if (style) {
3171       css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
3172       css_property_t *color_prop      = chxj_css_get_property_value(doc, style, "color");
3173       css_property_t *text_deco_prop  = chxj_css_get_property_value(doc, style, "text-decoration");
3174       css_property_t *clear_prop      = chxj_css_get_property_value(doc, style, "clear");
3175       css_property_t *cur;
3176       for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
3177         if (STRCASEEQ('l','L',"left",cur->value)) {
3178           attr_align = apr_pstrdup(doc->pool, "left");
3179         }
3180         else if (STRCASEEQ('c','C',"center",cur->value)) {
3181           attr_align = apr_pstrdup(doc->pool, "center");
3182         }
3183         else if (STRCASEEQ('r','R',"right",cur->value)) {
3184           attr_align = apr_pstrdup(doc->pool, "right");
3185         }
3186       }
3187       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
3188         if (cur->value && *cur->value) {
3189           attr_color = apr_pstrdup(doc->pool, cur->value);
3190         }
3191       }
3192       for (cur = text_deco_prop->next; cur != text_deco_prop; cur = cur->next) {
3193         if (cur->value && *cur->value && STRCASEEQ('b','B',"blink",cur->value)) {
3194           attr_blink = apr_pstrdup(doc->pool, cur->value);
3195         }
3196       }
3197       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
3198         css_clear = apr_pstrdup(doc->pool, cur->value);
3199       }
3200     }
3201   }
3202   W_L("<p");
3203   if ((attr_align && *attr_align) || (attr_color && *attr_color) || (attr_blink && *attr_blink) || css_clear) {
3204     W_L(" style=\"");
3205     if (attr_align) {
3206       W_L("text-align:");
3207       W_V(attr_align);
3208       W_L(";");
3209     }
3210     if (attr_color) {
3211       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
3212       W_L("color:");
3213       W_V(attr_color);
3214       W_L(";");
3215     }
3216     if (attr_blink) {
3217       W_L("text-decoration:");
3218       W_V(attr_blink);
3219       W_L(";");
3220     }
3221     if (css_clear){
3222       W_L("clear:");
3223       W_V(css_clear);
3224       W_L(";");
3225     }
3226     W_L("\"");
3227   }
3228   W_L(">");
3229   return jxhtml->out;
3230 }
3231
3232
3233 /**
3234  * It is a handler who processes the P tag.
3235  *
3236  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
3237  *                     destination is specified.
3238  * @param node   [i]   The P tag node is specified.
3239  * @return The conversion result is returned.
3240  */
3241 static char *
3242 s_jxhtml_end_p_tag(void *pdoc, Node *UNUSED(child)) 
3243 {
3244   jxhtml_t  *jxhtml = GET_JXHTML(pdoc);
3245   Doc       *doc    = jxhtml->doc;
3246
3247   W_L("</p>");
3248   if (IS_CSS_ON(jxhtml->entryp)) {
3249     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
3250   }
3251   return jxhtml->out;
3252 }
3253
3254
3255 /**
3256  * It is a handler who processes the PRE tag.
3257  *
3258  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
3259  *                     destination is specified.
3260  * @param node   [i]   The PRE tag node is specified.
3261  * @return The conversion result is returned.
3262  */
3263 static char *
3264 s_jxhtml_start_pre_tag(void *pdoc, Node *node)
3265 {
3266   jxhtml_t  *jxhtml = GET_JXHTML(pdoc);
3267   Doc       *doc   = jxhtml->doc;
3268   Attr      *attr;
3269   char      *attr_style = NULL;
3270   char      *css_clear  = NULL;
3271
3272   for (attr = qs_get_attr(doc,node);
3273        attr;
3274        attr = qs_get_next_attr(doc,attr)) {
3275     char *nm  = qs_get_attr_name(doc,attr);
3276     char *val = qs_get_attr_value(doc,attr);
3277     if (val && STRCASEEQ('s','S',"style", nm)) {
3278       attr_style = val;
3279     }
3280   }
3281
3282   if (IS_CSS_ON(jxhtml->entryp)) {
3283     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
3284     if (style) {
3285       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
3286       
3287       css_property_t *cur;
3288       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
3289         css_clear = apr_pstrdup(doc->pool, cur->value);
3290       }
3291     }
3292   }
3293
3294   jxhtml->pre_flag++;
3295   W_L("<pre");
3296   if (css_clear) {
3297     W_L(" style=\"");
3298     W_L("clear:");
3299     W_V(css_clear);
3300     W_L(";");
3301     W_L("\"");
3302   }
3303   W_L(">");
3304   return jxhtml->out;
3305 }
3306
3307
3308 /**
3309  * It is a handler who processes the PRE tag.
3310  *
3311  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
3312  *                     destination is specified.
3313  * @param node   [i]   The PRE tag node is specified.
3314  * @return The conversion result is returned.
3315  */
3316 static char *
3317 s_jxhtml_end_pre_tag(void *pdoc, Node *UNUSED(child)) 
3318 {
3319   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
3320   Doc     *doc   = jxhtml->doc;
3321
3322   W_L("</pre>");
3323   jxhtml->pre_flag--;
3324   if (IS_CSS_ON(jxhtml->entryp)) {
3325     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
3326   }
3327
3328   return jxhtml->out;
3329 }
3330
3331
3332 /**
3333  * It is a handler who processes the UL tag.
3334  *
3335  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
3336  *                     destination is specified.
3337  * @param node   [i]   The UL tag node is specified.
3338  * @return The conversion result is returned.
3339  */
3340 static char *
3341 s_jxhtml_start_ul_tag(void *pdoc, Node *node)
3342 {
3343   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
3344   Doc      *doc    = jxhtml->doc;
3345   Attr     *attr;
3346   char     *attr_type = NULL;
3347   char     *attr_style = NULL;
3348   char     *css_clear  = NULL;
3349   
3350   /*--------------------------------------------------------------------------*/
3351   /* Get Attributes                                                           */
3352   /*--------------------------------------------------------------------------*/
3353   for (attr = qs_get_attr(doc,node);
3354        attr;
3355        attr = qs_get_next_attr(doc,attr)) {
3356     char *name   = qs_get_attr_name(doc,attr);
3357     char *value  = qs_get_attr_value(doc,attr);
3358     if (STRCASEEQ('t','T',"type",name)) {
3359       if (value && (STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
3360         attr_type = value;
3361       }
3362     }
3363     else if (value && *value && STRCASEEQ('s','S',"style", name)) {
3364       attr_style = value;
3365     }
3366   }
3367   if (IS_CSS_ON(jxhtml->entryp)) {
3368     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
3369     if (style) {
3370       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
3371       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
3372       
3373       css_property_t *cur;
3374       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3375         if (STRCASEEQ('d','D',"disc",cur->value)) {
3376           attr_type = apr_pstrdup(doc->pool, "disc");
3377         }
3378         else if (STRCASEEQ('c','C',"circle",cur->value)) {
3379           attr_type = apr_pstrdup(doc->pool, "circle");
3380         }
3381         else if (STRCASEEQ('s','S',"square",cur->value)) {
3382           attr_type = apr_pstrdup(doc->pool, "square");
3383         }
3384       }
3385       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
3386         css_clear = apr_pstrdup(doc->pool, cur->value);
3387       }
3388     }
3389   }
3390   W_L("<ul");
3391   if (attr_type || css_clear) {
3392     W_L(" style=\"");
3393     if (attr_type ){
3394       W_L("list-style-type:");
3395       W_V(attr_type);
3396       W_L(";");
3397     }
3398     if (css_clear){
3399       W_L("clear:");
3400       W_V(css_clear);
3401       W_L(";");
3402     }
3403     W_L("\"");
3404   }
3405   W_L(">");
3406   return jxhtml->out;
3407 }
3408
3409
3410 /**
3411  * It is a handler who processes the UL tag.
3412  *
3413  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
3414  *                     destination is specified.
3415  * @param node   [i]   The UL tag node is specified.
3416  * @return The conversion result is returned.
3417  */
3418 static char *
3419 s_jxhtml_end_ul_tag(void *pdoc, Node *UNUSED(child)) 
3420 {
3421   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
3422   Doc     *doc   = jxhtml->doc;
3423
3424   W_L("</ul>");
3425   if (IS_CSS_ON(jxhtml->entryp)) {
3426     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
3427   }
3428   return jxhtml->out;
3429 }
3430
3431
3432 /**
3433  * It is a handler who processes the HR tag.
3434  *
3435  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
3436  *                     destination is specified.
3437  * @param node   [i]   The HR tag node is specified.
3438  * @return The conversion result is returned.
3439  */
3440 static char *
3441 s_jxhtml_start_hr_tag(void *pdoc, Node *node) 
3442 {
3443   Attr        *attr;
3444   jxhtml_t     *jxhtml;
3445   Doc         *doc;
3446   request_rec *r;
3447   char        *attr_align   = NULL;
3448   char        *attr_size    = NULL;
3449   char        *attr_width   = NULL;
3450   char        *attr_noshade = NULL;
3451   char        *attr_style   = NULL;
3452   char        *attr_color   = NULL;
3453   
3454   char        *style_float  = NULL;
3455   char        *style_border_color = NULL;
3456   char        *css_clear          = NULL;
3457
3458   jxhtml   = GET_JXHTML(pdoc);
3459   doc     = jxhtml->doc;
3460   r       = doc->r;
3461
3462   for (attr = qs_get_attr(doc,node);
3463        attr; 
3464        attr = qs_get_next_attr(doc,attr)) {
3465     char *name  = qs_get_attr_name (doc,attr);
3466     char *value = qs_get_attr_value(doc,attr);
3467     switch(*name) {
3468     case 'a':
3469     case 'A':
3470       if (strcasecmp(name, "align") == 0) {
3471         /*--------------------------------------------------------------------*/
3472         /* CHTML 1.0                                                          */
3473         /*--------------------------------------------------------------------*/
3474         if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3475           attr_align = value;
3476         }
3477       }
3478       break;
3479
3480     case 's':
3481     case 'S':
3482       if (strcasecmp(name, "size") == 0) {
3483         /*--------------------------------------------------------------------*/
3484         /* CHTML 1.0                                                          */
3485         /*--------------------------------------------------------------------*/
3486         if (value && *value) {
3487           attr_size = value;
3488         }
3489       }
3490       else if (strcasecmp(name, "style") == 0) {
3491         if (value && *value) {
3492           attr_style = value;
3493         }
3494       }
3495       break;
3496
3497     case 'w':
3498     case 'W':
3499       if (strcasecmp(name, "width") == 0) {
3500         /*--------------------------------------------------------------------*/
3501         /* CHTML 1.0                                                          */
3502         /*--------------------------------------------------------------------*/
3503         if (value && *value) {
3504           attr_width = value;
3505         }
3506       }
3507       break;
3508
3509     case 'n':
3510     case 'N':
3511       if (strcasecmp(name, "noshade") == 0) {
3512         /*--------------------------------------------------------------------*/
3513         /* CHTML 1.0                                                          */
3514         /*--------------------------------------------------------------------*/
3515         attr_noshade = apr_pstrdup(doc->pool, "noshade");
3516       }
3517       break;
3518
3519     case 'c':
3520     case 'C':
3521       if (strcasecmp(name, "color") == 0 && value && *value) {
3522         /*--------------------------------------------------------------------*/
3523         /* CHTML 4.0                                                          */
3524         /*--------------------------------------------------------------------*/
3525         attr_color = value;
3526       }
3527       break;
3528
3529     default:
3530       break;
3531     }
3532   }
3533   if (IS_CSS_ON(jxhtml->entryp)) {
3534     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
3535     if (style) {
3536       css_property_t *border_style_prop = chxj_css_get_property_value(doc, style, "border-style");
3537       css_property_t *height_prop       = chxj_css_get_property_value(doc, style, "height");
3538       css_property_t *width_prop        = chxj_css_get_property_value(doc, style, "width");
3539       
3540       css_property_t *bgcolor_prop      = chxj_css_get_property_value(doc, style, "background-color");
3541       css_property_t *float_prop        = chxj_css_get_property_value(doc, style, "float");
3542       css_property_t *border_color_prop = chxj_css_get_property_value(doc, style, "border-color");
3543       css_property_t *clear_prop        = chxj_css_get_property_value(doc, style, "clear");
3544       css_property_t *cur;
3545       
3546       for (cur = border_style_prop->next; cur != border_style_prop; cur = cur->next) {
3547         if (STRCASEEQ('s','S',"solid",cur->value)) {
3548           attr_noshade = "noshade";
3549         }
3550       }
3551       for (cur = height_prop->next; cur != height_prop; cur = cur->next) {
3552         attr_size = apr_pstrdup(doc->pool, cur->value);
3553       }
3554       if(!attr_color){
3555           for(cur = bgcolor_prop->next; cur != bgcolor_prop; cur = cur->next){
3556           char *tmp   = apr_pstrdup(doc->pool,cur->value);
3557           attr_color  = apr_pstrdup(doc->pool,tmp);
3558         }
3559       }
3560       for (cur = float_prop->next; cur != float_prop; cur = cur->next) {
3561         char *tmp = apr_pstrdup(doc->pool, cur->value);
3562         char *tmpp = strstr(tmp,"none");
3563         if(tmpp){
3564           style_float = "center";
3565         }
3566         else{
3567           style_float = apr_pstrdup(doc->pool,tmp);
3568         }
3569       }
3570       
3571       
3572       for (cur = width_prop->next; cur != width_prop; cur = cur->next) {
3573         char *tmp = apr_pstrdup(doc->pool, cur->value);
3574         char *tmpp = strstr(tmp, "px");
3575         if (tmpp) {
3576           attr_width = apr_pstrdup(doc->pool, tmp);
3577         }
3578         else {
3579           tmpp = strstr(tmp, "%");
3580           if (tmpp) {
3581             attr_width = apr_pstrdup(doc->pool, tmp);
3582           }
3583         }
3584       }
3585       
3586       for (cur = border_color_prop->next; cur != border_color_prop; cur = cur->next) {
3587         char *tmp = apr_pstrdup(doc->pool, cur->value);
3588         if(tmp){
3589           style_border_color = apr_pstrdup(doc->pool, tmp);
3590         }
3591       }
3592       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
3593         css_clear = apr_pstrdup(doc->pool, cur->value);
3594       }
3595     }
3596   }
3597   W_L("<hr");
3598   if (attr_align) {
3599     W_L(" align=\"");
3600     W_V(attr_align);
3601     W_L("\"");
3602   }
3603   else{
3604     if(style_float){
3605       W_L(" align=\"");
3606       W_V(style_float);
3607       W_L("\"");
3608     }
3609   }
3610   if (attr_size || attr_width || attr_noshade || style_border_color || css_clear) {
3611     W_L(" style=\"");
3612     if (attr_size) {
3613       W_L("height:");
3614       W_V(attr_size);
3615       if (chxj_chk_numeric(attr_size) == 0) {
3616         W_L("px");
3617       }
3618       W_L(";");
3619     }
3620     if (attr_width) {
3621       W_L("width:");
3622       W_V(attr_width);
3623       if (!strstr(attr_width, "px") && !strstr(attr_width, "%")) {
3624         W_L("px");
3625       }
3626       W_L(";");
3627     }
3628     if (attr_noshade) {
3629       W_L("border-style:solid;");
3630     }
3631     if(style_border_color){
3632       W_L("border-color:");
3633       W_V(style_border_color);
3634       W_V(";");
3635     }
3636     if (css_clear){
3637       W_L("clear:");
3638       W_V(css_clear);
3639       W_L(";");
3640     }
3641     W_L("\"");
3642   }
3643   if (attr_color) {
3644     W_L(" color=\"");
3645     W_V(attr_color);
3646     W_L("\"");
3647   }
3648   
3649   W_L(" />");
3650
3651   return jxhtml->out;
3652 }
3653
3654
3655 /**
3656  * It is a handler who processes the HR tag.
3657  *
3658  * @param jxhtml  [i/o] The pointer to the JXHTML structure at the output
3659  *                     destination is specified.
3660  * @param node   [i]   The HR tag node is specified.
3661  * @return The conversion result is returned.
3662  */
3663 static char *
3664 s_jxhtml_end_hr_tag(void *pdoc, Node *UNUSED(child)) 
3665 {
3666   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
3667   return jxhtml->out;
3668 }
3669
3670
3671 /**
3672  * It is a handler who processes the IMG tag.
3673  *
3674  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
3675  *                     destination is specified.
3676  * @param node   [i]   The IMG tag node is specified.
3677  * @return The conversion result is returned.
3678  */
3679 static char *
3680 s_jxhtml_start_img_tag(void *pdoc, Node *node) 
3681 {
3682   jxhtml_t    *jxhtml = GET_JXHTML(pdoc);
3683   Doc         *doc   = jxhtml->doc;
3684   request_rec *r     = doc->r;
3685   Attr        *attr;
3686   char        *attr_src    = NULL;
3687   char        *attr_height = NULL;
3688   char        *attr_width  = NULL;
3689   char        *attr_alt    = NULL;
3690   char        *attr_style  = NULL;
3691   char        *attr_hspace = NULL;
3692   char        *attr_vspace = NULL;
3693   
3694   char        *css_float          = NULL;
3695   char        *css_margin_left    = NULL;
3696   char        *css_margin_right   = NULL;
3697   char        *css_margin_top     = NULL;
3698   char        *css_margin_bottom  = NULL;
3699   char        *css_display        = NULL;
3700   char        *css_valign         = NULL;
3701   
3702 #ifndef IMG_NOT_CONVERT_FILENAME
3703   device_table  *spec = jxhtml->spec;
3704 #endif
3705
3706   /*--------------------------------------------------------------------------*/
3707   /* Get Attributes                                                           */
3708   /*--------------------------------------------------------------------------*/
3709   for (attr = qs_get_attr(doc,node);
3710        attr;
3711        attr = qs_get_next_attr(doc,attr)) {
3712     char *name  = qs_get_attr_name(doc,attr);
3713     char *value = qs_get_attr_value(doc,attr);
3714     if (STRCASEEQ('s','S',"src",name)) {
3715       /*----------------------------------------------------------------------*/
3716       /* CHTML 1.0                                                            */
3717       /*----------------------------------------------------------------------*/
3718 #ifdef IMG_NOT_CONVERT_FILENAME
3719       value = chxj_encoding_parameter(r, value, 1);
3720       value = chxj_jreserved_tag_to_safe_for_query_string(r, value, jxhtml->entryp, 1);
3721       value = chxj_add_cookie_no_update_parameter(r, value, 1);
3722       value = chxj_img_rewrite_parameter(r,jxhtml->conf,value);
3723       attr_src = value;
3724 #else
3725       value = chxj_img_conv(r, spec, value);
3726       value = chxj_encoding_parameter(r, value, 1);
3727       value = chxj_jreserved_tag_to_safe_for_query_string(r, value, jxhtml->entryp, 1);
3728       value = chxj_add_cookie_no_update_parameter(r, value, 1);
3729       value = chxj_img_rewrite_parameter(r,jxhtml->conf,value);
3730       attr_src = value;
3731 #endif
3732     }
3733     else if (STRCASEEQ('a','A',"align",name)) {
3734       /*----------------------------------------------------------------------*/
3735       /* CHTML 1.0                                                            */
3736       /*----------------------------------------------------------------------*/
3737       if (value) {
3738         if (STRCASEEQ('t','T',"top",   value) ||
3739             STRCASEEQ('m','M',"middle",value) ||
3740             STRCASEEQ('b','B',"bottom",value)){
3741           css_valign = value;
3742         }else if (STRCASEEQ('l','L',"left",  value) || STRCASEEQ('r','R',"right", value)) {
3743           css_float = value;
3744         }
3745         else if (STRCASEEQ('c','C',"center",value)) {
3746           css_valign = apr_pstrdup(doc->pool, "middle");
3747         }
3748       }
3749     }
3750     else if (STRCASEEQ('w','W',"width",name) && value && *value) {
3751       /*----------------------------------------------------------------------*/
3752       /* CHTML 1.0                                                            */
3753       /*----------------------------------------------------------------------*/
3754       attr_width = value;
3755     }
3756     else if (STRCASEEQ('h','H',"height",name) && value && *value) {
3757       /*----------------------------------------------------------------------*/
3758       /* CHTML 1.0                                                            */
3759       /*----------------------------------------------------------------------*/
3760       attr_height = value;
3761     }
3762     else if (STRCASEEQ('h','H',"hspace",name)) {
3763       /*----------------------------------------------------------------------*/
3764       /* CHTML 1.0                                                            */
3765       /*----------------------------------------------------------------------*/
3766       attr_hspace = value;
3767     }
3768     else if (STRCASEEQ('v','V',"vspace",name)) {
3769       /*----------------------------------------------------------------------*/
3770       /* CHTML 1.0                                                            */
3771       /*----------------------------------------------------------------------*/
3772       attr_vspace = value;
3773     }
3774     else if (STRCASEEQ('a','A',"alt",name) && value && *value) {
3775       /*----------------------------------------------------------------------*/
3776       /* CHTML 1.0                                                            */
3777       /*----------------------------------------------------------------------*/
3778       attr_alt = value;
3779     }
3780     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3781       /*----------------------------------------------------------------------*/
3782       /* CHTML 1.0                                                            */
3783       /*----------------------------------------------------------------------*/
3784       attr_style = value;
3785     }
3786   }
3787
3788   if (IS_CSS_ON(jxhtml->entryp)) {
3789     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
3790     if (style) {
3791       css_property_t *height_prop = chxj_css_get_property_value(doc, style, "height");
3792       css_property_t *width_prop  = chxj_css_get_property_value(doc, style, "width");
3793       css_property_t *valign_prop = chxj_css_get_property_value(doc, style, "vertical-align");
3794       css_property_t *margin_left_prop   = chxj_css_get_property_value(doc, style, "margin-left");
3795       css_property_t *margin_right_prop  = chxj_css_get_property_value(doc, style, "margin-right");
3796       css_property_t *margin_top_prop    = chxj_css_get_property_value(doc, style, "margin-top");
3797       css_property_t *margin_bottom_prop = chxj_css_get_property_value(doc, style, "margin-bottom");
3798       
3799       
3800       css_property_t *cur;
3801       for (cur = height_prop->next; cur != height_prop; cur = cur->next) {
3802         attr_height = apr_pstrdup(doc->pool, cur->value);
3803       }
3804       for (cur = width_prop->next; cur != width_prop; cur = cur->next) {
3805         attr_width = apr_pstrdup(doc->pool, cur->value);
3806       }
3807       if(!css_valign){
3808         for (cur = valign_prop->next; cur != valign_prop; cur = cur->next) {
3809           css_valign = apr_pstrdup(doc->pool, cur->value);
3810         }
3811       }
3812       if (! attr_hspace) {
3813         for (cur = margin_left_prop->next; cur != margin_left_prop; cur = cur->next) {
3814           css_margin_left   = apr_pstrdup(doc->pool, cur->value);
3815         }
3816         for (cur = margin_right_prop->next; cur != margin_right_prop; cur = cur->next) {
3817           css_margin_right  = apr_pstrdup(doc->pool, cur->value);
3818         }
3819       }
3820       if (! attr_vspace) {
3821         for (cur = margin_top_prop->next; cur != margin_top_prop; cur = cur->next) {
3822           css_margin_top = apr_pstrdup(doc->pool, cur->value);
3823         }
3824         for (cur = margin_bottom_prop->next; cur != margin_bottom_prop; cur = cur->next) {
3825           css_margin_bottom = apr_pstrdup(doc->pool, cur->value);
3826         }
3827       }
3828       if(!css_float){
3829         css_property_t *float_prop = chxj_css_get_property_value(doc, style, "float");
3830         for (cur = float_prop->next; cur != float_prop; cur = cur->next) {
3831           css_float = apr_pstrdup(doc->pool, cur->value);
3832         }
3833       }
3834       
3835       css_property_t *display_prop       = chxj_css_get_property_value(doc, style, "display");
3836       for (cur = display_prop->next; cur != display_prop; cur = cur->next) {
3837         char *tmp = apr_pstrdup(doc->pool, cur->value);
3838         char *tmpp = strstr(tmp, "none");
3839         if(tmpp){
3840           css_display = apr_pstrdup(doc->pool, tmp);
3841         }
3842       }
3843     }
3844   }
3845
3846   W_L("<img");
3847   if (attr_src) {
3848     W_L(" src=\"");
3849     W_V(attr_src);
3850     W_L("\"");
3851   }
3852   if (attr_hspace || attr_vspace || css_float || css_margin_left || css_margin_right || css_margin_top || css_margin_bottom || css_valign || css_display) {
3853     W_L(" style=\"");
3854     if(css_float){
3855       W_L("float:");
3856       W_V(css_float);
3857       W_L(";");
3858     }
3859     if(css_valign){
3860       W_L("vertical-align:");
3861       W_V(css_valign);
3862       W_L(";");
3863     }
3864     if (attr_hspace) {
3865       W_L("margin-left:");
3866       W_V(attr_hspace);
3867       W_L(";");
3868       W_L("margin-right:");
3869       W_V(attr_hspace);
3870       W_L(";");
3871     }
3872     else{
3873       if(css_margin_left){
3874         W_L("margin-left:");
3875         W_V(css_margin_left);
3876         W_L(";");
3877       }
3878       if(css_margin_right){
3879         W_L("margin-right:");
3880         W_V(css_margin_right);
3881         W_L(";");
3882       }
3883     }
3884     if (attr_vspace) {
3885       W_L("margin-top:");
3886       W_V(attr_vspace);
3887       W_L(";");
3888       W_L("margin-bottom:");
3889       W_V(attr_vspace);
3890       W_L(";");
3891     }
3892     else{
3893       if(css_margin_top){
3894         W_L("margin-top:");
3895         W_V(css_margin_top);
3896         W_L(";");
3897       }
3898       if(css_margin_bottom){
3899         W_L("margin-bottom:");
3900         W_V(css_margin_bottom);
3901         W_L(";");
3902       }
3903     }
3904     if(css_display){
3905       W_L("display:none;");
3906     }
3907     W_L("\"");
3908   }
3909   
3910   if (attr_width) {
3911     W_L(" width=\"");
3912     W_V(attr_width);
3913     W_L("\"");
3914   }
3915   if (attr_height) {
3916     W_L(" height=\"");
3917     W_V(attr_height);
3918     W_L("\"");
3919   }
3920   if (attr_alt) {
3921     W_L(" alt=\"");
3922     W_V(attr_alt);
3923     W_L("\"");
3924   } 
3925   else {
3926     W_L(" alt=\"\"");
3927   }
3928   W_L(" />");
3929   return jxhtml->out;
3930 }
3931
3932
3933 /**
3934  * It is a handler who processes the IMG tag.
3935  *
3936  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
3937  *                     destination is specified.
3938  * @param node   [i]   The IMG tag node is specified.
3939  * @return The conversion result is returned.
3940  */
3941 static char *
3942 s_jxhtml_end_img_tag(void *pdoc, Node *UNUSED(child)) 
3943 {
3944   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
3945   return jxhtml->out;
3946 }
3947
3948
3949 /**
3950  * It is a handler who processes the SELECT tag.
3951  *
3952  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
3953  *                     destination is specified.
3954  * @param node   [i]   The SELECT tag node is specified.
3955  * @return The conversion result is returned.
3956  */
3957 static char *
3958 s_jxhtml_start_select_tag(void *pdoc, Node *node)
3959 {
3960   jxhtml_t *jxhtml    = GET_JXHTML(pdoc);
3961   Doc     *doc      = jxhtml->doc;
3962   Attr    *attr;
3963   char    *size     = NULL;
3964   char    *name     = NULL;
3965   char    *multiple = NULL;
3966   char    *attr_style = NULL;
3967
3968   W_L("<select");
3969   for (attr = qs_get_attr(doc,node);
3970        attr;
3971        attr = qs_get_next_attr(doc,attr)) {
3972     char *nm  = qs_get_attr_name(doc,attr);
3973     char *val = qs_get_attr_value(doc,attr);
3974     if (STRCASEEQ('s','S',"size",nm)) {
3975       /*----------------------------------------------------------------------*/
3976       /* CHTML 1.0 version 2.0                                                */
3977       /*----------------------------------------------------------------------*/
3978       size = apr_pstrdup(doc->buf.pool, val);
3979     }
3980     else if (STRCASEEQ('s','S',"style",nm) && val && *val) {
3981       /*----------------------------------------------------------------------*/
3982       /* CHTML 1.0 version 2.0                                                */
3983       /*----------------------------------------------------------------------*/
3984       attr_style = apr_pstrdup(doc->buf.pool, val);
3985     }
3986     else if (STRCASEEQ('n','N',"name",nm)) {
3987       /*----------------------------------------------------------------------*/
3988       /* CHTML 1.0 version 2.0                                                */
3989       /*----------------------------------------------------------------------*/
3990       name = apr_pstrdup(doc->buf.pool, val);
3991     }
3992     else if (STRCASEEQ('m','M',"multiple", nm)) {
3993       /*----------------------------------------------------------------------*/
3994       /* CHTML 1.0 version 2.0                                                */
3995       /*----------------------------------------------------------------------*/
3996       multiple = apr_pstrdup(doc->buf.pool, val);
3997     }
3998   }
3999   if (size && *size) {
4000     W_L(" size=\"");
4001     W_V(size);
4002     W_L("\"");
4003   }
4004   if (name && *name) {
4005     W_L(" name=\"");
4006     W_V(name);
4007     W_L("\"");
4008   }
4009   if (multiple) {
4010     W_L(" multiple");
4011   }
4012   W_L(">");
4013
4014   if (IS_CSS_ON(jxhtml->entryp)) {
4015     s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
4016   }
4017
4018   return jxhtml->out;
4019 }
4020
4021
4022 /**
4023  * It is a handler who processes the SELECT tag.
4024  *
4025  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4026  *                     destination is specified.
4027  * @param node   [i]   The SELECT tag node is specified.
4028  * @return The conversion result is returned.
4029  */
4030 static char *
4031 s_jxhtml_end_select_tag(void *pdoc, Node *UNUSED(child))
4032 {
4033   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
4034   Doc     *doc   = jxhtml->doc;
4035
4036   W_L("</select>");
4037   if (IS_CSS_ON(jxhtml->entryp)) {
4038     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
4039   }
4040
4041   return jxhtml->out;
4042 }
4043
4044 /**
4045  * It is a handler who processes the OPTION tag.
4046  *
4047  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4048  *                     destination is specified.
4049  * @param node   [i]   The OPTION tag node is specified.
4050  * @return The conversion result is returned.
4051  */
4052 static char *
4053 s_jxhtml_start_option_tag(void *pdoc, Node *node)
4054 {
4055   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
4056   Doc     *doc   = jxhtml->doc;
4057   Attr    *attr;
4058
4059   char *selected   = NULL;
4060   char *value      = NULL;
4061   char *attr_style = NULL;
4062
4063   W_L("<option");
4064   for (attr = qs_get_attr(doc,node);
4065        attr;
4066        attr = qs_get_next_attr(doc,attr)) {
4067     char *nm  = qs_get_attr_name(doc,attr);
4068     char *val = qs_get_attr_value(doc,attr);
4069     if (STRCASEEQ('s','S',"selected",nm)) {
4070       /*----------------------------------------------------------------------*/
4071       /* CHTML 1.0 version 2.0                                                */
4072       /*----------------------------------------------------------------------*/
4073       selected = apr_pstrdup(doc->buf.pool, val);
4074     }
4075     else if (STRCASEEQ('s','S',"style",nm) && val && *val) {
4076       /*----------------------------------------------------------------------*/
4077       /* CHTML 1.0 version 2.0                                                */
4078       /*----------------------------------------------------------------------*/
4079       attr_style = apr_pstrdup(doc->buf.pool, val);
4080     }
4081     else if (STRCASEEQ('v','V',"value",nm)) {
4082       /*----------------------------------------------------------------------*/
4083       /* CHTML 1.0 version 2.0                                                */
4084       /*----------------------------------------------------------------------*/
4085       value = apr_pstrdup(doc->buf.pool, val);
4086     }
4087   }
4088   if (value) {
4089     W_L(" value=\"");
4090     W_V(value);
4091     W_L("\"");
4092   }
4093   if (selected) {
4094     W_L(" selected");
4095   }
4096   W_L(">");
4097
4098   if (IS_CSS_ON(jxhtml->entryp)) {
4099     s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
4100   }
4101
4102   return jxhtml->out;
4103 }
4104
4105
4106 /**
4107  * It is a handler who processes the OPTION tag.
4108  *
4109  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4110  *                     destination is specified.
4111  * @param node   [i]   The OPTION tag node is specified.
4112  * @return The conversion result is returned.
4113  */
4114 static char *
4115 s_jxhtml_end_option_tag(void *pdoc, Node *UNUSED(child))
4116 {
4117   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
4118   Doc      *doc = jxhtml->doc;
4119
4120   W_L("</option>");
4121   if (IS_CSS_ON(jxhtml->entryp)) {
4122     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
4123   }
4124
4125   return jxhtml->out;
4126 }
4127
4128
4129 /**
4130  * It is a handler who processes the DIV tag.
4131  *
4132  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4133  *                     destination is specified.
4134  * @param node   [i]   The DIV tag node is specified.
4135  * @return The conversion result is returned.
4136  */
4137 static char *
4138 s_jxhtml_start_div_tag(void *pdoc, Node *node)
4139 {
4140   jxhtml_t    *jxhtml;
4141   Doc         *doc;
4142   request_rec *r;
4143   Attr        *attr;
4144   char        *attr_style             = NULL;
4145   char        *attr_align             = NULL;
4146   char        *attr_display           = NULL;
4147   char        *attr_decoration        = NULL;
4148   char        *attr_wap_marquee_style = NULL;
4149   char        *attr_wap_marquee_dir   = NULL;
4150   char        *attr_wap_marquee_loop  = NULL;
4151   char        *attr_color             = NULL;
4152   char        *attr_bgcolor           = NULL;
4153   char        *attr_font_size         = NULL;
4154   char        *css_clear              = NULL;
4155
4156   jxhtml = GET_JXHTML(pdoc);
4157   doc   = jxhtml->doc;
4158   r     = doc->r;
4159
4160   for (attr = qs_get_attr(doc,node);
4161        attr;
4162        attr = qs_get_next_attr(doc,attr)) {
4163     char *nm  = qs_get_attr_name(doc,attr);
4164     char *val = qs_get_attr_value(doc,attr);
4165     if (STRCASEEQ('a','A',"align",nm)) {
4166       /*----------------------------------------------------------------------*/
4167       /* CHTML 1.0 (W3C version 3.2)                                          */
4168       /*----------------------------------------------------------------------*/
4169       if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
4170         attr_align = apr_pstrdup(doc->buf.pool, val);
4171       }
4172     }
4173     else if (STRCASEEQ('s','S',"style",nm) && val && *val) {
4174       attr_style = apr_pstrdup(doc->buf.pool, val);
4175     }
4176   }
4177
4178   if (IS_CSS_ON(jxhtml->entryp)) {
4179     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
4180     if (style) {
4181       css_property_t *display_prop           = chxj_css_get_property_value(doc, style, "display");
4182       css_property_t *text_decoration_prop   = chxj_css_get_property_value(doc, style, "text-decoration");
4183       css_property_t *color_prop             = chxj_css_get_property_value(doc, style, "color");
4184       css_property_t *text_align_prop        = chxj_css_get_property_value(doc, style, "text-align");
4185       css_property_t *font_size_prop         = chxj_css_get_property_value(doc, style, "font-size");
4186       css_property_t *background_color_prop  = chxj_css_get_property_value(doc, style, "background-color");
4187       css_property_t *background_prop        = chxj_css_get_property_value(doc, style, "background");
4188       css_property_t *clear_prop             = chxj_css_get_property_value(doc, style, "clear");
4189
4190       css_property_t *cur;
4191       for (cur = display_prop->next; cur != display_prop; cur = cur->next) {
4192         if (strcasecmp("-wap-marquee", cur->value) == 0) {
4193           attr_display = apr_pstrdup(doc->pool, cur->value);
4194         }
4195       }
4196       for (cur = text_decoration_prop->next; cur != text_decoration_prop; cur = cur->next) {
4197         if (STRCASEEQ('b','B',"blink", cur->value)) {
4198           attr_decoration = apr_pstrdup(doc->pool, cur->value);
4199         }
4200       }
4201       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4202         attr_color = apr_pstrdup(doc->pool, cur->value);
4203       }
4204       for (cur = background_color_prop->next; cur != background_color_prop; cur = cur->next) {
4205         attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
4206         attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
4207       }
4208       for (cur = background_prop->next; cur != background_prop; cur = cur->next) {
4209         char *ss = strchr(cur->value, '#');
4210         if (!ss || !*ss) {
4211           ss = strstr(cur->value, "rgb");
4212         }
4213         if (ss && *ss) {
4214           attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
4215           attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
4216         }
4217       }
4218       for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
4219         attr_align = apr_pstrdup(doc->pool, cur->value);
4220       }
4221       for (cur = font_size_prop->next; cur != font_size_prop; cur = cur->next) {
4222         if (   STRCASEEQ('x','X',"xx-small",cur->value)
4223             || STRCASEEQ('x','X',"x-small",cur->value)
4224             || STRCASEEQ('s','S',"small",cur->value)
4225             || STRCASEEQ('m','M',"medium",cur->value)
4226             || STRCASEEQ('l','L',"large",cur->value)
4227             || STRCASEEQ('x','X',"x-large",cur->value)
4228             || STRCASEEQ('x','X',"xx-large",cur->value)) {
4229           attr_font_size = apr_pstrdup(doc->pool, cur->value);
4230         }
4231       }
4232       if (attr_display) {
4233         css_property_t *wap_marquee_style_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-style");
4234         css_property_t *wap_marquee_dir_prop   = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
4235         css_property_t *wap_marquee_loop_prop  = chxj_css_get_property_value(doc, style, "-wap-marquee-loop");
4236         for (cur = wap_marquee_style_prop->next; cur != wap_marquee_style_prop; cur = cur->next) {
4237           if (STRCASEEQ('s','S',"scroll", cur->value) || STRCASEEQ('s','S',"slide",cur->value) || STRCASEEQ('a','A',"alternate",cur->value)) {
4238             attr_wap_marquee_style = apr_pstrdup(doc->pool, cur->value);
4239           }
4240         }
4241         for (cur = wap_marquee_dir_prop->next; cur != wap_marquee_dir_prop; cur = cur->next) {
4242           if (STRCASEEQ('l','L',"ltr",cur->value)) {
4243             attr_wap_marquee_dir = apr_pstrdup(doc->pool, cur->value);
4244           }
4245           else if (STRCASEEQ('r','R',"rtl",cur->value)) {
4246             attr_wap_marquee_dir = apr_pstrdup(doc->pool, cur->value);
4247           }
4248         }
4249         for (cur = wap_marquee_loop_prop->next; cur != wap_marquee_loop_prop; cur = cur->next) {
4250           if(strcmp(cur->value,"0") == 0 || strcmp(cur->value,"-1") == 0){
4251             attr_wap_marquee_loop = "infinite";
4252           }
4253           else{
4254             attr_wap_marquee_loop = apr_pstrdup(doc->pool, cur->value);
4255           }
4256         }
4257       }
4258       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
4259         css_clear = apr_pstrdup(doc->pool, cur->value);
4260       }
4261     }
4262   }  
4263   W_L("<div");
4264   if (attr_align
4265       || attr_display
4266       || attr_decoration
4267       || attr_wap_marquee_style
4268       || attr_wap_marquee_dir
4269       || attr_wap_marquee_loop
4270       || attr_color
4271       || attr_bgcolor
4272       || attr_font_size
4273       || css_clear ) {
4274     W_L(" style=\"");
4275     if (attr_align) {
4276       W_L("text-align:");
4277       W_V(attr_align);
4278       W_L(";");
4279     }
4280     if (attr_display) {
4281       W_L("display:");
4282       W_V(attr_display);
4283       W_L(";");
4284     }
4285     if (attr_decoration) {
4286       W_L("text-decoration:");
4287       W_V(attr_decoration);
4288       W_L(";");
4289     }
4290     if (attr_wap_marquee_style) {
4291       W_L("-wap-marquee-style:");
4292       W_V(attr_wap_marquee_style);
4293       W_L(";");
4294     }
4295     if (attr_wap_marquee_dir) {
4296       W_L("-wap-marquee-dir:");
4297       W_V(attr_wap_marquee_dir);
4298       W_L(";");
4299     }
4300     if (attr_wap_marquee_loop) {
4301       W_L("-wap-marquee-loop:");
4302       W_V(attr_wap_marquee_loop);
4303       W_L(";");
4304     }
4305     if (attr_color) {
4306       W_L("color:");
4307       W_V(attr_color);
4308       W_L(";");
4309     }
4310     if (attr_bgcolor) {
4311       W_L("background-color:");
4312       W_V(attr_bgcolor);
4313       W_L(";");
4314     }
4315     if (attr_font_size) {
4316       W_L("font-size:");
4317       W_V(attr_font_size);
4318       W_L(";");
4319     }
4320     if (css_clear){
4321       W_L("clear:");
4322       W_V(css_clear);
4323       W_L(";");
4324     }
4325     W_L("\"");
4326   }
4327   W_L(">");
4328   return jxhtml->out;
4329 }
4330
4331
4332 /**
4333  * It is a handler who processes the DIV tag.
4334  *
4335  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4336  *                     destination is specified.
4337  * @param node   [i]   The DIV tag node is specified.
4338  * @return The conversion result is returned.
4339  */
4340 static char *
4341 s_jxhtml_end_div_tag(void *pdoc, Node *UNUSED(child))
4342 {
4343   jxhtml_t      *jxhtml;
4344   Doc          *doc;
4345   request_rec  *r;
4346
4347   jxhtml = GET_JXHTML(pdoc);
4348   doc   = jxhtml->doc;
4349   r     = doc->r;
4350
4351   W_L("</div>");
4352   if (IS_CSS_ON(jxhtml->entryp)) {
4353     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
4354   }
4355   return jxhtml->out;
4356 }
4357
4358
4359 static char *
4360 s_jxhtml_chxjif_tag(void *pdoc, Node *node)
4361 {
4362   jxhtml_t *jxhtml;
4363   Doc     *doc;
4364   Node    *child;
4365   request_rec *r;
4366
4367   jxhtml = GET_JXHTML(pdoc);
4368   doc   = jxhtml->doc;
4369   r     = doc->r;
4370
4371   for (child = qs_get_child_node(doc, node);
4372        child;
4373        child = qs_get_next_node(doc, child)) {
4374     W_V(child->otext);
4375     s_jxhtml_chxjif_tag(jxhtml, child);
4376   }
4377   return NULL;
4378 }
4379
4380
4381 /**
4382  * It is a handler who processes the TEXTARE tag.
4383  *
4384  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4385  *                     destination is specified.
4386  * @param node   [i]   The TEXTAREA tag node is specified.
4387  * @return The conversion result is returned.
4388  */
4389 static char *
4390 s_jxhtml_start_textarea_tag(void *pdoc, Node *node) 
4391 {
4392   jxhtml_t      *jxhtml;
4393   Doc           *doc;
4394   request_rec   *r;
4395   Attr          *attr;
4396   char          *attr_accesskey = NULL;
4397   char          *attr_name      = NULL;
4398   char          *attr_rows      = NULL;
4399   char          *attr_cols      = NULL;
4400   char          *attr_istyle    = NULL;
4401   char          *attr_style     = NULL;
4402
4403
4404   jxhtml = GET_JXHTML(pdoc);
4405   doc   = jxhtml->doc;
4406   r     = doc->r;
4407
4408   jxhtml->textarea_flag++;
4409   for (attr = qs_get_attr(doc,node);
4410        attr;
4411        attr = qs_get_next_attr(doc,attr)) {
4412     char *name  = qs_get_attr_name(doc,attr);
4413     char *value = qs_get_attr_value(doc,attr);
4414     if (STRCASEEQ('a','A',"accesskey",name) && value && *value != 0) {
4415       attr_accesskey = value;
4416     }
4417     else if (STRCASEEQ('i','I',"istyle", name) && value && (*value == '1' || *value == '2' || *value == '3' || *value == '4')) {
4418       attr_istyle = value;
4419     }
4420     else if (STRCASEEQ('n','N',"name", name) && value && *value) {
4421       attr_name = value;
4422     }
4423     else if (STRCASEEQ('r','R',"rows", name) && value && *value) {
4424       attr_rows = value;
4425     }
4426     else if (STRCASEEQ('c','C',"cols", name) && value && *value) {
4427       attr_cols = value;
4428     }
4429     else if (STRCASEEQ('s','S',"style", name) && value && *value) {
4430       attr_style = value;
4431     }
4432   }
4433   if (IS_CSS_ON(jxhtml->entryp)) {
4434     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
4435     if (style) {
4436       css_property_t *wap_input_format = chxj_css_get_property_value(doc, style, "-wap-input-format");
4437       css_property_t *cur;
4438       for (cur = wap_input_format->next; cur != wap_input_format; cur = cur->next) {
4439         if (strcasestr(cur->value, "<ja:n>")) {
4440           attr_istyle = "4";
4441         }
4442         else if (strcasestr(cur->value, "<ja:en>")) {
4443           attr_istyle = "3";
4444         }
4445         else if (strcasestr(cur->value, "<ja:hk>")) {
4446           attr_istyle = "2";
4447         }
4448         else if (strcasestr(cur->value, "<ja:h>")) {
4449           attr_istyle = "1";
4450         }
4451       }
4452     }
4453   }
4454   W_L("<textarea");
4455   if (attr_accesskey) {
4456     W_L(" accesskey=\"");
4457     W_V(attr_accesskey);
4458     W_L("\"");
4459   }
4460   if (attr_name) {
4461     W_L(" name=\"");
4462     W_V(attr_name);
4463     W_L("\"");
4464   }
4465   if (attr_rows) {
4466     W_L(" rows=\"");
4467     W_V(attr_rows);
4468     W_L("\"");
4469   }
4470   if (attr_cols) {
4471     W_L(" cols=\"");
4472     W_V(attr_cols);
4473     W_L("\"");
4474   }
4475   if (attr_istyle) {
4476     W_L(" istyle=\"");
4477     W_V(attr_istyle);
4478     W_L("\"");
4479
4480     char *vv = s_jxhtml_istyle_to_wap_input_format(doc->buf.pool,attr_istyle);
4481         W_L(" style=\"");
4482         W_L("-wap-input-format:");
4483         W_V(vv);
4484         W_L(";");
4485         W_L("\"");
4486
4487   }
4488   W_L(">");
4489   return jxhtml->out;
4490 }
4491
4492
4493 /**
4494  * It is a handler who processes the TEXTAREA tag.
4495  *
4496  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4497  *                     destination is specified.
4498  * @param node   [i]   The TEXTAREA tag node is specified.
4499  * @return The conversion result is returned.
4500  */
4501 static char *
4502 s_jxhtml_end_textarea_tag(void *pdoc, Node *UNUSED(child)) 
4503 {
4504   jxhtml_t       *jxhtml;
4505   Doc           *doc;
4506   request_rec   *r;
4507
4508   jxhtml = GET_JXHTML(pdoc);
4509   doc   = jxhtml->doc;
4510   r     = doc->r;
4511
4512   W_L("</textarea>");
4513   jxhtml->textarea_flag--;
4514
4515   return jxhtml->out;
4516 }
4517
4518
4519 /**
4520  * It is a handler who processes the B tag.
4521  *
4522  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4523  *                     destination is specified.
4524  * @param node   [i]   The B tag node is specified.
4525  * @return The conversion result is returned.
4526  */
4527 static char*
4528 s_jxhtml_start_b_tag(void* pdoc, Node* UNUSED(node)) 
4529 {
4530   jxhtml_t*      jxhtml;
4531   Doc*          doc;
4532   request_rec*  r;
4533
4534   jxhtml = GET_JXHTML(pdoc);
4535   doc   = jxhtml->doc;
4536   r     = doc->r;
4537
4538   W_L("<b>");
4539   return jxhtml->out;
4540 }
4541
4542
4543 /**
4544  * It is a handler who processes the B tag.
4545  *
4546  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4547  *                     destination is specified.
4548  * @param node   [i]   The B tag node is specified.
4549  * @return The conversion result is returned.
4550  */
4551 static char*
4552 s_jxhtml_end_b_tag(void* pdoc, Node* UNUSED(child)) 
4553 {
4554   jxhtml_t*      jxhtml = GET_JXHTML(pdoc);
4555   Doc*          doc   = jxhtml->doc;
4556
4557   W_L("</b>");
4558   return jxhtml->out;
4559 }
4560
4561 static char*
4562 s_jxhtml_text_tag(void* pdoc, Node* child)
4563 {
4564   jxhtml_t*     jxhtml;
4565   Doc*         doc;
4566   char*        textval;
4567   char*        tmp;
4568   char*        tdst;
4569   char         one_byte[2];
4570   int          ii;
4571   int          tdst_len;
4572   request_rec* r;
4573   apr_size_t   z2h_input_len;
4574
4575   jxhtml = GET_JXHTML(pdoc);
4576   doc   = jxhtml->doc;
4577   r     = doc->r;
4578
4579   textval = qs_get_node_value(doc,child);
4580   if (strlen(textval) == 0) {
4581     return jxhtml->out;
4582   }
4583
4584   tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
4585   memset(tmp, 0, qs_get_node_size(doc,child)+1);
4586
4587   tdst     = qs_alloc_zero_byte_string(doc->buf.pool);
4588   memset(one_byte, 0, sizeof(one_byte));
4589   tdst_len = 0;
4590
4591   for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
4592     char* out;
4593     int rtn = s_jxhtml_search_emoji(jxhtml, &textval[ii], &out);
4594     if (rtn) {
4595       tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
4596       ii+=(rtn - 1);
4597       continue;
4598     }
4599
4600     if (is_sjis_kanji(textval[ii])) {
4601       one_byte[0] = textval[ii+0];
4602       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
4603       one_byte[0] = textval[ii+1];
4604       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
4605       ii++;
4606     }
4607     else 
4608     if (jxhtml->pre_flag) {
4609       one_byte[0] = textval[ii+0];
4610       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
4611     }
4612     else
4613     if (jxhtml->textarea_flag) {
4614       one_byte[0] = textval[ii+0];
4615       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
4616     }
4617     else {
4618       if (textval[ii] != '\r' && textval[ii] != '\n') {
4619         one_byte[0] = textval[ii+0];
4620         tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
4621       }
4622     }
4623   }
4624   z2h_input_len = strlen(tdst);
4625   tdst = chxj_conv_z2h(r, tdst, &z2h_input_len, jxhtml->entryp);
4626
4627   W_V(tdst);
4628   return jxhtml->out;
4629 }
4630
4631
4632 /**
4633  * It is a handler who processes the BLOCKQUOTE tag.
4634  *
4635  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4636  *                     destination is specified.
4637  * @param node   [i]   The BLOCKQUOTE tag node is specified.
4638  * @return The conversion result is returned.
4639  */
4640 static char *
4641 s_jxhtml_start_blockquote_tag(void *pdoc, Node *node)
4642 {
4643   jxhtml_t *jxhtml;
4644   Doc      *doc;
4645   Attr     *attr;
4646   char     *attr_style = NULL;
4647   char     *attr_color = NULL;
4648   char     *attr_size  = NULL;
4649   char     *css_clear  = NULL;
4650
4651   jxhtml  = GET_JXHTML(pdoc);
4652   doc     = jxhtml->doc;
4653   for (attr = qs_get_attr(doc,node);
4654        attr;
4655        attr = qs_get_next_attr(doc,attr)) {
4656     char *nm  = qs_get_attr_name(doc,attr);
4657     char *val = qs_get_attr_value(doc,attr);
4658     if (val && STRCASEEQ('s','S',"style", nm)) {
4659       attr_style = val;
4660     }
4661   }
4662   if (IS_CSS_ON(jxhtml->entryp)) {
4663     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
4664     if (style) {
4665       css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4666       css_property_t *font_size_prop = chxj_css_get_property_value(doc, style, "font-size");
4667       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
4668       
4669       css_property_t *cur;
4670       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4671         if (cur->value && *cur->value) {
4672           attr_color = apr_pstrdup(doc->pool, cur->value);
4673         }
4674       }
4675       for (cur = font_size_prop->next; cur != font_size_prop; cur = cur->next) {
4676         if (cur->value && *cur->value) {
4677           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
4678             attr_size = apr_pstrdup(doc->pool, cur->value);
4679           }
4680           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
4681             attr_size = apr_pstrdup(doc->pool, cur->value);
4682           }
4683           else if (STRCASEEQ('s','S',"small",cur->value)) {
4684             attr_size = apr_pstrdup(doc->pool, cur->value);
4685           }
4686           else if (STRCASEEQ('m','M',"medium",cur->value)) {
4687             attr_size = apr_pstrdup(doc->pool, cur->value);
4688           }
4689           else if (STRCASEEQ('l','L',"large",cur->value)) {
4690             attr_size = apr_pstrdup(doc->pool, cur->value);
4691           }
4692           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
4693             attr_size = apr_pstrdup(doc->pool, cur->value);
4694           }
4695           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
4696             attr_size = apr_pstrdup(doc->pool, cur->value);
4697           }
4698         }
4699       }
4700       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
4701         css_clear = apr_pstrdup(doc->pool, cur->value);
4702       }
4703     }
4704   }
4705   W_L("<blockquote");
4706   if (attr_color || attr_size || css_clear) {
4707     W_L(" style=\"");
4708     if (attr_color) {
4709       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4710       W_L("color:");
4711       W_V(attr_color);
4712       W_L(";");
4713     }
4714     if (attr_size) {
4715       W_L("font-size:");
4716       W_V(attr_size);
4717       W_L(";");
4718     }
4719     if (css_clear){
4720       W_L("clear:");
4721       W_V(css_clear);
4722       W_L(";");
4723     }
4724     W_L("\"");
4725   }
4726   W_L(">");
4727   return jxhtml->out;
4728 }
4729
4730
4731 /**
4732  * It is a handler who processes the BLOCKQUOTE tag.
4733  *
4734  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4735  *                     destination is specified.
4736  * @param node   [i]   The BLOCKQUOTE tag node is specified.
4737  * @return The conversion result is returned.
4738  */
4739 static char *
4740 s_jxhtml_end_blockquote_tag(void *pdoc, Node *UNUSED(child))
4741 {
4742   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
4743   Doc     *doc   = jxhtml->doc;
4744   W_L("</blockquote>");
4745   if (IS_CSS_ON(jxhtml->entryp)) {
4746     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
4747   }
4748   return jxhtml->out;
4749 }
4750
4751
4752 /**
4753  * It is a handler who processes the DIR tag.
4754  *
4755  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4756  *                     destination is specified.
4757  * @param node   [i]   The DIR tag node is specified.
4758  * @return The conversion result is returned.
4759  */
4760 static char *
4761 s_jxhtml_start_dir_tag(void *pdoc, Node *node)
4762 {
4763   jxhtml_t *jxhtml      = GET_JXHTML(pdoc);
4764   Doc       *doc        = jxhtml->doc;
4765   Attr      *attr;
4766   char      *attr_style = NULL;
4767   char      *attr_color = NULL;
4768   char      *attr_type  = NULL;
4769   char      *attr_size  = NULL;
4770   for (attr = qs_get_attr(doc,node);
4771        attr;
4772        attr = qs_get_next_attr(doc,attr)) {
4773     char *name   = qs_get_attr_name(doc,attr);
4774     char *value  = qs_get_attr_value(doc,attr);
4775     if (STRCASEEQ('t','T',"type",name)) {
4776       if (value && (STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
4777         attr_type = value;
4778       }
4779     }
4780     else if (STRCASEEQ('s','S',"style", name) && value && *value) {
4781       attr_style = value;
4782     }
4783   }
4784   if (IS_CSS_ON(jxhtml->entryp)) {
4785     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
4786     if (style) {
4787       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
4788       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
4789       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
4790       css_property_t *cur;
4791       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4792         if (cur->value && *cur->value) {
4793           attr_color = apr_pstrdup(doc->pool, cur->value);
4794         }
4795       }
4796       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
4797         if (cur->value && *cur->value) {
4798           attr_type = apr_pstrdup(doc->pool, cur->value);
4799         }
4800       }
4801       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
4802         if (cur->value && *cur->value) {
4803           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
4804             attr_size = apr_pstrdup(doc->pool, cur->value);
4805           }
4806           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
4807             attr_size = apr_pstrdup(doc->pool, cur->value);
4808           }
4809           else if (STRCASEEQ('s','S',"small",cur->value)) {
4810             attr_size = apr_pstrdup(doc->pool, cur->value);
4811           }
4812           else if (STRCASEEQ('m','M',"medium",cur->value)) {
4813             attr_size = apr_pstrdup(doc->pool, cur->value);
4814           }
4815           else if (STRCASEEQ('l','L',"large",cur->value)) {
4816             attr_size = apr_pstrdup(doc->pool, cur->value);
4817           }
4818           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
4819             attr_size = apr_pstrdup(doc->pool, cur->value);
4820           }
4821           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
4822             attr_size = apr_pstrdup(doc->pool, cur->value);
4823           }
4824         }
4825       }
4826     }
4827   }
4828   W_L("<dir");
4829   if (attr_type || attr_color || attr_size) {
4830     W_L(" style=\"");
4831     if (attr_type) {
4832       W_L("list-style-type:");
4833       W_V(attr_type);
4834       W_L(";");
4835     }
4836     if (attr_color) {
4837       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4838       W_L("color:");
4839       W_V(attr_color);
4840       W_L(";");
4841     }
4842     if (attr_size) {
4843       W_L("font-size:");
4844       W_V(attr_size);
4845       W_L(";");
4846     }
4847     W_L("\"");
4848   }
4849   W_L(">");
4850   return jxhtml->out;
4851 }
4852
4853
4854 /**
4855  * It is a handler who processes the DIR tag.
4856  *
4857  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4858  *                     destination is specified.
4859  * @param node   [i]   The DIR tag node is specified.
4860  * @return The conversion result is returned.
4861  */
4862 static char *
4863 s_jxhtml_end_dir_tag(void *pdoc, Node *UNUSED(child))
4864 {
4865   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
4866   Doc *doc = jxhtml->doc;
4867   W_L("</dir>");
4868   if (IS_CSS_ON(jxhtml->entryp)) {
4869     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
4870   }
4871   return jxhtml->out;
4872 }
4873
4874
4875 /**
4876  * It is a handler who processes the DL tag.
4877  *
4878  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4879  *                     destination is specified.
4880  * @param node   [i]   The DL tag node is specified.
4881  * @return The conversion result is returned.
4882  */
4883 static char *
4884 s_jxhtml_start_dl_tag(void *pdoc, Node *node)
4885 {
4886   jxhtml_t *jxhtml      = GET_JXHTML(pdoc);
4887   Doc       *doc        = jxhtml->doc;
4888   Attr      *attr;
4889   char      *attr_style = NULL;
4890   char      *attr_color = NULL;
4891   char      *attr_size  = NULL;
4892   char      *css_clear  = NULL;
4893   
4894   for (attr = qs_get_attr(doc,node);
4895        attr;
4896        attr = qs_get_next_attr(doc,attr)) {
4897     char *name   = qs_get_attr_name(doc,attr);
4898     char *value  = qs_get_attr_value(doc,attr);
4899     if (STRCASEEQ('s','S',"style", name) && value && *value) {
4900       attr_style = value;
4901     }
4902   }
4903   if (IS_CSS_ON(jxhtml->entryp)) {
4904     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
4905     if (style) {
4906       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
4907       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
4908       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
4909       
4910       css_property_t *cur;
4911       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4912         if (cur->value && *cur->value) {
4913           attr_color = apr_pstrdup(doc->pool, cur->value);
4914         }
4915       }
4916       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
4917         if (cur->value && *cur->value) {
4918           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
4919             attr_size = apr_pstrdup(doc->pool, cur->value);
4920           }
4921           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
4922             attr_size = apr_pstrdup(doc->pool, cur->value);
4923           }
4924           else if (STRCASEEQ('s','S',"small",cur->value)) {
4925             attr_size = apr_pstrdup(doc->pool, cur->value);
4926           }
4927           else if (STRCASEEQ('m','M',"medium",cur->value)) {
4928             attr_size = apr_pstrdup(doc->pool, cur->value);
4929           }
4930           else if (STRCASEEQ('l','L',"large",cur->value)) {
4931             attr_size = apr_pstrdup(doc->pool, cur->value);
4932           }
4933           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
4934             attr_size = apr_pstrdup(doc->pool, cur->value);
4935           }
4936           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
4937             attr_size = apr_pstrdup(doc->pool, cur->value);
4938           }
4939         }
4940       }
4941       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
4942         css_clear = apr_pstrdup(doc->pool, cur->value);
4943       }
4944     }
4945   }
4946   W_L("<dl");
4947   if (attr_color || attr_size || css_clear) {
4948     W_L(" style=\"");
4949     if (attr_color) {
4950       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4951       W_L("color:");
4952       W_V(attr_color);
4953       W_L(";");
4954     }
4955     if (attr_size) {
4956       W_L("font-size:");
4957       W_V(attr_size);
4958       W_L(";");
4959     }
4960     if (css_clear){
4961       W_L("clear:");
4962       W_V(css_clear);
4963       W_L(";");
4964     }
4965     W_L("\"");
4966   }
4967   W_L(">");
4968   return jxhtml->out;
4969 }
4970
4971
4972 /**
4973  * It is a handler who processes the DL tag.
4974  *
4975  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4976  *                     destination is specified.
4977  * @param node   [i]   The DL tag node is specified.
4978  * @return The conversion result is returned.
4979  */
4980 static char *
4981 s_jxhtml_end_dl_tag(void *pdoc, Node *UNUSED(child))
4982 {
4983   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
4984   Doc *doc = jxhtml->doc;
4985   W_L("</dl>");
4986   if (IS_CSS_ON(jxhtml->entryp)) {
4987     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
4988   }
4989   return jxhtml->out;
4990 }
4991
4992
4993 /**
4994  * It is a handler who processes the DT tag.
4995  *
4996  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4997  *                     destination is specified.
4998  * @param node   [i]   The DT tag node is specified.
4999  * @return The conversion result is returned.
5000  */
5001 static char *
5002 s_jxhtml_start_dt_tag(void *pdoc, Node *node)
5003 {
5004   jxhtml_t *jxhtml      = GET_JXHTML(pdoc);
5005   Doc       *doc        = jxhtml->doc;
5006   Attr      *attr;
5007   char      *attr_style = NULL;
5008   char      *attr_color = NULL;
5009   char      *attr_size  = NULL;
5010   for (attr = qs_get_attr(doc,node);
5011        attr;
5012        attr = qs_get_next_attr(doc,attr)) {
5013     char *name   = qs_get_attr_name(doc,attr);
5014     char *value  = qs_get_attr_value(doc,attr);
5015     if (STRCASEEQ('s','S',"style", name) && value && *value) {
5016       attr_style = value;
5017     }
5018   }
5019   if (IS_CSS_ON(jxhtml->entryp)) {
5020     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
5021     if (style) {
5022       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
5023       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
5024       css_property_t *cur;
5025       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
5026         if (cur->value && *cur->value) {
5027           attr_color = apr_pstrdup(doc->pool, cur->value);
5028         }
5029       }
5030       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
5031         if (cur->value && *cur->value) {
5032           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
5033             attr_size = apr_pstrdup(doc->pool, cur->value);
5034           }
5035           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
5036             attr_size = apr_pstrdup(doc->pool, cur->value);
5037           }
5038           else if (STRCASEEQ('s','S',"small",cur->value)) {
5039             attr_size = apr_pstrdup(doc->pool, cur->value);
5040           }
5041           else if (STRCASEEQ('m','M',"medium",cur->value)) {
5042             attr_size = apr_pstrdup(doc->pool, cur->value);
5043           }
5044           else if (STRCASEEQ('l','L',"large",cur->value)) {
5045             attr_size = apr_pstrdup(doc->pool, cur->value);
5046           }
5047           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
5048             attr_size = apr_pstrdup(doc->pool, cur->value);
5049           }
5050           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
5051             attr_size = apr_pstrdup(doc->pool, cur->value);
5052           }
5053         }
5054       }
5055     }
5056   }
5057   W_L("<dt");
5058   if (attr_color || attr_size) {
5059     W_L(" style=\"");
5060     if (attr_color) {
5061       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
5062       W_L("color:");
5063       W_V(attr_color);
5064       W_L(";");
5065     }
5066     if (attr_size) {
5067       W_L("font-size:");
5068       W_V(attr_size);
5069       W_L(";");
5070     }
5071     W_L("\"");
5072   }
5073   W_L(">");
5074   return jxhtml->out;
5075 }
5076
5077
5078 /**
5079  * It is a handler who processes the DT tag.
5080  *
5081  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5082  *                     destination is specified.
5083  * @param node   [i]   The DT tag node is specified.
5084  * @return The conversion result is returned.
5085  */
5086 static char *
5087 s_jxhtml_end_dt_tag(void *pdoc, Node *UNUSED(child))
5088 {
5089   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
5090   Doc      *doc    = jxhtml->doc;
5091   W_L("</dt>");
5092   if (IS_CSS_ON(jxhtml->entryp)) {
5093     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
5094   }
5095   return jxhtml->out;
5096 }
5097
5098
5099 /**
5100  * It is a handler who processes the DD tag.
5101  *
5102  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5103  *                     destination is specified.
5104  * @param node   [i]   The DD tag node is specified.
5105  * @return The conversion result is returned.
5106  */
5107 static char *
5108 s_jxhtml_start_dd_tag(void *pdoc, Node *node)
5109 {
5110   jxhtml_t *jxhtml      = GET_JXHTML(pdoc);
5111   Doc       *doc        = jxhtml->doc;
5112   Attr      *attr;
5113   char      *attr_style = NULL;
5114   char      *attr_color = NULL;
5115   char      *attr_size  = NULL;
5116   for (attr = qs_get_attr(doc,node);
5117        attr;
5118        attr = qs_get_next_attr(doc,attr)) {
5119     char *name   = qs_get_attr_name(doc,attr);
5120     char *value  = qs_get_attr_value(doc,attr);
5121     if (STRCASEEQ('s','S',"style", name) && value && *value) {
5122       attr_style = value;
5123     }
5124   }
5125   if (IS_CSS_ON(jxhtml->entryp)) {
5126     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
5127     if (style) {
5128       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
5129       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
5130       css_property_t *cur;
5131       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
5132         if (cur->value && *cur->value) {
5133           attr_color = apr_pstrdup(doc->pool, cur->value);
5134         }
5135       }
5136       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
5137         if (cur->value && *cur->value) {
5138           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
5139             attr_size = apr_pstrdup(doc->pool, cur->value);
5140           }
5141           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
5142             attr_size = apr_pstrdup(doc->pool, cur->value);
5143           }
5144           else if (STRCASEEQ('s','S',"small",cur->value)) {
5145             attr_size = apr_pstrdup(doc->pool, cur->value);
5146           }
5147           else if (STRCASEEQ('m','M',"medium",cur->value)) {
5148             attr_size = apr_pstrdup(doc->pool, cur->value);
5149           }
5150           else if (STRCASEEQ('l','L',"large",cur->value)) {
5151             attr_size = apr_pstrdup(doc->pool, cur->value);
5152           }
5153           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
5154             attr_size = apr_pstrdup(doc->pool, cur->value);
5155           }
5156           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
5157             attr_size = apr_pstrdup(doc->pool, cur->value);
5158           }
5159         }
5160       }
5161     }
5162   }
5163   W_L("<dd");
5164   if (attr_color || attr_size) {
5165     W_L(" style=\"");
5166     if (attr_color) {
5167       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
5168       W_L("color:");
5169       W_V(attr_color);
5170       W_L(";");
5171     }
5172     if (attr_size) {
5173       W_L("font-size:");
5174       W_V(attr_size);
5175       W_L(";");
5176     }
5177     W_L("\"");
5178   }
5179   W_L(">");
5180   return jxhtml->out;
5181 }
5182
5183
5184 /**
5185  * It is a handler who processes the DD tag.
5186  *
5187  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5188  *                     destination is specified.
5189  * @param node   [i]   The DD tag node is specified.
5190  * @return The conversion result is returned.
5191  */
5192 static char *
5193 s_jxhtml_end_dd_tag(void *pdoc, Node *UNUSED(child))
5194 {
5195   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
5196   Doc      *doc = jxhtml->doc;
5197   W_L("</dd>");
5198   if (IS_CSS_ON(jxhtml->entryp)) {
5199     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
5200   }
5201   return jxhtml->out;
5202 }
5203
5204
5205 /**
5206  * It is a handler who processes the H1 tag.
5207  *
5208  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5209  *                     destination is specified.
5210  * @param node   [i]   The H1 tag node is specified.
5211  * @return The conversion result is returned.
5212  */
5213 static char *
5214 s_jxhtml_start_h1_tag(void *pdoc, Node *node)
5215 {
5216   jxhtml_t    *jxhtml;
5217   Doc         *doc;
5218   request_rec *r;
5219   Attr        *attr;
5220   char        *attr_style = NULL;
5221   char        *attr_align = NULL;
5222   char        *css_clear  = NULL;
5223
5224   jxhtml = GET_JXHTML(pdoc);
5225   doc    = jxhtml->doc;
5226   r      = doc->r;
5227
5228   for (attr = qs_get_attr(doc,node);
5229        attr;
5230        attr = qs_get_next_attr(doc,attr)) {
5231     char *name  = qs_get_attr_name(doc,attr);
5232     char *value = qs_get_attr_value(doc,attr);
5233     if (STRCASEEQ('a','A',"align", name)) {
5234       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
5235         attr_align = value;
5236       }
5237     }
5238     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
5239       attr_style = value;
5240     }
5241   }
5242   if (IS_CSS_ON(jxhtml->entryp)) {
5243     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
5244     if (style) {
5245       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
5246       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
5247       css_property_t *cur;
5248       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
5249         if (STRCASEEQ('l','L',"left", cur->value)) {
5250           attr_align = apr_pstrdup(doc->pool, "left");
5251         }
5252         else if (STRCASEEQ('c','C',"center",cur->value)) {
5253           attr_align = apr_pstrdup(doc->pool, "center");
5254         }
5255         else if (STRCASEEQ('r','R',"right",cur->value)) {
5256           attr_align = apr_pstrdup(doc->pool, "right");
5257         }
5258       }
5259       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
5260         if (STRCASEEQ('b','B',"both", cur->value)) {
5261           css_clear = apr_pstrdup(doc->pool, "both");
5262         }
5263         else if (STRCASEEQ('r','R',"right", cur->value)) {
5264           css_clear = apr_pstrdup(doc->pool, "right");
5265         }
5266         else if (STRCASEEQ('l','L',"left", cur->value)) {
5267           css_clear = apr_pstrdup(doc->pool, "left");
5268         }
5269       }
5270     }
5271   }
5272   W_L("<h1");
5273   if (attr_align || css_clear ) {
5274     W_L(" style=\"");
5275     if(attr_align){
5276       W_L("text-align:");
5277       W_V(attr_align);
5278       W_L(";");
5279     }
5280     if(css_clear){
5281       W_L("clear:");
5282       W_V(css_clear);
5283       W_L(";");
5284     }
5285     W_L("\"");
5286   }
5287   W_L(">");
5288
5289   return jxhtml->out;
5290 }
5291
5292
5293 /**
5294  * It is a handler who processes the H1 tag.
5295  *
5296  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5297  *                     destination is specified.
5298  * @param node   [i]   The H1 tag node is specified.
5299  * @return The conversion result is returned.
5300  */
5301 static char *
5302 s_jxhtml_end_h1_tag(void *pdoc, Node *UNUSED(child)) 
5303 {
5304   jxhtml_t*    jxhtml;
5305   Doc*          doc;
5306   request_rec*  r;
5307
5308   jxhtml = GET_JXHTML(pdoc);
5309   doc     = jxhtml->doc;
5310   r       = doc->r;
5311   
5312   W_L("</h1>");
5313   if (IS_CSS_ON(jxhtml->entryp)) {
5314     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
5315   }
5316
5317   return jxhtml->out;
5318 }
5319
5320
5321 /**
5322  * It is a handler who processes the H2 tag.
5323  *
5324  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5325  *                     destination is specified.
5326  * @param node   [i]   The H1 tag node is specified.
5327  * @return The conversion result is returned.
5328  */
5329 static char *
5330 s_jxhtml_start_h2_tag(void *pdoc, Node *node)
5331 {
5332   jxhtml_t    *jxhtml;
5333   Doc         *doc;
5334   request_rec *r;
5335   Attr        *attr;
5336   char        *attr_style = NULL;
5337   char        *attr_align = NULL;
5338   char        *css_clear  = NULL;
5339
5340   jxhtml   = GET_JXHTML(pdoc);
5341   doc     = jxhtml->doc;
5342   r       = doc->r;
5343
5344   for (attr = qs_get_attr(doc,node);
5345        attr;
5346        attr = qs_get_next_attr(doc,attr)) {
5347     char *name  = qs_get_attr_name(doc,attr);
5348     char *value = qs_get_attr_value(doc,attr);
5349     if (STRCASEEQ('a','A',"align", name)) {
5350       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
5351         attr_align = value;
5352       }
5353     }
5354     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
5355       attr_style = value;
5356     }
5357   }
5358   if (IS_CSS_ON(jxhtml->entryp)) {
5359     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
5360     if (style) {
5361       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
5362       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
5363       css_property_t *cur;
5364       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
5365         if (STRCASEEQ('l','L',"left", cur->value)) {
5366           attr_align = apr_pstrdup(doc->pool, "left");
5367         }
5368         else if (STRCASEEQ('c','C',"center",cur->value)) {
5369           attr_align = apr_pstrdup(doc->pool, "center");
5370         }
5371         else if (STRCASEEQ('r','R',"right",cur->value)) {
5372           attr_align = apr_pstrdup(doc->pool, "right");
5373         }
5374       }
5375       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
5376         if (STRCASEEQ('b','B',"both", cur->value)) {
5377           css_clear = apr_pstrdup(doc->pool, "both");
5378         }
5379         else if (STRCASEEQ('r','R',"right", cur->value)) {
5380           css_clear = apr_pstrdup(doc->pool, "right");
5381         }
5382         else if (STRCASEEQ('l','L',"left", cur->value)) {
5383           css_clear = apr_pstrdup(doc->pool, "left");
5384         }
5385       }
5386     }
5387   }
5388   W_L("<h2");
5389   if (attr_align || css_clear ) {
5390     W_L(" style=\"");
5391     if(attr_align){
5392       W_L("text-align:");
5393       W_V(attr_align);
5394       W_L(";");
5395     }
5396     if(css_clear){
5397       W_L("clear:");
5398       W_V(css_clear);
5399       W_L(";");
5400     }
5401     W_L("\"");
5402   }
5403   W_L(">");
5404
5405   return jxhtml->out;
5406 }
5407
5408
5409 /**
5410  * It is a handler who processes the H2 tag.
5411  *
5412  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5413  *                     destination is specified.
5414  * @param node   [i]   The H1 tag node is specified.
5415  * @return The conversion result is returned.
5416  */
5417 static char *
5418 s_jxhtml_end_h2_tag(void *pdoc, Node *UNUSED(child)) 
5419 {
5420   jxhtml_t*    jxhtml;
5421   Doc*          doc;
5422   request_rec*  r;
5423
5424   jxhtml = GET_JXHTML(pdoc);
5425   doc     = jxhtml->doc;
5426   r       = doc->r;
5427   
5428   W_L("</h2>");
5429   if (IS_CSS_ON(jxhtml->entryp)) {
5430     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
5431   }
5432   return jxhtml->out;
5433 }
5434
5435
5436 /**
5437  * It is a handler who processes the H3 tag.
5438  *
5439  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5440  *                     destination is specified.
5441  * @param node   [i]   The H1 tag node is specified.
5442  * @return The conversion result is returned.
5443  */
5444 static char *
5445 s_jxhtml_start_h3_tag(void *pdoc, Node *node)
5446 {
5447   jxhtml_t    *jxhtml;
5448   Doc         *doc;
5449   request_rec *r;
5450   Attr        *attr;
5451   char        *attr_style = NULL;
5452   char        *attr_align = NULL;
5453   char        *css_clear  = NULL;
5454
5455   jxhtml   = GET_JXHTML(pdoc);
5456   doc     = jxhtml->doc;
5457   r       = doc->r;
5458
5459   for (attr = qs_get_attr(doc,node);
5460        attr;
5461        attr = qs_get_next_attr(doc,attr)) {
5462     char *name  = qs_get_attr_name(doc,attr);
5463     char *value = qs_get_attr_value(doc,attr);
5464     if (STRCASEEQ('a','A',"align", name)) {
5465       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
5466         attr_align = value;
5467       }
5468     }
5469     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
5470       attr_style = value;
5471     }
5472   }
5473   if (IS_CSS_ON(jxhtml->entryp)) {
5474     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
5475     if (style) {
5476       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
5477       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
5478       css_property_t *cur;
5479       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
5480         if (STRCASEEQ('l','L',"left", cur->value)) {
5481           attr_align = apr_pstrdup(doc->pool, "left");
5482         }
5483         else if (STRCASEEQ('c','C',"center",cur->value)) {
5484           attr_align = apr_pstrdup(doc->pool, "center");
5485         }
5486         else if (STRCASEEQ('r','R',"right",cur->value)) {
5487           attr_align = apr_pstrdup(doc->pool, "right");
5488         }
5489       }
5490       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
5491         if (STRCASEEQ('b','B',"both", cur->value)) {
5492           css_clear = apr_pstrdup(doc->pool, "both");
5493         }
5494         else if (STRCASEEQ('r','R',"right", cur->value)) {
5495           css_clear = apr_pstrdup(doc->pool, "right");
5496         }
5497         else if (STRCASEEQ('l','L',"left", cur->value)) {
5498           css_clear = apr_pstrdup(doc->pool, "left");
5499         }
5500       }
5501     }
5502   }
5503   W_L("<h3");
5504   if (attr_align || css_clear ) {
5505     W_L(" style=\"");
5506     if(attr_align){
5507       W_L("text-align:");
5508       W_V(attr_align);
5509       W_L(";");
5510     }
5511     if(css_clear){
5512       W_L("clear:");
5513       W_V(css_clear);
5514       W_L(";");
5515     }
5516     W_L("\"");
5517   }
5518   W_L(">");
5519
5520   return jxhtml->out;
5521 }
5522
5523
5524 /**
5525  * It is a handler who processes the H3 tag.
5526  *
5527  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5528  *                     destination is specified.
5529  * @param node   [i]   The H1 tag node is specified.
5530  * @return The conversion result is returned.
5531  */
5532 static char *
5533 s_jxhtml_end_h3_tag(void *pdoc, Node *UNUSED(child)) 
5534 {
5535   jxhtml_t*    jxhtml;
5536   Doc*          doc;
5537   request_rec*  r;
5538
5539   jxhtml = GET_JXHTML(pdoc);
5540   doc     = jxhtml->doc;
5541   r       = doc->r;
5542
5543   W_L("</h3>");
5544   if (IS_CSS_ON(jxhtml->entryp)) {
5545     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
5546   }
5547   return jxhtml->out;
5548 }
5549
5550
5551 /**
5552  * It is a handler who processes the H4 tag.
5553  *
5554  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5555  *                     destination is specified.
5556  * @param node   [i]   The H1 tag node is specified.
5557  * @return The conversion result is returned.
5558  */
5559 static char *
5560 s_jxhtml_start_h4_tag(void *pdoc, Node *node)
5561 {
5562   jxhtml_t    *jxhtml;
5563   Doc         *doc;
5564   request_rec *r;
5565   Attr        *attr;
5566   char        *attr_style = NULL;
5567   char        *attr_align = NULL;
5568   char        *css_clear  = NULL;
5569
5570   jxhtml   = GET_JXHTML(pdoc);
5571   doc     = jxhtml->doc;
5572   r       = doc->r;
5573
5574   for (attr = qs_get_attr(doc,node);
5575        attr;
5576        attr = qs_get_next_attr(doc,attr)) {
5577     char *name  = qs_get_attr_name(doc,attr);
5578     char *value = qs_get_attr_value(doc,attr);
5579     if (STRCASEEQ('a','A',"align", name)) {
5580       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
5581         attr_align = value;
5582       }
5583     }
5584     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
5585       attr_style = value;
5586     }
5587   }
5588   if (IS_CSS_ON(jxhtml->entryp)) {
5589     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
5590     if (style) {
5591       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
5592       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
5593       css_property_t *cur;
5594       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
5595         if (STRCASEEQ('l','L',"left", cur->value)) {
5596           attr_align = apr_pstrdup(doc->pool, "left");
5597         }
5598         else if (STRCASEEQ('c','C',"center",cur->value)) {
5599           attr_align = apr_pstrdup(doc->pool, "center");
5600         }
5601         else if (STRCASEEQ('r','R',"right",cur->value)) {
5602           attr_align = apr_pstrdup(doc->pool, "right");
5603         }
5604       }
5605       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
5606         if (STRCASEEQ('b','B',"both", cur->value)) {
5607           css_clear = apr_pstrdup(doc->pool, "both");
5608         }
5609         else if (STRCASEEQ('r','R',"right", cur->value)) {
5610           css_clear = apr_pstrdup(doc->pool, "right");
5611         }
5612         else if (STRCASEEQ('l','L',"left", cur->value)) {
5613           css_clear = apr_pstrdup(doc->pool, "left");
5614         }
5615       }
5616     }
5617   }
5618   W_L("<h4");
5619   if (attr_align || css_clear ) {
5620     W_L(" style=\"");
5621     if(attr_align){
5622       W_L("text-align:");
5623       W_V(attr_align);
5624       W_L(";");
5625     }
5626     if(css_clear){
5627       W_L("clear:");
5628       W_V(css_clear);
5629       W_L(";");
5630     }
5631     W_L("\"");
5632   }
5633   W_L(">");
5634
5635   return jxhtml->out;
5636 }
5637
5638
5639 /**
5640  * It is a handler who processes the H4 tag.
5641  *
5642  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5643  *                     destination is specified.
5644  * @param node   [i]   The H1 tag node is specified.
5645  * @return The conversion result is returned.
5646  */
5647 static char *
5648 s_jxhtml_end_h4_tag(void *pdoc, Node *UNUSED(child)) 
5649 {
5650   jxhtml_t      *jxhtml;
5651   Doc           *doc;
5652   request_rec   *r;
5653
5654   jxhtml = GET_JXHTML(pdoc);
5655   doc     = jxhtml->doc;
5656   r       = doc->r;
5657   
5658   W_L("</h4>");
5659   if (IS_CSS_ON(jxhtml->entryp)) {
5660     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
5661   }
5662
5663   return jxhtml->out;
5664 }
5665
5666
5667 /**
5668  * It is a handler who processes the H5 tag.
5669  *
5670  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5671  *                     destination is specified.
5672  * @param node   [i]   The H1 tag node is specified.
5673  * @return The conversion result is returned.
5674  */
5675 static char *
5676 s_jxhtml_start_h5_tag(void *pdoc, Node *node)
5677 {
5678   jxhtml_t    *jxhtml;
5679   Doc         *doc;
5680   request_rec *r;
5681   Attr        *attr;
5682   char        *attr_style = NULL;
5683   char        *attr_align = NULL;
5684   char        *css_clear  = NULL;
5685
5686   jxhtml   = GET_JXHTML(pdoc);
5687   doc     = jxhtml->doc;
5688   r       = doc->r;
5689
5690   for (attr = qs_get_attr(doc,node);
5691        attr;
5692        attr = qs_get_next_attr(doc,attr)) {
5693     char *name  = qs_get_attr_name(doc,attr);
5694     char *value = qs_get_attr_value(doc,attr);
5695     if (STRCASEEQ('a','A',"align", name)) {
5696       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
5697         attr_align = value;
5698       }
5699     }
5700     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
5701       attr_style = value;
5702     }
5703   }
5704   if (IS_CSS_ON(jxhtml->entryp)) {
5705     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
5706     if (style) {
5707       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
5708       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
5709       css_property_t *cur;
5710       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
5711         if (STRCASEEQ('l','L',"left", cur->value)) {
5712           attr_align = apr_pstrdup(doc->pool, "left");
5713         }
5714         else if (STRCASEEQ('c','C',"center",cur->value)) {
5715           attr_align = apr_pstrdup(doc->pool, "center");
5716         }
5717         else if (STRCASEEQ('r','R',"right",cur->value)) {
5718           attr_align = apr_pstrdup(doc->pool, "right");
5719         }
5720       }
5721       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
5722         if (STRCASEEQ('b','B',"both", cur->value)) {
5723           css_clear = apr_pstrdup(doc->pool, "both");
5724         }
5725         else if (STRCASEEQ('r','R',"right", cur->value)) {
5726           css_clear = apr_pstrdup(doc->pool, "right");
5727         }
5728         else if (STRCASEEQ('l','L',"left", cur->value)) {
5729           css_clear = apr_pstrdup(doc->pool, "left");
5730         }
5731       }
5732     }
5733   }
5734   W_L("<h5");
5735   if (attr_align || css_clear ) {
5736     W_L(" style=\"");
5737     if(attr_align){
5738       W_L("text-align:");
5739       W_V(attr_align);
5740       W_L(";");
5741     }
5742     if(css_clear){
5743       W_L("clear:");
5744       W_V(css_clear);
5745       W_L(";");
5746     }
5747     W_L("\"");
5748   }
5749   W_L(">");
5750
5751   return jxhtml->out;
5752 }
5753
5754
5755 /**
5756  * It is a handler who processes the H5 tag.
5757  *
5758  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5759  *                     destination is specified.
5760  * @param node   [i]   The H1 tag node is specified.
5761  * @return The conversion result is returned.
5762  */
5763 static char *
5764 s_jxhtml_end_h5_tag(void *pdoc, Node *UNUSED(child)) 
5765 {
5766   jxhtml_t    *jxhtml;
5767   Doc         *doc;
5768   request_rec *r;
5769
5770   jxhtml = GET_JXHTML(pdoc);
5771   doc     = jxhtml->doc;
5772   r       = doc->r;
5773   
5774   W_L("</h5>");
5775   if (IS_CSS_ON(jxhtml->entryp)) {
5776     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
5777   }
5778
5779   return jxhtml->out;
5780 }
5781
5782
5783 /**
5784  * It is a handler who processes the H6 tag.
5785  *
5786  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5787  *                     destination is specified.
5788  * @param node   [i]   The H1 tag node is specified.
5789  * @return The conversion result is returned.
5790  */
5791 static char *
5792 s_jxhtml_start_h6_tag(void *pdoc, Node *node)
5793 {
5794   jxhtml_t    *jxhtml;
5795   Doc         *doc;
5796   request_rec *r;
5797   Attr        *attr;
5798   char        *attr_style = NULL;
5799   char        *attr_align = NULL;
5800   char        *css_clear  = NULL;
5801
5802   jxhtml   = GET_JXHTML(pdoc);
5803   doc     = jxhtml->doc;
5804   r       = doc->r;
5805
5806   for (attr = qs_get_attr(doc,node);
5807        attr;
5808        attr = qs_get_next_attr(doc,attr)) {
5809     char *name  = qs_get_attr_name(doc,attr);
5810     char *value = qs_get_attr_value(doc,attr);
5811     if (STRCASEEQ('a','A',"align", name)) {
5812       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
5813         attr_align = value;
5814       }
5815     }
5816     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
5817       attr_style = value;
5818     }
5819   }
5820   if (IS_CSS_ON(jxhtml->entryp)) {
5821     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
5822     if (style) {
5823       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
5824       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
5825       css_property_t *cur;
5826       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
5827         if (STRCASEEQ('l','L',"left", cur->value)) {
5828           attr_align = apr_pstrdup(doc->pool, "left");
5829         }
5830         else if (STRCASEEQ('c','C',"center",cur->value)) {
5831           attr_align = apr_pstrdup(doc->pool, "center");
5832         }
5833         else if (STRCASEEQ('r','R',"right",cur->value)) {
5834           attr_align = apr_pstrdup(doc->pool, "right");
5835         }
5836       }
5837       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
5838         if (STRCASEEQ('b','B',"both", cur->value)) {
5839           css_clear = apr_pstrdup(doc->pool, "both");
5840         }
5841         else if (STRCASEEQ('r','R',"right", cur->value)) {
5842           css_clear = apr_pstrdup(doc->pool, "right");
5843         }
5844         else if (STRCASEEQ('l','L',"left", cur->value)) {
5845           css_clear = apr_pstrdup(doc->pool, "left");
5846         }
5847       }
5848     }
5849   }
5850   W_L("<h6");
5851   if (attr_align || css_clear ) {
5852     W_L(" style=\"");
5853     if(attr_align){
5854       W_L("text-align:");
5855       W_V(attr_align);
5856       W_L(";");
5857     }
5858     if(css_clear){
5859       W_L("clear:");
5860       W_V(css_clear);
5861       W_L(";");
5862     }
5863     W_L("\"");
5864   }
5865   W_L(">");
5866
5867   return jxhtml->out;
5868 }
5869
5870
5871 /**
5872  * It is a handler who processes the H6 tag.
5873  *
5874  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5875  *                     destination is specified.
5876  * @param node   [i]   The H1 tag node is specified.
5877  * @return The conversion result is returned.
5878  */
5879 static char *
5880 s_jxhtml_end_h6_tag(void *pdoc, Node *UNUSED(child)) 
5881 {
5882   jxhtml_t    *jxhtml;
5883   Doc         *doc;
5884   request_rec *r;
5885
5886   jxhtml = GET_JXHTML(pdoc);
5887   doc     = jxhtml->doc;
5888   r       = doc->r;
5889   
5890   W_L("</h6>");
5891   if (IS_CSS_ON(jxhtml->entryp)) {
5892     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
5893   }
5894
5895   return jxhtml->out;
5896 }
5897
5898
5899 /**
5900  * It is a handler who processes the MENU tag.
5901  *
5902  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5903  *                     destination is specified.
5904  * @param node   [i]   The MENU tag node is specified.
5905  * @return The conversion result is returned.
5906  */
5907 static char *
5908 s_jxhtml_start_menu_tag(void *pdoc, Node *node)
5909 {
5910   jxhtml_t *jxhtml      = GET_JXHTML(pdoc);
5911   Doc       *doc        = jxhtml->doc;
5912   Attr      *attr;
5913   char      *attr_style = NULL;
5914   char      *attr_color = NULL;
5915   char      *attr_type  = NULL;
5916   char      *attr_size  = NULL;
5917   for (attr = qs_get_attr(doc,node);
5918        attr;
5919        attr = qs_get_next_attr(doc,attr)) {
5920     char *name   = qs_get_attr_name(doc,attr);
5921     char *value  = qs_get_attr_value(doc,attr);
5922     if (STRCASEEQ('t','T',"type",name)) {
5923       if (value && (STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
5924         attr_type = value;
5925       }
5926     }
5927     else if (STRCASEEQ('s','S',"style", name) && value && *value) {
5928       attr_style = value;
5929     }
5930   }
5931   if (IS_CSS_ON(jxhtml->entryp)) {
5932     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
5933     if (style) {
5934       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
5935       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
5936       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
5937       css_property_t *cur;
5938       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
5939         if (cur->value && *cur->value) {
5940           attr_color = apr_pstrdup(doc->pool, cur->value);
5941         }
5942       }
5943       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
5944         if (cur->value && *cur->value) {
5945           attr_type = apr_pstrdup(doc->pool, cur->value);
5946         }
5947       }
5948       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
5949         if (cur->value && *cur->value) {
5950           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
5951             attr_size = apr_pstrdup(doc->pool, cur->value);
5952           }
5953           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
5954             attr_size = apr_pstrdup(doc->pool, cur->value);
5955           }
5956           else if (STRCASEEQ('s','S',"small",cur->value)) {
5957             attr_size = apr_pstrdup(doc->pool, cur->value);
5958           }
5959           else if (STRCASEEQ('m','M',"medium",cur->value)) {
5960             attr_size = apr_pstrdup(doc->pool, cur->value);
5961           }
5962           else if (STRCASEEQ('l','L',"large",cur->value)) {
5963             attr_size = apr_pstrdup(doc->pool, cur->value);
5964           }
5965           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
5966             attr_size = apr_pstrdup(doc->pool, cur->value);
5967           }
5968           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
5969             attr_size = apr_pstrdup(doc->pool, cur->value);
5970           }
5971         }
5972       }
5973     }
5974   }
5975   W_L("<menu");
5976   if (attr_type || attr_color || attr_size) {
5977     W_L(" style=\"");
5978     if (attr_type) {
5979       W_L("list-style-type:");
5980       W_V(attr_type);
5981       W_L(";");
5982     }
5983     if (attr_color) {
5984       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
5985       W_L("color:");
5986       W_V(attr_color);
5987       W_L(";");
5988     }
5989     if (attr_size) {
5990       W_L("font-size:");
5991       W_V(attr_size);
5992       W_L(";");
5993     }
5994     W_L("\"");
5995   }
5996   W_L(">");
5997   return jxhtml->out;
5998 }
5999
6000
6001 /**
6002  * It is a handler who processes the MENU tag.
6003  *
6004  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
6005  *                     destination is specified.
6006  * @param node   [i]   The MENU tag node is specified.
6007  * @return The conversion result is returned.
6008  */
6009 static char *
6010 s_jxhtml_end_menu_tag(void *pdoc, Node *UNUSED(child))
6011 {
6012   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
6013   Doc *doc = jxhtml->doc;
6014   W_L("</menu>");
6015   if (IS_CSS_ON(jxhtml->entryp)) {
6016     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
6017   }
6018   return jxhtml->out;
6019 }
6020
6021
6022 /**
6023  * It is a handler who processes the PLAINTEXT tag.
6024  *
6025  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
6026  *                     destination is specified.
6027  * @param node   [i]   The PLAINTEXT tag node is specified.
6028  * @return The conversion result is returned.
6029  */
6030 static char *
6031 s_jxhtml_start_plaintext_tag(void *pdoc, Node *node)
6032 {
6033   jxhtml_t *jxhtml;
6034   Doc *doc;
6035
6036   jxhtml = GET_JXHTML(pdoc);
6037   doc     = jxhtml->doc;
6038   W_L("<plaintext>");
6039   s_jxhtml_start_plaintext_tag_inner(pdoc,node);
6040   return jxhtml->out;
6041 }
6042
6043 static char *
6044 s_jxhtml_start_plaintext_tag_inner(void *pdoc, Node *node)
6045 {
6046   jxhtml_t *jxhtml;
6047   Doc *doc;
6048   Node *child;
6049   jxhtml = GET_JXHTML(pdoc);
6050   doc     = jxhtml->doc;
6051   for (child = qs_get_child_node(doc, node);
6052        child;
6053        child = qs_get_next_node(doc, child)) {
6054     W_V(child->otext);
6055     s_jxhtml_start_plaintext_tag_inner(pdoc, child);
6056   }
6057   return jxhtml->out;
6058 }
6059
6060
6061 /**
6062  * It is a handler who processes the PLAINTEXT tag.
6063  *
6064  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
6065  *                     destination is specified.
6066  * @param node   [i]   The PLAINTEXT tag node is specified.
6067  * @return The conversion result is returned.
6068  */
6069 static char *
6070 s_jxhtml_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
6071 {
6072   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
6073   return jxhtml->out;
6074 }
6075
6076
6077 /**
6078  * It is a handler who processes the BLINK tag.
6079  *
6080  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
6081  *                     destination is specified.
6082  * @param node   [i]   The BLINK tag node is specified.
6083  * @return The conversion result is returned.
6084  */
6085 static char *
6086 s_jxhtml_start_blink_tag(void *pdoc, Node *node)
6087 {
6088   jxhtml_t *jxhtml      = GET_JXHTML(pdoc);
6089   Doc       *doc        = jxhtml->doc;
6090   Attr      *attr;
6091   char      *attr_style = NULL;
6092   char      *attr_color = NULL;
6093   char      *attr_size  = NULL;
6094   for (attr = qs_get_attr(doc,node);
6095        attr;
6096        attr = qs_get_next_attr(doc,attr)) {
6097     char *name   = qs_get_attr_name(doc,attr);
6098     char *value  = qs_get_attr_value(doc,attr);
6099     if (STRCASEEQ('s','S',"style", name) && value && *value) {
6100       attr_style = value;
6101     }
6102   }
6103   if (IS_CSS_ON(jxhtml->entryp)) {
6104     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
6105     if (style) {
6106       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
6107       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
6108       css_property_t *cur;
6109       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
6110         if (cur->value && *cur->value) {
6111           attr_color = apr_pstrdup(doc->pool, cur->value);
6112         }
6113       }
6114       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
6115         if (cur->value && *cur->value) {
6116           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
6117             attr_size = apr_pstrdup(doc->pool, cur->value);
6118           }
6119           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
6120             attr_size = apr_pstrdup(doc->pool, cur->value);
6121           }
6122           else if (STRCASEEQ('s','S',"small",cur->value)) {
6123             attr_size = apr_pstrdup(doc->pool, cur->value);
6124           }
6125           else if (STRCASEEQ('m','M',"medium",cur->value)) {
6126             attr_size = apr_pstrdup(doc->pool, cur->value);
6127           }
6128           else if (STRCASEEQ('l','L',"large",cur->value)) {
6129             attr_size = apr_pstrdup(doc->pool, cur->value);
6130           }
6131           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
6132             attr_size = apr_pstrdup(doc->pool, cur->value);
6133           }
6134           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
6135             attr_size = apr_pstrdup(doc->pool, cur->value);
6136           }
6137         }
6138       }
6139     }
6140   }
6141   W_L("<blink");
6142   if (attr_color || attr_size) {
6143     W_L(" style=\"");
6144     if (attr_color) {
6145       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
6146       W_L("color:");
6147       W_V(attr_color);
6148       W_L(";");
6149     }
6150     if (attr_size) {
6151       W_L("font-size:");
6152       W_V(attr_size);
6153       W_L(";");
6154     }
6155     W_L("\"");
6156   }
6157   W_L(">");
6158   return jxhtml->out;
6159 }
6160
6161
6162 /**
6163  * It is a handler who processes the BLINK tag.
6164  *
6165  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
6166  *                     destination is specified.
6167  * @param node   [i]   The BLINK tag node is specified.
6168  * @return The conversion result is returned.
6169  */
6170 static char *
6171 s_jxhtml_end_blink_tag(void *pdoc, Node *UNUSED(child))
6172 {
6173   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
6174   Doc      *doc = jxhtml->doc;
6175   W_L("</blink>");
6176   if (IS_CSS_ON(jxhtml->entryp)) {
6177     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
6178   }
6179   return jxhtml->out;
6180 }
6181
6182
6183 /**
6184  * It is a handler who processes the MARQUEE tag.
6185  *
6186  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
6187  *                     destination is specified.
6188  * @param node   [i]   The MARQUEE tag node is specified.
6189  * @return The conversion result is returned.
6190  */
6191 static char *
6192 s_jxhtml_start_marquee_tag(void *pdoc, Node *node)
6193 {
6194   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
6195   Doc       *doc = jxhtml->doc;
6196   Attr      *attr;
6197   char      *attr_direction = NULL;
6198   char      *attr_style     = NULL;
6199   char      *attr_color     = NULL;
6200   char      *attr_size      = NULL;
6201   char      *attr_bgcolor   = NULL;
6202   /*--------------------------------------------------------------------------*/
6203   /* Get Attributes                                                           */
6204   /*--------------------------------------------------------------------------*/
6205   for (attr = qs_get_attr(doc,node);
6206        attr;
6207        attr = qs_get_next_attr(doc,attr)) {
6208     char *name   = qs_get_attr_name(doc,attr);
6209     char *value  = qs_get_attr_value(doc,attr);
6210     if (STRCASEEQ('d','D',"direction", name)) {
6211       if (value) {
6212         if (STRCASEEQ('l','L',"left",value)) {
6213           attr_direction = "rtl";
6214         }
6215         else if (STRCASEEQ('r','R',"right",value)) {
6216           attr_direction = "ltr";
6217         }
6218       }
6219     }
6220     else if (STRCASEEQ('b','B',"behavior",name)) {
6221       /* ignore */
6222     }
6223     else if (STRCASEEQ('l','L',"loop",name)) {
6224       /* ignore */
6225     }
6226     else if (STRCASEEQ('b','B',"bgcolor",name)) {
6227       if (value && *value) {
6228         attr_bgcolor = value;
6229       }
6230     }
6231     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
6232       attr_style = value;
6233     }
6234   }
6235   if (IS_CSS_ON(jxhtml->entryp)) {
6236     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
6237     if (style) {
6238       css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
6239       css_property_t *size_prop  = chxj_css_get_property_value(doc, style, "font-size");
6240       css_property_t *bgcolor_prop  = chxj_css_get_property_value(doc, style, "background-color");
6241       css_property_t *direction_prop  = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
6242       css_property_t *cur;
6243       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
6244         if (cur->value && *cur->value) {
6245           attr_color = apr_pstrdup(doc->pool, cur->value);
6246         }
6247       }
6248       for (cur = bgcolor_prop->next; cur != bgcolor_prop; cur = cur->next) {
6249         if (cur->value && *cur->value) {
6250           attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
6251         }
6252       }
6253       for (cur = direction_prop->next; cur != direction_prop; cur = cur->next) {
6254         if (cur->value && *cur->value) {
6255           attr_direction = apr_pstrdup(doc->pool, cur->value);
6256         }
6257       }
6258       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
6259         if (cur->value && *cur->value) {
6260           if ( STRCASEEQ('x','X',"xx-small",cur->value)
6261             || STRCASEEQ('x','X',"x-small", cur->value)
6262             || STRCASEEQ('s','S',"small",   cur->value)
6263             || STRCASEEQ('m','M',"medium",  cur->value)
6264             || STRCASEEQ('l','L',"large",   cur->value)
6265             || STRCASEEQ('x','X',"x-large", cur->value)
6266             || STRCASEEQ('x','X',"xx-large",cur->value)) {
6267             attr_size = apr_pstrdup(doc->pool, cur->value);
6268           }
6269         }
6270       }
6271     }
6272   }
6273   W_L("<marquee");
6274   if (attr_color || attr_size || attr_direction || attr_bgcolor) {
6275     W_L(" style=\"");
6276     if (attr_direction) {
6277       W_L("-wap-marquee-dir:");
6278       W_V(attr_direction);
6279       W_L(";");
6280     }
6281     if (attr_bgcolor) {
6282       attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
6283       W_L("background-color:");
6284       W_V(attr_bgcolor);
6285       W_L(";");
6286     }
6287     if (attr_color) {
6288       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
6289       W_L("color:");
6290       W_V(attr_color);
6291       W_L(";");
6292     }
6293     if (attr_size) {
6294       W_L("font-size:");
6295       W_V(attr_size);
6296       W_L(";");
6297     }
6298     W_L("\"");
6299   }
6300   W_L(">");
6301
6302   return jxhtml->out;
6303 }
6304
6305
6306 /**
6307  * It is a handler who processes the MARQUEE tag.
6308  *
6309  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
6310  *                     destination is specified.
6311  * @param node   [i]   The MARQUEE tag node is specified.
6312  * @return The conversion result is returned.
6313  */
6314 static char *
6315 s_jxhtml_end_marquee_tag(void *pdoc, Node *UNUSED(node))
6316 {
6317   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
6318   Doc      *doc     = jxhtml->doc;
6319   W_L("</marquee>");
6320   if (IS_CSS_ON(jxhtml->entryp)) {
6321     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
6322   }
6323   return jxhtml->out;
6324 }
6325
6326
6327 /**
6328  * It is handler who processes the New Line Code.
6329  */
6330 static char *
6331 s_jxhtml_newline_mark(void *pdoc, Node *UNUSED(node))
6332 {
6333   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
6334   if (jxhtml->start_html_flag) {
6335     Doc *doc = jxhtml->doc;
6336     W_NLCODE();
6337   }
6338   return jxhtml->out;
6339 }
6340
6341
6342 /**
6343  * It is a handler who processes the LINK tag.
6344  *
6345  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
6346  *                     destination is specified.
6347  * @param node   [i]   The LINK tag node is specified.
6348  * @return The conversion result is returned.
6349  */
6350 static char *
6351 s_jxhtml_link_tag(void *pdoc, Node *node)
6352 {
6353   jxhtml_t      *jxhtml;
6354   Doc           *doc;
6355   Attr          *attr;
6356   char          *rel  = NULL;
6357   char          *href = NULL;
6358   char          *type = NULL;
6359
6360   jxhtml = GET_JXHTML(pdoc);
6361   doc    = jxhtml->doc;
6362
6363   if (! IS_CSS_ON(jxhtml->entryp)) {
6364     return jxhtml->out;
6365   }
6366
6367   for (attr = qs_get_attr(doc,node);
6368        attr;
6369        attr = qs_get_next_attr(doc,attr)) {
6370     char *name  = qs_get_attr_name(doc,attr);
6371     char *value = qs_get_attr_value(doc,attr);
6372     if (STRCASEEQ('r','R',"rel", name)) {
6373       if (value && *value && STRCASEEQ('s','S',"stylesheet", value)) {
6374         rel = value;
6375       }
6376     }
6377     else if (STRCASEEQ('h','H',"href", name)) {
6378       if (value && *value) {
6379         href = value;
6380       }
6381     }
6382     else if (STRCASEEQ('t','T',"type", name)) {
6383       if (value && *value && STRCASEEQ('t','T',"text/css",value)) {
6384         type = value;
6385       }
6386     }
6387   }
6388
6389   if (rel && href && type) {
6390     DBG(doc->r,"REQ[%X] start load CSS. url:[%s]", TO_ADDR(doc->r),href);
6391     jxhtml->style = chxj_css_parse_from_uri(doc->r, doc->pool, jxhtml->style, href);
6392     DBG(doc->r,"REQ[%X] end load CSS. url:[%s]", TO_ADDR(doc->r),href);
6393   }
6394
6395   return jxhtml->out;
6396 }
6397
6398
6399 static css_prop_list_t *
6400 s_jxhtml_push_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value)
6401 {
6402   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
6403   Doc *doc = jxhtml->doc;
6404   css_prop_list_t *last_css = NULL;
6405   if (IS_CSS_ON(jxhtml->entryp)) {
6406     css_prop_list_t *dup_css;
6407     css_selector_t  *selector;
6408
6409     last_css = chxj_css_get_last_prop_list(jxhtml->css_prop_stack);
6410     dup_css  = chxj_dup_css_prop_list(doc, last_css);
6411     selector = chxj_css_find_selector(doc, jxhtml->style, node);
6412     if (selector) {
6413       chxj_css_prop_list_merge_property(doc, dup_css, selector);
6414     }
6415     chxj_css_push_prop_list(jxhtml->css_prop_stack, dup_css);
6416     last_css = chxj_css_get_last_prop_list(jxhtml->css_prop_stack);
6417
6418     if (style_attr_value) {
6419       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));
6420       if (ssheet) {
6421         chxj_css_prop_list_merge_property(doc, last_css, ssheet->selector_head.next);
6422       }
6423     }
6424   }
6425   return last_css;
6426 }
6427
6428
6429 static css_prop_list_t *
6430 s_jxhtml_nopush_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value)
6431 {
6432   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
6433   Doc *doc = jxhtml->doc;
6434   css_prop_list_t *last_css = NULL;
6435   if (IS_CSS_ON(jxhtml->entryp)) {
6436     css_prop_list_t *dup_css;
6437     css_selector_t  *selector;
6438
6439     last_css = chxj_css_get_last_prop_list(jxhtml->css_prop_stack);
6440     dup_css  = chxj_dup_css_prop_list(doc, last_css);
6441     selector = chxj_css_find_selector(doc, jxhtml->style, node);
6442     if (selector) {
6443       chxj_css_prop_list_merge_property(doc, dup_css, selector);
6444     }
6445     last_css = dup_css;
6446
6447     if (style_attr_value) {
6448       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));
6449       if (ssheet) {
6450         chxj_css_prop_list_merge_property(doc, last_css, ssheet->selector_head.next);
6451       }
6452     }
6453   }
6454   return last_css;
6455 }
6456
6457
6458 /**
6459  * It is a handler who processes the SPAN tag.
6460  *
6461  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
6462  *                     destination is specified.
6463  * @param node   [i]   The SPAN tag node is specified.
6464  * @return The conversion result is returned.
6465  */
6466 static char *
6467 s_jxhtml_start_span_tag(void *pdoc, Node *node)
6468 {
6469   jxhtml_t *jxhtml;
6470   Doc *doc;
6471   Attr *attr;
6472   char *attr_style = NULL;
6473   char *attr_color = NULL;
6474   char *attr_size = NULL;
6475   char *attr_align = NULL;
6476   char *attr_blink = NULL;
6477   char *attr_marquee = NULL;
6478   char *attr_marquee_dir = NULL;
6479   char *attr_marquee_style = NULL;
6480   char *attr_marquee_loop = NULL;
6481   char *css_bgcolor        = NULL;
6482
6483   jxhtml = GET_JXHTML(pdoc);
6484   doc     = jxhtml->doc;
6485
6486   for (attr = qs_get_attr(doc,node);
6487        attr;
6488        attr = qs_get_next_attr(doc,attr)) {
6489     char *nm  = qs_get_attr_name(doc,attr);
6490     char *val = qs_get_attr_value(doc,attr);
6491     if (val && STRCASEEQ('s','S',"style", nm)) {
6492       attr_style = val;
6493     }
6494   }
6495   if (IS_CSS_ON(jxhtml->entryp)) {
6496     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
6497     if (style) {
6498       css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
6499       css_property_t *size_prop = chxj_css_get_property_value(doc, style, "font-size");
6500       css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
6501       css_property_t *decoration_prop = chxj_css_get_property_value(doc, style, "text-decoration");
6502       css_property_t *display_prop = chxj_css_get_property_value(doc, style, "display");
6503       css_property_t *marquee_dir_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
6504       css_property_t *marquee_style_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-style");
6505       css_property_t *marquee_loop_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-loop");
6506       css_property_t *bgcolor_prop = chxj_css_get_property_value(doc, style, "background-color");
6507       
6508       css_property_t *cur;
6509       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
6510         attr_color = apr_pstrdup(doc->pool, cur->value);
6511       }
6512       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
6513         if (cur->value && *cur->value) {
6514           if ( STRCASEEQ('x','X',"xx-small",cur->value)
6515             || STRCASEEQ('x','X',"x-small", cur->value)
6516             || STRCASEEQ('s','S',"small",   cur->value)
6517             || STRCASEEQ('m','M',"medium",  cur->value)
6518             || STRCASEEQ('l','L',"large",   cur->value)
6519             || STRCASEEQ('x','X',"x-large", cur->value)
6520             || STRCASEEQ('x','X',"xx-large",cur->value)) {
6521             attr_size = apr_pstrdup(doc->pool, cur->value);
6522           }
6523         }
6524       }
6525       for (cur = decoration_prop->next; cur != decoration_prop; cur = cur->next) {
6526         if (cur->value && STRCASEEQ('b','B',"blink",cur->value)) {
6527           attr_blink = apr_pstrdup(doc->pool, cur->value);
6528         }
6529       }
6530       for (cur = display_prop->next; cur != display_prop; cur = cur->next) {
6531         if (cur->value && strcasecmp("-wap-marquee",cur->value) == 0) {
6532           attr_marquee = apr_pstrdup(doc->pool, cur->value);
6533         }
6534       }
6535       for (cur = marquee_dir_prop->next; cur != marquee_dir_prop; cur = cur->next) {
6536         if (cur->value && *cur->value) {
6537           if ( STRCASEEQ('l','L',"ltr",cur->value)
6538             || STRCASEEQ('r','R',"rtl",cur->value)) {
6539             attr_marquee_dir = apr_pstrdup(doc->pool, cur->value);
6540           }
6541         }
6542       }
6543       for (cur = marquee_style_prop->next; cur != marquee_style_prop; cur = cur->next) {
6544         if (cur->value && *cur->value) {
6545           if ( STRCASEEQ('s','S',"scroll",cur->value)
6546             || STRCASEEQ('s','S',"slide",cur->value)
6547             || STRCASEEQ('a','A',"alternate",cur->value)) {
6548             attr_marquee_style = apr_pstrdup(doc->pool, cur->value);
6549           }
6550         }
6551       }
6552       for (cur = marquee_loop_prop->next; cur != marquee_loop_prop; cur = cur->next) {
6553         if (cur->value && *cur->value) {
6554           if(strcmp(cur->value,"0") == 0 || strcmp(cur->value,"-1") == 0){
6555             attr_marquee_loop = "infinite";
6556           }
6557           else{
6558             attr_marquee_loop = apr_pstrdup(doc->pool, cur->value);
6559           }
6560         }
6561       }
6562       for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
6563         if (STRCASEEQ('l','L',"left", cur->value)) {
6564           attr_align = apr_pstrdup(doc->pool, "left");
6565         }
6566         else if (STRCASEEQ('c','C',"center",cur->value)) {
6567           attr_align = apr_pstrdup(doc->pool, "center");
6568         }
6569         else if (STRCASEEQ('r','R',"right",cur->value)) {
6570           attr_align = apr_pstrdup(doc->pool, "right");
6571         }
6572       }
6573       for (cur = bgcolor_prop->next; cur != bgcolor_prop; cur = cur->next) {
6574         if (cur->value && *cur->value) {
6575           css_bgcolor = apr_pstrdup(doc->pool, cur->value);
6576         }
6577       }
6578     }
6579   }
6580
6581   W_L("<span");
6582   if (attr_color || attr_size || attr_align || attr_blink || attr_marquee || css_bgcolor) {
6583     W_L(" style=\"");
6584     if (attr_color) {
6585       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
6586       W_L("color:");
6587       W_V(attr_color);
6588       W_L(";");
6589     }
6590     if (attr_size) {
6591       W_L("font-size:");
6592       W_V(attr_size);
6593       W_L(";");
6594     }
6595     if (attr_align) {
6596       W_L("text-align:");
6597       W_V(attr_align);
6598       W_L(";");
6599     }
6600     if (attr_blink) {
6601       W_L("text-decoration:");
6602       W_V("blink");
6603       W_L(";");
6604     }
6605     if (attr_marquee) {
6606       W_L("display:-wap-marquee;");
6607       if (attr_marquee_dir) {
6608         W_L("-wap-marquee-dir:");
6609         W_V(attr_marquee_dir);
6610         W_L(";");
6611       }
6612       if (attr_marquee_style) {
6613         W_L("-wap-marquee-style:");
6614         W_V(attr_marquee_style);
6615         W_L(";");
6616       }
6617       if (attr_marquee_loop) {
6618         W_L("-wap-marquee-loop:");
6619         W_V(attr_marquee_loop);
6620         W_L(";");
6621       }
6622     }
6623     if(css_bgcolor){
6624       W_L("background-color:");
6625       W_V(css_bgcolor);
6626       W_L(";");
6627     }
6628     W_L("\"");
6629   }
6630   W_L(">");
6631   return jxhtml->out;
6632 }
6633
6634
6635 /**
6636  * It is a handler who processes the SPAN tag.
6637  *
6638  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
6639  *                     destination is specified.
6640  * @param node   [i]   The SPAN tag node is specified.
6641  * @return The conversion result is returned.
6642  */
6643 static char *
6644 s_jxhtml_end_span_tag(void *pdoc, Node *UNUSED(node))
6645 {
6646   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
6647   Doc *doc = jxhtml->doc;
6648
6649   W_L("</span>");
6650   if (IS_CSS_ON(jxhtml->entryp)) {
6651     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
6652   }
6653   return jxhtml->out;
6654 }
6655
6656
6657 /**
6658  * It is a handler who processes the STYLE tag.
6659  *
6660  * @param pdoc  [i/o] The pointer to the SoftBank XHTML structure at the output
6661  *                     destination is specified.
6662  * @param node   [i]   The STYLE tag node is specified.
6663  * @return The conversion result is returned.
6664  */
6665 static char *
6666 s_jxhtml_style_tag(void *pdoc, Node *node)
6667 {
6668   jxhtml_t     *jxhtml;
6669   Doc           *doc;
6670   Attr          *attr;
6671   char          *type = NULL;
6672   Node          *child   = NULL;
6673   char          *style;
6674
6675
6676   jxhtml = GET_JXHTML(pdoc);
6677   doc     = jxhtml->doc;
6678
6679   if (! IS_CSS_ON(jxhtml->entryp)) {
6680     return jxhtml->out;
6681   }
6682
6683   for (attr = qs_get_attr(doc,node);
6684        attr;
6685        attr = qs_get_next_attr(doc,attr)) {
6686     char *name  = qs_get_attr_name(doc,attr);
6687     char *value = qs_get_attr_value(doc,attr);
6688     if (STRCASEEQ('t','T',"type", name)) {
6689       if (value && *value && STRCASEEQ('t','T',"text/css",value)) {
6690         type = value;
6691       }
6692     }
6693   }
6694   if (type) {
6695     style = "";
6696     for (child = qs_get_child_node(doc, node);
6697          child;
6698          child = qs_get_next_node(doc, child)) {
6699       char *name = qs_get_node_name(doc, child);
6700       if (STRCASEEQ('t','T',"text", name)) {
6701         char *value = qs_get_node_value(doc, child);
6702         if (value && *value) {
6703           style = apr_pstrcat(doc->r->pool, style, value, NULL);
6704         }
6705       }
6706     }
6707     if (strlen(style) > 0) {
6708       DBG(doc->r,"REQ[%X] start load CSS. buf:[%s]", TO_ADDR(doc->r),style);
6709       jxhtml->style = chxj_css_parse_style_value(doc, jxhtml->style, style);
6710       DBG(doc->r,"REQ[%X] end load CSS. value:[%s]", TO_ADDR(doc->r),style);
6711     }
6712   }
6713   return jxhtml->out;
6714 }
6715 /**
6716  * It is a handler who processes the OBJECT tag.
6717  *
6718  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
6719  *                     destination is specified.
6720  * @param node   [i]   The OBJECT tag node is specified.
6721  * @return The conversion result is returned.
6722  */
6723 static char *
6724 s_jxhtml_start_object_tag(void *pdoc, Node *node)
6725 {
6726   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
6727   Doc *doc = jxhtml->doc;
6728   Attr *attr;
6729   
6730   char *attr_id            = NULL;
6731   char *attr_width         = NULL;
6732   char *attr_height        = NULL;
6733   char *attr_data          = NULL;
6734   char *attr_type          = NULL;
6735   char *attr_declare       = NULL;
6736   char *attr_classid       = NULL;
6737   char *attr_codebase      = NULL;
6738   
6739   /*--------------------------------------------------------------------------*/
6740   /* Get Attributes                                                           */
6741   /*--------------------------------------------------------------------------*/
6742   for (attr = qs_get_attr(doc,node);
6743        attr;
6744        attr = qs_get_next_attr(doc,attr)) {
6745     char *name   = qs_get_attr_name(doc,attr);
6746     char *value  = qs_get_attr_value(doc,attr);
6747     if (STRCASEEQ('i','I',"id",name)) {
6748       attr_id = apr_pstrdup(doc->pool, value);
6749     }
6750     else if (STRCASEEQ('w','W',"width",name)) {
6751       attr_width = apr_pstrdup(doc->pool, value);
6752     }
6753     else if (STRCASEEQ('h','H',"height",name)) {
6754       attr_height = apr_pstrdup(doc->pool, value);
6755     }
6756     else if (STRCASEEQ('d','D',"data",name)) {
6757       attr_data = apr_pstrdup(doc->pool, value);
6758     }
6759     else if  (STRCASEEQ('t','T',"type",name)) {
6760       attr_type = apr_pstrdup(doc->pool, value);
6761     }
6762     else if  (STRCASEEQ('d','D',"declare",name)) {
6763       attr_declare = apr_pstrdup(doc->pool, value);
6764     }
6765     else if (STRCASEEQ('c','C',"classid",name)) {
6766       attr_classid = apr_pstrdup(doc->pool, value);
6767     }
6768     else if (STRCASEEQ('c','C',"codebase",name)) {
6769       attr_codebase = apr_pstrdup(doc->pool, value);
6770     }
6771     
6772   }
6773   W_L("<object");
6774   
6775   if(attr_id){
6776     W_L(" id=\"");
6777     W_V(attr_id);
6778     W_L("\"");
6779   }
6780   if(attr_width){
6781     W_L(" width=\"");
6782     W_V(attr_width);
6783     W_L("\"");
6784   }
6785   if(attr_height){
6786     W_L(" height=\"");
6787     W_V(attr_height);
6788     W_L("\"");
6789   }
6790   if(attr_data){
6791     W_L(" data=\"");
6792     W_V(attr_data);
6793     W_L("\"");
6794   }
6795   if(attr_type){
6796     W_L(" type=\"");
6797     W_V(attr_type);
6798     W_L("\"");
6799   }
6800   if(attr_declare){
6801     W_L(" declare=\"declare\"");
6802   }
6803   if(attr_classid){
6804     W_L(" classid=\"");
6805     W_V(attr_classid);
6806     W_L("\"");
6807   }
6808   if(attr_codebase){
6809     W_L(" codebase=\"");
6810     W_V(attr_codebase);
6811     W_L("\"");
6812   }
6813   
6814   W_L(">");
6815   return jxhtml->out;
6816 }
6817 /**
6818  * It is a handler who processes the OBJECT tag.
6819  *
6820  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
6821  *                     destination is specified.
6822  * @param node   [i]   The OBJECT tag node is specified.
6823  * @return The conversion result is returned.
6824  */
6825 static char *
6826 s_jxhtml_end_object_tag(void *pdoc, Node *UNUSED(node))
6827 {
6828   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
6829   Doc *doc = jxhtml->doc;
6830
6831   W_L("</object>");
6832   return jxhtml->out;
6833 }
6834 /**
6835  * It is a handler who processes the OBJECT tag.
6836  *
6837  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
6838  *                     destination is specified.
6839  * @param node   [i]   The OBJECT tag node is specified.
6840  * @return The conversion result is returned.
6841  */
6842 static char *
6843 s_jxhtml_start_param_tag(void *pdoc, Node *node)
6844 {
6845   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
6846   Doc *doc = jxhtml->doc;
6847
6848   Attr *attr;
6849   char *attr_name          = NULL;
6850   char *attr_value         = NULL;
6851   char *attr_valuetype     = NULL;
6852   
6853   /*--------------------------------------------------------------------------*/
6854   /* Get Attributes                                                           */
6855   /*--------------------------------------------------------------------------*/
6856   for (attr = qs_get_attr(doc,node);
6857        attr;
6858        attr = qs_get_next_attr(doc,attr)) {
6859     char *name   = qs_get_attr_name(doc,attr);
6860     char *value  = qs_get_attr_value(doc,attr);
6861     if (STRCASEEQ('n','N',"name",name)) {
6862       attr_name = apr_pstrdup(doc->pool, value);
6863     }
6864     else if (STRCASEEQ('v','V',"value",name)) {
6865       attr_value = apr_pstrdup(doc->pool, value);
6866     }
6867     else if (STRCASEEQ('v','V',"valuetype",name)) {
6868       attr_valuetype = apr_pstrdup(doc->pool, value);
6869     }
6870   }
6871   W_L("<param");
6872   
6873   if(attr_name){
6874     W_L(" name=\"");
6875     W_V(attr_name);
6876     W_L("\"");
6877   }
6878   if(attr_value){
6879     W_L(" value=\"");
6880     W_V(attr_value);
6881     W_L("\"");
6882   }
6883   if(attr_valuetype){
6884     W_L(" valuetype=\"");
6885     W_V(attr_valuetype);
6886     W_L("\"");
6887   }
6888   W_L(" />");
6889   return jxhtml->out;
6890 }
6891 /**
6892  * It is a handler who processes the CAPTION tag.
6893  *
6894  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
6895  *                     destination is specified.
6896  * @param node   [i]   The CAPTION tag node is specified.
6897  * @return The conversion result is returned.
6898  */
6899 static char *
6900 s_jxhtml_start_caption_tag(void *pdoc, Node *node)
6901 {
6902   jxhtml_t    *jxhtml;
6903   Doc         *doc;
6904   request_rec *r;
6905   Attr        *attr;
6906   char        *attr_style = NULL;
6907   char        *attr_align = NULL;
6908
6909   jxhtml = GET_JXHTML(pdoc);
6910   doc    = jxhtml->doc;
6911   r      = doc->r;
6912
6913   for (attr = qs_get_attr(doc,node);
6914        attr;
6915        attr = qs_get_next_attr(doc,attr)) {
6916     char *name  = qs_get_attr_name(doc,attr);
6917     char *value = qs_get_attr_value(doc,attr);
6918     if (STRCASEEQ('a','A',"align", name)) {
6919       if (value && 
6920           (STRCASEEQ('l','L',"left",value) 
6921         || STRCASEEQ('r','R',"right",value) 
6922         || STRCASEEQ('t','T',"top",value)
6923         || STRCASEEQ('b','B',"bottom",value) 
6924         )) {
6925         attr_align = value;
6926       }
6927     }
6928     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
6929       attr_style = value;
6930     }
6931   }
6932   
6933   W_L("<caption");
6934   if(attr_align){
6935     W_L(" align=\"");
6936     W_V(attr_align);
6937     W_L("\"");
6938   }
6939   W_L(">");
6940
6941   return jxhtml->out;
6942 }
6943
6944
6945 /**
6946  * It is a handler who processes the CAPTION tag.
6947  *
6948  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
6949  *                     destination is specified.
6950  * @param node   [i]   The CAPTION tag node is specified.
6951  * @return The conversion result is returned.
6952  */
6953 static char *
6954 s_jxhtml_end_caption_tag(void *pdoc, Node *UNUSED(child)) 
6955 {
6956   jxhtml_t*    jxhtml = GET_JXHTML(pdoc);
6957   Doc*          doc   = jxhtml->doc;
6958   
6959   W_L("</caption>");
6960   
6961   return jxhtml->out;
6962 }
6963
6964
6965 /*
6966  * vim:ts=2 et
6967  */