OSDN Git Service

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