OSDN Git Service

Merge branch 'master' into branch_0.13.0
[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_align  = NULL;
3647   char        *attr_alt    = NULL;
3648   char        *attr_style  = NULL;
3649   char        *attr_hspace = NULL;
3650   char        *attr_vspace = NULL;
3651   
3652   char        *css_float          = NULL;
3653   char        *css_margin_left    = NULL;
3654   char        *css_margin_right   = NULL;
3655   char        *css_margin_top     = NULL;
3656   char        *css_margin_bottom  = NULL;
3657   char        *css_display        = NULL;
3658   char        *css_valign         = NULL;
3659   
3660 #ifndef IMG_NOT_CONVERT_FILENAME
3661   device_table  *spec = jxhtml->spec;
3662 #endif
3663
3664   /*--------------------------------------------------------------------------*/
3665   /* Get Attributes                                                           */
3666   /*--------------------------------------------------------------------------*/
3667   for (attr = qs_get_attr(doc,node);
3668        attr;
3669        attr = qs_get_next_attr(doc,attr)) {
3670     char *name  = qs_get_attr_name(doc,attr);
3671     char *value = qs_get_attr_value(doc,attr);
3672     if (STRCASEEQ('s','S',"src",name)) {
3673       /*----------------------------------------------------------------------*/
3674       /* CHTML 1.0                                                            */
3675       /*----------------------------------------------------------------------*/
3676 #ifdef IMG_NOT_CONVERT_FILENAME
3677       value = chxj_encoding_parameter(r, value, 1);
3678       value = chxj_jreserved_tag_to_safe_for_query_string(r, value, jxhtml->entryp, 1);
3679       value = chxj_add_cookie_no_update_parameter(r, value);
3680       value = chxj_img_rewrite_parameter(r,jxhtml->conf,value);
3681       attr_src = value;
3682 #else
3683       value = chxj_img_conv(r, spec, value);
3684       value = chxj_encoding_parameter(r, value, 1);
3685       value = chxj_jreserved_tag_to_safe_for_query_string(r, value, jxhtml->entryp, 1);
3686       value = chxj_add_cookie_no_update_parameter(r, value);
3687       value = chxj_img_rewrite_parameter(r,jxhtml->conf,value);
3688       attr_src = value;
3689 #endif
3690     }
3691     else if (STRCASEEQ('a','A',"align",name)) {
3692       /*----------------------------------------------------------------------*/
3693       /* CHTML 1.0                                                            */
3694       /*----------------------------------------------------------------------*/
3695       if (value) {
3696         if (STRCASEEQ('t','T',"top",   value) ||
3697             STRCASEEQ('m','M',"middle",value) ||
3698             STRCASEEQ('b','B',"bottom",value)){
3699           css_valign = value;
3700         }else if (STRCASEEQ('l','L',"left",  value) || STRCASEEQ('r','R',"right", value)) {
3701           css_float = value;
3702         }
3703         else if (STRCASEEQ('c','C',"center",value)) {
3704           css_valign = apr_pstrdup(doc->pool, "middle");
3705         }
3706       }
3707     }
3708     else if (STRCASEEQ('w','W',"width",name) && value && *value) {
3709       /*----------------------------------------------------------------------*/
3710       /* CHTML 1.0                                                            */
3711       /*----------------------------------------------------------------------*/
3712       attr_width = value;
3713     }
3714     else if (STRCASEEQ('h','H',"height",name) && value && *value) {
3715       /*----------------------------------------------------------------------*/
3716       /* CHTML 1.0                                                            */
3717       /*----------------------------------------------------------------------*/
3718       attr_height = value;
3719     }
3720     else if (STRCASEEQ('h','H',"hspace",name)) {
3721       /*----------------------------------------------------------------------*/
3722       /* CHTML 1.0                                                            */
3723       /*----------------------------------------------------------------------*/
3724       attr_hspace = value;
3725     }
3726     else if (STRCASEEQ('v','V',"vspace",name)) {
3727       /*----------------------------------------------------------------------*/
3728       /* CHTML 1.0                                                            */
3729       /*----------------------------------------------------------------------*/
3730       attr_vspace = value;
3731     }
3732     else if (STRCASEEQ('a','A',"alt",name) && value && *value) {
3733       /*----------------------------------------------------------------------*/
3734       /* CHTML 1.0                                                            */
3735       /*----------------------------------------------------------------------*/
3736       attr_alt = value;
3737     }
3738     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3739       /*----------------------------------------------------------------------*/
3740       /* CHTML 1.0                                                            */
3741       /*----------------------------------------------------------------------*/
3742       attr_style = value;
3743     }
3744   }
3745
3746   if (IS_CSS_ON(jxhtml->entryp)) {
3747     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
3748     if (style) {
3749       css_property_t *height_prop = chxj_css_get_property_value(doc, style, "height");
3750       css_property_t *width_prop  = chxj_css_get_property_value(doc, style, "width");
3751       css_property_t *valign_prop = chxj_css_get_property_value(doc, style, "vertical-align");
3752       css_property_t *margin_left_prop   = chxj_css_get_property_value(doc, style, "margin-left");
3753       css_property_t *margin_right_prop  = chxj_css_get_property_value(doc, style, "margin-right");
3754       css_property_t *margin_top_prop    = chxj_css_get_property_value(doc, style, "margin-top");
3755       css_property_t *margin_bottom_prop = chxj_css_get_property_value(doc, style, "margin-bottom");
3756       
3757       
3758       css_property_t *cur;
3759       for (cur = height_prop->next; cur != height_prop; cur = cur->next) {
3760         attr_height = apr_pstrdup(doc->pool, cur->value);
3761       }
3762       for (cur = width_prop->next; cur != width_prop; cur = cur->next) {
3763         attr_width = apr_pstrdup(doc->pool, cur->value);
3764       }
3765       if(!css_valign){
3766         for (cur = valign_prop->next; cur != valign_prop; cur = cur->next) {
3767           css_valign = apr_pstrdup(doc->pool, cur->value);
3768         }
3769       }
3770       if (! attr_hspace) {
3771         for (cur = margin_left_prop->next; cur != margin_left_prop; cur = cur->next) {
3772           css_margin_left   = apr_pstrdup(doc->pool, cur->value);
3773         }
3774         for (cur = margin_right_prop->next; cur != margin_right_prop; cur = cur->next) {
3775           css_margin_right  = apr_pstrdup(doc->pool, cur->value);
3776         }
3777       }
3778       if (! attr_vspace) {
3779         for (cur = margin_top_prop->next; cur != margin_top_prop; cur = cur->next) {
3780           css_margin_top = apr_pstrdup(doc->pool, cur->value);
3781         }
3782         for (cur = margin_bottom_prop->next; cur != margin_bottom_prop; cur = cur->next) {
3783           css_margin_bottom = apr_pstrdup(doc->pool, cur->value);
3784         }
3785       }
3786       if(!css_float){
3787         css_property_t *float_prop = chxj_css_get_property_value(doc, style, "float");
3788         for (cur = float_prop->next; cur != float_prop; cur = cur->next) {
3789           css_float = apr_pstrdup(doc->pool, cur->value);
3790         }
3791       }
3792       
3793       css_property_t *display_prop       = chxj_css_get_property_value(doc, style, "display");
3794       for (cur = display_prop->next; cur != display_prop; cur = cur->next) {
3795         char *tmp = apr_pstrdup(doc->pool, cur->value);
3796         char *tmpp = strstr(tmp, "none");
3797         if(tmpp){
3798           css_display = apr_pstrdup(doc->pool, tmp);
3799         }
3800       }
3801     }
3802   }
3803
3804   W_L("<img");
3805   if (attr_src) {
3806     W_L(" src=\"");
3807     W_V(attr_src);
3808     W_L("\"");
3809   }
3810   if (attr_hspace || attr_vspace || css_float || css_margin_left || css_margin_right || css_margin_top || css_margin_bottom || css_valign || css_display) {
3811     W_L(" style=\"");
3812     if(css_float){
3813       W_L("float:");
3814       W_V(css_float);
3815       W_L(";");
3816     }
3817     if(css_valign){
3818       W_L("vertical-align:");
3819       W_V(css_valign);
3820       W_L(";");
3821     }
3822     if (attr_hspace) {
3823       W_L("margin-left:");
3824       W_V(attr_hspace);
3825       W_L(";");
3826       W_L("margin-right:");
3827       W_V(attr_hspace);
3828       W_L(";");
3829     }
3830     else{
3831       if(css_margin_left){
3832         W_L("margin-left:");
3833         W_V(css_margin_left);
3834         W_L(";");
3835       }
3836       if(css_margin_right){
3837         W_L("margin-right:");
3838         W_V(css_margin_right);
3839         W_L(";");
3840       }
3841     }
3842     if (attr_vspace) {
3843       W_L("margin-top:");
3844       W_V(attr_vspace);
3845       W_L(";");
3846       W_L("margin-bottom:");
3847       W_V(attr_vspace);
3848       W_L(";");
3849     }
3850     else{
3851       if(css_margin_top){
3852         W_L("margin-top:");
3853         W_V(css_margin_top);
3854         W_L(";");
3855       }
3856       if(css_margin_bottom){
3857         W_L("margin-bottom:");
3858         W_V(css_margin_bottom);
3859         W_L(";");
3860       }
3861     }
3862     if(css_display){
3863       W_L("display:none;");
3864     }
3865     W_L("\"");
3866   }
3867   
3868   if (attr_width) {
3869     W_L(" width=\"");
3870     W_V(attr_width);
3871     W_L("\"");
3872   }
3873   if (attr_height) {
3874     W_L(" height=\"");
3875     W_V(attr_height);
3876     W_L("\"");
3877   }
3878   if (attr_alt) {
3879     W_L(" alt=\"");
3880     W_V(attr_alt);
3881     W_L("\"");
3882   } 
3883   else {
3884     W_L(" alt=\"\"");
3885   }
3886   W_L(" />");
3887   return jxhtml->out;
3888 }
3889
3890
3891 /**
3892  * It is a handler who processes the IMG tag.
3893  *
3894  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
3895  *                     destination is specified.
3896  * @param node   [i]   The IMG tag node is specified.
3897  * @return The conversion result is returned.
3898  */
3899 static char *
3900 s_jxhtml_end_img_tag(void *pdoc, Node *UNUSED(child)) 
3901 {
3902   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
3903   return jxhtml->out;
3904 }
3905
3906
3907 /**
3908  * It is a handler who processes the SELECT tag.
3909  *
3910  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
3911  *                     destination is specified.
3912  * @param node   [i]   The SELECT tag node is specified.
3913  * @return The conversion result is returned.
3914  */
3915 static char *
3916 s_jxhtml_start_select_tag(void *pdoc, Node *node)
3917 {
3918   jxhtml_t *jxhtml    = GET_JXHTML(pdoc);
3919   Doc     *doc      = jxhtml->doc;
3920   Attr    *attr;
3921   char    *size     = NULL;
3922   char    *name     = NULL;
3923   char    *multiple = NULL;
3924   char    *attr_style = NULL;
3925
3926   W_L("<select");
3927   for (attr = qs_get_attr(doc,node);
3928        attr;
3929        attr = qs_get_next_attr(doc,attr)) {
3930     char *nm  = qs_get_attr_name(doc,attr);
3931     char *val = qs_get_attr_value(doc,attr);
3932     if (STRCASEEQ('s','S',"size",nm)) {
3933       /*----------------------------------------------------------------------*/
3934       /* CHTML 1.0 version 2.0                                                */
3935       /*----------------------------------------------------------------------*/
3936       size = apr_pstrdup(doc->buf.pool, val);
3937     }
3938     else if (STRCASEEQ('s','S',"style",nm) && val && *val) {
3939       /*----------------------------------------------------------------------*/
3940       /* CHTML 1.0 version 2.0                                                */
3941       /*----------------------------------------------------------------------*/
3942       attr_style = apr_pstrdup(doc->buf.pool, val);
3943     }
3944     else if (STRCASEEQ('n','N',"name",nm)) {
3945       /*----------------------------------------------------------------------*/
3946       /* CHTML 1.0 version 2.0                                                */
3947       /*----------------------------------------------------------------------*/
3948       name = apr_pstrdup(doc->buf.pool, val);
3949     }
3950     else if (STRCASEEQ('m','M',"multiple", nm)) {
3951       /*----------------------------------------------------------------------*/
3952       /* CHTML 1.0 version 2.0                                                */
3953       /*----------------------------------------------------------------------*/
3954       multiple = apr_pstrdup(doc->buf.pool, val);
3955     }
3956   }
3957   if (size && *size) {
3958     W_L(" size=\"");
3959     W_V(size);
3960     W_L("\"");
3961   }
3962   if (name && *name) {
3963     W_L(" name=\"");
3964     W_V(name);
3965     W_L("\"");
3966   }
3967   if (multiple) {
3968     W_L(" multiple");
3969   }
3970   W_L(">");
3971
3972   if (IS_CSS_ON(jxhtml->entryp)) {
3973     s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
3974   }
3975
3976   return jxhtml->out;
3977 }
3978
3979
3980 /**
3981  * It is a handler who processes the SELECT tag.
3982  *
3983  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
3984  *                     destination is specified.
3985  * @param node   [i]   The SELECT tag node is specified.
3986  * @return The conversion result is returned.
3987  */
3988 static char *
3989 s_jxhtml_end_select_tag(void *pdoc, Node *UNUSED(child))
3990 {
3991   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
3992   Doc     *doc   = jxhtml->doc;
3993
3994   W_L("</select>");
3995   if (IS_CSS_ON(jxhtml->entryp)) {
3996     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
3997   }
3998
3999   return jxhtml->out;
4000 }
4001
4002 /**
4003  * It is a handler who processes the OPTION tag.
4004  *
4005  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4006  *                     destination is specified.
4007  * @param node   [i]   The OPTION tag node is specified.
4008  * @return The conversion result is returned.
4009  */
4010 static char *
4011 s_jxhtml_start_option_tag(void *pdoc, Node *node)
4012 {
4013   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
4014   Doc     *doc   = jxhtml->doc;
4015   Attr    *attr;
4016
4017   char *selected   = NULL;
4018   char *value      = NULL;
4019   char *attr_style = NULL;
4020
4021   W_L("<option");
4022   for (attr = qs_get_attr(doc,node);
4023        attr;
4024        attr = qs_get_next_attr(doc,attr)) {
4025     char *nm  = qs_get_attr_name(doc,attr);
4026     char *val = qs_get_attr_value(doc,attr);
4027     if (STRCASEEQ('s','S',"selected",nm)) {
4028       /*----------------------------------------------------------------------*/
4029       /* CHTML 1.0 version 2.0                                                */
4030       /*----------------------------------------------------------------------*/
4031       selected = apr_pstrdup(doc->buf.pool, val);
4032     }
4033     else if (STRCASEEQ('s','S',"style",nm) && val && *val) {
4034       /*----------------------------------------------------------------------*/
4035       /* CHTML 1.0 version 2.0                                                */
4036       /*----------------------------------------------------------------------*/
4037       attr_style = apr_pstrdup(doc->buf.pool, val);
4038     }
4039     else if (STRCASEEQ('v','V',"value",nm)) {
4040       /*----------------------------------------------------------------------*/
4041       /* CHTML 1.0 version 2.0                                                */
4042       /*----------------------------------------------------------------------*/
4043       value = apr_pstrdup(doc->buf.pool, val);
4044     }
4045   }
4046   if (value) {
4047     W_L(" value=\"");
4048     W_V(value);
4049     W_L("\"");
4050   }
4051   if (selected) {
4052     W_L(" selected");
4053   }
4054   W_L(">");
4055
4056   if (IS_CSS_ON(jxhtml->entryp)) {
4057     s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
4058   }
4059
4060   return jxhtml->out;
4061 }
4062
4063
4064 /**
4065  * It is a handler who processes the OPTION tag.
4066  *
4067  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4068  *                     destination is specified.
4069  * @param node   [i]   The OPTION tag node is specified.
4070  * @return The conversion result is returned.
4071  */
4072 static char *
4073 s_jxhtml_end_option_tag(void *pdoc, Node *UNUSED(child))
4074 {
4075   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
4076   Doc      *doc = jxhtml->doc;
4077
4078   W_L("</option>");
4079   if (IS_CSS_ON(jxhtml->entryp)) {
4080     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
4081   }
4082
4083   return jxhtml->out;
4084 }
4085
4086
4087 /**
4088  * It is a handler who processes the DIV tag.
4089  *
4090  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4091  *                     destination is specified.
4092  * @param node   [i]   The DIV tag node is specified.
4093  * @return The conversion result is returned.
4094  */
4095 static char *
4096 s_jxhtml_start_div_tag(void *pdoc, Node *node)
4097 {
4098   jxhtml_t    *jxhtml;
4099   Doc         *doc;
4100   request_rec *r;
4101   Attr        *attr;
4102   char        *attr_style             = NULL;
4103   char        *attr_align             = NULL;
4104   char        *attr_display           = NULL;
4105   char        *attr_decoration        = NULL;
4106   char        *attr_wap_marquee_style = NULL;
4107   char        *attr_wap_marquee_dir   = NULL;
4108   char        *attr_wap_marquee_loop  = NULL;
4109   char        *attr_color             = NULL;
4110   char        *attr_bgcolor           = NULL;
4111   char        *attr_font_size         = NULL;
4112   char        *css_clear              = NULL;
4113
4114   jxhtml = GET_JXHTML(pdoc);
4115   doc   = jxhtml->doc;
4116   r     = doc->r;
4117
4118   for (attr = qs_get_attr(doc,node);
4119        attr;
4120        attr = qs_get_next_attr(doc,attr)) {
4121     char *nm  = qs_get_attr_name(doc,attr);
4122     char *val = qs_get_attr_value(doc,attr);
4123     if (STRCASEEQ('a','A',"align",nm)) {
4124       /*----------------------------------------------------------------------*/
4125       /* CHTML 1.0 (W3C version 3.2)                                          */
4126       /*----------------------------------------------------------------------*/
4127       if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
4128         attr_align = apr_pstrdup(doc->buf.pool, val);
4129       }
4130     }
4131     else if (STRCASEEQ('s','S',"style",nm) && val && *val) {
4132       attr_style = apr_pstrdup(doc->buf.pool, val);
4133     }
4134   }
4135
4136   if (IS_CSS_ON(jxhtml->entryp)) {
4137     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
4138     if (style) {
4139       css_property_t *display_prop           = chxj_css_get_property_value(doc, style, "display");
4140       css_property_t *text_decoration_prop   = chxj_css_get_property_value(doc, style, "text-decoration");
4141       css_property_t *color_prop             = chxj_css_get_property_value(doc, style, "color");
4142       css_property_t *text_align_prop        = chxj_css_get_property_value(doc, style, "text-align");
4143       css_property_t *font_size_prop         = chxj_css_get_property_value(doc, style, "font-size");
4144       css_property_t *background_color_prop  = chxj_css_get_property_value(doc, style, "background-color");
4145       css_property_t *background_prop        = chxj_css_get_property_value(doc, style, "background");
4146       css_property_t *clear_prop             = chxj_css_get_property_value(doc, style, "clear");
4147
4148       css_property_t *cur;
4149       for (cur = display_prop->next; cur != display_prop; cur = cur->next) {
4150         if (strcasecmp("-wap-marquee", cur->value) == 0) {
4151           attr_display = apr_pstrdup(doc->pool, cur->value);
4152         }
4153       }
4154       for (cur = text_decoration_prop->next; cur != text_decoration_prop; cur = cur->next) {
4155         if (STRCASEEQ('b','B',"blink", cur->value)) {
4156           attr_decoration = apr_pstrdup(doc->pool, cur->value);
4157         }
4158       }
4159       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4160         attr_color = apr_pstrdup(doc->pool, cur->value);
4161       }
4162       for (cur = background_color_prop->next; cur != background_color_prop; cur = cur->next) {
4163         attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
4164         attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
4165       }
4166       for (cur = background_prop->next; cur != background_prop; cur = cur->next) {
4167         char *ss = strchr(cur->value, '#');
4168         if (!ss || !*ss) {
4169           ss = strstr(cur->value, "rgb");
4170         }
4171         if (ss && *ss) {
4172           attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
4173           attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
4174         }
4175       }
4176       for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
4177         attr_align = apr_pstrdup(doc->pool, cur->value);
4178       }
4179       for (cur = font_size_prop->next; cur != font_size_prop; cur = cur->next) {
4180         if (   STRCASEEQ('x','X',"xx-small",cur->value)
4181             || STRCASEEQ('x','X',"x-small",cur->value)
4182             || STRCASEEQ('s','S',"small",cur->value)
4183             || STRCASEEQ('m','M',"medium",cur->value)
4184             || STRCASEEQ('l','L',"large",cur->value)
4185             || STRCASEEQ('x','X',"x-large",cur->value)
4186             || STRCASEEQ('x','X',"xx-large",cur->value)) {
4187           attr_font_size = apr_pstrdup(doc->pool, cur->value);
4188         }
4189       }
4190       if (attr_display) {
4191         css_property_t *wap_marquee_style_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-style");
4192         css_property_t *wap_marquee_dir_prop   = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
4193         css_property_t *wap_marquee_loop_prop  = chxj_css_get_property_value(doc, style, "-wap-marquee-loop");
4194         for (cur = wap_marquee_style_prop->next; cur != wap_marquee_style_prop; cur = cur->next) {
4195           if (STRCASEEQ('s','S',"scroll", cur->value) || STRCASEEQ('s','S',"slide",cur->value) || STRCASEEQ('a','A',"alternate",cur->value)) {
4196             attr_wap_marquee_style = apr_pstrdup(doc->pool, cur->value);
4197           }
4198         }
4199         for (cur = wap_marquee_dir_prop->next; cur != wap_marquee_dir_prop; cur = cur->next) {
4200           if (STRCASEEQ('l','L',"ltr",cur->value)) {
4201             attr_wap_marquee_dir = apr_pstrdup(doc->pool, cur->value);
4202           }
4203           else if (STRCASEEQ('r','R',"rtl",cur->value)) {
4204             attr_wap_marquee_dir = apr_pstrdup(doc->pool, cur->value);
4205           }
4206         }
4207         for (cur = wap_marquee_loop_prop->next; cur != wap_marquee_loop_prop; cur = cur->next) {
4208           if(strcmp(cur->value,"0") == 0 || strcmp(cur->value,"-1") == 0){
4209             attr_wap_marquee_loop = "infinite";
4210           }
4211           else{
4212             attr_wap_marquee_loop = apr_pstrdup(doc->pool, cur->value);
4213           }
4214         }
4215       }
4216       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
4217         css_clear = apr_pstrdup(doc->pool, cur->value);
4218       }
4219     }
4220   }  
4221   W_L("<div");
4222   if (attr_align
4223       || attr_display
4224       || attr_decoration
4225       || attr_wap_marquee_style
4226       || attr_wap_marquee_dir
4227       || attr_wap_marquee_loop
4228       || attr_color
4229       || attr_bgcolor
4230       || attr_font_size
4231       || css_clear ) {
4232     W_L(" style=\"");
4233     if (attr_align) {
4234       W_L("text-align:");
4235       W_V(attr_align);
4236       W_L(";");
4237     }
4238     if (attr_display) {
4239       W_L("display:");
4240       W_V(attr_display);
4241       W_L(";");
4242     }
4243     if (attr_decoration) {
4244       W_L("text-decoration:");
4245       W_V(attr_decoration);
4246       W_L(";");
4247     }
4248     if (attr_wap_marquee_style) {
4249       W_L("-wap-marquee-style:");
4250       W_V(attr_wap_marquee_style);
4251       W_L(";");
4252     }
4253     if (attr_wap_marquee_dir) {
4254       W_L("-wap-marquee-dir:");
4255       W_V(attr_wap_marquee_dir);
4256       W_L(";");
4257     }
4258     if (attr_wap_marquee_loop) {
4259       W_L("-wap-marquee-loop:");
4260       W_V(attr_wap_marquee_loop);
4261       W_L(";");
4262     }
4263     if (attr_color) {
4264       W_L("color:");
4265       W_V(attr_color);
4266       W_L(";");
4267     }
4268     if (attr_bgcolor) {
4269       W_L("background-color:");
4270       W_V(attr_bgcolor);
4271       W_L(";");
4272     }
4273     if (attr_font_size) {
4274       W_L("font-size:");
4275       W_V(attr_font_size);
4276       W_L(";");
4277     }
4278     if (css_clear){
4279       W_L("clear:");
4280       W_V(css_clear);
4281       W_L(";");
4282     }
4283     W_L("\"");
4284   }
4285   W_L(">");
4286   return jxhtml->out;
4287 }
4288
4289
4290 /**
4291  * It is a handler who processes the DIV tag.
4292  *
4293  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4294  *                     destination is specified.
4295  * @param node   [i]   The DIV tag node is specified.
4296  * @return The conversion result is returned.
4297  */
4298 static char *
4299 s_jxhtml_end_div_tag(void *pdoc, Node *UNUSED(child))
4300 {
4301   jxhtml_t      *jxhtml;
4302   Doc          *doc;
4303   request_rec  *r;
4304
4305   jxhtml = GET_JXHTML(pdoc);
4306   doc   = jxhtml->doc;
4307   r     = doc->r;
4308
4309   W_L("</div>");
4310   if (IS_CSS_ON(jxhtml->entryp)) {
4311     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
4312   }
4313   return jxhtml->out;
4314 }
4315
4316
4317 static char *
4318 s_jxhtml_chxjif_tag(void *pdoc, Node *node)
4319 {
4320   jxhtml_t *jxhtml;
4321   Doc     *doc;
4322   Node    *child;
4323   request_rec *r;
4324
4325   jxhtml = GET_JXHTML(pdoc);
4326   doc   = jxhtml->doc;
4327   r     = doc->r;
4328
4329   for (child = qs_get_child_node(doc, node);
4330        child;
4331        child = qs_get_next_node(doc, child)) {
4332     W_V(child->otext);
4333     s_jxhtml_chxjif_tag(jxhtml, child);
4334   }
4335   return NULL;
4336 }
4337
4338
4339 /**
4340  * It is a handler who processes the TEXTARE tag.
4341  *
4342  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4343  *                     destination is specified.
4344  * @param node   [i]   The TEXTAREA tag node is specified.
4345  * @return The conversion result is returned.
4346  */
4347 static char *
4348 s_jxhtml_start_textarea_tag(void *pdoc, Node *node) 
4349 {
4350   jxhtml_t      *jxhtml;
4351   Doc           *doc;
4352   request_rec   *r;
4353   Attr          *attr;
4354   char          *attr_accesskey = NULL;
4355   char          *attr_name      = NULL;
4356   char          *attr_rows      = NULL;
4357   char          *attr_cols      = NULL;
4358   char          *attr_istyle    = NULL;
4359   char          *attr_style     = NULL;
4360
4361
4362   jxhtml = GET_JXHTML(pdoc);
4363   doc   = jxhtml->doc;
4364   r     = doc->r;
4365
4366   jxhtml->textarea_flag++;
4367   for (attr = qs_get_attr(doc,node);
4368        attr;
4369        attr = qs_get_next_attr(doc,attr)) {
4370     char *name  = qs_get_attr_name(doc,attr);
4371     char *value = qs_get_attr_value(doc,attr);
4372     if (STRCASEEQ('a','A',"accesskey",name) && value && *value != 0) {
4373       attr_accesskey = value;
4374     }
4375     else if (STRCASEEQ('i','I',"istyle", name) && value && (*value == '1' || *value == '2' || *value == '3' || *value == '4')) {
4376       attr_istyle = value;
4377     }
4378     else if (STRCASEEQ('n','N',"name", name) && value && *value) {
4379       attr_name = value;
4380     }
4381     else if (STRCASEEQ('r','R',"rows", name) && value && *value) {
4382       attr_rows = value;
4383     }
4384     else if (STRCASEEQ('c','C',"cols", name) && value && *value) {
4385       attr_cols = value;
4386     }
4387     else if (STRCASEEQ('s','S',"style", name) && value && *value) {
4388       attr_style = value;
4389     }
4390   }
4391   if (IS_CSS_ON(jxhtml->entryp)) {
4392     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
4393     if (style) {
4394       css_property_t *wap_input_format = chxj_css_get_property_value(doc, style, "-wap-input-format");
4395       css_property_t *cur;
4396       for (cur = wap_input_format->next; cur != wap_input_format; cur = cur->next) {
4397         if (strcasestr(cur->value, "<ja:n>")) {
4398           attr_istyle = "4";
4399         }
4400         else if (strcasestr(cur->value, "<ja:en>")) {
4401           attr_istyle = "3";
4402         }
4403         else if (strcasestr(cur->value, "<ja:hk>")) {
4404           attr_istyle = "2";
4405         }
4406         else if (strcasestr(cur->value, "<ja:h>")) {
4407           attr_istyle = "1";
4408         }
4409       }
4410     }
4411   }
4412   W_L("<textarea");
4413   if (attr_accesskey) {
4414     W_L(" accesskey=\"");
4415     W_V(attr_accesskey);
4416     W_L("\"");
4417   }
4418   if (attr_name) {
4419     W_L(" name=\"");
4420     W_V(attr_name);
4421     W_L("\"");
4422   }
4423   if (attr_rows) {
4424     W_L(" rows=\"");
4425     W_V(attr_rows);
4426     W_L("\"");
4427   }
4428   if (attr_cols) {
4429     W_L(" cols=\"");
4430     W_V(attr_cols);
4431     W_L("\"");
4432   }
4433   if (attr_istyle) {
4434     W_L(" istyle=\"");
4435     W_V(attr_istyle);
4436     W_L("\"");
4437
4438     char *vv = s_jxhtml_istyle_to_wap_input_format(doc->buf.pool,attr_istyle);
4439         W_L(" style=\"");
4440         W_L("-wap-input-format:");
4441         W_V(vv);
4442         W_L(";");
4443         W_L("\"");
4444
4445   }
4446   W_L(">");
4447   return jxhtml->out;
4448 }
4449
4450
4451 /**
4452  * It is a handler who processes the TEXTAREA tag.
4453  *
4454  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4455  *                     destination is specified.
4456  * @param node   [i]   The TEXTAREA tag node is specified.
4457  * @return The conversion result is returned.
4458  */
4459 static char *
4460 s_jxhtml_end_textarea_tag(void *pdoc, Node *UNUSED(child)) 
4461 {
4462   jxhtml_t       *jxhtml;
4463   Doc           *doc;
4464   request_rec   *r;
4465
4466   jxhtml = GET_JXHTML(pdoc);
4467   doc   = jxhtml->doc;
4468   r     = doc->r;
4469
4470   W_L("</textarea>");
4471   jxhtml->textarea_flag--;
4472
4473   return jxhtml->out;
4474 }
4475
4476
4477 /**
4478  * It is a handler who processes the B tag.
4479  *
4480  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4481  *                     destination is specified.
4482  * @param node   [i]   The B tag node is specified.
4483  * @return The conversion result is returned.
4484  */
4485 static char*
4486 s_jxhtml_start_b_tag(void* pdoc, Node* UNUSED(node)) 
4487 {
4488   jxhtml_t*      jxhtml;
4489   Doc*          doc;
4490   request_rec*  r;
4491
4492   jxhtml = GET_JXHTML(pdoc);
4493   doc   = jxhtml->doc;
4494   r     = doc->r;
4495
4496   W_L("<b>");
4497   return jxhtml->out;
4498 }
4499
4500
4501 /**
4502  * It is a handler who processes the B tag.
4503  *
4504  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4505  *                     destination is specified.
4506  * @param node   [i]   The B tag node is specified.
4507  * @return The conversion result is returned.
4508  */
4509 static char*
4510 s_jxhtml_end_b_tag(void* pdoc, Node* UNUSED(child)) 
4511 {
4512   jxhtml_t*      jxhtml = GET_JXHTML(pdoc);
4513   Doc*          doc   = jxhtml->doc;
4514
4515   W_L("</b>");
4516   return jxhtml->out;
4517 }
4518
4519 static char*
4520 s_jxhtml_text_tag(void* pdoc, Node* child)
4521 {
4522   jxhtml_t*     jxhtml;
4523   Doc*         doc;
4524   char*        textval;
4525   char*        tmp;
4526   char*        tdst;
4527   char         one_byte[2];
4528   int          ii;
4529   int          tdst_len;
4530   request_rec* r;
4531   apr_size_t   z2h_input_len;
4532
4533   jxhtml = GET_JXHTML(pdoc);
4534   doc   = jxhtml->doc;
4535   r     = doc->r;
4536
4537   textval = qs_get_node_value(doc,child);
4538   if (strlen(textval) == 0) {
4539     return jxhtml->out;
4540   }
4541
4542   tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
4543   memset(tmp, 0, qs_get_node_size(doc,child)+1);
4544
4545   tdst     = qs_alloc_zero_byte_string(doc->buf.pool);
4546   memset(one_byte, 0, sizeof(one_byte));
4547   tdst_len = 0;
4548
4549   for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
4550     char* out;
4551     int rtn = s_jxhtml_search_emoji(jxhtml, &textval[ii], &out);
4552     if (rtn) {
4553       tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
4554       ii+=(rtn - 1);
4555       continue;
4556     }
4557
4558     if (is_sjis_kanji(textval[ii])) {
4559       one_byte[0] = textval[ii+0];
4560       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
4561       one_byte[0] = textval[ii+1];
4562       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
4563       ii++;
4564     }
4565     else 
4566     if (jxhtml->pre_flag) {
4567       one_byte[0] = textval[ii+0];
4568       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
4569     }
4570     else
4571     if (jxhtml->textarea_flag) {
4572       one_byte[0] = textval[ii+0];
4573       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
4574     }
4575     else {
4576       if (textval[ii] != '\r' && textval[ii] != '\n') {
4577         one_byte[0] = textval[ii+0];
4578         tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
4579       }
4580     }
4581   }
4582   z2h_input_len = strlen(tdst);
4583   tdst = chxj_conv_z2h(r, tdst, &z2h_input_len, jxhtml->entryp);
4584
4585   W_V(tdst);
4586   return jxhtml->out;
4587 }
4588
4589
4590 /**
4591  * It is a handler who processes the BLOCKQUOTE tag.
4592  *
4593  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4594  *                     destination is specified.
4595  * @param node   [i]   The BLOCKQUOTE tag node is specified.
4596  * @return The conversion result is returned.
4597  */
4598 static char *
4599 s_jxhtml_start_blockquote_tag(void *pdoc, Node *node)
4600 {
4601   jxhtml_t *jxhtml;
4602   Doc      *doc;
4603   Attr     *attr;
4604   char     *attr_style = NULL;
4605   char     *attr_color = NULL;
4606   char     *attr_size  = NULL;
4607   char     *css_clear  = NULL;
4608
4609   jxhtml  = GET_JXHTML(pdoc);
4610   doc     = jxhtml->doc;
4611   for (attr = qs_get_attr(doc,node);
4612        attr;
4613        attr = qs_get_next_attr(doc,attr)) {
4614     char *nm  = qs_get_attr_name(doc,attr);
4615     char *val = qs_get_attr_value(doc,attr);
4616     if (val && STRCASEEQ('s','S',"style", nm)) {
4617       attr_style = val;
4618     }
4619   }
4620   if (IS_CSS_ON(jxhtml->entryp)) {
4621     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
4622     if (style) {
4623       css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4624       css_property_t *font_size_prop = chxj_css_get_property_value(doc, style, "font-size");
4625       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
4626       
4627       css_property_t *cur;
4628       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4629         if (cur->value && *cur->value) {
4630           attr_color = apr_pstrdup(doc->pool, cur->value);
4631         }
4632       }
4633       for (cur = font_size_prop->next; cur != font_size_prop; cur = cur->next) {
4634         if (cur->value && *cur->value) {
4635           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
4636             attr_size = apr_pstrdup(doc->pool, cur->value);
4637           }
4638           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
4639             attr_size = apr_pstrdup(doc->pool, cur->value);
4640           }
4641           else if (STRCASEEQ('s','S',"small",cur->value)) {
4642             attr_size = apr_pstrdup(doc->pool, cur->value);
4643           }
4644           else if (STRCASEEQ('m','M',"medium",cur->value)) {
4645             attr_size = apr_pstrdup(doc->pool, cur->value);
4646           }
4647           else if (STRCASEEQ('l','L',"large",cur->value)) {
4648             attr_size = apr_pstrdup(doc->pool, cur->value);
4649           }
4650           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
4651             attr_size = apr_pstrdup(doc->pool, cur->value);
4652           }
4653           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
4654             attr_size = apr_pstrdup(doc->pool, cur->value);
4655           }
4656         }
4657       }
4658       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
4659         css_clear = apr_pstrdup(doc->pool, cur->value);
4660       }
4661     }
4662   }
4663   W_L("<blockquote");
4664   if (attr_color || attr_size || css_clear) {
4665     W_L(" style=\"");
4666     if (attr_color) {
4667       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4668       W_L("color:");
4669       W_V(attr_color);
4670       W_L(";");
4671     }
4672     if (attr_size) {
4673       W_L("font-size:");
4674       W_V(attr_size);
4675       W_L(";");
4676     }
4677     if (css_clear){
4678       W_L("clear:");
4679       W_V(css_clear);
4680       W_L(";");
4681     }
4682     W_L("\"");
4683   }
4684   W_L(">");
4685   return jxhtml->out;
4686 }
4687
4688
4689 /**
4690  * It is a handler who processes the BLOCKQUOTE tag.
4691  *
4692  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4693  *                     destination is specified.
4694  * @param node   [i]   The BLOCKQUOTE tag node is specified.
4695  * @return The conversion result is returned.
4696  */
4697 static char *
4698 s_jxhtml_end_blockquote_tag(void *pdoc, Node *UNUSED(child))
4699 {
4700   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
4701   Doc     *doc   = jxhtml->doc;
4702   W_L("</blockquote>");
4703   if (IS_CSS_ON(jxhtml->entryp)) {
4704     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
4705   }
4706   return jxhtml->out;
4707 }
4708
4709
4710 /**
4711  * It is a handler who processes the DIR tag.
4712  *
4713  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4714  *                     destination is specified.
4715  * @param node   [i]   The DIR tag node is specified.
4716  * @return The conversion result is returned.
4717  */
4718 static char *
4719 s_jxhtml_start_dir_tag(void *pdoc, Node *node)
4720 {
4721   jxhtml_t *jxhtml      = GET_JXHTML(pdoc);
4722   Doc       *doc        = jxhtml->doc;
4723   Attr      *attr;
4724   char      *attr_style = NULL;
4725   char      *attr_color = NULL;
4726   char      *attr_type  = NULL;
4727   char      *attr_size  = NULL;
4728   for (attr = qs_get_attr(doc,node);
4729        attr;
4730        attr = qs_get_next_attr(doc,attr)) {
4731     char *name   = qs_get_attr_name(doc,attr);
4732     char *value  = qs_get_attr_value(doc,attr);
4733     if (STRCASEEQ('t','T',"type",name)) {
4734       if (value && (STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
4735         attr_type = value;
4736       }
4737     }
4738     else if (STRCASEEQ('s','S',"style", name) && value && *value) {
4739       attr_style = value;
4740     }
4741   }
4742   if (IS_CSS_ON(jxhtml->entryp)) {
4743     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
4744     if (style) {
4745       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
4746       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
4747       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
4748       css_property_t *cur;
4749       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4750         if (cur->value && *cur->value) {
4751           attr_color = apr_pstrdup(doc->pool, cur->value);
4752         }
4753       }
4754       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
4755         if (cur->value && *cur->value) {
4756           attr_type = apr_pstrdup(doc->pool, cur->value);
4757         }
4758       }
4759       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
4760         if (cur->value && *cur->value) {
4761           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
4762             attr_size = apr_pstrdup(doc->pool, cur->value);
4763           }
4764           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
4765             attr_size = apr_pstrdup(doc->pool, cur->value);
4766           }
4767           else if (STRCASEEQ('s','S',"small",cur->value)) {
4768             attr_size = apr_pstrdup(doc->pool, cur->value);
4769           }
4770           else if (STRCASEEQ('m','M',"medium",cur->value)) {
4771             attr_size = apr_pstrdup(doc->pool, cur->value);
4772           }
4773           else if (STRCASEEQ('l','L',"large",cur->value)) {
4774             attr_size = apr_pstrdup(doc->pool, cur->value);
4775           }
4776           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
4777             attr_size = apr_pstrdup(doc->pool, cur->value);
4778           }
4779           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
4780             attr_size = apr_pstrdup(doc->pool, cur->value);
4781           }
4782         }
4783       }
4784     }
4785   }
4786   W_L("<dir");
4787   if (attr_type || attr_color || attr_size) {
4788     W_L(" style=\"");
4789     if (attr_type) {
4790       W_L("list-style-type:");
4791       W_V(attr_type);
4792       W_L(";");
4793     }
4794     if (attr_color) {
4795       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4796       W_L("color:");
4797       W_V(attr_color);
4798       W_L(";");
4799     }
4800     if (attr_size) {
4801       W_L("font-size:");
4802       W_V(attr_size);
4803       W_L(";");
4804     }
4805     W_L("\"");
4806   }
4807   W_L(">");
4808   return jxhtml->out;
4809 }
4810
4811
4812 /**
4813  * It is a handler who processes the DIR tag.
4814  *
4815  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4816  *                     destination is specified.
4817  * @param node   [i]   The DIR tag node is specified.
4818  * @return The conversion result is returned.
4819  */
4820 static char *
4821 s_jxhtml_end_dir_tag(void *pdoc, Node *UNUSED(child))
4822 {
4823   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
4824   Doc *doc = jxhtml->doc;
4825   W_L("</dir>");
4826   if (IS_CSS_ON(jxhtml->entryp)) {
4827     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
4828   }
4829   return jxhtml->out;
4830 }
4831
4832
4833 /**
4834  * It is a handler who processes the DL tag.
4835  *
4836  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4837  *                     destination is specified.
4838  * @param node   [i]   The DL tag node is specified.
4839  * @return The conversion result is returned.
4840  */
4841 static char *
4842 s_jxhtml_start_dl_tag(void *pdoc, Node *node)
4843 {
4844   jxhtml_t *jxhtml      = GET_JXHTML(pdoc);
4845   Doc       *doc        = jxhtml->doc;
4846   Attr      *attr;
4847   char      *attr_style = NULL;
4848   char      *attr_color = NULL;
4849   char      *attr_size  = NULL;
4850   char      *css_clear  = NULL;
4851   
4852   for (attr = qs_get_attr(doc,node);
4853        attr;
4854        attr = qs_get_next_attr(doc,attr)) {
4855     char *name   = qs_get_attr_name(doc,attr);
4856     char *value  = qs_get_attr_value(doc,attr);
4857     if (STRCASEEQ('s','S',"style", name) && value && *value) {
4858       attr_style = value;
4859     }
4860   }
4861   if (IS_CSS_ON(jxhtml->entryp)) {
4862     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
4863     if (style) {
4864       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
4865       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
4866       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
4867       
4868       css_property_t *cur;
4869       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4870         if (cur->value && *cur->value) {
4871           attr_color = apr_pstrdup(doc->pool, cur->value);
4872         }
4873       }
4874       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
4875         if (cur->value && *cur->value) {
4876           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
4877             attr_size = apr_pstrdup(doc->pool, cur->value);
4878           }
4879           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
4880             attr_size = apr_pstrdup(doc->pool, cur->value);
4881           }
4882           else if (STRCASEEQ('s','S',"small",cur->value)) {
4883             attr_size = apr_pstrdup(doc->pool, cur->value);
4884           }
4885           else if (STRCASEEQ('m','M',"medium",cur->value)) {
4886             attr_size = apr_pstrdup(doc->pool, cur->value);
4887           }
4888           else if (STRCASEEQ('l','L',"large",cur->value)) {
4889             attr_size = apr_pstrdup(doc->pool, cur->value);
4890           }
4891           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
4892             attr_size = apr_pstrdup(doc->pool, cur->value);
4893           }
4894           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
4895             attr_size = apr_pstrdup(doc->pool, cur->value);
4896           }
4897         }
4898       }
4899       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
4900         css_clear = apr_pstrdup(doc->pool, cur->value);
4901       }
4902     }
4903   }
4904   W_L("<dl");
4905   if (attr_color || attr_size || css_clear) {
4906     W_L(" style=\"");
4907     if (attr_color) {
4908       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4909       W_L("color:");
4910       W_V(attr_color);
4911       W_L(";");
4912     }
4913     if (attr_size) {
4914       W_L("font-size:");
4915       W_V(attr_size);
4916       W_L(";");
4917     }
4918     if (css_clear){
4919       W_L("clear:");
4920       W_V(css_clear);
4921       W_L(";");
4922     }
4923     W_L("\"");
4924   }
4925   W_L(">");
4926   return jxhtml->out;
4927 }
4928
4929
4930 /**
4931  * It is a handler who processes the DL tag.
4932  *
4933  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4934  *                     destination is specified.
4935  * @param node   [i]   The DL tag node is specified.
4936  * @return The conversion result is returned.
4937  */
4938 static char *
4939 s_jxhtml_end_dl_tag(void *pdoc, Node *UNUSED(child))
4940 {
4941   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
4942   Doc *doc = jxhtml->doc;
4943   W_L("</dl>");
4944   if (IS_CSS_ON(jxhtml->entryp)) {
4945     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
4946   }
4947   return jxhtml->out;
4948 }
4949
4950
4951 /**
4952  * It is a handler who processes the DT tag.
4953  *
4954  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4955  *                     destination is specified.
4956  * @param node   [i]   The DT tag node is specified.
4957  * @return The conversion result is returned.
4958  */
4959 static char *
4960 s_jxhtml_start_dt_tag(void *pdoc, Node *node)
4961 {
4962   jxhtml_t *jxhtml      = GET_JXHTML(pdoc);
4963   Doc       *doc        = jxhtml->doc;
4964   Attr      *attr;
4965   char      *attr_style = NULL;
4966   char      *attr_color = NULL;
4967   char      *attr_size  = NULL;
4968   for (attr = qs_get_attr(doc,node);
4969        attr;
4970        attr = qs_get_next_attr(doc,attr)) {
4971     char *name   = qs_get_attr_name(doc,attr);
4972     char *value  = qs_get_attr_value(doc,attr);
4973     if (STRCASEEQ('s','S',"style", name) && value && *value) {
4974       attr_style = value;
4975     }
4976   }
4977   if (IS_CSS_ON(jxhtml->entryp)) {
4978     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
4979     if (style) {
4980       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
4981       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
4982       css_property_t *cur;
4983       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4984         if (cur->value && *cur->value) {
4985           attr_color = apr_pstrdup(doc->pool, cur->value);
4986         }
4987       }
4988       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
4989         if (cur->value && *cur->value) {
4990           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
4991             attr_size = apr_pstrdup(doc->pool, cur->value);
4992           }
4993           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
4994             attr_size = apr_pstrdup(doc->pool, cur->value);
4995           }
4996           else if (STRCASEEQ('s','S',"small",cur->value)) {
4997             attr_size = apr_pstrdup(doc->pool, cur->value);
4998           }
4999           else if (STRCASEEQ('m','M',"medium",cur->value)) {
5000             attr_size = apr_pstrdup(doc->pool, cur->value);
5001           }
5002           else if (STRCASEEQ('l','L',"large",cur->value)) {
5003             attr_size = apr_pstrdup(doc->pool, cur->value);
5004           }
5005           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
5006             attr_size = apr_pstrdup(doc->pool, cur->value);
5007           }
5008           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
5009             attr_size = apr_pstrdup(doc->pool, cur->value);
5010           }
5011         }
5012       }
5013     }
5014   }
5015   W_L("<dt");
5016   if (attr_color || attr_size) {
5017     W_L(" style=\"");
5018     if (attr_color) {
5019       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
5020       W_L("color:");
5021       W_V(attr_color);
5022       W_L(";");
5023     }
5024     if (attr_size) {
5025       W_L("font-size:");
5026       W_V(attr_size);
5027       W_L(";");
5028     }
5029     W_L("\"");
5030   }
5031   W_L(">");
5032   return jxhtml->out;
5033 }
5034
5035
5036 /**
5037  * It is a handler who processes the DT tag.
5038  *
5039  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5040  *                     destination is specified.
5041  * @param node   [i]   The DT tag node is specified.
5042  * @return The conversion result is returned.
5043  */
5044 static char *
5045 s_jxhtml_end_dt_tag(void *pdoc, Node *UNUSED(child))
5046 {
5047   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
5048   Doc      *doc    = jxhtml->doc;
5049   W_L("</dt>");
5050   if (IS_CSS_ON(jxhtml->entryp)) {
5051     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
5052   }
5053   return jxhtml->out;
5054 }
5055
5056
5057 /**
5058  * It is a handler who processes the DD tag.
5059  *
5060  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5061  *                     destination is specified.
5062  * @param node   [i]   The DD tag node is specified.
5063  * @return The conversion result is returned.
5064  */
5065 static char *
5066 s_jxhtml_start_dd_tag(void *pdoc, Node *node)
5067 {
5068   jxhtml_t *jxhtml      = GET_JXHTML(pdoc);
5069   Doc       *doc        = jxhtml->doc;
5070   Attr      *attr;
5071   char      *attr_style = NULL;
5072   char      *attr_color = NULL;
5073   char      *attr_size  = NULL;
5074   for (attr = qs_get_attr(doc,node);
5075        attr;
5076        attr = qs_get_next_attr(doc,attr)) {
5077     char *name   = qs_get_attr_name(doc,attr);
5078     char *value  = qs_get_attr_value(doc,attr);
5079     if (STRCASEEQ('s','S',"style", name) && value && *value) {
5080       attr_style = value;
5081     }
5082   }
5083   if (IS_CSS_ON(jxhtml->entryp)) {
5084     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
5085     if (style) {
5086       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
5087       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
5088       css_property_t *cur;
5089       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
5090         if (cur->value && *cur->value) {
5091           attr_color = apr_pstrdup(doc->pool, cur->value);
5092         }
5093       }
5094       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
5095         if (cur->value && *cur->value) {
5096           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
5097             attr_size = apr_pstrdup(doc->pool, cur->value);
5098           }
5099           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
5100             attr_size = apr_pstrdup(doc->pool, cur->value);
5101           }
5102           else if (STRCASEEQ('s','S',"small",cur->value)) {
5103             attr_size = apr_pstrdup(doc->pool, cur->value);
5104           }
5105           else if (STRCASEEQ('m','M',"medium",cur->value)) {
5106             attr_size = apr_pstrdup(doc->pool, cur->value);
5107           }
5108           else if (STRCASEEQ('l','L',"large",cur->value)) {
5109             attr_size = apr_pstrdup(doc->pool, cur->value);
5110           }
5111           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
5112             attr_size = apr_pstrdup(doc->pool, cur->value);
5113           }
5114           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
5115             attr_size = apr_pstrdup(doc->pool, cur->value);
5116           }
5117         }
5118       }
5119     }
5120   }
5121   W_L("<dd");
5122   if (attr_color || attr_size) {
5123     W_L(" style=\"");
5124     if (attr_color) {
5125       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
5126       W_L("color:");
5127       W_V(attr_color);
5128       W_L(";");
5129     }
5130     if (attr_size) {
5131       W_L("font-size:");
5132       W_V(attr_size);
5133       W_L(";");
5134     }
5135     if (css_clear){
5136       W_L("clear:");
5137       W_V(css_clear);
5138       W_L(";");
5139     }
5140     W_L("\"");
5141   }
5142   W_L(">");
5143   return jxhtml->out;
5144 }
5145
5146
5147 /**
5148  * It is a handler who processes the DD tag.
5149  *
5150  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5151  *                     destination is specified.
5152  * @param node   [i]   The DD tag node is specified.
5153  * @return The conversion result is returned.
5154  */
5155 static char *
5156 s_jxhtml_end_dd_tag(void *pdoc, Node *UNUSED(child))
5157 {
5158   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
5159   Doc      *doc = jxhtml->doc;
5160   W_L("</dd>");
5161   if (IS_CSS_ON(jxhtml->entryp)) {
5162     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
5163   }
5164   return jxhtml->out;
5165 }
5166
5167
5168 /**
5169  * It is a handler who processes the H1 tag.
5170  *
5171  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5172  *                     destination is specified.
5173  * @param node   [i]   The H1 tag node is specified.
5174  * @return The conversion result is returned.
5175  */
5176 static char *
5177 s_jxhtml_start_h1_tag(void *pdoc, Node *node)
5178 {
5179   jxhtml_t    *jxhtml;
5180   Doc         *doc;
5181   request_rec *r;
5182   Attr        *attr;
5183   char        *attr_style = NULL;
5184   char        *attr_align = NULL;
5185   char        *css_clear  = NULL;
5186
5187   jxhtml = GET_JXHTML(pdoc);
5188   doc    = jxhtml->doc;
5189   r      = doc->r;
5190
5191   for (attr = qs_get_attr(doc,node);
5192        attr;
5193        attr = qs_get_next_attr(doc,attr)) {
5194     char *name  = qs_get_attr_name(doc,attr);
5195     char *value = qs_get_attr_value(doc,attr);
5196     if (STRCASEEQ('a','A',"align", name)) {
5197       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
5198         attr_align = value;
5199       }
5200     }
5201     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
5202       attr_style = value;
5203     }
5204   }
5205   if (IS_CSS_ON(jxhtml->entryp)) {
5206     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
5207     if (style) {
5208       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
5209       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
5210       css_property_t *cur;
5211       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
5212         if (STRCASEEQ('l','L',"left", cur->value)) {
5213           attr_align = apr_pstrdup(doc->pool, "left");
5214         }
5215         else if (STRCASEEQ('c','C',"center",cur->value)) {
5216           attr_align = apr_pstrdup(doc->pool, "center");
5217         }
5218         else if (STRCASEEQ('r','R',"right",cur->value)) {
5219           attr_align = apr_pstrdup(doc->pool, "right");
5220         }
5221       }
5222       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
5223         if (STRCASEEQ('b','B',"both", cur->value)) {
5224           css_clear = apr_pstrdup(doc->pool, "both");
5225         }
5226         else if (STRCASEEQ('r','R',"right", cur->value)) {
5227           css_clear = apr_pstrdup(doc->pool, "right");
5228         }
5229         else if (STRCASEEQ('l','L',"left", cur->value)) {
5230           css_clear = apr_pstrdup(doc->pool, "left");
5231         }
5232       }
5233     }
5234   }
5235   W_L("<h1");
5236   if (attr_align || css_clear ) {
5237     W_L(" style=\"");
5238     if(attr_align){
5239       W_L("text-align:");
5240       W_V(attr_align);
5241       W_L(";");
5242     }
5243     if(css_clear){
5244       W_L("clear:");
5245       W_V(css_clear);
5246       W_L(";");
5247     }
5248     W_L("\"");
5249   }
5250   W_L(">");
5251
5252   return jxhtml->out;
5253 }
5254
5255
5256 /**
5257  * It is a handler who processes the H1 tag.
5258  *
5259  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5260  *                     destination is specified.
5261  * @param node   [i]   The H1 tag node is specified.
5262  * @return The conversion result is returned.
5263  */
5264 static char *
5265 s_jxhtml_end_h1_tag(void *pdoc, Node *UNUSED(child)) 
5266 {
5267   jxhtml_t*    jxhtml;
5268   Doc*          doc;
5269   request_rec*  r;
5270
5271   jxhtml = GET_JXHTML(pdoc);
5272   doc     = jxhtml->doc;
5273   r       = doc->r;
5274   
5275   W_L("</h1>");
5276   if (IS_CSS_ON(jxhtml->entryp)) {
5277     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
5278   }
5279
5280   return jxhtml->out;
5281 }
5282
5283
5284 /**
5285  * It is a handler who processes the H2 tag.
5286  *
5287  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5288  *                     destination is specified.
5289  * @param node   [i]   The H1 tag node is specified.
5290  * @return The conversion result is returned.
5291  */
5292 static char *
5293 s_jxhtml_start_h2_tag(void *pdoc, Node *node)
5294 {
5295   jxhtml_t    *jxhtml;
5296   Doc         *doc;
5297   request_rec *r;
5298   Attr        *attr;
5299   char        *attr_style = NULL;
5300   char        *attr_align = NULL;
5301   char        *css_clear  = NULL;
5302
5303   jxhtml   = GET_JXHTML(pdoc);
5304   doc     = jxhtml->doc;
5305   r       = doc->r;
5306
5307   for (attr = qs_get_attr(doc,node);
5308        attr;
5309        attr = qs_get_next_attr(doc,attr)) {
5310     char *name  = qs_get_attr_name(doc,attr);
5311     char *value = qs_get_attr_value(doc,attr);
5312     if (STRCASEEQ('a','A',"align", name)) {
5313       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
5314         attr_align = value;
5315       }
5316     }
5317     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
5318       attr_style = value;
5319     }
5320   }
5321   if (IS_CSS_ON(jxhtml->entryp)) {
5322     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
5323     if (style) {
5324       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
5325       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
5326       css_property_t *cur;
5327       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
5328         if (STRCASEEQ('l','L',"left", cur->value)) {
5329           attr_align = apr_pstrdup(doc->pool, "left");
5330         }
5331         else if (STRCASEEQ('c','C',"center",cur->value)) {
5332           attr_align = apr_pstrdup(doc->pool, "center");
5333         }
5334         else if (STRCASEEQ('r','R',"right",cur->value)) {
5335           attr_align = apr_pstrdup(doc->pool, "right");
5336         }
5337       }
5338       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
5339         if (STRCASEEQ('b','B',"both", cur->value)) {
5340           css_clear = apr_pstrdup(doc->pool, "both");
5341         }
5342         else if (STRCASEEQ('r','R',"right", cur->value)) {
5343           css_clear = apr_pstrdup(doc->pool, "right");
5344         }
5345         else if (STRCASEEQ('l','L',"left", cur->value)) {
5346           css_clear = apr_pstrdup(doc->pool, "left");
5347         }
5348       }
5349     }
5350   }
5351   W_L("<h2");
5352   if (attr_align || css_clear ) {
5353     W_L(" style=\"");
5354     if(attr_align){
5355       W_L("text-align:");
5356       W_V(attr_align);
5357       W_L(";");
5358     }
5359     if(css_clear){
5360       W_L("clear:");
5361       W_V(css_clear);
5362       W_L(";");
5363     }
5364     W_L("\"");
5365   }
5366   W_L(">");
5367
5368   return jxhtml->out;
5369 }
5370
5371
5372 /**
5373  * It is a handler who processes the H2 tag.
5374  *
5375  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5376  *                     destination is specified.
5377  * @param node   [i]   The H1 tag node is specified.
5378  * @return The conversion result is returned.
5379  */
5380 static char *
5381 s_jxhtml_end_h2_tag(void *pdoc, Node *UNUSED(child)) 
5382 {
5383   jxhtml_t*    jxhtml;
5384   Doc*          doc;
5385   request_rec*  r;
5386
5387   jxhtml = GET_JXHTML(pdoc);
5388   doc     = jxhtml->doc;
5389   r       = doc->r;
5390   
5391   W_L("</h2>");
5392   if (IS_CSS_ON(jxhtml->entryp)) {
5393     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
5394   }
5395   return jxhtml->out;
5396 }
5397
5398
5399 /**
5400  * It is a handler who processes the H3 tag.
5401  *
5402  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5403  *                     destination is specified.
5404  * @param node   [i]   The H1 tag node is specified.
5405  * @return The conversion result is returned.
5406  */
5407 static char *
5408 s_jxhtml_start_h3_tag(void *pdoc, Node *node)
5409 {
5410   jxhtml_t    *jxhtml;
5411   Doc         *doc;
5412   request_rec *r;
5413   Attr        *attr;
5414   char        *attr_style = NULL;
5415   char        *attr_align = NULL;
5416   char        *css_clear  = NULL;
5417
5418   jxhtml   = GET_JXHTML(pdoc);
5419   doc     = jxhtml->doc;
5420   r       = doc->r;
5421
5422   for (attr = qs_get_attr(doc,node);
5423        attr;
5424        attr = qs_get_next_attr(doc,attr)) {
5425     char *name  = qs_get_attr_name(doc,attr);
5426     char *value = qs_get_attr_value(doc,attr);
5427     if (STRCASEEQ('a','A',"align", name)) {
5428       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
5429         attr_align = value;
5430       }
5431     }
5432     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
5433       attr_style = value;
5434     }
5435   }
5436   if (IS_CSS_ON(jxhtml->entryp)) {
5437     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
5438     if (style) {
5439       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
5440       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
5441       css_property_t *cur;
5442       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
5443         if (STRCASEEQ('l','L',"left", cur->value)) {
5444           attr_align = apr_pstrdup(doc->pool, "left");
5445         }
5446         else if (STRCASEEQ('c','C',"center",cur->value)) {
5447           attr_align = apr_pstrdup(doc->pool, "center");
5448         }
5449         else if (STRCASEEQ('r','R',"right",cur->value)) {
5450           attr_align = apr_pstrdup(doc->pool, "right");
5451         }
5452       }
5453       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
5454         if (STRCASEEQ('b','B',"both", cur->value)) {
5455           css_clear = apr_pstrdup(doc->pool, "both");
5456         }
5457         else if (STRCASEEQ('r','R',"right", cur->value)) {
5458           css_clear = apr_pstrdup(doc->pool, "right");
5459         }
5460         else if (STRCASEEQ('l','L',"left", cur->value)) {
5461           css_clear = apr_pstrdup(doc->pool, "left");
5462         }
5463       }
5464     }
5465   }
5466   W_L("<h3");
5467   if (attr_align || css_clear ) {
5468     W_L(" style=\"");
5469     if(attr_align){
5470       W_L("text-align:");
5471       W_V(attr_align);
5472       W_L(";");
5473     }
5474     if(css_clear){
5475       W_L("clear:");
5476       W_V(css_clear);
5477       W_L(";");
5478     }
5479     W_L("\"");
5480   }
5481   W_L(">");
5482
5483   return jxhtml->out;
5484 }
5485
5486
5487 /**
5488  * It is a handler who processes the H3 tag.
5489  *
5490  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5491  *                     destination is specified.
5492  * @param node   [i]   The H1 tag node is specified.
5493  * @return The conversion result is returned.
5494  */
5495 static char *
5496 s_jxhtml_end_h3_tag(void *pdoc, Node *UNUSED(child)) 
5497 {
5498   jxhtml_t*    jxhtml;
5499   Doc*          doc;
5500   request_rec*  r;
5501
5502   jxhtml = GET_JXHTML(pdoc);
5503   doc     = jxhtml->doc;
5504   r       = doc->r;
5505
5506   W_L("</h3>");
5507   if (IS_CSS_ON(jxhtml->entryp)) {
5508     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
5509   }
5510   return jxhtml->out;
5511 }
5512
5513
5514 /**
5515  * It is a handler who processes the H4 tag.
5516  *
5517  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5518  *                     destination is specified.
5519  * @param node   [i]   The H1 tag node is specified.
5520  * @return The conversion result is returned.
5521  */
5522 static char *
5523 s_jxhtml_start_h4_tag(void *pdoc, Node *node)
5524 {
5525   jxhtml_t    *jxhtml;
5526   Doc         *doc;
5527   request_rec *r;
5528   Attr        *attr;
5529   char        *attr_style = NULL;
5530   char        *attr_align = NULL;
5531   char        *css_clear  = NULL;
5532
5533   jxhtml   = GET_JXHTML(pdoc);
5534   doc     = jxhtml->doc;
5535   r       = doc->r;
5536
5537   for (attr = qs_get_attr(doc,node);
5538        attr;
5539        attr = qs_get_next_attr(doc,attr)) {
5540     char *name  = qs_get_attr_name(doc,attr);
5541     char *value = qs_get_attr_value(doc,attr);
5542     if (STRCASEEQ('a','A',"align", name)) {
5543       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
5544         attr_align = value;
5545       }
5546     }
5547     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
5548       attr_style = value;
5549     }
5550   }
5551   if (IS_CSS_ON(jxhtml->entryp)) {
5552     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
5553     if (style) {
5554       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
5555       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
5556       css_property_t *cur;
5557       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
5558         if (STRCASEEQ('l','L',"left", cur->value)) {
5559           attr_align = apr_pstrdup(doc->pool, "left");
5560         }
5561         else if (STRCASEEQ('c','C',"center",cur->value)) {
5562           attr_align = apr_pstrdup(doc->pool, "center");
5563         }
5564         else if (STRCASEEQ('r','R',"right",cur->value)) {
5565           attr_align = apr_pstrdup(doc->pool, "right");
5566         }
5567       }
5568       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
5569         if (STRCASEEQ('b','B',"both", cur->value)) {
5570           css_clear = apr_pstrdup(doc->pool, "both");
5571         }
5572         else if (STRCASEEQ('r','R',"right", cur->value)) {
5573           css_clear = apr_pstrdup(doc->pool, "right");
5574         }
5575         else if (STRCASEEQ('l','L',"left", cur->value)) {
5576           css_clear = apr_pstrdup(doc->pool, "left");
5577         }
5578       }
5579     }
5580   }
5581   W_L("<h4");
5582   if (attr_align || css_clear ) {
5583     W_L(" style=\"");
5584     if(attr_align){
5585       W_L("text-align:");
5586       W_V(attr_align);
5587       W_L(";");
5588     }
5589     if(css_clear){
5590       W_L("clear:");
5591       W_V(css_clear);
5592       W_L(";");
5593     }
5594     W_L("\"");
5595   }
5596   W_L(">");
5597
5598   return jxhtml->out;
5599 }
5600
5601
5602 /**
5603  * It is a handler who processes the H4 tag.
5604  *
5605  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5606  *                     destination is specified.
5607  * @param node   [i]   The H1 tag node is specified.
5608  * @return The conversion result is returned.
5609  */
5610 static char *
5611 s_jxhtml_end_h4_tag(void *pdoc, Node *UNUSED(child)) 
5612 {
5613   jxhtml_t      *jxhtml;
5614   Doc           *doc;
5615   request_rec   *r;
5616
5617   jxhtml = GET_JXHTML(pdoc);
5618   doc     = jxhtml->doc;
5619   r       = doc->r;
5620   
5621   W_L("</h4>");
5622   if (IS_CSS_ON(jxhtml->entryp)) {
5623     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
5624   }
5625
5626   return jxhtml->out;
5627 }
5628
5629
5630 /**
5631  * It is a handler who processes the H5 tag.
5632  *
5633  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5634  *                     destination is specified.
5635  * @param node   [i]   The H1 tag node is specified.
5636  * @return The conversion result is returned.
5637  */
5638 static char *
5639 s_jxhtml_start_h5_tag(void *pdoc, Node *node)
5640 {
5641   jxhtml_t    *jxhtml;
5642   Doc         *doc;
5643   request_rec *r;
5644   Attr        *attr;
5645   char        *attr_style = NULL;
5646   char        *attr_align = NULL;
5647   char        *css_clear  = NULL;
5648
5649   jxhtml   = GET_JXHTML(pdoc);
5650   doc     = jxhtml->doc;
5651   r       = doc->r;
5652
5653   for (attr = qs_get_attr(doc,node);
5654        attr;
5655        attr = qs_get_next_attr(doc,attr)) {
5656     char *name  = qs_get_attr_name(doc,attr);
5657     char *value = qs_get_attr_value(doc,attr);
5658     if (STRCASEEQ('a','A',"align", name)) {
5659       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
5660         attr_align = value;
5661       }
5662     }
5663     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
5664       attr_style = value;
5665     }
5666   }
5667   if (IS_CSS_ON(jxhtml->entryp)) {
5668     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
5669     if (style) {
5670       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
5671       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
5672       css_property_t *cur;
5673       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
5674         if (STRCASEEQ('l','L',"left", cur->value)) {
5675           attr_align = apr_pstrdup(doc->pool, "left");
5676         }
5677         else if (STRCASEEQ('c','C',"center",cur->value)) {
5678           attr_align = apr_pstrdup(doc->pool, "center");
5679         }
5680         else if (STRCASEEQ('r','R',"right",cur->value)) {
5681           attr_align = apr_pstrdup(doc->pool, "right");
5682         }
5683       }
5684       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
5685         if (STRCASEEQ('b','B',"both", cur->value)) {
5686           css_clear = apr_pstrdup(doc->pool, "both");
5687         }
5688         else if (STRCASEEQ('r','R',"right", cur->value)) {
5689           css_clear = apr_pstrdup(doc->pool, "right");
5690         }
5691         else if (STRCASEEQ('l','L',"left", cur->value)) {
5692           css_clear = apr_pstrdup(doc->pool, "left");
5693         }
5694       }
5695     }
5696   }
5697   W_L("<h5");
5698   if (attr_align || css_clear ) {
5699     W_L(" style=\"");
5700     if(attr_align){
5701       W_L("text-align:");
5702       W_V(attr_align);
5703       W_L(";");
5704     }
5705     if(css_clear){
5706       W_L("clear:");
5707       W_V(css_clear);
5708       W_L(";");
5709     }
5710     W_L("\"");
5711   }
5712   W_L(">");
5713
5714   return jxhtml->out;
5715 }
5716
5717
5718 /**
5719  * It is a handler who processes the H5 tag.
5720  *
5721  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5722  *                     destination is specified.
5723  * @param node   [i]   The H1 tag node is specified.
5724  * @return The conversion result is returned.
5725  */
5726 static char *
5727 s_jxhtml_end_h5_tag(void *pdoc, Node *UNUSED(child)) 
5728 {
5729   jxhtml_t    *jxhtml;
5730   Doc         *doc;
5731   request_rec *r;
5732
5733   jxhtml = GET_JXHTML(pdoc);
5734   doc     = jxhtml->doc;
5735   r       = doc->r;
5736   
5737   W_L("</h5>");
5738   if (IS_CSS_ON(jxhtml->entryp)) {
5739     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
5740   }
5741
5742   return jxhtml->out;
5743 }
5744
5745
5746 /**
5747  * It is a handler who processes the H6 tag.
5748  *
5749  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5750  *                     destination is specified.
5751  * @param node   [i]   The H1 tag node is specified.
5752  * @return The conversion result is returned.
5753  */
5754 static char *
5755 s_jxhtml_start_h6_tag(void *pdoc, Node *node)
5756 {
5757   jxhtml_t    *jxhtml;
5758   Doc         *doc;
5759   request_rec *r;
5760   Attr        *attr;
5761   char        *attr_style = NULL;
5762   char        *attr_align = NULL;
5763   char        *css_clear  = NULL;
5764
5765   jxhtml   = GET_JXHTML(pdoc);
5766   doc     = jxhtml->doc;
5767   r       = doc->r;
5768
5769   for (attr = qs_get_attr(doc,node);
5770        attr;
5771        attr = qs_get_next_attr(doc,attr)) {
5772     char *name  = qs_get_attr_name(doc,attr);
5773     char *value = qs_get_attr_value(doc,attr);
5774     if (STRCASEEQ('a','A',"align", name)) {
5775       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
5776         attr_align = value;
5777       }
5778     }
5779     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
5780       attr_style = value;
5781     }
5782   }
5783   if (IS_CSS_ON(jxhtml->entryp)) {
5784     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
5785     if (style) {
5786       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
5787       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
5788       css_property_t *cur;
5789       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
5790         if (STRCASEEQ('l','L',"left", cur->value)) {
5791           attr_align = apr_pstrdup(doc->pool, "left");
5792         }
5793         else if (STRCASEEQ('c','C',"center",cur->value)) {
5794           attr_align = apr_pstrdup(doc->pool, "center");
5795         }
5796         else if (STRCASEEQ('r','R',"right",cur->value)) {
5797           attr_align = apr_pstrdup(doc->pool, "right");
5798         }
5799       }
5800       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
5801         if (STRCASEEQ('b','B',"both", cur->value)) {
5802           css_clear = apr_pstrdup(doc->pool, "both");
5803         }
5804         else if (STRCASEEQ('r','R',"right", cur->value)) {
5805           css_clear = apr_pstrdup(doc->pool, "right");
5806         }
5807         else if (STRCASEEQ('l','L',"left", cur->value)) {
5808           css_clear = apr_pstrdup(doc->pool, "left");
5809         }
5810       }
5811     }
5812   }
5813   W_L("<h6");
5814   if (attr_align || css_clear ) {
5815     W_L(" style=\"");
5816     if(attr_align){
5817       W_L("text-align:");
5818       W_V(attr_align);
5819       W_L(";");
5820     }
5821     if(css_clear){
5822       W_L("clear:");
5823       W_V(css_clear);
5824       W_L(";");
5825     }
5826     W_L("\"");
5827   }
5828   W_L(">");
5829
5830   return jxhtml->out;
5831 }
5832
5833
5834 /**
5835  * It is a handler who processes the H6 tag.
5836  *
5837  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5838  *                     destination is specified.
5839  * @param node   [i]   The H1 tag node is specified.
5840  * @return The conversion result is returned.
5841  */
5842 static char *
5843 s_jxhtml_end_h6_tag(void *pdoc, Node *UNUSED(child)) 
5844 {
5845   jxhtml_t    *jxhtml;
5846   Doc         *doc;
5847   request_rec *r;
5848
5849   jxhtml = GET_JXHTML(pdoc);
5850   doc     = jxhtml->doc;
5851   r       = doc->r;
5852   
5853   W_L("</h6>");
5854   if (IS_CSS_ON(jxhtml->entryp)) {
5855     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
5856   }
5857
5858   return jxhtml->out;
5859 }
5860
5861
5862 /**
5863  * It is a handler who processes the MENU tag.
5864  *
5865  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5866  *                     destination is specified.
5867  * @param node   [i]   The MENU tag node is specified.
5868  * @return The conversion result is returned.
5869  */
5870 static char *
5871 s_jxhtml_start_menu_tag(void *pdoc, Node *node)
5872 {
5873   jxhtml_t *jxhtml      = GET_JXHTML(pdoc);
5874   Doc       *doc        = jxhtml->doc;
5875   Attr      *attr;
5876   char      *attr_style = NULL;
5877   char      *attr_color = NULL;
5878   char      *attr_type  = NULL;
5879   char      *attr_size  = NULL;
5880   for (attr = qs_get_attr(doc,node);
5881        attr;
5882        attr = qs_get_next_attr(doc,attr)) {
5883     char *name   = qs_get_attr_name(doc,attr);
5884     char *value  = qs_get_attr_value(doc,attr);
5885     if (STRCASEEQ('t','T',"type",name)) {
5886       if (value && (STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
5887         attr_type = value;
5888       }
5889     }
5890     else if (STRCASEEQ('s','S',"style", name) && value && *value) {
5891       attr_style = value;
5892     }
5893   }
5894   if (IS_CSS_ON(jxhtml->entryp)) {
5895     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
5896     if (style) {
5897       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
5898       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
5899       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
5900       css_property_t *cur;
5901       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
5902         if (cur->value && *cur->value) {
5903           attr_color = apr_pstrdup(doc->pool, cur->value);
5904         }
5905       }
5906       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
5907         if (cur->value && *cur->value) {
5908           attr_type = apr_pstrdup(doc->pool, cur->value);
5909         }
5910       }
5911       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
5912         if (cur->value && *cur->value) {
5913           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
5914             attr_size = apr_pstrdup(doc->pool, cur->value);
5915           }
5916           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
5917             attr_size = apr_pstrdup(doc->pool, cur->value);
5918           }
5919           else if (STRCASEEQ('s','S',"small",cur->value)) {
5920             attr_size = apr_pstrdup(doc->pool, cur->value);
5921           }
5922           else if (STRCASEEQ('m','M',"medium",cur->value)) {
5923             attr_size = apr_pstrdup(doc->pool, cur->value);
5924           }
5925           else if (STRCASEEQ('l','L',"large",cur->value)) {
5926             attr_size = apr_pstrdup(doc->pool, cur->value);
5927           }
5928           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
5929             attr_size = apr_pstrdup(doc->pool, cur->value);
5930           }
5931           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
5932             attr_size = apr_pstrdup(doc->pool, cur->value);
5933           }
5934         }
5935       }
5936     }
5937   }
5938   W_L("<menu");
5939   if (attr_type || attr_color || attr_size) {
5940     W_L(" style=\"");
5941     if (attr_type) {
5942       W_L("list-style-type:");
5943       W_V(attr_type);
5944       W_L(";");
5945     }
5946     if (attr_color) {
5947       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
5948       W_L("color:");
5949       W_V(attr_color);
5950       W_L(";");
5951     }
5952     if (attr_size) {
5953       W_L("font-size:");
5954       W_V(attr_size);
5955       W_L(";");
5956     }
5957     if (css_clear){
5958       W_L("clear:");
5959       W_V(css_clear);
5960       W_L(";");
5961     }
5962     W_L("\"");
5963   }
5964   W_L(">");
5965   return jxhtml->out;
5966 }
5967
5968
5969 /**
5970  * It is a handler who processes the MENU tag.
5971  *
5972  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5973  *                     destination is specified.
5974  * @param node   [i]   The MENU tag node is specified.
5975  * @return The conversion result is returned.
5976  */
5977 static char *
5978 s_jxhtml_end_menu_tag(void *pdoc, Node *UNUSED(child))
5979 {
5980   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
5981   Doc *doc = jxhtml->doc;
5982   W_L("</menu>");
5983   if (IS_CSS_ON(jxhtml->entryp)) {
5984     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
5985   }
5986   return jxhtml->out;
5987 }
5988
5989
5990 /**
5991  * It is a handler who processes the PLAINTEXT tag.
5992  *
5993  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5994  *                     destination is specified.
5995  * @param node   [i]   The PLAINTEXT tag node is specified.
5996  * @return The conversion result is returned.
5997  */
5998 static char *
5999 s_jxhtml_start_plaintext_tag(void *pdoc, Node *node)
6000 {
6001   jxhtml_t *jxhtml;
6002   Doc *doc;
6003
6004   jxhtml = GET_JXHTML(pdoc);
6005   doc     = jxhtml->doc;
6006   W_L("<plaintext>");
6007   s_jxhtml_start_plaintext_tag_inner(pdoc,node);
6008   return jxhtml->out;
6009 }
6010
6011 static char *
6012 s_jxhtml_start_plaintext_tag_inner(void *pdoc, Node *node)
6013 {
6014   jxhtml_t *jxhtml;
6015   Doc *doc;
6016   Node *child;
6017   jxhtml = GET_JXHTML(pdoc);
6018   doc     = jxhtml->doc;
6019   for (child = qs_get_child_node(doc, node);
6020        child;
6021        child = qs_get_next_node(doc, child)) {
6022     W_V(child->otext);
6023     s_jxhtml_start_plaintext_tag_inner(pdoc, child);
6024   }
6025   return jxhtml->out;
6026 }
6027
6028
6029 /**
6030  * It is a handler who processes the PLAINTEXT tag.
6031  *
6032  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
6033  *                     destination is specified.
6034  * @param node   [i]   The PLAINTEXT tag node is specified.
6035  * @return The conversion result is returned.
6036  */
6037 static char *
6038 s_jxhtml_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
6039 {
6040   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
6041   return jxhtml->out;
6042 }
6043
6044
6045 /**
6046  * It is a handler who processes the BLINK tag.
6047  *
6048  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
6049  *                     destination is specified.
6050  * @param node   [i]   The BLINK tag node is specified.
6051  * @return The conversion result is returned.
6052  */
6053 static char *
6054 s_jxhtml_start_blink_tag(void *pdoc, Node *node)
6055 {
6056   jxhtml_t *jxhtml      = GET_JXHTML(pdoc);
6057   Doc       *doc        = jxhtml->doc;
6058   Attr      *attr;
6059   char      *attr_style = NULL;
6060   char      *attr_color = NULL;
6061   char      *attr_size  = NULL;
6062   char      *css_clear  = NULL;
6063   
6064   for (attr = qs_get_attr(doc,node);
6065        attr;
6066        attr = qs_get_next_attr(doc,attr)) {
6067     char *name   = qs_get_attr_name(doc,attr);
6068     char *value  = qs_get_attr_value(doc,attr);
6069     if (STRCASEEQ('s','S',"style", name) && value && *value) {
6070       attr_style = value;
6071     }
6072   }
6073   if (IS_CSS_ON(jxhtml->entryp)) {
6074     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
6075     if (style) {
6076       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
6077       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
6078       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
6079       
6080       css_property_t *cur;
6081       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
6082         if (cur->value && *cur->value) {
6083           attr_color = apr_pstrdup(doc->pool, cur->value);
6084         }
6085       }
6086       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
6087         if (cur->value && *cur->value) {
6088           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
6089             attr_size = apr_pstrdup(doc->pool, cur->value);
6090           }
6091           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
6092             attr_size = apr_pstrdup(doc->pool, cur->value);
6093           }
6094           else if (STRCASEEQ('s','S',"small",cur->value)) {
6095             attr_size = apr_pstrdup(doc->pool, cur->value);
6096           }
6097           else if (STRCASEEQ('m','M',"medium",cur->value)) {
6098             attr_size = apr_pstrdup(doc->pool, cur->value);
6099           }
6100           else if (STRCASEEQ('l','L',"large",cur->value)) {
6101             attr_size = apr_pstrdup(doc->pool, cur->value);
6102           }
6103           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
6104             attr_size = apr_pstrdup(doc->pool, cur->value);
6105           }
6106           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
6107             attr_size = apr_pstrdup(doc->pool, cur->value);
6108           }
6109         }
6110       }
6111     }
6112   }
6113   W_L("<blink");
6114   if (attr_color || attr_size) {
6115     W_L(" style=\"");
6116     if (attr_color) {
6117       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
6118       W_L("color:");
6119       W_V(attr_color);
6120       W_L(";");
6121     }
6122     if (attr_size) {
6123       W_L("font-size:");
6124       W_V(attr_size);
6125       W_L(";");
6126     }
6127     W_L("\"");
6128   }
6129   W_L(">");
6130   return jxhtml->out;
6131 }
6132
6133
6134 /**
6135  * It is a handler who processes the BLINK tag.
6136  *
6137  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
6138  *                     destination is specified.
6139  * @param node   [i]   The BLINK tag node is specified.
6140  * @return The conversion result is returned.
6141  */
6142 static char *
6143 s_jxhtml_end_blink_tag(void *pdoc, Node *UNUSED(child))
6144 {
6145   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
6146   Doc      *doc = jxhtml->doc;
6147   W_L("</blink>");
6148   if (IS_CSS_ON(jxhtml->entryp)) {
6149     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
6150   }
6151   return jxhtml->out;
6152 }
6153
6154
6155 /**
6156  * It is a handler who processes the MARQUEE tag.
6157  *
6158  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
6159  *                     destination is specified.
6160  * @param node   [i]   The MARQUEE tag node is specified.
6161  * @return The conversion result is returned.
6162  */
6163 static char *
6164 s_jxhtml_start_marquee_tag(void *pdoc, Node *node)
6165 {
6166   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
6167   Doc       *doc = jxhtml->doc;
6168   Attr      *attr;
6169   char      *attr_direction = NULL;
6170   char      *attr_style     = NULL;
6171   char      *attr_color     = NULL;
6172   char      *attr_size      = NULL;
6173   char      *attr_bgcolor   = NULL;
6174   /*--------------------------------------------------------------------------*/
6175   /* Get Attributes                                                           */
6176   /*--------------------------------------------------------------------------*/
6177   for (attr = qs_get_attr(doc,node);
6178        attr;
6179        attr = qs_get_next_attr(doc,attr)) {
6180     char *name   = qs_get_attr_name(doc,attr);
6181     char *value  = qs_get_attr_value(doc,attr);
6182     if (STRCASEEQ('d','D',"direction", name)) {
6183       if (value) {
6184         if (STRCASEEQ('l','L',"left",value)) {
6185           attr_direction = "rtl";
6186         }
6187         else if (STRCASEEQ('r','R',"right",value)) {
6188           attr_direction = "ltr";
6189         }
6190       }
6191     }
6192     else if (STRCASEEQ('b','B',"behavior",name)) {
6193       /* ignore */
6194     }
6195     else if (STRCASEEQ('l','L',"loop",name)) {
6196       /* ignore */
6197     }
6198     else if (STRCASEEQ('b','B',"bgcolor",name)) {
6199       if (value && *value) {
6200         attr_bgcolor = value;
6201       }
6202     }
6203     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
6204       attr_style = value;
6205     }
6206   }
6207   if (IS_CSS_ON(jxhtml->entryp)) {
6208     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
6209     if (style) {
6210       css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
6211       css_property_t *size_prop  = chxj_css_get_property_value(doc, style, "font-size");
6212       css_property_t *bgcolor_prop  = chxj_css_get_property_value(doc, style, "background-color");
6213       css_property_t *direction_prop  = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
6214       css_property_t *cur;
6215       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
6216         if (cur->value && *cur->value) {
6217           attr_color = apr_pstrdup(doc->pool, cur->value);
6218         }
6219       }
6220       for (cur = bgcolor_prop->next; cur != bgcolor_prop; cur = cur->next) {
6221         if (cur->value && *cur->value) {
6222           attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
6223         }
6224       }
6225       for (cur = direction_prop->next; cur != direction_prop; cur = cur->next) {
6226         if (cur->value && *cur->value) {
6227           attr_direction = apr_pstrdup(doc->pool, cur->value);
6228         }
6229       }
6230       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
6231         if (cur->value && *cur->value) {
6232           if ( STRCASEEQ('x','X',"xx-small",cur->value)
6233             || STRCASEEQ('x','X',"x-small", cur->value)
6234             || STRCASEEQ('s','S',"small",   cur->value)
6235             || STRCASEEQ('m','M',"medium",  cur->value)
6236             || STRCASEEQ('l','L',"large",   cur->value)
6237             || STRCASEEQ('x','X',"x-large", cur->value)
6238             || STRCASEEQ('x','X',"xx-large",cur->value)) {
6239             attr_size = apr_pstrdup(doc->pool, cur->value);
6240           }
6241         }
6242       }
6243     }
6244   }
6245   W_L("<marquee");
6246   if (attr_color || attr_size || attr_direction || attr_bgcolor) {
6247     W_L(" style=\"");
6248     if (attr_direction) {
6249       W_L("-wap-marquee-dir:");
6250       W_V(attr_direction);
6251       W_L(";");
6252     }
6253     if (attr_bgcolor) {
6254       attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
6255       W_L("background-color:");
6256       W_V(attr_bgcolor);
6257       W_L(";");
6258     }
6259     if (attr_color) {
6260       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
6261       W_L("color:");
6262       W_V(attr_color);
6263       W_L(";");
6264     }
6265     if (attr_size) {
6266       W_L("font-size:");
6267       W_V(attr_size);
6268       W_L(";");
6269     }
6270     W_L("\"");
6271   }
6272   W_L(">");
6273
6274   return jxhtml->out;
6275 }
6276
6277
6278 /**
6279  * It is a handler who processes the MARQUEE tag.
6280  *
6281  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
6282  *                     destination is specified.
6283  * @param node   [i]   The MARQUEE tag node is specified.
6284  * @return The conversion result is returned.
6285  */
6286 static char *
6287 s_jxhtml_end_marquee_tag(void *pdoc, Node *UNUSED(node))
6288 {
6289   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
6290   Doc      *doc     = jxhtml->doc;
6291   W_L("</marquee>");
6292   if (IS_CSS_ON(jxhtml->entryp)) {
6293     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
6294   }
6295   return jxhtml->out;
6296 }
6297
6298
6299 /**
6300  * It is handler who processes the New Line Code.
6301  */
6302 static char *
6303 s_jxhtml_newline_mark(void *pdoc, Node *UNUSED(node))
6304 {
6305   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
6306   if (jxhtml->start_html_flag) {
6307     Doc *doc = jxhtml->doc;
6308     W_NLCODE();
6309   }
6310   return jxhtml->out;
6311 }
6312
6313
6314 /**
6315  * It is a handler who processes the LINK tag.
6316  *
6317  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
6318  *                     destination is specified.
6319  * @param node   [i]   The LINK tag node is specified.
6320  * @return The conversion result is returned.
6321  */
6322 static char *
6323 s_jxhtml_link_tag(void *pdoc, Node *node)
6324 {
6325   jxhtml_t      *jxhtml;
6326   Doc           *doc;
6327   Attr          *attr;
6328   char          *rel  = NULL;
6329   char          *href = NULL;
6330   char          *type = NULL;
6331
6332   jxhtml = GET_JXHTML(pdoc);
6333   doc    = jxhtml->doc;
6334
6335   if (! IS_CSS_ON(jxhtml->entryp)) {
6336     return jxhtml->out;
6337   }
6338
6339   for (attr = qs_get_attr(doc,node);
6340        attr;
6341        attr = qs_get_next_attr(doc,attr)) {
6342     char *name  = qs_get_attr_name(doc,attr);
6343     char *value = qs_get_attr_value(doc,attr);
6344     if (STRCASEEQ('r','R',"rel", name)) {
6345       if (value && *value && STRCASEEQ('s','S',"stylesheet", value)) {
6346         rel = value;
6347       }
6348     }
6349     else if (STRCASEEQ('h','H',"href", name)) {
6350       if (value && *value) {
6351         href = value;
6352       }
6353     }
6354     else if (STRCASEEQ('t','T',"type", name)) {
6355       if (value && *value && STRCASEEQ('t','T',"text/css",value)) {
6356         type = value;
6357       }
6358     }
6359   }
6360
6361   if (rel && href && type) {
6362     DBG(doc->r, "start load CSS. url:[%s]", href);
6363     jxhtml->style = chxj_css_parse_from_uri(doc->r, doc->pool, jxhtml->style, href);
6364     DBG(doc->r, "end load CSS. url:[%s]", href);
6365   }
6366
6367   return jxhtml->out;
6368 }
6369
6370
6371 static css_prop_list_t *
6372 s_jxhtml_push_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value)
6373 {
6374   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
6375   Doc *doc = jxhtml->doc;
6376   css_prop_list_t *last_css = NULL;
6377   if (IS_CSS_ON(jxhtml->entryp)) {
6378     css_prop_list_t *dup_css;
6379     css_selector_t  *selector;
6380
6381     last_css = chxj_css_get_last_prop_list(jxhtml->css_prop_stack);
6382     dup_css  = chxj_dup_css_prop_list(doc, last_css);
6383     selector = chxj_css_find_selector(doc, jxhtml->style, node);
6384     if (selector) {
6385       chxj_css_prop_list_merge_property(doc, dup_css, selector);
6386     }
6387     chxj_css_push_prop_list(jxhtml->css_prop_stack, dup_css);
6388     last_css = chxj_css_get_last_prop_list(jxhtml->css_prop_stack);
6389
6390     if (style_attr_value) {
6391       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));
6392       if (ssheet) {
6393         chxj_css_prop_list_merge_property(doc, last_css, ssheet->selector_head.next);
6394       }
6395     }
6396   }
6397   return last_css;
6398 }
6399
6400
6401 static css_prop_list_t *
6402 s_jxhtml_nopush_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value)
6403 {
6404   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
6405   Doc *doc = jxhtml->doc;
6406   css_prop_list_t *last_css = NULL;
6407   if (IS_CSS_ON(jxhtml->entryp)) {
6408     css_prop_list_t *dup_css;
6409     css_selector_t  *selector;
6410
6411     last_css = chxj_css_get_last_prop_list(jxhtml->css_prop_stack);
6412     dup_css  = chxj_dup_css_prop_list(doc, last_css);
6413     selector = chxj_css_find_selector(doc, jxhtml->style, node);
6414     if (selector) {
6415       chxj_css_prop_list_merge_property(doc, dup_css, selector);
6416     }
6417     last_css = dup_css;
6418
6419     if (style_attr_value) {
6420       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));
6421       if (ssheet) {
6422         chxj_css_prop_list_merge_property(doc, last_css, ssheet->selector_head.next);
6423       }
6424     }
6425   }
6426   return last_css;
6427 }
6428
6429
6430 /**
6431  * It is a handler who processes the SPAN tag.
6432  *
6433  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
6434  *                     destination is specified.
6435  * @param node   [i]   The SPAN tag node is specified.
6436  * @return The conversion result is returned.
6437  */
6438 static char *
6439 s_jxhtml_start_span_tag(void *pdoc, Node *node)
6440 {
6441   jxhtml_t *jxhtml;
6442   Doc *doc;
6443   Attr *attr;
6444   char *attr_style = NULL;
6445   char *attr_color = NULL;
6446   char *attr_size = NULL;
6447   char *attr_align = NULL;
6448   char *attr_blink = NULL;
6449   char *attr_marquee = NULL;
6450   char *attr_marquee_dir = NULL;
6451   char *attr_marquee_style = NULL;
6452   char *attr_marquee_loop = NULL;
6453   char *css_bgcolor        = NULL;
6454
6455   jxhtml = GET_JXHTML(pdoc);
6456   doc     = jxhtml->doc;
6457
6458   for (attr = qs_get_attr(doc,node);
6459        attr;
6460        attr = qs_get_next_attr(doc,attr)) {
6461     char *nm  = qs_get_attr_name(doc,attr);
6462     char *val = qs_get_attr_value(doc,attr);
6463     if (val && STRCASEEQ('s','S',"style", nm)) {
6464       attr_style = val;
6465     }
6466   }
6467   if (IS_CSS_ON(jxhtml->entryp)) {
6468     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
6469     if (style) {
6470       css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
6471       css_property_t *size_prop = chxj_css_get_property_value(doc, style, "font-size");
6472       css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
6473       css_property_t *decoration_prop = chxj_css_get_property_value(doc, style, "text-decoration");
6474       css_property_t *display_prop = chxj_css_get_property_value(doc, style, "display");
6475       css_property_t *marquee_dir_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
6476       css_property_t *marquee_style_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-style");
6477       css_property_t *marquee_loop_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-loop");
6478       css_property_t *bgcolor_prop = chxj_css_get_property_value(doc, style, "background-color");
6479       
6480       css_property_t *cur;
6481       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
6482         attr_color = apr_pstrdup(doc->pool, cur->value);
6483       }
6484       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
6485         if (cur->value && *cur->value) {
6486           if ( STRCASEEQ('x','X',"xx-small",cur->value)
6487             || STRCASEEQ('x','X',"x-small", cur->value)
6488             || STRCASEEQ('s','S',"small",   cur->value)
6489             || STRCASEEQ('m','M',"medium",  cur->value)
6490             || STRCASEEQ('l','L',"large",   cur->value)
6491             || STRCASEEQ('x','X',"x-large", cur->value)
6492             || STRCASEEQ('x','X',"xx-large",cur->value)) {
6493             attr_size = apr_pstrdup(doc->pool, cur->value);
6494           }
6495         }
6496       }
6497       for (cur = decoration_prop->next; cur != decoration_prop; cur = cur->next) {
6498         if (cur->value && STRCASEEQ('b','B',"blink",cur->value)) {
6499           attr_blink = apr_pstrdup(doc->pool, cur->value);
6500         }
6501       }
6502       for (cur = display_prop->next; cur != display_prop; cur = cur->next) {
6503         if (cur->value && strcasecmp("-wap-marquee",cur->value) == 0) {
6504           attr_marquee = apr_pstrdup(doc->pool, cur->value);
6505         }
6506       }
6507       for (cur = marquee_dir_prop->next; cur != marquee_dir_prop; cur = cur->next) {
6508         if (cur->value && *cur->value) {
6509           if ( STRCASEEQ('l','L',"ltr",cur->value)
6510             || STRCASEEQ('r','R',"rtl",cur->value)) {
6511             attr_marquee_dir = apr_pstrdup(doc->pool, cur->value);
6512           }
6513         }
6514       }
6515       for (cur = marquee_style_prop->next; cur != marquee_style_prop; cur = cur->next) {
6516         if (cur->value && *cur->value) {
6517           if ( STRCASEEQ('s','S',"scroll",cur->value)
6518             || STRCASEEQ('s','S',"slide",cur->value)
6519             || STRCASEEQ('a','A',"alternate",cur->value)) {
6520             attr_marquee_style = apr_pstrdup(doc->pool, cur->value);
6521           }
6522         }
6523       }
6524       for (cur = marquee_loop_prop->next; cur != marquee_loop_prop; cur = cur->next) {
6525         if (cur->value && *cur->value) {
6526           if(strcmp(cur->value,"0") == 0 || strcmp(cur->value,"-1") == 0){
6527             attr_marquee_loop = "infinite";
6528           }
6529           else{
6530             attr_marquee_loop = apr_pstrdup(doc->pool, cur->value);
6531           }
6532         }
6533       }
6534       for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
6535         if (STRCASEEQ('l','L',"left", cur->value)) {
6536           attr_align = apr_pstrdup(doc->pool, "left");
6537         }
6538         else if (STRCASEEQ('c','C',"center",cur->value)) {
6539           attr_align = apr_pstrdup(doc->pool, "center");
6540         }
6541         else if (STRCASEEQ('r','R',"right",cur->value)) {
6542           attr_align = apr_pstrdup(doc->pool, "right");
6543         }
6544       }
6545       for (cur = bgcolor_prop->next; cur != bgcolor_prop; cur = cur->next) {
6546         if (cur->value && *cur->value) {
6547           css_bgcolor = apr_pstrdup(doc->pool, cur->value);
6548         }
6549       }
6550     }
6551   }
6552
6553   W_L("<span");
6554   if (attr_color || attr_size || attr_align || attr_blink || attr_marquee || css_bgcolor) {
6555     W_L(" style=\"");
6556     if (attr_color) {
6557       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
6558       W_L("color:");
6559       W_V(attr_color);
6560       W_L(";");
6561     }
6562     if (attr_size) {
6563       W_L("font-size:");
6564       W_V(attr_size);
6565       W_L(";");
6566     }
6567     if (attr_align) {
6568       W_L("text-align:");
6569       W_V(attr_align);
6570       W_L(";");
6571     }
6572     if (attr_blink) {
6573       W_L("text-decoration:");
6574       W_V("blink");
6575       W_L(";");
6576     }
6577     if (attr_marquee) {
6578       W_L("display:-wap-marquee;");
6579       if (attr_marquee_dir) {
6580         W_L("-wap-marquee-dir:");
6581         W_V(attr_marquee_dir);
6582         W_L(";");
6583       }
6584       if (attr_marquee_style) {
6585         W_L("-wap-marquee-style:");
6586         W_V(attr_marquee_style);
6587         W_L(";");
6588       }
6589       if (attr_marquee_loop) {
6590         W_L("-wap-marquee-loop:");
6591         W_V(attr_marquee_loop);
6592         W_L(";");
6593       }
6594     }
6595     if(css_bgcolor){
6596       W_L("background-color:");
6597       W_V(css_bgcolor);
6598       W_L(";");
6599     }
6600     W_L("\"");
6601   }
6602   W_L(">");
6603   return jxhtml->out;
6604 }
6605
6606
6607 /**
6608  * It is a handler who processes the SPAN tag.
6609  *
6610  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
6611  *                     destination is specified.
6612  * @param node   [i]   The SPAN tag node is specified.
6613  * @return The conversion result is returned.
6614  */
6615 static char *
6616 s_jxhtml_end_span_tag(void *pdoc, Node *UNUSED(node))
6617 {
6618   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
6619   Doc *doc = jxhtml->doc;
6620
6621   W_L("</span>");
6622   if (IS_CSS_ON(jxhtml->entryp)) {
6623     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
6624   }
6625   return jxhtml->out;
6626 }
6627
6628
6629 /**
6630  * It is a handler who processes the STYLE tag.
6631  *
6632  * @param pdoc  [i/o] The pointer to the SoftBank XHTML structure at the output
6633  *                     destination is specified.
6634  * @param node   [i]   The STYLE tag node is specified.
6635  * @return The conversion result is returned.
6636  */
6637 static char *
6638 s_jxhtml_style_tag(void *pdoc, Node *node)
6639 {
6640   jxhtml_t     *jxhtml;
6641   Doc           *doc;
6642   Attr          *attr;
6643   char          *type = NULL;
6644
6645   jxhtml = GET_JXHTML(pdoc);
6646   doc     = jxhtml->doc;
6647
6648   if (! IS_CSS_ON(jxhtml->entryp)) {
6649     return jxhtml->out;
6650   }
6651
6652   for (attr = qs_get_attr(doc,node);
6653        attr;
6654        attr = qs_get_next_attr(doc,attr)) {
6655     char *name  = qs_get_attr_name(doc,attr);
6656     char *value = qs_get_attr_value(doc,attr);
6657     if (STRCASEEQ('t','T',"type", name)) {
6658       if (value && *value && STRCASEEQ('t','T',"text/css",value)) {
6659         type = value;
6660       }
6661     }
6662   }
6663
6664   Node *child = qs_get_child_node(doc, node);
6665   if (type && child) {
6666     char *name  = qs_get_node_name(doc, child);
6667     if (STRCASEEQ('t','T',"text", name)) {
6668       char *value = qs_get_node_value(doc, child);
6669       DBG(doc->r, "start load CSS. buf:[%s]", value);
6670       jxhtml->style = chxj_css_parse_style_value(doc, jxhtml->style, value);
6671       DBG(doc->r, "end load CSS. value:[%s]", value);
6672     }
6673   }
6674   return jxhtml->out;
6675 }
6676 /**
6677  * It is a handler who processes the OBJECT tag.
6678  *
6679  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
6680  *                     destination is specified.
6681  * @param node   [i]   The OBJECT tag node is specified.
6682  * @return The conversion result is returned.
6683  */
6684 static char *
6685 s_jxhtml_start_object_tag(void *pdoc, Node *node)
6686 {
6687   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
6688   Doc *doc = jxhtml->doc;
6689   Attr *attr;
6690   
6691   char *attr_id            = NULL;
6692   char *attr_width         = NULL;
6693   char *attr_height        = NULL;
6694   char *attr_data          = NULL;
6695   char *attr_type          = NULL;
6696   char *attr_declare       = NULL;
6697   char *attr_classid       = NULL;
6698   char *attr_codebase      = NULL;
6699   
6700   /*--------------------------------------------------------------------------*/
6701   /* Get Attributes                                                           */
6702   /*--------------------------------------------------------------------------*/
6703   for (attr = qs_get_attr(doc,node);
6704        attr;
6705        attr = qs_get_next_attr(doc,attr)) {
6706     char *name   = qs_get_attr_name(doc,attr);
6707     char *value  = qs_get_attr_value(doc,attr);
6708     if (STRCASEEQ('i','I',"id",name)) {
6709       attr_id = apr_pstrdup(doc->pool, value);
6710     }
6711     else if (STRCASEEQ('w','W',"width",name)) {
6712       attr_width = apr_pstrdup(doc->pool, value);
6713     }
6714     else if (STRCASEEQ('h','H',"height",name)) {
6715       attr_height = apr_pstrdup(doc->pool, value);
6716     }
6717     else if (STRCASEEQ('d','D',"data",name)) {
6718       attr_data = apr_pstrdup(doc->pool, value);
6719     }
6720     else if  (STRCASEEQ('t','T',"type",name)) {
6721       attr_type = apr_pstrdup(doc->pool, value);
6722     }
6723     else if  (STRCASEEQ('d','D',"declare",name)) {
6724       attr_declare = apr_pstrdup(doc->pool, value);
6725     }
6726     else if (STRCASEEQ('c','C',"classid",name)) {
6727       attr_classid = apr_pstrdup(doc->pool, value);
6728     }
6729     else if (STRCASEEQ('c','C',"codebase",name)) {
6730       attr_codebase = apr_pstrdup(doc->pool, value);
6731     }
6732     
6733   }
6734   W_L("<object");
6735   
6736   if(attr_id){
6737     W_L(" id=\"");
6738     W_V(attr_id);
6739     W_L("\"");
6740   }
6741   if(attr_width){
6742     W_L(" width=\"");
6743     W_V(attr_width);
6744     W_L("\"");
6745   }
6746   if(attr_height){
6747     W_L(" height=\"");
6748     W_V(attr_height);
6749     W_L("\"");
6750   }
6751   if(attr_data){
6752     W_L(" data=\"");
6753     W_V(attr_data);
6754     W_L("\"");
6755   }
6756   if(attr_type){
6757     W_L(" type=\"");
6758     W_V(attr_type);
6759     W_L("\"");
6760   }
6761   if(attr_declare){
6762     W_L(" declare=\"declare\"");
6763   }
6764   if(attr_classid){
6765     W_L(" classid=\"");
6766     W_V(attr_classid);
6767     W_L("\"");
6768   }
6769   if(attr_codebase){
6770     W_L(" codebase=\"");
6771     W_V(attr_codebase);
6772     W_L("\"");
6773   }
6774   
6775   W_L(">");
6776   return jxhtml->out;
6777 }
6778 /**
6779  * It is a handler who processes the OBJECT tag.
6780  *
6781  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
6782  *                     destination is specified.
6783  * @param node   [i]   The OBJECT tag node is specified.
6784  * @return The conversion result is returned.
6785  */
6786 static char *
6787 s_jxhtml_end_object_tag(void *pdoc, Node *UNUSED(node))
6788 {
6789   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
6790   Doc *doc = jxhtml->doc;
6791
6792   W_L("</object>");
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_start_param_tag(void *pdoc, Node *node)
6805 {
6806   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
6807   Doc *doc = jxhtml->doc;
6808
6809   Attr *attr;
6810   char *attr_style         = NULL;
6811   char *attr_name          = NULL;
6812   char *attr_value         = NULL;
6813   char *attr_valuetype     = NULL;
6814   
6815   /*--------------------------------------------------------------------------*/
6816   /* Get Attributes                                                           */
6817   /*--------------------------------------------------------------------------*/
6818   for (attr = qs_get_attr(doc,node);
6819        attr;
6820        attr = qs_get_next_attr(doc,attr)) {
6821     char *name   = qs_get_attr_name(doc,attr);
6822     char *value  = qs_get_attr_value(doc,attr);
6823     if (STRCASEEQ('n','N',"name",name)) {
6824       attr_name = apr_pstrdup(doc->pool, value);
6825     }
6826     else if (STRCASEEQ('v','V',"value",name)) {
6827       attr_value = apr_pstrdup(doc->pool, value);
6828     }
6829     else if (STRCASEEQ('v','V',"valuetype",name)) {
6830       attr_valuetype = apr_pstrdup(doc->pool, value);
6831     }
6832   }
6833   W_L("<param");
6834   
6835   if(attr_name){
6836     W_L(" name=\"");
6837     W_V(attr_name);
6838     W_L("\"");
6839   }
6840   if(attr_value){
6841     W_L(" value=\"");
6842     W_V(attr_value);
6843     W_L("\"");
6844   }
6845   if(attr_valuetype){
6846     W_L(" valuetype=\"");
6847     W_V(attr_valuetype);
6848     W_L("\"");
6849   }
6850   W_L(" />");
6851   return jxhtml->out;
6852 }
6853 /**
6854  * It is a handler who processes the CAPTION tag.
6855  *
6856  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
6857  *                     destination is specified.
6858  * @param node   [i]   The CAPTION tag node is specified.
6859  * @return The conversion result is returned.
6860  */
6861 static char *
6862 s_jxhtml_start_caption_tag(void *pdoc, Node *node)
6863 {
6864   jxhtml_t    *jxhtml;
6865   Doc         *doc;
6866   request_rec *r;
6867   Attr        *attr;
6868   char        *attr_style = NULL;
6869   char        *attr_align = NULL;
6870
6871   jxhtml = GET_JXHTML(pdoc);
6872   doc    = jxhtml->doc;
6873   r      = doc->r;
6874
6875   for (attr = qs_get_attr(doc,node);
6876        attr;
6877        attr = qs_get_next_attr(doc,attr)) {
6878     char *name  = qs_get_attr_name(doc,attr);
6879     char *value = qs_get_attr_value(doc,attr);
6880     if (STRCASEEQ('a','A',"align", name)) {
6881       if (value && 
6882           (STRCASEEQ('l','L',"left",value) 
6883         || STRCASEEQ('r','R',"right",value) 
6884         || STRCASEEQ('t','T',"top",value)
6885         || STRCASEEQ('b','B',"bottom",value) 
6886         )) {
6887         attr_align = value;
6888       }
6889     }
6890     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
6891       attr_style = value;
6892     }
6893   }
6894   
6895   W_L("<caption");
6896   if(attr_align){
6897     W_L(" align=\"");
6898     W_V(attr_align);
6899     W_L("\"");
6900   }
6901   W_L(">");
6902
6903   return jxhtml->out;
6904 }
6905
6906
6907 /**
6908  * It is a handler who processes the CAPTION tag.
6909  *
6910  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
6911  *                     destination is specified.
6912  * @param node   [i]   The CAPTION tag node is specified.
6913  * @return The conversion result is returned.
6914  */
6915 static char *
6916 s_jxhtml_end_caption_tag(void *pdoc, Node *UNUSED(child)) 
6917 {
6918   jxhtml_t*    jxhtml = GET_JXHTML(pdoc);
6919   Doc*          doc   = jxhtml->doc;
6920   
6921   W_L("</caption>");
6922   
6923   return jxhtml->out;
6924 }
6925
6926
6927 /*
6928  * vim:ts=2 et
6929  */