OSDN Git Service

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