OSDN Git Service

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