OSDN Git Service

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