OSDN Git Service

Merge branch 'branch_0.12.0' into branch_0.13.0
[modchxj/mod_chxj.git] / src / chxj_xhtml_mobile_1_0.c
1 /*
2  * Copyright (C) 2005-2009 Atsushi Konno All rights reserved.
3  * Copyright (C) 2005 QSDN,Inc. All rights reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #include "mod_chxj.h"
18 #include "chxj_encoding.h"
19 #include "chxj_xhtml_mobile_1_0.h"
20 #include "chxj_hdml.h"
21 #include "chxj_dump.h"
22 #include "chxj_img_conv.h"
23 #include "chxj_qr_code.h"
24 #include "chxj_buffered_write.h"
25 #include "chxj_str_util.h"
26 #include "chxj_header_inf.h"
27
28 #define GET_XHTML(X) ((xhtml_t*)(X))
29 #undef W_L
30 #undef W_V
31 #define W_L(X)          do { xhtml->out = BUFFERED_WRITE_LITERAL(xhtml->out, &doc->buf, (X)); } while(0)
32 #define W_V(X)          do { xhtml->out = (X) ? BUFFERED_WRITE_VALUE(xhtml->out, &doc->buf, (X))  \
33                                                : BUFFERED_WRITE_LITERAL(xhtml->out, &doc->buf, ""); } while(0)
34 #undef W_NLCODE
35 #define W_NLCODE()     do { char *nlcode = TO_NLCODE(xhtml->conf); W_V(nlcode); } while (0)
36
37 static char *s_xhtml_1_0_start_html_tag   (void *pdoc, Node *node);
38 static char *s_xhtml_1_0_end_html_tag     (void *pdoc, Node *node);
39 static char *s_xhtml_1_0_start_p_tag      (void *pdoc, Node *node);
40 static char *s_xhtml_1_0_end_p_tag        (void *pdoc, Node *node);
41 static char *s_xhtml_1_0_start_pre_tag    (void *pdoc, Node *node);
42 static char *s_xhtml_1_0_end_pre_tag      (void *pdoc, Node *node);
43 static char *s_xhtml_1_0_start_ul_tag     (void *pdoc, Node *node);
44 static char *s_xhtml_1_0_end_ul_tag       (void *pdoc, Node *node);
45 static char *s_xhtml_1_0_start_h1_tag     (void *pdoc, Node *node);
46 static char *s_xhtml_1_0_end_h1_tag       (void *pdoc, Node *node);
47 static char *s_xhtml_1_0_start_h2_tag     (void *pdoc, Node *node);
48 static char *s_xhtml_1_0_end_h2_tag       (void *pdoc, Node *node);
49 static char *s_xhtml_1_0_start_h3_tag     (void *pdoc, Node *node);
50 static char *s_xhtml_1_0_end_h3_tag       (void *pdoc, Node *node);
51 static char *s_xhtml_1_0_start_h4_tag     (void *pdoc, Node *node);
52 static char *s_xhtml_1_0_end_h4_tag       (void *pdoc, Node *node);
53 static char *s_xhtml_1_0_start_h5_tag     (void *pdoc, Node *node);
54 static char *s_xhtml_1_0_end_h5_tag       (void *pdoc, Node *node);
55 static char *s_xhtml_1_0_start_h6_tag     (void *pdoc, Node *node);
56 static char *s_xhtml_1_0_end_h6_tag       (void *pdoc, Node *node);
57 static char *s_xhtml_1_0_start_ol_tag     (void *pdoc, Node *node);
58 static char *s_xhtml_1_0_end_ol_tag       (void *pdoc, Node *node);
59 static char *s_xhtml_1_0_start_li_tag     (void *pdoc, Node *node);
60 static char *s_xhtml_1_0_end_li_tag       (void *pdoc, Node *node);
61 static char *s_xhtml_1_0_start_meta_tag   (void *pdoc, Node *node);
62 static char *s_xhtml_1_0_end_meta_tag     (void *pdoc, Node *node);
63 static char *s_xhtml_1_0_start_head_tag   (void *pdoc, Node *node);
64 static char *s_xhtml_1_0_end_head_tag     (void *pdoc, Node *node);
65 static char *s_xhtml_1_0_start_title_tag  (void *pdoc, Node *node);
66 static char *s_xhtml_1_0_end_title_tag    (void *pdoc, Node *node);
67 static char *s_xhtml_1_0_start_base_tag   (void *pdoc, Node *node);
68 static char *s_xhtml_1_0_end_base_tag     (void *pdoc, Node *node);
69 static char *s_xhtml_1_0_start_body_tag   (void *pdoc, Node *node);
70 static char *s_xhtml_1_0_end_body_tag     (void *pdoc, Node *node);
71 static char *s_xhtml_1_0_start_a_tag      (void *pdoc, Node *node);
72 static char *s_xhtml_1_0_end_a_tag        (void *pdoc, Node *node);
73 static char *s_xhtml_1_0_start_br_tag     (void *pdoc, Node *node);
74 static char *s_xhtml_1_0_end_br_tag       (void *pdoc, Node *node);
75 static char *s_xhtml_1_0_start_tr_tag     (void *pdoc, Node *node);
76 static char *s_xhtml_1_0_end_tr_tag       (void *pdoc, Node *node);
77 static char *s_xhtml_1_0_start_font_tag   (void *pdoc, Node *node);
78 static char *s_xhtml_1_0_end_font_tag     (void *pdoc, Node *node);
79 static char *s_xhtml_1_0_start_form_tag   (void *pdoc, Node *node);
80 static char *s_xhtml_1_0_end_form_tag     (void *pdoc, Node *node);
81 static char *s_xhtml_1_0_start_input_tag  (void *pdoc, Node *node);
82 static char *s_xhtml_1_0_end_input_tag    (void *pdoc, Node *node);
83 static char *s_xhtml_1_0_start_center_tag (void *pdoc, Node *node);
84 static char *s_xhtml_1_0_end_center_tag   (void *pdoc, Node *node);
85 static char *s_xhtml_1_0_start_hr_tag     (void *pdoc, Node *node);
86 static char *s_xhtml_1_0_end_hr_tag       (void *pdoc, Node *node);
87 static char *s_xhtml_1_0_start_img_tag    (void *pdoc, Node *node);
88 static char *s_xhtml_1_0_end_img_tag      (void *pdoc, Node *node);
89 static char *s_xhtml_1_0_start_select_tag (void *pdoc, Node *node);
90 static char *s_xhtml_1_0_end_select_tag   (void *pdoc, Node *node);
91 static char *s_xhtml_1_0_start_option_tag (void *pdoc, Node *node);
92 static char *s_xhtml_1_0_end_option_tag   (void *pdoc, Node *node);
93 static char *s_xhtml_1_0_start_div_tag       (void *pdoc, Node *node);
94 static char *s_xhtml_1_0_end_div_tag         (void *pdoc, Node *node);
95 static char *s_xhtml_1_0_start_textarea_tag  (void *pdoc, Node *node);
96 static char *s_xhtml_1_0_end_textarea_tag    (void *pdoc, Node *node);
97 static char *s_xhtml_1_0_start_b_tag         (void *pdoc, Node *node);
98 static char *s_xhtml_1_0_end_b_tag           (void *pdoc, Node *node);
99 static char *s_xhtml_1_0_chxjif_tag          (void *pdoc, Node *node);
100 static char *s_xhtml_1_0_start_blockquote_tag (void *pdoc, Node *node);
101 static char *s_xhtml_1_0_end_blockquote_tag  (void *pdoc, Node *node);
102 static char *s_xhtml_1_0_start_dir_tag       (void *pdoc, Node *node);
103 static char *s_xhtml_1_0_end_dir_tag         (void *pdoc, Node *node);
104 static char *s_xhtml_1_0_start_dl_tag        (void *pdoc, Node *node);
105 static char *s_xhtml_1_0_end_dl_tag          (void *pdoc, Node *node);
106 static char *s_xhtml_1_0_start_dt_tag        (void *pdoc, Node *node);
107 static char *s_xhtml_1_0_end_dt_tag          (void *pdoc, Node *node);
108 static char *s_xhtml_1_0_start_dd_tag        (void *pdoc, Node *node);
109 static char *s_xhtml_1_0_end_dd_tag          (void *pdoc, Node *node);
110 static char *s_xhtml_1_0_start_menu_tag      (void *pdoc, Node *node);
111 static char *s_xhtml_1_0_end_menu_tag        (void *pdoc, Node *node);
112 static char *s_xhtml_1_0_start_plaintext_tag       (void *pdoc, Node *node);
113 static char *s_xhtml_1_0_start_plaintext_tag_inner (void *pdoc, Node *node);
114 static char *s_xhtml_1_0_end_plaintext_tag         (void *pdoc, Node *node);
115 static char *s_xhtml_1_0_start_blink_tag     (void *pdoc, Node *node);
116 static char *s_xhtml_1_0_end_blink_tag       (void *pdoc, Node *node);
117 static char *s_xhtml_1_0_start_marquee_tag   (void *pdoc, Node *node);
118 static char *s_xhtml_1_0_end_marquee_tag     (void *pdoc, Node *node);
119 static char *s_xhtml_1_0_newline_mark       (void *pdoc, Node *node);
120 static char *s_xhtml_1_0_link_tag           (void *pdoc, Node *node);
121 static char *s_xhtml_1_0_start_span_tag      (void *pdoc, Node *node);
122 static char *s_xhtml_1_0_end_span_tag        (void *pdoc, Node *node);
123 static char *s_xhtml_1_0_style_tag        (void *pdoc, Node *node);
124
125 static void  s_init_xhtml(xhtml_t *xhtml, Doc *doc, request_rec *r, device_table *spec);
126 static int   s_xhtml_search_emoji(xhtml_t *xhtml, char *txt, char **rslt);
127 static char *s_xhtml_1_0_text_tag(void *pdoc, Node *child);
128 static css_prop_list_t *s_xhtml_1_0_nopush_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value);
129 static css_prop_list_t *s_xhtml_1_0_push_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value);
130 /* pend */
131
132
133 tag_handler xhtml_handler[] = {
134   /* tagHTML */
135   {
136     s_xhtml_1_0_start_html_tag,
137     s_xhtml_1_0_end_html_tag,
138   },
139   /* tagMETA */
140   {
141     s_xhtml_1_0_start_meta_tag,
142     s_xhtml_1_0_end_meta_tag,
143   },
144   /* tagTEXTAREA */
145   {
146     s_xhtml_1_0_start_textarea_tag,
147     s_xhtml_1_0_end_textarea_tag,
148   },
149   /* tagP */
150   {
151     s_xhtml_1_0_start_p_tag,
152     s_xhtml_1_0_end_p_tag,
153   },
154   /* tagPRE */
155   {
156     s_xhtml_1_0_start_pre_tag,
157     s_xhtml_1_0_end_pre_tag,
158   },
159   /* tagUL */
160   {
161     s_xhtml_1_0_start_ul_tag,
162     s_xhtml_1_0_end_ul_tag,
163   },
164   /* tagLI */
165   {
166     s_xhtml_1_0_start_li_tag,
167     s_xhtml_1_0_end_li_tag,
168   },
169   /* tagOL */
170   {
171     s_xhtml_1_0_start_ol_tag,
172     s_xhtml_1_0_end_ol_tag,
173   },
174   /* tagH1 */
175   {
176     s_xhtml_1_0_start_h1_tag,
177     s_xhtml_1_0_end_h1_tag,
178   },
179   /* tagH2 */
180   {
181     s_xhtml_1_0_start_h2_tag,
182     s_xhtml_1_0_end_h2_tag,
183   },
184   /* tagH3 */
185   {
186     s_xhtml_1_0_start_h3_tag,
187     s_xhtml_1_0_end_h3_tag,
188   },
189   /* tagH4 */
190   {
191     s_xhtml_1_0_start_h4_tag,
192     s_xhtml_1_0_end_h4_tag,
193   },
194   /* tagH5 */
195   {
196     s_xhtml_1_0_start_h5_tag,
197     s_xhtml_1_0_end_h5_tag,
198   },
199   /* tagH6 */
200   {
201     s_xhtml_1_0_start_h6_tag,
202     s_xhtml_1_0_end_h6_tag,
203   },
204   /* tagHEAD */
205   {
206     s_xhtml_1_0_start_head_tag,
207     s_xhtml_1_0_end_head_tag,
208   },
209   /* tagTITLE */
210   {
211     s_xhtml_1_0_start_title_tag,
212     s_xhtml_1_0_end_title_tag,
213   },
214   /* tagBASE */
215   {
216     s_xhtml_1_0_start_base_tag,
217     s_xhtml_1_0_end_base_tag,
218   },
219   /* tagBODY */
220   {
221     s_xhtml_1_0_start_body_tag,
222     s_xhtml_1_0_end_body_tag,
223   },
224   /* tagA */
225   {
226     s_xhtml_1_0_start_a_tag,
227     s_xhtml_1_0_end_a_tag,
228   },
229   /* tagBR */
230   {
231     s_xhtml_1_0_start_br_tag,
232     s_xhtml_1_0_end_br_tag,
233   },
234   /* tagTABLE */
235   {
236     NULL,
237     NULL,
238   },
239   /* tagTR */
240   {
241     s_xhtml_1_0_start_tr_tag,
242     s_xhtml_1_0_end_tr_tag,
243   },
244   /* tagTD */
245   {
246     NULL,
247     NULL,
248   },
249   /* tagTBODY */
250   {
251     NULL,
252     NULL,
253   },
254   /* tagFONT */
255   {
256     s_xhtml_1_0_start_font_tag,
257     s_xhtml_1_0_end_font_tag,
258   },
259   /* tagFORM */
260   {
261     s_xhtml_1_0_start_form_tag,
262     s_xhtml_1_0_end_form_tag,
263   },
264   /* tagINPUT */
265   {
266     s_xhtml_1_0_start_input_tag,
267     s_xhtml_1_0_end_input_tag,
268   },
269   /* tagCENTER */
270   {
271     s_xhtml_1_0_start_center_tag,
272     s_xhtml_1_0_end_center_tag,
273   },
274   /* tagHR */
275   {
276     s_xhtml_1_0_start_hr_tag,
277     s_xhtml_1_0_end_hr_tag,
278   },
279   /* tagIMG */
280   {
281     s_xhtml_1_0_start_img_tag,
282     s_xhtml_1_0_end_img_tag,
283   },
284   /* tagSELECT */
285   {
286     s_xhtml_1_0_start_select_tag,
287     s_xhtml_1_0_end_select_tag,
288   },
289   /* tagOPTION */
290   {
291     s_xhtml_1_0_start_option_tag,
292     s_xhtml_1_0_end_option_tag,
293   },
294   /* tagDIV */
295   {
296     s_xhtml_1_0_start_div_tag,
297     s_xhtml_1_0_end_div_tag,
298   },
299   /* tagCHXJIF */
300   {
301     s_xhtml_1_0_chxjif_tag,
302     NULL,
303   },
304   /* tagNOBR */
305   {
306     NULL,
307     NULL,
308   },
309   /* tagSMALL */
310   {
311     NULL,
312     NULL,
313   },
314   /* tagSTYLE */
315   {
316     s_xhtml_1_0_style_tag,
317     NULL,
318   },
319   /* tagSPAN */
320   {
321     s_xhtml_1_0_start_span_tag,
322     s_xhtml_1_0_end_span_tag,
323   },
324   /* tagTEXT */
325   {
326     s_xhtml_1_0_text_tag,
327     NULL,
328   },
329   /* tagTH */
330   {
331     NULL,
332     NULL,
333   },
334   /* tagB */
335   {
336     s_xhtml_1_0_start_b_tag,
337     s_xhtml_1_0_end_b_tag,
338   },
339   /* tagFIELDSET */
340   {
341     NULL,
342     NULL,
343   },
344   /* tagDT */
345   {
346     s_xhtml_1_0_start_dt_tag,
347     s_xhtml_1_0_end_dt_tag,
348   },
349   /* tagLEGEND */
350   {
351     NULL,
352     NULL,
353   },
354   /* tagLABEL */
355   {
356     NULL,
357     NULL,
358   },
359   /* tagBLOCKQUOTE */
360   {
361     s_xhtml_1_0_start_blockquote_tag,
362     s_xhtml_1_0_end_blockquote_tag,
363   },
364   /* tagDIR */
365   {
366     s_xhtml_1_0_start_dir_tag,
367     s_xhtml_1_0_end_dir_tag,
368   },
369   /* tagDL */
370   {
371     s_xhtml_1_0_start_dl_tag,
372     s_xhtml_1_0_end_dl_tag,
373   },
374   /* tagDD */
375   {
376     s_xhtml_1_0_start_dd_tag,
377     s_xhtml_1_0_end_dd_tag,
378   },
379   /* tagMENU */
380   {
381     s_xhtml_1_0_start_menu_tag,
382     s_xhtml_1_0_end_menu_tag,
383   },
384   /* tagPLAINTEXT */
385   {
386     s_xhtml_1_0_start_plaintext_tag,
387     s_xhtml_1_0_end_plaintext_tag,
388   },
389   /* tagBLINK */
390   {
391     s_xhtml_1_0_start_blink_tag,
392     s_xhtml_1_0_end_blink_tag,
393   },
394   /* tagMARQUEE */
395   {
396     s_xhtml_1_0_start_marquee_tag,
397     s_xhtml_1_0_end_marquee_tag,
398   },
399   /* tagLINK */
400   {
401     s_xhtml_1_0_link_tag,
402     NULL,
403   },
404   /* tagNLMARK */
405   {
406     s_xhtml_1_0_newline_mark,
407     NULL,
408   },
409 };
410  
411 /**
412  * converts from CHTML to XHTML.
413  *
414  * @param r     [i]   Requet_rec is appointed.
415  * @param spec  [i]   The result of the device specification processing which 
416  *                    was done in advance is appointed.
417  * @param src   [i]   The character string before the converting is appointed.
418  * @return The character string after the converting is returned.
419  */
420 char *
421 chxj_convert_xhtml_mobile_1_0(
422   request_rec        *r,
423   device_table       *spec,
424   const char         *src,
425   apr_size_t         srclen,
426   apr_size_t         *dstlen,
427   chxjconvrule_entry *entryp,
428   cookie_t           *cookie
429 )
430 {
431   char      *dst = NULL;
432   char      *ss;
433   xhtml_t   xhtml;
434   Doc       doc;
435
436   DBG(r,"start chxj_convert_xhtml_mobile_1_0()");
437   /*--------------------------------------------------------------------------*/
438   /* If qrcode xml                                                            */
439   /*--------------------------------------------------------------------------*/
440   *dstlen = srclen;
441   dst = chxj_qr_code_blob_handler(r, src, (size_t*)dstlen);
442   if (dst != NULL) {
443     DBG(r,"end chxj_convert_xhtml_mobile_1_0() (found qrcode.xml)");
444     return dst;
445   }
446
447   /*--------------------------------------------------------------------------*/
448   /* The XHTML structure is initialized.                                      */
449   /*--------------------------------------------------------------------------*/
450   s_init_xhtml(&xhtml, &doc, r, spec);
451
452   xhtml.entryp = entryp;
453   xhtml.cookie = cookie;
454
455   chxj_set_content_type(r, chxj_header_inf_set_content_type(r, "text/html; charset=Windows-31J"));
456
457   /*--------------------------------------------------------------------------*/
458   /* The character string of the input is analyzed.                           */
459   /*--------------------------------------------------------------------------*/
460   qs_init_malloc(&doc);
461   qs_init_root_node(&doc);
462
463   ss = apr_pcalloc(r->pool, srclen + 1);
464   memset(ss,   0, srclen + 1);
465   memcpy(ss, src, srclen);
466
467   if (IS_CSS_ON(xhtml.entryp)) {
468     /* current property list */
469     xhtml.css_prop_stack = chxj_new_prop_list_stack(&doc);
470   }
471 #ifdef DUMP_LOG
472   chxj_dump_out("[src] CHTML->XHTML", ss, srclen);
473 #endif
474   qs_parse_string(&doc,ss, strlen(ss));
475
476   chxj_buffered_write_init(r->pool, &doc.buf);
477   /*--------------------------------------------------------------------------*/
478   /* It converts it from CHTML to XHTML.                                      */
479   /*--------------------------------------------------------------------------*/
480   chxj_node_convert(spec,r,(void *)&xhtml, &doc, qs_get_root(&doc), 0);
481   xhtml.out = chxj_buffered_write_flush(xhtml.out, &doc.buf);
482   dst = apr_pstrdup(r->pool, xhtml.out);
483   chxj_buffered_write_terminate(&doc.buf);
484
485   qs_all_free(&doc,QX_LOGMARK);
486
487   if (! dst) {
488     return apr_pstrdup(r->pool,ss);
489   }
490
491   if (! *dst) {
492     dst = apr_psprintf(r->pool, "\n");
493   }
494   *dstlen = strlen(dst);
495
496 #ifdef DUMP_LOG
497   chxj_dump_out("[dst] CHTML->XHTML", dst, *dstlen);
498 #endif
499
500   DBG(r,"end chxj_convert_xhtml_mobile_1_0()");
501   return dst;
502 }
503
504
505 /**
506  * The XHTML structure is initialized.
507  *
508  * @param xhtml [i/o] The pointer to the HDML structure that wants to be
509  *                   initialized is specified.
510  * @param doc   [i]   The Doc structure that should be set to the initialized
511  *                   HDML structure is specified.
512  * @param r     [i]   To use POOL, the pointer to request_rec is specified.
513  * @param spec  [i]   The pointer to the device_table
514  */
515 static void
516 s_init_xhtml(xhtml_t *xhtml, Doc *doc, request_rec *r, device_table *spec)
517 {
518   memset(doc,   0, sizeof(Doc));
519   memset(xhtml, 0, sizeof(xhtml_t));
520
521   doc->r      = r;
522   xhtml->doc  = doc;
523   xhtml->spec = spec;
524   xhtml->out  = qs_alloc_zero_byte_string(r->pool);
525   xhtml->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
526   xhtml->doc->parse_mode = PARSE_MODE_CHTML;
527 }
528
529
530 /**
531  * Corresponding EMOJI to a current character-code is retrieved. 
532  * The substitution character string is stored in the rslt pointer if agreeing.
533  *
534  * @param xhtml   [i]   The pointer to the XHTML structure is specified. 
535  * @param txt     [i]   The character string to want to examine whether it is 
536  *                      EMOJI is specified. 
537  * @param rslt    [o]   The pointer to the pointer that stores the result is 
538  *                      specified. 
539  * @return When corresponding EMOJI exists, it returns it excluding 0. 
540  */
541 static int
542 s_xhtml_search_emoji(xhtml_t *xhtml, char *txt, char **rslt)
543 {
544   emoji_t       *ee;
545   request_rec   *r;
546   device_table  *spec;
547   int           len;
548
549   spec = xhtml->spec;
550
551   len = strlen(txt);
552   r = xhtml->doc->r;
553
554   if (spec == NULL) {
555     DBG(r,"spec is NULL");
556   }
557
558   for (ee = xhtml->conf->emoji;
559        ee;
560        ee = ee->next) {
561     unsigned char hex1byte;
562     unsigned char hex2byte;
563     if (!ee->imode) {
564       DBG(r,"emoji->imode is NULL");
565       continue;
566     }
567
568     if (ee->imode->string != NULL
569     &&  strlen(ee->imode->string) > 0
570     &&  strncasecmp(ee->imode->string, txt, strlen(ee->imode->string)) == 0) {
571       if (spec == NULL || spec->emoji_type == NULL) {
572         *rslt = apr_psprintf(r->pool,
573                         "<img localsrc=%s>",
574                         ee->ezweb->typeA);
575         return strlen(ee->imode->string);
576       }
577
578       if (strcasecmp(xhtml->spec->emoji_type, "a") == 0) {
579         *rslt = apr_psprintf(r->pool,
580                         "<img localsrc=%s>",
581                         ee->ezweb->typeA);
582         return strlen(ee->imode->string);
583       } 
584       else
585       if (strcasecmp(xhtml->spec->emoji_type, "b") == 0) {
586         *rslt = apr_psprintf(r->pool,
587                         "<img localsrc=%s>",
588                         ee->ezweb->typeB);
589         return strlen(ee->imode->string);
590       }
591       else
592       if (strcasecmp(xhtml->spec->emoji_type, "c") == 0) {
593         *rslt = apr_psprintf(r->pool,
594                         "<img localsrc=%s>",
595                         ee->ezweb->typeC);
596         return strlen(ee->imode->string);
597       }
598       else
599       if (strcasecmp(xhtml->spec->emoji_type, "d") == 0) {
600         *rslt = apr_psprintf(r->pool,
601                         "<img localsrc=%s>",
602                         ee->ezweb->typeD);
603         return strlen(ee->imode->string);
604       }
605       else {
606         *rslt = apr_psprintf(r->pool,
607                         "<img localsrc=%s>",
608                         ee->ezweb->typeA);
609         return strlen(ee->imode->string);
610       }
611       return 0;
612     }
613     hex1byte = ee->imode->hex1byte & 0xff;
614     hex2byte = ee->imode->hex2byte & 0xff;
615     if (len >= 2
616     && ((unsigned char)txt[0] & 0xff) == ((unsigned char)hex1byte)
617     && ((unsigned char)txt[1] & 0xff) == ((unsigned char)hex2byte)) {
618       if (spec == NULL || spec->emoji_type == NULL) {
619         *rslt = apr_psprintf(r->pool,
620                         "<img localsrc=\"%s\">",
621                         ee->ezweb->typeA);
622         return 2;
623       }
624
625       if (strcasecmp(xhtml->spec->emoji_type, "a") == 0) {
626         *rslt = apr_psprintf(r->pool,
627                         "<img localsrc=\"%s\">",
628                         ee->ezweb->typeA);
629         return 2;
630       } 
631       else
632       if (strcasecmp(xhtml->spec->emoji_type, "b") == 0) {
633         *rslt = apr_psprintf(r->pool,
634                         "<img localsrc=\"%s\">",
635                         ee->ezweb->typeB);
636         return 2;
637       }
638       else
639       if (strcasecmp(xhtml->spec->emoji_type, "c") == 0) {
640         *rslt = apr_psprintf(r->pool,
641                         "<img localsrc=\"%s\">",
642                         ee->ezweb->typeC);
643         return 2;
644       }
645       else
646       if (strcasecmp(xhtml->spec->emoji_type, "d") == 0) {
647         *rslt = apr_psprintf(r->pool,
648                         "<img localsrc=\"%s\">",
649                         ee->ezweb->typeD);
650         return 2;
651       }
652       else {
653         *rslt = apr_psprintf(r->pool,
654                         "<img localsrc=\"%s\">",
655                         ee->ezweb->typeD);
656         return 2;
657       }
658       return 0;
659     }
660   }
661   return 0;
662 }
663
664
665 char *
666 chxj_xhtml_emoji_only_converter(request_rec *r, device_table *spec, const char *src, apr_size_t len)
667 {
668   apr_size_t ii;
669   Doc __doc;
670   Doc *doc;
671   xhtml_t __xhtml;
672   xhtml_t *xhtml;
673   char one_byte[2];
674   char two_byte[3];
675   apr_pool_t *pool;
676
677   xhtml = &__xhtml;
678   doc   = &__doc;
679
680   DBG(r, "REQ[%X] start chxj_xhtml_emoji_eonly_converter()", (unsigned int)(apr_size_t)r);
681   memset(doc,     0, sizeof(Doc));
682   memset(xhtml, 0, sizeof(xhtml_t));
683
684   doc->r        = r;
685   xhtml->doc  = doc;
686   xhtml->spec = spec;
687   xhtml->out  = qs_alloc_zero_byte_string(r->pool);
688   xhtml->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
689   xhtml->doc->parse_mode = PARSE_MODE_CHTML;
690
691   apr_pool_create(&pool, r->pool);
692
693   chxj_buffered_write_init(pool, &doc->buf);
694
695   for (ii=0; ii<len; ii++) {
696     char *out;
697     int   rtn;
698
699     rtn = s_xhtml_search_emoji(xhtml, (char *)&src[ii], &out);
700     if (rtn) {
701       W_V(out);
702       ii+=(rtn - 1);
703       continue;
704     }
705
706     if (is_sjis_kanji(src[ii])) {
707       two_byte[0] = src[ii+0];
708       two_byte[1] = src[ii+1];
709       two_byte[2] = 0;
710       W_V(two_byte);
711       ii++;
712     }
713     else {
714       one_byte[0] = src[ii+0];
715       one_byte[1] = 0;
716       W_V(one_byte);
717     }
718   }
719   xhtml->out = chxj_buffered_write_flush(xhtml->out, &doc->buf);
720
721   DBG(r, "REQ[%X] end chxj_xhtml_emoji_eonly_converter()", (unsigned int)(apr_size_t)r);
722   return xhtml->out;
723 }
724
725
726 /**
727  * It is a handler who processes the HTML tag.
728  *
729  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
730  *                     destination is specified.
731  * @param node   [i]   The HTML tag node is specified.
732  * @return The conversion result is returned.
733  */
734 static char *
735 s_xhtml_1_0_start_html_tag(void *pdoc, Node *UNUSED(node)) 
736 {
737   xhtml_t       *xhtml = GET_XHTML(pdoc);
738   Doc           *doc   = xhtml->doc;
739
740   /*--------------------------------------------------------------------------*/
741   /* Add XML Declare                                                          */
742   /*--------------------------------------------------------------------------*/
743   W_L("<?xml version=\"1.0\" encoding=\"Shift_JIS\"?>");
744   W_NLCODE();
745   /*--------------------------------------------------------------------------*/
746   /* Add DocType                                                              */
747   /*--------------------------------------------------------------------------*/
748   W_L("<!DOCTYPE html PUBLIC \"-//OPENWAVE//DTD XHTML 1.0//EN\"");
749   W_NLCODE();
750   W_L(" \"http://www.openwave.com/DTD/xhtml-basic.dtd\">");
751   W_NLCODE();
752   /*--------------------------------------------------------------------------*/
753   /* start HTML tag                                                           */
754   /*--------------------------------------------------------------------------*/
755   W_L("<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"ja\" xml:lang=\"ja\">");
756
757   xhtml->start_html_flag = 1;
758   return xhtml->out;
759 }
760
761
762 /**
763  * It is a handler who processes the HTML tag.
764  *
765  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
766  *                     destination is specified.
767  * @param node   [i]   The HTML tag node is specified.
768  * @return The conversion result is returned.
769  */
770 static char *
771 s_xhtml_1_0_end_html_tag(void *pdoc, Node *UNUSED(child)) 
772 {
773   xhtml_t       *xhtml = GET_XHTML(pdoc);
774   Doc           *doc   = xhtml->doc;
775   W_L("</html>");
776   return xhtml->out;
777 }
778
779
780 /**
781  * It is a handler who processes the META tag.
782  *
783  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
784  *                     destination is specified.
785  * @param node   [i]   The META tag node is specified.
786  * @return The conversion result is returned.
787  */
788 static char *
789 s_xhtml_1_0_start_meta_tag(void *pdoc, Node *node) 
790 {
791   xhtml_t       *xhtml = GET_XHTML(pdoc);
792   Attr          *attr;
793   Doc           *doc   = xhtml->doc;
794   int           content_type_flag = 0;
795   request_rec   *r = doc->r;
796
797   W_L("<meta");
798   /*--------------------------------------------------------------------------*/
799   /* Get Attributes                                                           */
800   /*--------------------------------------------------------------------------*/
801   for (attr = qs_get_attr(doc,node);
802        attr; 
803        attr = qs_get_next_attr(doc,attr)) {
804     char *name  = qs_get_attr_name(doc,attr);
805     char *value = qs_get_attr_value(doc,attr);
806     if (STRCASEEQ('n','N',"name", name) && value && *value) {
807       W_L(" ");
808       W_V(name);
809       W_L("=\"");
810       W_V(value);
811       W_L("\"");
812     }
813     else if (STRCASEEQ('h','H',"http-equiv", name) && value && *value) {
814       W_L(" ");
815       W_V(name);
816       W_L("=\"");
817       W_V(value);
818       W_L("\"");
819       if (STRCASEEQ('c','C', "content-type", value)) {
820         content_type_flag = 1;
821       }
822     }
823     else if (STRCASEEQ('c','C',"content", name) && value && *value) {
824       if (content_type_flag) {
825         W_L(" ");
826         W_V(name);
827         W_L("=\"");
828         W_V(chxj_header_inf_set_content_type(r, "text/html; charset=Windows-31J"));
829         W_L("\"");
830       }
831       else {
832         W_L(" ");
833         W_V(name);
834         W_L("=\"");
835         W_V(value);
836         W_L("\"");
837       }
838     }
839   }
840   W_L(" />");
841   return xhtml->out;
842 }
843
844
845 /**
846  * It is a handler who processes the META tag.
847  *
848  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
849  *                     destination is specified.
850  * @param node   [i]   The META tag node is specified.
851  * @return The conversion result is returned.
852  */
853 static char *
854 s_xhtml_1_0_end_meta_tag(void *pdoc, Node *UNUSED(child)) 
855 {
856   xhtml_t *xhtml = GET_XHTML(pdoc);
857
858   return xhtml->out;
859 }
860
861
862 /**
863  * It is a handler who processes the HEAD tag.
864  *
865  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
866  *                     destination is specified.
867  * @param node   [i]   The HEAD tag node is specified.
868  * @return The conversion result is returned.
869  */
870 static char *
871 s_xhtml_1_0_start_head_tag(void *pdoc, Node *UNUSED(node)) 
872 {
873   xhtml_t       *xhtml = GET_XHTML(pdoc);
874   Doc           *doc   = xhtml->doc;
875
876   W_L("<head>");
877   return xhtml->out;
878 }
879
880
881 /**
882  * It is a handler who processes the HEAD tag.
883  *
884  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
885  *                     destination is specified.
886  * @param node   [i]   The HEAD tag node is specified.
887  * @return The conversion result is returned.
888  */
889 static char *
890 s_xhtml_1_0_end_head_tag(void *pdoc, Node *UNUSED(child)) 
891 {
892   xhtml_t       *xhtml = GET_XHTML(pdoc);
893   Doc           *doc   = xhtml->doc;
894
895   W_L("</head>");
896   return xhtml->out;
897 }
898
899
900 /**
901  * It is a handler who processes the TITLE tag.
902  *
903  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
904  *                     destination is specified.
905  * @param node   [i]   The TITLE tag node is specified.
906  * @return The conversion result is returned.
907  */
908 static char *
909 s_xhtml_1_0_start_title_tag(void *pdoc, Node *UNUSED(node)) 
910 {
911   xhtml_t      *xhtml = GET_XHTML(pdoc);
912   Doc          *doc   = xhtml->doc;
913
914   W_L("<title>");
915   return xhtml->out;
916 }
917
918
919 /**
920  * It is a handler who processes the TITLE tag.
921  *
922  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
923  *                     destination is specified.
924  * @param node   [i]   The TITLE tag node is specified.
925  * @return The conversion result is returned.
926  */
927 static char *
928 s_xhtml_1_0_end_title_tag(void *pdoc, Node *UNUSED(child)) 
929 {
930   xhtml_t       *xhtml = GET_XHTML(pdoc);
931   Doc           *doc   = xhtml->doc;
932
933   W_L("</title>");
934
935   return xhtml->out;
936 }
937
938
939 /**
940  * It is a handler who processes the BASE tag.
941  *
942  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
943  *                     destination is specified.
944  * @param node   [i]   The BASE tag node is specified.
945  * @return The conversion result is returned.
946  */
947 static char *
948 s_xhtml_1_0_start_base_tag(void *pdoc, Node *node) 
949 {
950   xhtml_t       *xhtml = GET_XHTML(pdoc);
951   Attr          *attr;
952   Doc           *doc   = xhtml->doc;
953
954   W_L("<base");
955   /*--------------------------------------------------------------------------*/
956   /* Get Attributes                                                           */
957   /*--------------------------------------------------------------------------*/
958   for (attr = qs_get_attr(doc,node);
959        attr;
960        attr = qs_get_next_attr(doc,attr)) {
961     char *name = qs_get_attr_name(doc,attr);
962     char *value = qs_get_attr_value(doc,attr);
963     if (STRCASEEQ('h','H',"href",name)) {
964       W_L(" href=\"");
965       W_V(value);
966       W_L("\"");
967       break;
968     }
969   }
970   W_L(" />");
971
972   return xhtml->out;
973 }
974
975
976 /**
977  * It is a handler who processes the BASE tag.
978  *
979  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
980  *                     destination is specified.
981  * @param node   [i]   The BASE tag node is specified.
982  * @return The conversion result is returned.
983  */
984 static char *
985 s_xhtml_1_0_end_base_tag(void *pdoc, Node *UNUSED(child)) 
986 {
987   xhtml_t *xhtml = GET_XHTML(pdoc);
988
989   return xhtml->out;
990 }
991
992
993 /**
994  * It is a handler who processes the BODY tag.
995  *
996  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
997  *                     destination is specified.
998  * @param node   [i]   The BODY tag node is specified.
999  * @return The conversion result is returned.
1000  */
1001 static char *
1002 s_xhtml_1_0_start_body_tag(void *pdoc, Node *node) 
1003 {
1004   xhtml_t     *xhtml = GET_XHTML(pdoc);
1005   Doc         *doc   = xhtml->doc;
1006   Attr        *attr;
1007   char        *attr_bgcolor = NULL;
1008   char        *attr_text    = NULL;
1009   char        *attr_link    = NULL;
1010   char        *attr_style   = NULL;
1011
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('b','B',"bgcolor", name) && value && *value) {
1021       attr_bgcolor = value;
1022     }
1023     else if (STRCASEEQ('t','T',"text",name) && value && *value) {
1024       attr_text = value;
1025     }
1026     else if (STRCASEEQ('l','L',"link", name) && value && *value) {
1027       attr_link = value;
1028     }
1029     else if (STRCASEEQ('a','A',"alink", name)) {
1030       /* ignore */
1031     }
1032     else if (STRCASEEQ('v','V',"vlink",name)) {
1033       /* ignore */
1034     }
1035     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
1036       attr_style = value;
1037     }
1038   }
1039
1040   if (IS_CSS_ON(xhtml->entryp)) {
1041     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
1042     if (style) {
1043       css_property_t *color_prop      = chxj_css_get_property_value(doc, style, "color");
1044       css_property_t *bgcolor_prop    = chxj_css_get_property_value(doc, style, "background-color");
1045       css_property_t *cur;
1046       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
1047         if (cur->value && *cur->value) {
1048           attr_text = apr_pstrdup(doc->pool, cur->value);
1049         }
1050       }
1051       for (cur = bgcolor_prop->next; cur != bgcolor_prop; cur = cur->next) {
1052         if (cur->value && *cur->value) {
1053           attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
1054         }
1055       }
1056     }
1057     if (xhtml->style) {
1058       css_stylesheet_t *pseudos = chxj_find_pseudo_selectors(doc, xhtml->style);
1059       css_selector_t *cur_sel;
1060       for (cur_sel = pseudos->selector_head.next; cur_sel != &pseudos->selector_head; cur_sel = cur_sel->next) {
1061         if (cur_sel->name && strcasecmp(cur_sel->name, "a:link") == 0) {
1062           css_property_t *cur;
1063           for (cur = cur_sel->property_head.next; cur != &cur_sel->property_head; cur = cur->next) {
1064             if (cur->name && strcasecmp(cur->name, "color") == 0) {
1065               attr_link = apr_pstrdup(doc->pool, cur->value);
1066             }
1067           }
1068         }
1069       }
1070     }
1071   }
1072
1073   W_L("<body");
1074   if (attr_bgcolor || attr_text) {
1075     W_L(" style=\"");
1076     if (attr_bgcolor) {
1077       attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
1078       W_L("background-color:");
1079       W_V(attr_bgcolor);
1080       W_L(";");
1081     }
1082     if (attr_text) {
1083       attr_text = chxj_css_rgb_func_to_value(doc->pool, attr_text);
1084       W_L("color:");
1085       W_V(attr_text);
1086       W_L(";");
1087     }
1088     W_L("\"");
1089   }
1090   if (attr_link) {
1091     attr_link = chxj_css_rgb_func_to_value(doc->pool, attr_link);
1092     W_L(" link=\"");
1093     W_V(attr_link);
1094     W_L("\"");
1095   }
1096   W_L(">");
1097
1098   return xhtml->out;
1099 }
1100
1101
1102 /**
1103  * It is a handler who processes the BODY tag.
1104  *
1105  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1106  *                     destination is specified.
1107  * @param node   [i]   The BODY tag node is specified.
1108  * @return The conversion result is returned.
1109  */
1110 static char *
1111 s_xhtml_1_0_end_body_tag(void *pdoc, Node *UNUSED(child)) 
1112 {
1113   xhtml_t       *xhtml = GET_XHTML(pdoc);
1114   Doc           *doc   = xhtml->doc;
1115
1116   W_L("</body>");
1117   if (IS_CSS_ON(xhtml->entryp)) {
1118     chxj_css_pop_prop_list(xhtml->css_prop_stack);
1119   }
1120
1121   return xhtml->out;
1122 }
1123
1124
1125 /**
1126  * It is a handler who processes the A tag.
1127  *
1128  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1129  *                     destination is specified.
1130  * @param node   [i]   The A tag node is specified.
1131  * @return The conversion result is returned.
1132  */
1133 static char *
1134 s_xhtml_1_0_start_a_tag(void *pdoc, Node *node) 
1135 {
1136   xhtml_t     *xhtml = GET_XHTML(pdoc);
1137   Doc         *doc   = xhtml->doc;
1138   request_rec *r     = doc->r;
1139   Attr        *attr;
1140   char        *attr_style = NULL;
1141
1142   W_L("<a");
1143   /*--------------------------------------------------------------------------*/
1144   /* Get Attributes                                                           */
1145   /*--------------------------------------------------------------------------*/
1146   for (attr = qs_get_attr(doc,node);
1147        attr; 
1148        attr = qs_get_next_attr(doc,attr)) {
1149     char* name  = qs_get_attr_name(doc,attr);
1150     char* value = qs_get_attr_value(doc,attr);
1151     if (STRCASEEQ('n','N',"name",name) && value && *value) {
1152       W_L(" id=\"");
1153       W_V(value);
1154       W_L("\"");
1155     }
1156     else if (STRCASEEQ('h','H',"href", name) && value && *value) {
1157       value = chxj_encoding_parameter(r, value, 1);
1158       if (! chxj_starts_with(value, "mailto:") && ! chxj_starts_with(value, "tel:")) {
1159         value = chxj_add_cookie_parameter(r, value, xhtml->cookie);
1160       }
1161       W_L(" href=\"");
1162       W_V(value);
1163       W_L("\"");
1164     }
1165     else if (STRCASEEQ('a','A',"accesskey", name)) {
1166       W_L(" accesskey=\"");
1167       W_V(value);
1168       W_L("\"");
1169     }
1170     else if (STRCASEEQ('c','C',"cti",name)) {
1171       /* ignore */
1172     }
1173     else if (STRCASEEQ('i','I',"ijam", name)) {
1174       /* ignore */
1175     }
1176     else if (STRCASEEQ('u','U',"utn", name)) {
1177       /* ignore */
1178     }
1179     else if (STRCASEEQ('t','T',"telbook",name)) {
1180       /* ignore */
1181     }
1182     else if (STRCASEEQ('k','K',"kana",name)) {
1183       /* ignore */
1184     }
1185     else if (STRCASEEQ('e','E',"email",name)) {
1186       /* ignore */
1187     }
1188     else if (STRCASEEQ('i','I',"ista",name)) {
1189       /* ignore */
1190     }
1191     else if (STRCASEEQ('i','I',"ilet",name)) {
1192       /* ignore */
1193     }
1194     else if (STRCASEEQ('i','I',"iswf",name)) {
1195       /* ignore */
1196     }
1197     else if (STRCASEEQ('i','I',"irst",name)) {
1198       /* ignore */
1199     }
1200     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
1201       attr_style = value;
1202     }
1203   }
1204   W_L(">");
1205
1206   if (IS_CSS_ON(xhtml->entryp)) {
1207     s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
1208   }
1209
1210   return xhtml->out;
1211 }
1212
1213
1214 /**
1215  * It is a handler who processes the A tag.
1216  *
1217  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1218  *                     destination is specified.
1219  * @param node   [i]   The A tag node is specified.
1220  * @return The conversion result is returned.
1221  */
1222 static char *
1223 s_xhtml_1_0_end_a_tag(void *pdoc, Node *UNUSED(child)) 
1224 {
1225   xhtml_t *xhtml = GET_XHTML(pdoc);
1226   Doc     *doc   = xhtml->doc;
1227
1228   W_L("</a>");
1229
1230   if (IS_CSS_ON(xhtml->entryp)) {
1231     chxj_css_pop_prop_list(xhtml->css_prop_stack);
1232   }
1233
1234   return xhtml->out;
1235 }
1236
1237
1238 /**
1239  * It is a handler who processes the BR tag.
1240  *
1241  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1242  *                     destination is specified.
1243  * @param node   [i]   The BR tag node is specified.
1244  * @return The conversion result is returned.
1245  */
1246 static char *
1247 s_xhtml_1_0_start_br_tag(void *pdoc, Node *node) 
1248 {
1249   xhtml_t *xhtml = GET_XHTML(pdoc);
1250   Doc     *doc   = xhtml->doc;
1251   Attr    *attr;
1252
1253   W_L("<br");
1254   /*--------------------------------------------------------------------------*/
1255   /* Get Attributes                                                           */
1256   /*--------------------------------------------------------------------------*/
1257   for (attr = qs_get_attr(doc,node);
1258        attr;
1259        attr = qs_get_next_attr(doc,attr)) {
1260     char *name  = qs_get_attr_name(doc,attr);
1261     char *value = qs_get_attr_value(doc,attr);
1262     if (STRCASEEQ('c','C',"clear",name)) {
1263       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('a','A',"all",value))) {
1264         W_L(" clear=\"");
1265         W_V(value);
1266         W_L("\"");
1267       }
1268     }
1269   }
1270   W_L(" />");
1271
1272   return xhtml->out;
1273 }
1274
1275
1276 /**
1277  * It is a handler who processes the BR tag.
1278  *
1279  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1280  *                     destination is specified.
1281  * @param node   [i]   The BR tag node is specified.
1282  * @return The conversion result is returned.
1283  */
1284 static char *
1285 s_xhtml_1_0_end_br_tag(void *pdoc, Node *UNUSED(child)) 
1286 {
1287   xhtml_t *xhtml = GET_XHTML(pdoc);
1288
1289   return xhtml->out;
1290 }
1291
1292
1293 /**
1294  * It is a handler who processes the TR tag.
1295  *
1296  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1297  *                     destination is specified.
1298  * @param node   [i]   The TR tag node is specified.
1299  * @return The conversion result is returned.
1300  */
1301 static char *
1302 s_xhtml_1_0_start_tr_tag(void *pdoc, Node *UNUSED(node)) 
1303 {
1304   xhtml_t *xhtml = GET_XHTML(pdoc);
1305   Doc     *doc   = xhtml->doc;
1306
1307   W_L("<br />");
1308
1309   return xhtml->out;
1310 }
1311
1312
1313 /**
1314  * It is a handler who processes the TR tag.
1315  *
1316  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1317  *                     destination is specified.
1318  * @param node   [i]   The TR tag node is specified.
1319  * @return The conversion result is returned.
1320  */
1321 static char *
1322 s_xhtml_1_0_end_tr_tag(void *pdoc, Node *UNUSED(child)) 
1323 {
1324   xhtml_t *xhtml = GET_XHTML(pdoc);
1325
1326   return xhtml->out;
1327 }
1328
1329
1330 /**
1331  * It is a handler who processes the FONT tag.
1332  *
1333  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1334  *                     destination is specified.
1335  * @param node   [i]   The FONT tag node is specified.
1336  * @return The conversion result is returned.
1337  */
1338 static char *
1339 s_xhtml_1_0_start_font_tag(void *pdoc, Node *node) 
1340 {
1341   xhtml_t *xhtml = GET_XHTML(pdoc);
1342   Doc     *doc   = xhtml->doc;
1343   Attr    *attr;
1344   char    *attr_color = NULL;
1345   char    *attr_size  = NULL;
1346   char    *attr_style = NULL;
1347
1348   /*--------------------------------------------------------------------------*/
1349   /* Get Attributes                                                           */
1350   /*--------------------------------------------------------------------------*/
1351   for (attr = qs_get_attr(doc,node);
1352        attr;
1353        attr = qs_get_next_attr(doc,attr)) {
1354     char *name  = qs_get_attr_name(doc,attr);
1355     char *value = qs_get_attr_value(doc,attr);
1356     if (STRCASEEQ('c','C',"color",name) && value && *value) {
1357       attr_color = apr_pstrdup(doc->buf.pool, value);
1358     }
1359     else if (STRCASEEQ('s','S',"size",name) && value && *value) {
1360       /*----------------------------------------------------------------------*/
1361       /* CHTML 5.0                                                            */
1362       /*----------------------------------------------------------------------*/
1363       attr_size = apr_pstrdup(doc->buf.pool, value);
1364     }
1365     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
1366       attr_style = apr_pstrdup(doc->buf.pool, value);
1367     }
1368   }
1369   if (IS_CSS_ON(xhtml->entryp)) {
1370     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
1371     if (style) {
1372       css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
1373       css_property_t *size_prop  = chxj_css_get_property_value(doc, style, "font-size");
1374       css_property_t *cur;
1375       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
1376         if (cur->value && *cur->value) {
1377           attr_color = apr_pstrdup(doc->pool, cur->value);
1378         }
1379       }
1380       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
1381         if (cur->value && *cur->value) {
1382           attr_size = apr_pstrdup(doc->pool, cur->value);
1383           if (STRCASEEQ('x','X',"xx-small",attr_size)) {
1384             attr_size = apr_pstrdup(doc->pool, "1");
1385           }
1386           else if (STRCASEEQ('x','X',"x-small",attr_size)) {
1387             attr_size = apr_pstrdup(doc->pool, "2");
1388           }
1389           else if (STRCASEEQ('s','S',"small",attr_size)) {
1390             attr_size = apr_pstrdup(doc->pool, "3");
1391           }
1392           else if (STRCASEEQ('m','M',"medium",attr_size)) {
1393             attr_size = apr_pstrdup(doc->pool, "4");
1394           }
1395           else if (STRCASEEQ('l','L',"large",attr_size)) {
1396             attr_size = apr_pstrdup(doc->pool, "5");
1397           }
1398           else if (STRCASEEQ('x','X',"x-large",attr_size)) {
1399             attr_size = apr_pstrdup(doc->pool, "6");
1400           }
1401           else if (STRCASEEQ('x','X',"xx-large",attr_size)) {
1402             attr_size = apr_pstrdup(doc->pool, "7");
1403           }
1404         }
1405       }
1406     }
1407   }
1408
1409   xhtml_flags_t *flg = (xhtml_flags_t *)apr_palloc(doc->pool, sizeof(*flg));
1410   memset(flg, 0, sizeof(*flg));
1411   if (attr_color) {
1412     W_L("<font color=\"");
1413     W_V(attr_color);
1414     W_L("\">");
1415     flg->font_color_flag = 1;
1416   }
1417   if (attr_size) {
1418     flg->font_size_flag = 1;
1419     switch(*attr_size) {
1420     case '1': W_L("<span style=\"font-size: xx-small\">"); break;
1421     case '2': W_L("<span style=\"font-size: x-small\">");  break;
1422     case '3': W_L("<span style=\"font-size: small\">");    break;
1423     case '4': W_L("<span style=\"font-size: medium\">");   break;
1424     case '5': W_L("<span style=\"font-size: large\">");    break;
1425     case '6': W_L("<span style=\"font-size: x-large\">");  break;
1426     case '7': W_L("<span style=\"font-size: xx-large\">"); break;
1427     case '-':
1428       if (*(attr_size + 1) == '1') {
1429         W_L("<span style=\"font-size: small\">");
1430         break;
1431       }
1432       if (*(attr_size + 1) == '2') {
1433         W_L("<span style=\"font-size: x-small\">");
1434         break;
1435       }
1436       if (*(attr_size + 1) == '3') {
1437         W_L("<span style=\"font-size: xx-small\">");
1438         break;
1439       }
1440       flg->font_size_flag = 0;
1441       break;
1442
1443     case '+':
1444       if (*(attr_size + 1) == '1') {
1445         W_L("<span style=\"font-size: large\">");
1446         break;
1447       }
1448       if (*(attr_size + 1) == '2') {
1449         W_L("<span style=\"font-size: x-large\">");
1450         break;
1451       }
1452       if (*(attr_size + 1) == '3') {
1453         W_L("<span style=\"font-size: xx-large\">");
1454         break;
1455       }
1456       flg->font_size_flag = 0;
1457       break;
1458
1459     default:
1460       WRN(doc->r, "invlalid font size. [%s] != (1|2|3|4|5|6|7|+1|+2|+3|-1|-2|-3)", attr_size);
1461       flg->font_size_flag = 0;
1462     }
1463   }
1464   node->userData = flg;
1465
1466   return xhtml->out;
1467 }
1468
1469
1470 /**
1471  * It is a handler who processes the FONT tag.
1472  *
1473  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1474  *                     destination is specified.
1475  * @param node   [i]   The FONT tag node is specified.
1476  * @return The conversion result is returned.
1477  */
1478 static char *
1479 s_xhtml_1_0_end_font_tag(void *pdoc, Node *node)
1480 {
1481   xhtml_t *xhtml = GET_XHTML(pdoc);
1482   Doc     *doc   = xhtml->doc;
1483
1484   xhtml_flags_t *flg = (xhtml_flags_t *)node->userData;
1485   if (flg && flg->font_size_flag) {
1486     W_L("</span>");
1487   }
1488   if (flg && flg->font_color_flag) {
1489     W_L("</font>");
1490   }
1491   if (IS_CSS_ON(xhtml->entryp)) {
1492     chxj_css_pop_prop_list(xhtml->css_prop_stack);
1493   }
1494   return xhtml->out;
1495 }
1496
1497
1498 /**
1499  * It is a handler who processes the FORM tag.
1500  *
1501  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1502  *                     destination is specified.
1503  * @param node   [i]   The FORM tag node is specified.
1504  * @return The conversion result is returned.
1505  */
1506 static char *
1507 s_xhtml_1_0_start_form_tag(void *pdoc, Node *node) 
1508 {
1509   xhtml_t     *xhtml = GET_XHTML(pdoc);
1510   Doc         *doc   = xhtml->doc;
1511   request_rec *r     = doc->r;
1512   Attr        *attr;
1513   char        *attr_action = NULL;
1514   char        *attr_method = NULL;
1515   char        *attr_style  = NULL;
1516   char        *attr_color  = NULL;
1517   char        *attr_align  = NULL;
1518   char        *attr_name   = NULL;
1519   char        *new_hidden_tag = NULL;
1520
1521   /*--------------------------------------------------------------------------*/
1522   /* Get Attributes                                                           */
1523   /*--------------------------------------------------------------------------*/
1524   for (attr = qs_get_attr(doc,node);
1525        attr;
1526        attr = qs_get_next_attr(doc,attr)) {
1527     char *name  = qs_get_attr_name(doc,attr);
1528     char *value = qs_get_attr_value(doc,attr);
1529     switch(*name) {
1530     case 'a':
1531     case 'A':
1532       if (strcasecmp(name, "action") == 0) {
1533         /*--------------------------------------------------------------------*/
1534         /* CHTML 1.0                                                          */
1535         /*--------------------------------------------------------------------*/
1536         attr_action = value;
1537       }
1538       break;
1539
1540     case 'm':
1541     case 'M':
1542       if (strcasecmp(name, "method") == 0) {
1543         /*--------------------------------------------------------------------*/
1544         /* CHTML 1.0                                                          */
1545         /*--------------------------------------------------------------------*/
1546         attr_method = value;
1547       }
1548       break;
1549
1550     case 'n':
1551     case 'N':
1552       if (strcasecmp(name, "name") == 0) {
1553         /*--------------------------------------------------------------------*/
1554         /* CHTML 1.0                                                          */
1555         /*--------------------------------------------------------------------*/
1556         attr_name = value;
1557       }
1558       break;
1559
1560     case 's':
1561     case 'S':
1562       if (strcasecmp(name, "style") == 0) {
1563         attr_style = value;
1564       }
1565       break;
1566
1567     default:
1568       break;
1569     }
1570   }
1571   if (IS_CSS_ON(xhtml->entryp)) {
1572     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
1573     if (style) {
1574       css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
1575       css_property_t *color_prop      = chxj_css_get_property_value(doc, style, "color");
1576       css_property_t *cur;
1577       for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
1578         if (STRCASEEQ('l','L',"left", cur->value)) {
1579           attr_align = apr_pstrdup(doc->pool, "left");
1580         }
1581         else if (STRCASEEQ('c','C',"center",cur->value)) {
1582           attr_align = apr_pstrdup(doc->pool, "center");
1583         }
1584         else if (STRCASEEQ('r','R',"right",cur->value)) {
1585           attr_align = apr_pstrdup(doc->pool, "right");
1586         }
1587       }
1588       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
1589         attr_color = apr_pstrdup(doc->pool, cur->value);
1590       }
1591     }
1592   }
1593
1594   int post_flag = (attr_method && strcasecmp(attr_method, "post") == 0) ? 1 : 0;
1595
1596   W_L("<form");
1597   if (attr_action) {
1598     attr_action = chxj_encoding_parameter(r, attr_action, 1);
1599     attr_action = chxj_add_cookie_parameter(r, attr_action, xhtml->cookie);
1600     char *q;
1601     char *old_qs = NULL;
1602     q = strchr(attr_action, '?');
1603     if (q) {
1604       new_hidden_tag = chxj_form_action_to_hidden_tag(r, doc->pool, attr_action, 1, post_flag, &old_qs, CHXJ_FALSE, CHXJ_FALSE, xhtml->entryp);
1605       if (new_hidden_tag || old_qs) {
1606         *q = 0;
1607       }
1608     }
1609     W_L(" action=\"");
1610     W_V(attr_action);
1611     if (old_qs) {
1612       W_L("?");
1613       W_V(old_qs);
1614     }
1615     W_L("\"");
1616   }
1617   if (attr_method) {
1618     W_L(" method=\"");
1619     W_V(attr_method);
1620     W_L("\"");
1621   }
1622   if (attr_name) {
1623     W_L(" name=\"");
1624     W_V(attr_name);
1625     W_L("\"");
1626   }
1627   W_L(">");
1628
1629   xhtml_flags_t *flg = (xhtml_flags_t *)apr_palloc(doc->pool, sizeof(xhtml_flags_t));
1630   memset(flg, 0, sizeof(*flg));
1631   if (attr_color) {
1632     attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
1633     W_L("<font color=\"");
1634     W_V(attr_color);
1635     W_L("\">");
1636     flg->with_font_flag = 1;
1637   }
1638   if (attr_align) {
1639     W_L("<div align=\"");
1640     W_V(attr_align);
1641     W_L("\">");
1642     flg->with_div_flag = 1;
1643   }
1644   node->userData = flg;
1645   if (new_hidden_tag) {
1646     W_V(new_hidden_tag);
1647   }
1648   return xhtml->out;
1649 }
1650
1651
1652 /**
1653  * It is a handler who processes the FORM tag.
1654  *
1655  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1656  *                     destination is specified.
1657  * @param node   [i]   The FORM tag node is specified.
1658  * @return The conversion result is returned.
1659  */
1660 static char *
1661 s_xhtml_1_0_end_form_tag(void *pdoc, Node *node)
1662 {
1663   xhtml_t *xhtml = GET_XHTML(pdoc);
1664   Doc     *doc   = xhtml->doc;
1665
1666   xhtml_flags_t *flg = (xhtml_flags_t *)node->userData;
1667   if (flg && flg->with_div_flag) {
1668     W_L("</div>");
1669   }
1670   if (flg && flg->with_font_flag) {
1671     W_L("</font>");
1672   }
1673   W_L("</form>");
1674   if (IS_CSS_ON(xhtml->entryp)) {
1675     chxj_css_pop_prop_list(xhtml->css_prop_stack);
1676   }
1677
1678   return xhtml->out;
1679 }
1680
1681
1682 /**
1683  * It is a handler who processes the INPUT tag.
1684  *
1685  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1686  *                     destination is specified.
1687  * @param node   [i]   The INPUT tag node is specified.
1688  * @return The conversion result is returned.
1689  */
1690 static char *
1691 s_xhtml_1_0_start_input_tag(void *pdoc, Node *node) 
1692 {
1693   xhtml_t     *xhtml       = GET_XHTML(pdoc);
1694   Doc         *doc         = xhtml->doc;
1695   request_rec *r           = doc->r;
1696   Attr        *attr;
1697   char        *attr_max_length  = NULL;
1698   char        *attr_type        = NULL;
1699   char        *attr_name        = NULL;
1700   char        *attr_value       = NULL;
1701   char        *attr_istyle      = NULL;
1702   char        *attr_size        = NULL;
1703   char        *attr_checked     = NULL;
1704   char        *attr_accesskey   = NULL;
1705   char        *attr_style       = NULL;
1706
1707   /*--------------------------------------------------------------------------*/
1708   /* Get Attributes                                                           */
1709   /*--------------------------------------------------------------------------*/
1710   for (attr = qs_get_attr(doc,node);
1711        attr;
1712        attr = qs_get_next_attr(doc,attr)) {
1713     char *name  = qs_get_attr_name(doc,attr);
1714     char *value = qs_get_attr_value(doc,attr);
1715     if (STRCASEEQ('t','T',"type",name) && value && *value) {
1716       char *tmp_type = qs_trim_string(doc->buf.pool, value);
1717       if (tmp_type && (STRCASEEQ('t','T',"text",    tmp_type) ||
1718                        STRCASEEQ('p','P',"password",tmp_type) ||
1719                        STRCASEEQ('c','C',"checkbox",tmp_type) ||
1720                        STRCASEEQ('r','R',"radio",   tmp_type) ||
1721                        STRCASEEQ('h','H',"hidden",  tmp_type) ||
1722                        STRCASEEQ('s','S',"submit",  tmp_type) ||
1723                        STRCASEEQ('r','R',"reset",   tmp_type))) {
1724         attr_type = tmp_type;
1725       }
1726     }
1727     else if (STRCASEEQ('n','N',"name",name) && value && *value) {
1728       attr_name = value;
1729     }
1730     else if (STRCASEEQ('v','V',"value",name) && value && *value) {
1731       attr_value = value;
1732     }
1733     else if (STRCASEEQ('i','I',"istyle",name) && value && *value) {
1734       attr_istyle = value;
1735     }
1736     else if (STRCASEEQ('m','M',"maxlength",name) && value && *value) {
1737       attr_max_length = value;
1738     }
1739     else if (STRCASEEQ('c','C',"checked", name)) {
1740       attr_checked = value;
1741     }
1742     else if (STRCASEEQ('a','A',"accesskey", name) && value && *value) {
1743       attr_accesskey = value;
1744     }
1745     else if (STRCASEEQ('s','S',"size", name) && value && *value) {
1746       attr_size = value;
1747     }
1748     else if (STRCASEEQ('s','S',"style", name) && value && *value) {
1749       attr_style = value;
1750     }
1751   }
1752
1753   if (IS_CSS_ON(xhtml->entryp)) {
1754     css_prop_list_t *style = s_xhtml_1_0_nopush_and_get_now_style(pdoc, node, attr_style);
1755     if (style) {
1756       css_property_t *wap_input_format = chxj_css_get_property_value(doc, style, "-wap-input-format");
1757       css_property_t *cur;
1758       for (cur = wap_input_format->next; cur != wap_input_format; cur = cur->next) {
1759         if (strcasestr(cur->value, "<ja:n>")) {
1760           attr_istyle = "4";
1761         }
1762         else if (strcasestr(cur->value, "<ja:en>")) {
1763           attr_istyle = "3";
1764         }
1765         else if (strcasestr(cur->value, "<ja:hk>")) {
1766           attr_istyle = "2";
1767         }
1768         else if (strcasestr(cur->value, "<ja:h>")) {
1769           attr_istyle = "1";
1770         }
1771       }
1772     }
1773   }
1774   W_L("<input");
1775   if (attr_type) {
1776     attr_type = qs_trim_string(doc->buf.pool, attr_type);
1777     if (attr_type && (STRCASEEQ('t','T',"text",    attr_type) ||
1778                       STRCASEEQ('p','P',"password",attr_type) ||
1779                       STRCASEEQ('c','C',"checkbox",attr_type) ||
1780                       STRCASEEQ('r','R',"radio",   attr_type) ||
1781                       STRCASEEQ('h','H',"hidden",  attr_type) ||
1782                       STRCASEEQ('s','S',"submit",  attr_type) ||
1783                       STRCASEEQ('r','R',"reset",   attr_type))) {
1784       W_L(" type=\"");
1785       W_V(attr_type);
1786       W_L("\"");
1787     }
1788   }
1789   if (attr_size && *attr_size) {
1790     W_L(" size=\"");
1791     W_V(attr_size);
1792     W_L("\"");
1793   }
1794   if (attr_name && *attr_name) {
1795     W_L(" name=\"");
1796     W_V(attr_name);
1797     W_L("\"");
1798   }
1799   if (attr_value && *attr_value) {
1800     W_L(" value=\"");
1801     W_V(chxj_add_slash_to_doublequote(doc->pool, attr_value));
1802     W_L("\"");
1803   }
1804   if (attr_accesskey && *attr_accesskey) {
1805     W_L(" accesskey=\"");
1806     W_V(attr_accesskey);
1807     W_L("\"");
1808   }
1809   if (attr_istyle && *attr_istyle && (*attr_istyle == '1' || *attr_istyle == '2' || *attr_istyle == '3' || *attr_istyle == '4')) {
1810     char *fmt = qs_conv_istyle_to_format(r->pool,attr_istyle);
1811     if (attr_max_length && *attr_max_length) {
1812       int ii;
1813       for (ii=0; (unsigned int)ii<strlen(attr_max_length); ii++) {
1814         if (attr_max_length[ii] < '0' || attr_max_length[ii] > '9') {
1815           attr_max_length = apr_psprintf(r->pool, "0");
1816           break;
1817         }
1818       }
1819
1820       if (strcmp(attr_max_length, "0")) {
1821         char *vv = apr_psprintf(r->pool, " FORMAT=\"%d%s\"", atoi(attr_max_length), fmt);
1822         W_V(vv);
1823       }
1824     }
1825     else {
1826       W_L(" FORMAT=\"");
1827       W_L("*");
1828       W_V(fmt);
1829       W_L("\"");
1830     }
1831   }
1832   else {
1833     if (attr_max_length && *attr_max_length) {
1834       if (chxj_chk_numeric(attr_max_length) != 0) {
1835         attr_max_length = apr_psprintf(r->pool, "0");
1836       }
1837       if (strcmp(attr_max_length, "0")) {
1838         char *vv = apr_psprintf(r->pool, " FORMAT=\"%dm\"", atoi(attr_max_length));
1839         W_V(vv);
1840       }
1841     }
1842   }
1843   /*--------------------------------------------------------------------------*/
1844   /* The figure is default for the password.                                  */
1845   /*--------------------------------------------------------------------------*/
1846   if (attr_type && (attr_istyle == NULL || *attr_istyle == 0) && STRCASEEQ('p','P',"password", attr_type) && ! xhtml->entryp->pc_flag) {
1847     if (attr_max_length) {
1848       W_L(" FORMAT=\"");
1849       W_V(attr_max_length);
1850       W_L("N\"");
1851     }
1852     else {
1853       W_L(" FORMAT=\"*N\"");
1854     }
1855   }
1856   if (attr_checked) {
1857     W_L(" checked=\"checked\"");
1858   }
1859   W_L(" />");
1860 #if 0
1861   W_L("<input");
1862   /*--------------------------------------------------------------------------*/
1863   /* Get Attributes                                                           */
1864   /*--------------------------------------------------------------------------*/
1865   type       = qs_get_type_attr(doc, node, doc->buf.pool);
1866   name       = qs_get_name_attr(doc, node, doc->buf.pool);
1867   value      = qs_get_value_attr(doc,node, doc->buf.pool);
1868   istyle     = qs_get_istyle_attr(doc,node,doc->buf.pool);
1869   max_length = qs_get_maxlength_attr(doc,node,doc->buf.pool);
1870   checked    = qs_get_checked_attr(doc,node, doc->buf.pool);
1871   accesskey  = qs_get_accesskey_attr(doc, node, doc->buf.pool);
1872   size       = qs_get_size_attr(doc, node, doc->buf.pool);
1873
1874   if (type) {
1875     type = qs_trim_string(doc->buf.pool, type);
1876     if (type && (STRCASEEQ('t','T',"text",    type) ||
1877                  STRCASEEQ('p','P',"password",type) ||
1878                  STRCASEEQ('c','C',"checkbox",type) ||
1879                  STRCASEEQ('r','R',"radio",   type) ||
1880                  STRCASEEQ('h','H',"hidden",  type) ||
1881                  STRCASEEQ('s','S',"submit",  type) ||
1882                  STRCASEEQ('r','R',"reset",   type))) {
1883       W_L(" type=\"");
1884       W_V(type);
1885       W_L("\"");
1886     }
1887   }
1888   if (size && *size) {
1889     W_L(" size=\"");
1890     W_V(size);
1891     W_L("\"");
1892   }
1893   if (name && *name) {
1894     W_L(" name=\"");
1895     W_V(name);
1896     W_L("\"");
1897   }
1898   if (value && *value) {
1899     W_L(" value=\"");
1900     W_V(chxj_add_slash_to_doublequote(doc->pool, value));
1901     W_L("\"");
1902   }
1903   if (accesskey && *accesskey) {
1904     W_L(" accesskey=\"");
1905     W_V(accesskey);
1906     W_L("\"");
1907   }
1908   if (istyle && *istyle && (*istyle == '1' || *istyle == '2' || *istyle == '3' || *istyle == '4')) {
1909     char *fmt = qs_conv_istyle_to_format(r->pool,istyle);
1910     if (max_length && *max_length) {
1911       int ii;
1912       for (ii=0; (unsigned int)ii<strlen(max_length); ii++) {
1913         if (max_length[ii] < '0' || max_length[ii] > '9') {
1914           max_length = apr_psprintf(r->pool, "0");
1915           break;
1916         }
1917       }
1918
1919       if (strcmp(max_length, "0")) {
1920         char *vv = apr_psprintf(r->pool, " FORMAT=\"%d%s\"", atoi(max_length), fmt);
1921         W_V(vv);
1922       }
1923     }
1924     else {
1925       W_L(" FORMAT=\"");
1926       W_L("*");
1927       W_V(fmt);
1928       W_L("\"");
1929     }
1930   }
1931   else {
1932     if (max_length && *max_length) {
1933       if (chxj_chk_numeric(max_length) != 0) {
1934         max_length = apr_psprintf(r->pool, "0");
1935       }
1936       if (strcmp(max_length, "0")) {
1937         char *vv = apr_psprintf(r->pool, " FORMAT=\"%dm\"", atoi(max_length));
1938         W_V(vv);
1939       }
1940     }
1941   }
1942   /*--------------------------------------------------------------------------*/
1943   /* The figure is default for the password.                                  */
1944   /*--------------------------------------------------------------------------*/
1945   if (type && (istyle == NULL || *istyle == 0) && STRCASEEQ('p','P',"password", type) && ! xhtml->entryp->pc_flag) {
1946     if (max_length) {
1947       W_L(" FORMAT=\"");
1948       W_V(max_length);
1949       W_L("N\"");
1950     }
1951     else {
1952       W_L(" FORMAT=\"*N\"");
1953     }
1954   }
1955   if (checked) {
1956     W_L(" checked=\"checked\"");
1957   }
1958   W_L(" />");
1959 #endif
1960
1961   return xhtml->out;
1962 }
1963
1964
1965 /**
1966  * It is a handler who processes the INPUT tag.
1967  *
1968  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1969  *                     destination is specified.
1970  * @param node   [i]   The INPUT tag node is specified.
1971  * @return The conversion result is returned.
1972  */
1973 static char *
1974 s_xhtml_1_0_end_input_tag(void *pdoc, Node *UNUSED(child)) 
1975 {
1976   xhtml_t *xhtml = GET_XHTML(pdoc);
1977
1978   return xhtml->out;
1979 }
1980
1981
1982 /**
1983  * It is a handler who processes the CENTER tag.
1984  *
1985  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
1986  *                     destination is specified.
1987  * @param node   [i]   The CENTER tag node is specified.
1988  * @return The conversion result is returned.
1989  */
1990 static char *
1991 s_xhtml_1_0_start_center_tag(void *pdoc, Node *node)
1992 {
1993   xhtml_t *xhtml;
1994   Doc     *doc;
1995   Attr    *attr;
1996   char    *attr_style = NULL;
1997   char    *attr_color = NULL;
1998   char    *attr_size  = NULL;
1999
2000   xhtml = GET_XHTML(pdoc);
2001   doc    = xhtml->doc;
2002
2003   for (attr = qs_get_attr(doc,node);
2004        attr;
2005        attr = qs_get_next_attr(doc,attr)) {
2006     char *name  = qs_get_attr_name(doc,attr);
2007     char *value = qs_get_attr_value(doc,attr);
2008     if (STRCASEEQ('s','S',"style",name) && value && *value) {
2009       attr_style = value;
2010     }
2011   }
2012   if (IS_CSS_ON(xhtml->entryp)) {
2013     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
2014     if (style) {
2015       css_property_t *color_prop      = chxj_css_get_property_value(doc, style, "color");
2016       css_property_t *size_prop       = chxj_css_get_property_value(doc, style, "font-size");
2017       css_property_t *cur;
2018       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
2019         if (cur->value && *cur->value) {
2020           attr_color = apr_pstrdup(doc->pool, cur->value);
2021         }
2022       }
2023       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
2024         if (cur->value && *cur->value) {
2025           attr_size = apr_pstrdup(doc->pool, cur->value);
2026         }
2027       }
2028     }
2029   }
2030
2031   W_L("<center");
2032   if (attr_size || attr_color) {
2033     W_L(" style=\"");
2034     if (attr_size) {
2035       W_L("font-size:");
2036       W_V(attr_size);
2037       W_L(";");
2038     }
2039     if (attr_color) {
2040       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
2041       W_L("color:");
2042       W_V(attr_color);
2043       W_L(";");
2044     }
2045     W_L("\"");
2046   }
2047   W_L(">");
2048   
2049   return xhtml->out;
2050 }
2051
2052
2053 /**
2054  * It is a handler who processes the CENTER tag.
2055  *
2056  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2057  *                     destination is specified.
2058  * @param node   [i]   The CENTER tag node is specified.
2059  * @return The conversion result is returned.
2060  */
2061 static char *
2062 s_xhtml_1_0_end_center_tag(void *pdoc, Node *UNUSED(node))
2063 {
2064   xhtml_t *xhtml = GET_XHTML(pdoc);
2065   Doc     *doc   = xhtml->doc;
2066
2067   W_L("</center>");
2068   if (IS_CSS_ON(xhtml->entryp)) {
2069     chxj_css_pop_prop_list(xhtml->css_prop_stack);
2070   }
2071   return xhtml->out;
2072 }
2073
2074
2075 /**
2076  * It is a handler who processes the HR tag.
2077  *
2078  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2079  *                     destination is specified.
2080  * @param node   [i]   The HR tag node is specified.
2081  * @return The conversion result is returned.
2082  */
2083 static char *
2084 s_xhtml_1_0_start_hr_tag(void *pdoc, Node *node)
2085 {
2086   Attr        *attr;
2087   xhtml_t     *xhtml;
2088   Doc         *doc;
2089   request_rec *r;
2090   char        *attr_align   = NULL;
2091   char        *attr_size    = NULL;
2092   char        *attr_width   = NULL;
2093   char        *attr_noshade = NULL;
2094   char        *attr_style   = NULL;
2095   char        *attr_color   = NULL;
2096
2097   xhtml   = GET_XHTML(pdoc);
2098   doc     = xhtml->doc;
2099   r       = doc->r;
2100
2101   for (attr = qs_get_attr(doc,node);
2102        attr; 
2103        attr = qs_get_next_attr(doc,attr)) {
2104     char *name  = qs_get_attr_name (doc,attr);
2105     char *value = qs_get_attr_value(doc,attr);
2106     switch(*name) {
2107     case 'a':
2108     case 'A':
2109       if (strcasecmp(name, "align") == 0) {
2110         /*--------------------------------------------------------------------*/
2111         /* CHTML 1.0                                                          */
2112         /*--------------------------------------------------------------------*/
2113         if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2114           attr_align = value;
2115         }
2116       }
2117       break;
2118
2119     case 's':
2120     case 'S':
2121       if (strcasecmp(name, "size") == 0) {
2122         /*--------------------------------------------------------------------*/
2123         /* CHTML 1.0                                                          */
2124         /*--------------------------------------------------------------------*/
2125         if (value && *value) {
2126           attr_size = value;
2127         }
2128       }
2129       else if (strcasecmp(name, "style") == 0) {
2130         if (value && *value) {
2131           attr_style = value;
2132         }
2133       }
2134       break;
2135
2136     case 'w':
2137     case 'W':
2138       if (strcasecmp(name, "width") == 0) {
2139         /*--------------------------------------------------------------------*/
2140         /* CHTML 1.0                                                          */
2141         /*--------------------------------------------------------------------*/
2142         if (value && *value) {
2143           attr_width = value;
2144         }
2145       }
2146       break;
2147
2148     case 'n':
2149     case 'N':
2150       if (strcasecmp(name, "noshade") == 0) {
2151         /*--------------------------------------------------------------------*/
2152         /* CHTML 1.0                                                          */
2153         /*--------------------------------------------------------------------*/
2154         attr_noshade = apr_pstrdup(doc->pool, "noshade");
2155       }
2156       break;
2157
2158     case 'c':
2159     case 'C':
2160       if (strcasecmp(name, "color") == 0 && value && *value) {
2161         /*--------------------------------------------------------------------*/
2162         /* CHTML 4.0                                                          */
2163         /*--------------------------------------------------------------------*/
2164         attr_color = value;
2165       }
2166       break;
2167
2168     default:
2169       break;
2170     }
2171   }
2172   if (IS_CSS_ON(xhtml->entryp)) {
2173     css_prop_list_t *style = s_xhtml_1_0_nopush_and_get_now_style(pdoc, node, attr_style);
2174     if (style) {
2175       css_property_t *border_style_prop = chxj_css_get_property_value(doc, style, "border-style");
2176       css_property_t *height_prop       = chxj_css_get_property_value(doc, style, "height");
2177       css_property_t *width_prop        = chxj_css_get_property_value(doc, style, "width");
2178       css_property_t *cur;
2179       for (cur = border_style_prop->next; cur != border_style_prop; cur = cur->next) {
2180         if (STRCASEEQ('s','S',"solid",cur->value)) {
2181           attr_noshade = "noshade";
2182         }
2183       }
2184       for (cur = height_prop->next; cur != height_prop; cur = cur->next) {
2185         char *tmp = apr_pstrdup(doc->pool, cur->value);
2186         char *tmpp = strstr(tmp, "px");
2187         if (tmpp) { 
2188           attr_size = apr_pstrdup(doc->pool, tmp);
2189         }
2190       }
2191       for (cur = width_prop->next; cur != width_prop; cur = cur->next) {
2192         char *tmp = apr_pstrdup(doc->pool, cur->value);
2193         char *tmpp = strstr(tmp, "px");
2194         if (tmpp) {
2195           attr_width = apr_pstrdup(doc->pool, tmp);
2196         }
2197         else {
2198           tmpp = strstr(tmp, "%");
2199           if (tmpp) {
2200             attr_width = apr_pstrdup(doc->pool, tmp);
2201           }
2202         }
2203       }
2204     }
2205   }
2206   W_L("<hr");
2207   if (attr_align) {
2208     W_L(" align=\"");
2209     W_V(attr_align);
2210     W_L("\"");
2211   }
2212   if (attr_size || attr_width || attr_noshade) {
2213     W_L(" style=\"");
2214     if (attr_size) {
2215       W_L("height:");
2216       W_V(attr_size);
2217       if (!strstr(attr_size, "px")) {
2218         W_L("px");
2219       }
2220       W_L(";");
2221     }
2222     if (attr_width) {
2223       W_L("width:");
2224       W_V(attr_width);
2225       if (!strstr(attr_width, "px") && !strstr(attr_width, "%")) {
2226         W_L("px");
2227       }
2228       W_L(";");
2229     }
2230     if (attr_noshade) {
2231       W_L("border-style:solid;");
2232     }
2233     W_L("\"");
2234   }
2235   if (attr_color) {
2236     W_L(" color=\"");
2237     W_V(attr_color);
2238     W_L("\"");
2239   }
2240   W_L(" />");
2241
2242   return xhtml->out;
2243 }
2244
2245
2246 /**
2247  * It is a handler who processes the HR tag.
2248  *
2249  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2250  *                     destination is specified.
2251  * @param node   [i]   The HR tag node is specified.
2252  * @return The conversion result is returned.
2253  */
2254 static char *
2255 s_xhtml_1_0_end_hr_tag(void *pdoc, Node *UNUSED(child)) 
2256 {
2257   xhtml_t *xhtml = GET_XHTML(pdoc);
2258
2259   return xhtml->out;
2260 }
2261
2262
2263 /**
2264  * It is a handler who processes the PRE tag.
2265  *
2266  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2267  *                     destination is specified.
2268  * @param node   [i]   The PRE tag node is specified.
2269  * @return The conversion result is returned.
2270  */
2271 static char *
2272 s_xhtml_1_0_start_pre_tag(void *pdoc, Node *node)
2273 {
2274   xhtml_t *xhtml = GET_XHTML(pdoc);
2275   Doc     *doc   = xhtml->doc;
2276   Attr    *attr;
2277   char    *attr_style = NULL;
2278
2279   for (attr = qs_get_attr(doc,node);
2280        attr;
2281        attr = qs_get_next_attr(doc,attr)) {
2282     char *nm  = qs_get_attr_name(doc,attr);
2283     char *val = qs_get_attr_value(doc,attr);
2284     if (val && STRCASEEQ('s','S',"style", nm)) {
2285       attr_style = val;
2286     }
2287   }
2288
2289   if (IS_CSS_ON(xhtml->entryp)) {
2290     s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
2291   }
2292
2293   xhtml->pre_flag++;
2294   W_L("<pre>");
2295   return xhtml->out;
2296 }
2297
2298
2299 /**
2300  * It is a handler who processes the PRE tag.
2301  *
2302  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2303  *                     destination is specified.
2304  * @param node   [i]   The PRE tag node is specified.
2305  * @return The conversion result is returned.
2306  */
2307 static char *
2308 s_xhtml_1_0_end_pre_tag(void *pdoc, Node *UNUSED(child)) 
2309 {
2310   xhtml_t *xhtml = GET_XHTML(pdoc);
2311   Doc     *doc   = xhtml->doc;
2312
2313   W_L("</pre>");
2314   xhtml->pre_flag--;
2315   if (IS_CSS_ON(xhtml->entryp)) {
2316     chxj_css_pop_prop_list(xhtml->css_prop_stack);
2317   }
2318
2319   return xhtml->out;
2320 }
2321
2322
2323 /**
2324  * It is a handler who processes the P tag.
2325  *
2326  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2327  *                     destination is specified.
2328  * @param node   [i]   The P tag node is specified.
2329  * @return The conversion result is returned.
2330  */
2331 static char *
2332 s_xhtml_1_0_start_p_tag(void *pdoc, Node *node) 
2333 {
2334   xhtml_t *xhtml = GET_XHTML(pdoc);
2335   Doc     *doc   = xhtml->doc;
2336   Attr    *attr;
2337   char    *attr_align = NULL;
2338   char    *attr_style = NULL;
2339   char    *attr_color = NULL;
2340   char    *attr_blink = NULL;
2341
2342   for (attr = qs_get_attr(doc,node);
2343        attr;
2344        attr = qs_get_next_attr(doc,attr)) {
2345     char *nm  = qs_get_attr_name(doc,attr);
2346     char *val = qs_get_attr_value(doc,attr);
2347     if (STRCASEEQ('a','A',"align", nm)) {
2348       /*----------------------------------------------------------------------*/
2349       /* CHTML 1.0 (W3C version 3.2)                                          */
2350       /*----------------------------------------------------------------------*/
2351       if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2352         attr_align = apr_pstrdup(doc->buf.pool, val);
2353         break;
2354       }
2355     }
2356     else if (STRCASEEQ('s','S',"style", nm) && val && *val) {
2357       attr_style = apr_pstrdup(doc->buf.pool, val);
2358     }
2359   }
2360   if (IS_CSS_ON(xhtml->entryp)) {
2361     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
2362     if (style) {
2363       css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
2364       css_property_t *color_prop      = chxj_css_get_property_value(doc, style, "color");
2365       css_property_t *text_deco_prop  = chxj_css_get_property_value(doc, style, "text-decoration");
2366       css_property_t *cur;
2367       for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
2368         if (STRCASEEQ('l','L',"left",cur->value)) {
2369           attr_align = apr_pstrdup(doc->pool, "left");
2370         }
2371         else if (STRCASEEQ('c','C',"center",cur->value)) {
2372           attr_align = apr_pstrdup(doc->pool, "center");
2373         }
2374         else if (STRCASEEQ('r','R',"right",cur->value)) {
2375           attr_align = apr_pstrdup(doc->pool, "right");
2376         }
2377       }
2378       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
2379         if (cur->value && *cur->value) {
2380           attr_color = apr_pstrdup(doc->pool, cur->value);
2381         }
2382       }
2383       for (cur = text_deco_prop->next; cur != text_deco_prop; cur = cur->next) {
2384         if (cur->value && *cur->value && STRCASEEQ('b','B',"blink",cur->value)) {
2385           attr_blink = apr_pstrdup(doc->pool, cur->value);
2386         }
2387       }
2388     }
2389   }
2390   W_L("<p");
2391   if ((attr_align && *attr_align) || (attr_color && *attr_color) || (attr_blink && *attr_blink)) {
2392     W_L(" style=\"");
2393     if (attr_align) {
2394       W_L("text-align:");
2395       W_V(attr_align);
2396       W_L(";");
2397     }
2398     if (attr_color) {
2399       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
2400       W_L("color:");
2401       W_V(attr_color);
2402       W_L(";");
2403     }
2404     if (attr_blink) {
2405       W_L("text-decoration:");
2406       W_V(attr_blink);
2407       W_L(";");
2408     }
2409     W_L("\"");
2410   }
2411   W_L(">");
2412   return xhtml->out;
2413 }
2414
2415
2416 /**
2417  * It is a handler who processes the P tag.
2418  *
2419  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2420  *                     destination is specified.
2421  * @param node   [i]   The P tag node is specified.
2422  * @return The conversion result is returned.
2423  */
2424 static char *
2425 s_xhtml_1_0_end_p_tag(void *pdoc, Node *UNUSED(child)) 
2426 {
2427   xhtml_t *xhtml = GET_XHTML(pdoc);
2428   Doc     *doc   = xhtml->doc;
2429
2430   W_L("</p>");
2431   if (IS_CSS_ON(xhtml->entryp)) {
2432     chxj_css_pop_prop_list(xhtml->css_prop_stack);
2433   }
2434   return xhtml->out;
2435 }
2436
2437
2438 /**
2439  * It is a handler who processes the UL tag.
2440  *
2441  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2442  *                     destination is specified.
2443  * @param node   [i]   The UL tag node is specified.
2444  * @return The conversion result is returned.
2445  */
2446 static char *
2447 s_xhtml_1_0_start_ul_tag(void *pdoc, Node *node)
2448 {
2449   xhtml_t *xhtml = GET_XHTML(pdoc);
2450   Doc     *doc   = xhtml->doc;
2451   Attr    *attr;
2452   char        *attr_type = NULL;
2453   char        *attr_style = NULL;
2454   /*--------------------------------------------------------------------------*/
2455   /* Get Attributes                                                           */
2456   /*--------------------------------------------------------------------------*/
2457   for (attr = qs_get_attr(doc,node);
2458        attr;
2459        attr = qs_get_next_attr(doc,attr)) {
2460     char *name   = qs_get_attr_name(doc,attr);
2461     char *value  = qs_get_attr_value(doc,attr);
2462     if (STRCASEEQ('t','T',"type",name)) {
2463       if (value && (STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
2464         attr_type = value;
2465       }
2466     }
2467     else if (value && *value && STRCASEEQ('s','S',"style", name)) {
2468       attr_style = value;
2469     }
2470   }
2471   if (IS_CSS_ON(xhtml->entryp)) {
2472     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
2473     if (style) {
2474       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
2475       css_property_t *cur;
2476       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
2477         if (STRCASEEQ('d','D',"disc",cur->value)) {
2478           attr_type = apr_pstrdup(doc->pool, "disc");
2479         }
2480         else if (STRCASEEQ('c','C',"circle",cur->value)) {
2481           attr_type = apr_pstrdup(doc->pool, "circle");
2482         }
2483         else if (STRCASEEQ('s','S',"square",cur->value)) {
2484           attr_type = apr_pstrdup(doc->pool, "square");
2485         }
2486       }
2487     }
2488   }
2489   W_L("<ul");
2490   if (attr_type) {
2491     W_L(" style=\"");
2492     W_L("list-style-type:");
2493     W_V(attr_type);
2494     W_L(";");
2495     W_L("\"");
2496   }
2497   W_L(">");
2498   return xhtml->out;
2499 }
2500
2501
2502 /**
2503  * It is a handler who processes the UL tag.
2504  *
2505  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2506  *                     destination is specified.
2507  * @param node   [i]   The UL tag node is specified.
2508  * @return The conversion result is returned.
2509  */
2510 static char *
2511 s_xhtml_1_0_end_ul_tag(void *pdoc, Node *UNUSED(child)) 
2512 {
2513   xhtml_t *xhtml = GET_XHTML(pdoc);
2514   Doc     *doc   = xhtml->doc;
2515
2516   W_L("</ul>");
2517   if (IS_CSS_ON(xhtml->entryp)) {
2518     chxj_css_pop_prop_list(xhtml->css_prop_stack);
2519   }
2520   return xhtml->out;
2521 }
2522
2523
2524 /**
2525  * It is a handler who processes the H1 tag.
2526  *
2527  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2528  *                     destination is specified.
2529  * @param node   [i]   The H1 tag node is specified.
2530  * @return The conversion result is returned.
2531  */
2532 static char *
2533 s_xhtml_1_0_start_h1_tag(void *pdoc, Node *node) 
2534 {
2535   xhtml_t *xhtml = GET_XHTML(pdoc);
2536   Doc     *doc   = xhtml->doc;
2537   Attr    *attr;
2538   char    *attr_style = NULL;
2539   char    *attr_align = NULL;
2540
2541   for (attr = qs_get_attr(doc,node);
2542        attr;
2543        attr = qs_get_next_attr(doc,attr)) {
2544     char *name  = qs_get_attr_name(doc,attr);
2545     char *value = qs_get_attr_value(doc,attr);
2546     if (STRCASEEQ('a','A',"align", name)) {
2547       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2548         attr_align = value;
2549       }
2550     }
2551     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
2552       attr_style = value;
2553     }
2554   }
2555   if (IS_CSS_ON(xhtml->entryp)) {
2556     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
2557     if (style) {
2558       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
2559       css_property_t *cur;
2560       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
2561         if (STRCASEEQ('l','L',"left", cur->value)) {
2562           attr_align = apr_pstrdup(doc->pool, "left");
2563         }
2564         else if (STRCASEEQ('c','C',"center",cur->value)) {
2565           attr_align = apr_pstrdup(doc->pool, "center");
2566         }
2567         else if (STRCASEEQ('r','R',"right",cur->value)) {
2568           attr_align = apr_pstrdup(doc->pool, "right");
2569         }
2570       }
2571     }
2572   }
2573   W_L("<h1");
2574   if (attr_align) {
2575     W_L(" style=\"");
2576     W_L("text-align:");
2577     W_V(attr_align);
2578     W_L(";");
2579     W_L("\"");
2580   }
2581   W_L(">");
2582
2583   return xhtml->out;
2584 }
2585
2586
2587 /**
2588  * It is a handler who processes the H1 tag.
2589  *
2590  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2591  *                     destination is specified.
2592  * @param node   [i]   The H1 tag node is specified.
2593  * @return The conversion result is returned.
2594  */
2595 static char *
2596 s_xhtml_1_0_end_h1_tag(void *pdoc, Node *UNUSED(child)) 
2597 {
2598   xhtml_t *xhtml = GET_XHTML(pdoc);
2599   Doc     *doc   = xhtml->doc;
2600
2601   W_L("</h1>");
2602   if (IS_CSS_ON(xhtml->entryp)) {
2603     chxj_css_pop_prop_list(xhtml->css_prop_stack);
2604   }
2605   return xhtml->out;
2606 }
2607
2608
2609 /**
2610  * It is a handler who processes the H2 tag.
2611  *
2612  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2613  *                     destination is specified.
2614  * @param node   [i]   The H2 tag node is specified.
2615  * @return The conversion result is returned.
2616  */
2617 static char *
2618 s_xhtml_1_0_start_h2_tag(void *pdoc, Node *node)
2619 {
2620   xhtml_t *xhtml = GET_XHTML(pdoc);
2621   Doc     *doc = xhtml->doc;
2622   Attr    *attr;
2623   char    *attr_style = NULL;
2624   char    *attr_align = NULL;
2625
2626   for (attr = qs_get_attr(doc,node);
2627        attr;
2628        attr = qs_get_next_attr(doc,attr)) {
2629     char *name  = qs_get_attr_name(doc,attr);
2630     char *value = qs_get_attr_value(doc,attr);
2631     if (STRCASEEQ('a','A',"align", name)) {
2632       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2633         attr_align = value;
2634       }
2635     }
2636     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
2637       attr_style = value;
2638     }
2639   }
2640   if (IS_CSS_ON(xhtml->entryp)) {
2641     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
2642     if (style) {
2643       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
2644       css_property_t *cur;
2645       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
2646         if (STRCASEEQ('l','L',"left", cur->value)) {
2647           attr_align = apr_pstrdup(doc->pool, "left");
2648         }
2649         else if (STRCASEEQ('c','C',"center",cur->value)) {
2650           attr_align = apr_pstrdup(doc->pool, "center");
2651         }
2652         else if (STRCASEEQ('r','R',"right",cur->value)) {
2653           attr_align = apr_pstrdup(doc->pool, "right");
2654         }
2655       }
2656     }
2657   }
2658   W_L("<h2");
2659   if (attr_align) {
2660     W_L(" style=\"");
2661     W_L("text-align:");
2662     W_V(attr_align);
2663     W_L(";");
2664     W_L("\"");
2665   }
2666   W_L(">");
2667
2668   return xhtml->out;
2669 }
2670
2671
2672 /**
2673  * It is a handler who processes the H2 tag.
2674  *
2675  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2676  *                     destination is specified.
2677  * @param node   [i]   The H2 tag node is specified.
2678  * @return The conversion result is returned.
2679  */
2680 static char *
2681 s_xhtml_1_0_end_h2_tag(void *pdoc, Node *UNUSED(child)) 
2682 {
2683   xhtml_t *xhtml = GET_XHTML(pdoc);
2684   Doc     *doc   = xhtml->doc;
2685
2686   W_L("</h2>");
2687   if (IS_CSS_ON(xhtml->entryp)) {
2688     chxj_css_pop_prop_list(xhtml->css_prop_stack);
2689   }
2690   return xhtml->out;
2691 }
2692
2693
2694 /**
2695  * It is a handler who processes the H3 tag.
2696  *
2697  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2698  *                     destination is specified.
2699  * @param node   [i]   The H3 tag node is specified.
2700  * @return The conversion result is returned.
2701  */
2702 static char *
2703 s_xhtml_1_0_start_h3_tag(void *pdoc, Node *node)
2704 {
2705   xhtml_t *xhtml = GET_XHTML(pdoc);
2706   Doc     *doc = xhtml->doc;
2707   Attr    *attr;
2708   char    *attr_style = NULL;
2709   char    *attr_align = NULL;
2710
2711   for (attr = qs_get_attr(doc,node);
2712        attr;
2713        attr = qs_get_next_attr(doc,attr)) {
2714     char *name  = qs_get_attr_name(doc,attr);
2715     char *value = qs_get_attr_value(doc,attr);
2716     if (STRCASEEQ('a','A',"align", name)) {
2717       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2718         attr_align = value;
2719       }
2720     }
2721     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
2722       attr_style = value;
2723     }
2724   }
2725   if (IS_CSS_ON(xhtml->entryp)) {
2726     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
2727     if (style) {
2728       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
2729       css_property_t *cur;
2730       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
2731         if (STRCASEEQ('l','L',"left", cur->value)) {
2732           attr_align = apr_pstrdup(doc->pool, "left");
2733         }
2734         else if (STRCASEEQ('c','C',"center",cur->value)) {
2735           attr_align = apr_pstrdup(doc->pool, "center");
2736         }
2737         else if (STRCASEEQ('r','R',"right",cur->value)) {
2738           attr_align = apr_pstrdup(doc->pool, "right");
2739         }
2740       }
2741     }
2742   }
2743   W_L("<h3");
2744   if (attr_align) {
2745     W_L(" style=\"");
2746     W_L("text-align:");
2747     W_V(attr_align);
2748     W_L(";");
2749     W_L("\"");
2750   }
2751   W_L(">");
2752
2753   return xhtml->out;
2754 }
2755
2756
2757 /**
2758  * It is a handler who processes the H3 tag.
2759  *
2760  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2761  *                     destination is specified.
2762  * @param node   [i]   The H3 tag node is specified.
2763  * @return The conversion result is returned.
2764  */
2765 static char *
2766 s_xhtml_1_0_end_h3_tag(void *pdoc, Node *UNUSED(child)) 
2767 {
2768   xhtml_t *xhtml = GET_XHTML(pdoc);
2769   Doc     *doc   = xhtml->doc;
2770
2771   W_L("</h3>");
2772   if (IS_CSS_ON(xhtml->entryp)) {
2773     chxj_css_pop_prop_list(xhtml->css_prop_stack);
2774   }
2775
2776   return xhtml->out;
2777 }
2778
2779
2780 /**
2781  * It is a handler who processes the H4 tag.
2782  *
2783  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2784  *                     destination is specified.
2785  * @param node   [i]   The H4 tag node is specified.
2786  * @return The conversion result is returned.
2787  */
2788 static char *
2789 s_xhtml_1_0_start_h4_tag(void *pdoc, Node *node)
2790 {
2791   xhtml_t *xhtml = GET_XHTML(pdoc);
2792   Doc     *doc = xhtml->doc;
2793   Attr    *attr;
2794   char    *attr_style = NULL;
2795   char    *attr_align = NULL;
2796
2797   for (attr = qs_get_attr(doc,node);
2798        attr;
2799        attr = qs_get_next_attr(doc,attr)) {
2800     char *name  = qs_get_attr_name(doc,attr);
2801     char *value = qs_get_attr_value(doc,attr);
2802     if (STRCASEEQ('a','A',"align", name)) {
2803       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2804         attr_align = value;
2805       }
2806     }
2807     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
2808       attr_style = value;
2809     }
2810   }
2811   if (IS_CSS_ON(xhtml->entryp)) {
2812     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
2813     if (style) {
2814       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
2815       css_property_t *cur;
2816       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
2817         if (STRCASEEQ('l','L',"left", cur->value)) {
2818           attr_align = apr_pstrdup(doc->pool, "left");
2819         }
2820         else if (STRCASEEQ('c','C',"center",cur->value)) {
2821           attr_align = apr_pstrdup(doc->pool, "center");
2822         }
2823         else if (STRCASEEQ('r','R',"right",cur->value)) {
2824           attr_align = apr_pstrdup(doc->pool, "right");
2825         }
2826       }
2827     }
2828   }
2829   W_L("<h4");
2830   if (attr_align) {
2831     W_L(" style=\"");
2832     W_L("text-align:");
2833     W_V(attr_align);
2834     W_L(";");
2835     W_L("\"");
2836   }
2837   W_L(">");
2838
2839   return xhtml->out;
2840 }
2841
2842
2843 /**
2844  * It is a handler who processes the H4 tag.
2845  *
2846  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2847  *                     destination is specified.
2848  * @param node   [i]   The H4 tag node is specified.
2849  * @return The conversion result is returned.
2850  */
2851 static char *
2852 s_xhtml_1_0_end_h4_tag(void *pdoc, Node *UNUSED(child)) 
2853 {
2854   xhtml_t *xhtml = GET_XHTML(pdoc);
2855   Doc     *doc   = xhtml->doc;
2856
2857   W_L("</h4>");
2858   if (IS_CSS_ON(xhtml->entryp)) {
2859     chxj_css_pop_prop_list(xhtml->css_prop_stack);
2860   }
2861
2862   return xhtml->out;
2863 }
2864
2865
2866 /**
2867  * It is a handler who processes the H5 tag.
2868  *
2869  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2870  *                     destination is specified.
2871  * @param node   [i]   The H5 tag node is specified.
2872  * @return The conversion result is returned.
2873  */
2874 static char *
2875 s_xhtml_1_0_start_h5_tag(void *pdoc, Node *node)
2876 {
2877   xhtml_t *xhtml = GET_XHTML(pdoc);
2878   Doc     *doc = xhtml->doc;
2879   Attr    *attr;
2880   char    *attr_style = NULL;
2881   char    *attr_align = NULL;
2882
2883   for (attr = qs_get_attr(doc,node);
2884        attr;
2885        attr = qs_get_next_attr(doc,attr)) {
2886     char *name  = qs_get_attr_name(doc,attr);
2887     char *value = qs_get_attr_value(doc,attr);
2888     if (STRCASEEQ('a','A',"align", name)) {
2889       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2890         attr_align = value;
2891       }
2892     }
2893     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
2894       attr_style = value;
2895     }
2896   }
2897   if (IS_CSS_ON(xhtml->entryp)) {
2898     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
2899     if (style) {
2900       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
2901       css_property_t *cur;
2902       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
2903         if (STRCASEEQ('l','L',"left", cur->value)) {
2904           attr_align = apr_pstrdup(doc->pool, "left");
2905         }
2906         else if (STRCASEEQ('c','C',"center",cur->value)) {
2907           attr_align = apr_pstrdup(doc->pool, "center");
2908         }
2909         else if (STRCASEEQ('r','R',"right",cur->value)) {
2910           attr_align = apr_pstrdup(doc->pool, "right");
2911         }
2912       }
2913     }
2914   }
2915   W_L("<h5");
2916   if (attr_align) {
2917     W_L(" style=\"");
2918     W_L("text-align:");
2919     W_V(attr_align);
2920     W_L(";");
2921     W_L("\"");
2922   }
2923   W_L(">");
2924
2925   return xhtml->out;
2926 }
2927
2928
2929 /**
2930  * It is a handler who processes the H5 tag.
2931  *
2932  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2933  *                     destination is specified.
2934  * @param node   [i]   The H5 tag node is specified.
2935  * @return The conversion result is returned.
2936  */
2937 static char *
2938 s_xhtml_1_0_end_h5_tag(void *pdoc, Node *UNUSED(child)) 
2939 {
2940   xhtml_t *xhtml = GET_XHTML(pdoc);
2941   Doc     *doc   = xhtml->doc;
2942
2943   W_L("</h5>");
2944   if (IS_CSS_ON(xhtml->entryp)) {
2945     chxj_css_pop_prop_list(xhtml->css_prop_stack);
2946   }
2947
2948   return xhtml->out;
2949 }
2950
2951
2952 /**
2953  * It is a handler who processes the H6 tag.
2954  *
2955  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
2956  *                     destination is specified.
2957  * @param node   [i]   The H6 tag node is specified.
2958  * @return The conversion result is returned.
2959  */
2960 static char *
2961 s_xhtml_1_0_start_h6_tag(void *pdoc, Node *node)
2962 {
2963   xhtml_t *xhtml = GET_XHTML(pdoc);
2964   Doc     *doc = xhtml->doc;
2965   Attr    *attr;
2966   char    *attr_style = NULL;
2967   char    *attr_align = NULL;
2968
2969   for (attr = qs_get_attr(doc,node);
2970        attr;
2971        attr = qs_get_next_attr(doc,attr)) {
2972     char *name  = qs_get_attr_name(doc,attr);
2973     char *value = qs_get_attr_value(doc,attr);
2974     if (STRCASEEQ('a','A',"align", name)) {
2975       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2976         attr_align = value;
2977       }
2978     }
2979     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
2980       attr_style = value;
2981     }
2982   }
2983   if (IS_CSS_ON(xhtml->entryp)) {
2984     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
2985     if (style) {
2986       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
2987       css_property_t *cur;
2988       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
2989         if (STRCASEEQ('l','L',"left", cur->value)) {
2990           attr_align = apr_pstrdup(doc->pool, "left");
2991         }
2992         else if (STRCASEEQ('c','C',"center",cur->value)) {
2993           attr_align = apr_pstrdup(doc->pool, "center");
2994         }
2995         else if (STRCASEEQ('r','R',"right",cur->value)) {
2996           attr_align = apr_pstrdup(doc->pool, "right");
2997         }
2998       }
2999     }
3000   }
3001   W_L("<h6");
3002   if (attr_align) {
3003     W_L(" style=\"");
3004     W_L("text-align:");
3005     W_V(attr_align);
3006     W_L(";");
3007     W_L("\"");
3008   }
3009   W_L(">");
3010
3011   return xhtml->out;
3012 }
3013
3014
3015 /**
3016  * It is a handler who processes the H6 tag.
3017  *
3018  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3019  *                     destination is specified.
3020  * @param node   [i]   The H6 tag node is specified.
3021  * @return The conversion result is returned.
3022  */
3023 static char *
3024 s_xhtml_1_0_end_h6_tag(void *pdoc, Node *UNUSED(child)) 
3025 {
3026   xhtml_t *xhtml = GET_XHTML(pdoc);
3027   Doc     *doc   = xhtml->doc;
3028
3029   W_L("</h6>");
3030   if (IS_CSS_ON(xhtml->entryp)) {
3031     chxj_css_pop_prop_list(xhtml->css_prop_stack);
3032   }
3033
3034   return xhtml->out;
3035 }
3036
3037
3038 /**
3039  * It is a handler who processes the OL tag.
3040  *
3041  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3042  *                     destination is specified.
3043  * @param node   [i]   The OL tag node is specified.
3044  * @return The conversion result is returned.
3045  */
3046 static char *
3047 s_xhtml_1_0_start_ol_tag(void *pdoc, Node *node)
3048 {
3049   xhtml_t *xhtml = GET_XHTML(pdoc);
3050   Doc     *doc   = xhtml->doc;
3051   Attr    *attr;
3052   char    *attr_style = NULL;
3053   char    *attr_start = NULL;
3054   char    *attr_type  = NULL;
3055
3056   /*--------------------------------------------------------------------------*/
3057   /* Get Attributes                                                           */
3058   /*--------------------------------------------------------------------------*/
3059   for (attr = qs_get_attr(doc,node);
3060        attr;
3061        attr = qs_get_next_attr(doc,attr)) {
3062     char *name = qs_get_attr_name(doc,attr);
3063     char *value = qs_get_attr_value(doc,attr);
3064     if (STRCASEEQ('t','T',"type",name) && value) {
3065       if (*value == '1') {
3066         attr_type = apr_pstrdup(doc->pool, "decimal");
3067       }
3068       else if (*value == 'a') {
3069         attr_type = apr_pstrdup(doc->pool, "lower-alpha");
3070       }
3071       else if (*value == 'A') {
3072         attr_type = apr_pstrdup(doc->pool, "upper-alpha");
3073       }
3074     }
3075     else if (STRCASEEQ('s','S',"start",name) && value && *value) {
3076       attr_start = value;
3077     }
3078     else if (STRCASEEQ('s','S',"style", name) && value && *value) {
3079       attr_style = value;
3080     }
3081   }
3082   if (IS_CSS_ON(xhtml->entryp)) {
3083     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
3084     if (style) {
3085       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
3086       css_property_t *cur;
3087       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3088         if (STRCASEEQ('d','D',"decimal", cur->value)) {
3089           attr_type = apr_pstrdup(doc->pool, "decimal");
3090         }
3091         else if (STRCASEEQ('u','U',"upper-alpha", cur->value)) {
3092           attr_type = apr_pstrdup(doc->pool, "upper-alpha");
3093         }
3094         else if (STRCASEEQ('l','L',"lower-alpha", cur->value)) {
3095           attr_type = apr_pstrdup(doc->pool, "lower-alpha");
3096         }
3097       }
3098     }
3099   }
3100   W_L("<ol");
3101   if (attr_type) {
3102     W_L(" style=\"");
3103     W_L("list-style-type:");
3104     W_V(attr_type);
3105     W_L(";");
3106     W_L("\"");
3107   }
3108   if (attr_start) {
3109     W_L(" start=\"");
3110     W_V(attr_start);
3111     W_L("\"");
3112   }
3113   W_L(">");
3114
3115   return xhtml->out;
3116 }
3117
3118
3119 /**
3120  * It is a handler who processes the OL tag.
3121  *
3122  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3123  *                     destination is specified.
3124  * @param node   [i]   The OL tag node is specified.
3125  * @return The conversion result is returned.
3126  */
3127 static char *
3128 s_xhtml_1_0_end_ol_tag(void *pdoc, Node *UNUSED(child)) 
3129 {
3130   xhtml_t *xhtml = GET_XHTML(pdoc);
3131   Doc     *doc   = xhtml->doc;
3132
3133   W_L("</ol>");
3134   if (IS_CSS_ON(xhtml->entryp)) {
3135     chxj_css_pop_prop_list(xhtml->css_prop_stack);
3136   }
3137
3138   return xhtml->out;
3139 }
3140
3141
3142 /**
3143  * It is a handler who processes the LI tag.
3144  *
3145  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3146  *                     destination is specified.
3147  * @param node   [i]   The LI tag node is specified.
3148  * @return The conversion result is returned.
3149  */
3150 static char *
3151 s_xhtml_1_0_start_li_tag(void *pdoc, Node *node)
3152 {
3153   xhtml_t *xhtml = GET_XHTML(pdoc);
3154   Doc     *doc   = xhtml->doc;
3155   Attr    *attr;
3156   char    *attr_type  = NULL;
3157   char    *attr_value = NULL;
3158   char    *attr_style = NULL;
3159
3160   for (attr = qs_get_attr(doc,node);
3161        attr;
3162        attr = qs_get_next_attr(doc,attr)) {
3163     char *name  = qs_get_attr_name(doc,attr);
3164     char *value = qs_get_attr_value(doc,attr);
3165     if (STRCASEEQ('t','T',"type",name)) {
3166       if (value && (*value == '1' || *value == 'a' || *value == 'A' || STRCASEEQ('d','D',"disc",value) || STRCASEEQ('s','S',"square",value) || STRCASEEQ('c','C',"circle",value))) {
3167         if (*value == '1') {
3168           attr_type = apr_pstrdup(doc->pool, "decimal");
3169         }
3170         else if (*value == 'a') {
3171           attr_type = apr_pstrdup(doc->pool, "lower-alpha");
3172         }
3173         else if (*value == 'A') {
3174           attr_type = apr_pstrdup(doc->pool, "upper-alpha");
3175         }
3176         else {
3177           attr_type = value;
3178         }
3179       }
3180     }
3181     else if (STRCASEEQ('v','V',"value", name) && value && *value) {
3182       attr_value = value;
3183     }
3184     else if (STRCASEEQ('s','S',"style", name) && value && *value) {
3185       attr_style = value;
3186     }
3187   }
3188   if (IS_CSS_ON(xhtml->entryp)) {
3189     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
3190     if (style) {
3191       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
3192       css_property_t *cur;
3193       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3194         if (STRCASEEQ('d','D',"decimal", cur->value)) {
3195           attr_type = apr_pstrdup(doc->pool, "decimal");
3196         }
3197         else if (STRCASEEQ('u','U',"upper-alpha", cur->value)) {
3198           attr_type = apr_pstrdup(doc->pool, "upper-alpha");
3199         }
3200         else if (STRCASEEQ('l','L',"lower-alpha", cur->value)) {
3201           attr_type = apr_pstrdup(doc->pool, "lower-alpha");
3202         }
3203         else if (STRCASEEQ('d','D',"disc", cur->value)) {
3204           attr_type = apr_pstrdup(doc->pool, "disc");
3205         }
3206         else if (STRCASEEQ('s','S',"square", cur->value)) {
3207           attr_type = apr_pstrdup(doc->pool, "square");
3208         }
3209         else if (STRCASEEQ('c','C',"circle", cur->value)) {
3210           attr_type = apr_pstrdup(doc->pool, "circle");
3211         }
3212       }
3213     }
3214   }
3215
3216
3217   W_L("<li");
3218   if (attr_type) {
3219     W_L(" style=\"");
3220     W_L("list-style-type:");
3221     W_V(attr_type);
3222     W_L(";");
3223     W_L("\"");
3224   }
3225   if (attr_value) {
3226     W_L(" value=\"");
3227     W_V(attr_value);
3228     W_L("\"");
3229   }
3230   W_L(">");
3231   return xhtml->out;
3232 }
3233
3234
3235 /**
3236  ** It is a handler who processes the LI tag.
3237  *
3238  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3239  *                     destination is specified.
3240  * @param node   [i]   The LI tag node is specified.
3241  * @return The conversion result is returned.
3242  */
3243 static char *
3244 s_xhtml_1_0_end_li_tag(void *pdoc, Node *UNUSED(child)) 
3245 {
3246   xhtml_t *xhtml = GET_XHTML(pdoc);
3247   Doc     *doc   = xhtml->doc;
3248
3249   W_L("</li>");
3250   if (IS_CSS_ON(xhtml->entryp)) {
3251     chxj_css_pop_prop_list(xhtml->css_prop_stack);
3252   }
3253   return xhtml->out;
3254 }
3255
3256 /**
3257  * It is a handler who processes the IMG tag.
3258  *
3259  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3260  *                     destination is specified.
3261  * @param node   [i]   The IMG tag node is specified.
3262  * @return The conversion result is returned.
3263  */
3264 static char *
3265 s_xhtml_1_0_start_img_tag(void *pdoc, Node *node) 
3266 {
3267   xhtml_t       *xhtml = GET_XHTML(pdoc);
3268   Doc           *doc   = xhtml->doc;
3269   request_rec   *r     = doc->r;
3270   Attr          *attr;
3271   char          *attr_src    = NULL;
3272   char          *attr_alt    = NULL;
3273   char          *attr_height = NULL;
3274   char          *attr_width  = NULL;
3275   char          *attr_align  = NULL;
3276   char          *attr_style  = NULL;
3277   char          *attr_hspace = NULL;
3278   char          *attr_vspace = NULL;
3279
3280 #ifndef IMG_NOT_CONVERT_FILENAME
3281   device_table  *spec = xhtml->spec;
3282 #endif
3283
3284   /*--------------------------------------------------------------------------*/
3285   /* Get Attributes                                                           */
3286   /*--------------------------------------------------------------------------*/
3287   for (attr = qs_get_attr(doc,node);
3288        attr;
3289        attr = qs_get_next_attr(doc,attr)) {
3290     char *name  = qs_get_attr_name(doc,attr);
3291     char *value = qs_get_attr_value(doc,attr);
3292
3293     if (STRCASEEQ('s','S',"src",name)) {
3294       value = chxj_encoding_parameter(r, value, 1);
3295       value = chxj_add_cookie_parameter(r, value, xhtml->cookie);
3296       value = chxj_add_cookie_no_update_parameter(r, value);
3297 #ifdef IMG_NOT_CONVERT_FILENAME
3298       attr_src = value;
3299
3300 #else
3301
3302       {
3303         attr_src = chxj_img_conv(r,spec,value);
3304       }
3305
3306 #endif
3307     }
3308     else 
3309     if (STRCASEEQ('a','A',"align",name)) {
3310       if (value) {
3311         if (STRCASEEQ('t','T',"top",   value) ||
3312             STRCASEEQ('m','M',"middle",value) ||
3313             STRCASEEQ('b','B',"bottom",value) ||
3314             STRCASEEQ('l','L',"left",  value) ||
3315             STRCASEEQ('r','R',"right", value)) {
3316           attr_align = value;
3317         }
3318         else if (STRCASEEQ('c','C',"center",  value)) {
3319           attr_align = apr_pstrdup(doc->pool, "middle");
3320         }
3321       }
3322     }
3323     else if (STRCASEEQ('a','A',"alt",name) && value && *value) {
3324       attr_alt = value;
3325     }
3326     else if (STRCASEEQ('w','W',"width",name) && value && *value) {
3327       attr_width = value;
3328     }
3329     else if (STRCASEEQ('h','H',"height",name) && value && *value) {
3330       attr_height = value;
3331     }
3332     else if (STRCASEEQ('h','H',"hspace",name) && value && *value) {
3333       attr_hspace = value;
3334     }
3335     else if (STRCASEEQ('v','V',"vspace",name) && value && *value) {
3336       attr_vspace = value;
3337     }
3338     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3339       attr_style = value;
3340     }
3341   }
3342
3343   if (IS_CSS_ON(xhtml->entryp)) {
3344     css_prop_list_t *style = s_xhtml_1_0_nopush_and_get_now_style(pdoc, node, attr_style);
3345     if (style) {
3346       css_property_t *height_prop = chxj_css_get_property_value(doc, style, "height");
3347       css_property_t *width_prop  = chxj_css_get_property_value(doc, style, "width");
3348       css_property_t *valign_prop = chxj_css_get_property_value(doc, style, "vertical-align");
3349       css_property_t *cur;
3350       for (cur = height_prop->next; cur != height_prop; cur = cur->next) {
3351         attr_height = apr_pstrdup(doc->pool, cur->value);
3352       }
3353       for (cur = width_prop->next; cur != width_prop; cur = cur->next) {
3354         attr_width = apr_pstrdup(doc->pool, cur->value);
3355       }
3356       for (cur = valign_prop->next; cur != valign_prop; cur = cur->next) {
3357         attr_align = apr_pstrdup(doc->pool, cur->value);
3358       }
3359     }
3360   }
3361
3362   W_L("<img");
3363   if (attr_src) {
3364     W_L(" src=\"");
3365     W_V(attr_src);
3366     W_L("\"");
3367   }
3368   if (attr_align) {
3369     W_L(" align=\"");
3370     W_V(attr_align);
3371     W_L("\"");
3372   }
3373   if (attr_width) {
3374     W_L(" width=\"");
3375     W_V(attr_width);
3376     W_L("\"");
3377   }
3378   if (attr_height) {
3379     W_L(" height=\"");
3380     W_V(attr_height);
3381     W_L("\"");
3382   }
3383   if (attr_hspace) {
3384     W_L(" hspace=\"");
3385     W_V(attr_hspace);
3386     W_L("\"");
3387   }
3388   if (attr_vspace) {
3389     W_L(" vspace=\"");
3390     W_V(attr_vspace);
3391     W_L("\"");
3392   }
3393   if (attr_alt) {
3394     W_L(" alt=\"");
3395     W_V(attr_alt);
3396     W_L("\"");
3397   }
3398   else {
3399     W_L(" alt=\"\"");
3400   }
3401   W_L(" />");
3402   return xhtml->out;
3403 }
3404
3405
3406 /**
3407  * It is a handler who processes the IMG tag.
3408  *
3409  * @param xhtml  [i/o] The pointer to the XHTML structure at the output
3410  *                     destination is specified.
3411  * @param node   [i]   The IMG tag node is specified.
3412  * @return The conversion result is returned.
3413  */
3414 static char *
3415 s_xhtml_1_0_end_img_tag(void *pdoc, Node *UNUSED(child)) 
3416 {
3417   xhtml_t *xhtml = GET_XHTML(pdoc);
3418
3419   return xhtml->out;
3420 }
3421
3422
3423 /**
3424  * It is a handler who processes the SELECT tag.
3425  *
3426  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3427  *                     destination is specified.
3428  * @param node   [i]   The SELECT tag node is specified.
3429  * @return The conversion result is returned.
3430  */
3431 static char *
3432 s_xhtml_1_0_start_select_tag(void *pdoc, Node *node)
3433 {
3434   xhtml_t *xhtml    = GET_XHTML(pdoc);
3435   Doc     *doc      = xhtml->doc;
3436   char    *size     = NULL;
3437   char    *name     = NULL;
3438   char    *multiple = NULL;
3439   Attr    *attr;
3440   char    *attr_style = NULL;
3441
3442   W_L("<select");
3443   for (attr = qs_get_attr(doc,node);
3444        attr;
3445        attr = qs_get_next_attr(doc,attr)) {
3446     char *nm  = qs_get_attr_name(doc,attr);
3447     char *val = qs_get_attr_value(doc,attr);
3448     if (STRCASEEQ('s','S',"size",nm)) {
3449       /*----------------------------------------------------------------------*/
3450       /* CHTML 1.0 version 2.0                                                */
3451       /*----------------------------------------------------------------------*/
3452       size = apr_pstrdup(doc->buf.pool, val);
3453     }
3454     else if (STRCASEEQ('s','S',"style",nm) && val && *val) {
3455       /*----------------------------------------------------------------------*/
3456       /* CHTML 1.0 version 2.0                                                */
3457       /*----------------------------------------------------------------------*/
3458       attr_style = apr_pstrdup(doc->buf.pool, val);
3459     }
3460     else if (STRCASEEQ('n','N',"name",nm)) {
3461       /*----------------------------------------------------------------------*/
3462       /* CHTML 1.0 version 2.0                                                */
3463       /*----------------------------------------------------------------------*/
3464       name = apr_pstrdup(doc->buf.pool, val);
3465     }
3466     else if (STRCASEEQ('m','M',"multiple",nm)) {
3467       /*----------------------------------------------------------------------*/
3468       /* CHTML 1.0 version 2.0                                                */
3469       /*----------------------------------------------------------------------*/
3470       multiple = apr_pstrdup(doc->buf.pool, val);
3471     }
3472   }
3473   if (size && *size) {
3474     W_L(" size=\"");
3475     W_V(size);
3476     W_L("\"");
3477   }
3478   if (name && *name) {
3479     W_L(" name=\"");
3480     W_V(name);
3481     W_L("\"");
3482   }
3483   if (multiple) {
3484     /* "true" is *NOT* W3C. it is specification of WAP2.0 for EZWEB */
3485     W_L(" multiple=\"true\"");
3486   }
3487   W_L(">");
3488   if (IS_CSS_ON(xhtml->entryp)) {
3489     s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
3490   }
3491
3492   return xhtml->out;
3493 }
3494
3495
3496 /**
3497  * It is a handler who processes the SELECT tag.
3498  *
3499  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3500  *                     destination is specified.
3501  * @param node   [i]   The SELECT tag node is specified.
3502  * @return The conversion result is returned.
3503  */
3504 static char *
3505 s_xhtml_1_0_end_select_tag(void *pdoc, Node *UNUSED(child))
3506 {
3507   xhtml_t *xhtml = GET_XHTML(pdoc);
3508   Doc     *doc   = xhtml->doc;
3509
3510   W_L("</select>");
3511   if (IS_CSS_ON(xhtml->entryp)) {
3512     chxj_css_pop_prop_list(xhtml->css_prop_stack);
3513   }
3514   return xhtml->out;
3515 }
3516
3517
3518 /**
3519  * It is a handler who processes the OPTION tag.
3520  *
3521  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3522  *                     destination is specified.
3523  * @param node   [i]   The OPTION tag node is specified.
3524  * @return The conversion result is returned.
3525  */
3526 static char *
3527 s_xhtml_1_0_start_option_tag(void *pdoc, Node *node)
3528 {
3529   xhtml_t *xhtml = GET_XHTML(pdoc);
3530   Doc     *doc   = xhtml->doc;
3531   Attr    *attr;
3532   char    *attr_style = NULL;
3533
3534   char *selected   = NULL;
3535   char *value      = NULL;
3536
3537   W_L("<option");
3538   for (attr = qs_get_attr(doc,node);
3539        attr;
3540        attr = qs_get_next_attr(doc,attr)) {
3541     char *nm  = qs_get_attr_name(doc,attr);
3542     char *val = qs_get_attr_value(doc,attr);
3543     if (STRCASEEQ('s','S',"selected",nm)) {
3544       /* CHTML version 2.0 */
3545       selected = apr_pstrdup(doc->buf.pool, val);
3546     }
3547     else if (STRCASEEQ('s','S',"style",nm) && val && *val) {
3548       /* CHTML version 2.0 */
3549       attr_style = apr_pstrdup(doc->buf.pool, val);
3550     }
3551     else if (STRCASEEQ('v','V',"value",nm)) {
3552       /* CHTML version 2.0 */
3553       value = apr_pstrdup(doc->buf.pool, val);
3554     }
3555   }
3556   if (value) {
3557     W_L(" value=\"");
3558     W_V(value);
3559     W_L("\"");
3560   }
3561   if (selected) {
3562     W_L(" selected=\"selected\"");
3563   }
3564   W_L(">");
3565   if (IS_CSS_ON(xhtml->entryp)) {
3566     s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
3567   }
3568   return xhtml->out;
3569 }
3570
3571
3572 /**
3573  * It is a handler who processes the OPTION tag.
3574  *
3575  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3576  *                     destination is specified.
3577  * @param node   [i]   The OPTION tag node is specified.
3578  * @return The conversion result is returned.
3579  */
3580 static char *
3581 s_xhtml_1_0_end_option_tag(void *pdoc, Node *UNUSED(child))
3582 {
3583   xhtml_t *xhtml = GET_XHTML(pdoc);
3584   Doc     *doc   = xhtml->doc;
3585
3586   W_L("</option>");
3587   if (IS_CSS_ON(xhtml->entryp)) {
3588     chxj_css_pop_prop_list(xhtml->css_prop_stack);
3589   }
3590
3591   return xhtml->out;
3592 }
3593
3594
3595 /**
3596  * It is a handler who processes the DIV tag.
3597  *
3598  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3599  *                     destination is specified.
3600  * @param node   [i]   The DIV tag node is specified.
3601  * @return The conversion result is returned.
3602  */
3603 static char *
3604 s_xhtml_1_0_start_div_tag(void *pdoc, Node *node)
3605 {
3606   xhtml_t     *xhtml = GET_XHTML(pdoc);
3607   Doc         *doc   = xhtml->doc;
3608   Attr        *attr;
3609   char        *attr_style             = NULL;
3610   char        *attr_align             = NULL;
3611   char        *attr_display           = NULL;
3612   char        *attr_decoration        = NULL;
3613   char        *attr_wap_marquee_style = NULL;
3614   char        *attr_wap_marquee_dir   = NULL;
3615   char        *attr_wap_marquee_loop  = NULL;
3616   char        *attr_color             = NULL;
3617   char        *attr_bgcolor           = NULL;
3618   char        *attr_font_size         = NULL;
3619
3620   for (attr = qs_get_attr(doc,node);
3621        attr;
3622        attr = qs_get_next_attr(doc,attr)) {
3623     char *nm  = qs_get_attr_name(doc,attr);
3624     char *val = qs_get_attr_value(doc,attr);
3625     if (STRCASEEQ('a','A',"align",nm)) {
3626       /*----------------------------------------------------------------------*/
3627       /* CHTML 1.0 (W3C version 3.2)                                          */
3628       /*----------------------------------------------------------------------*/
3629       if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
3630         attr_align = apr_pstrdup(doc->buf.pool, val);
3631       }
3632     }
3633     else if (STRCASEEQ('s','S',"style",nm) && val && *val) {
3634       attr_style = apr_pstrdup(doc->buf.pool, val);
3635     }
3636   }
3637
3638   if (IS_CSS_ON(xhtml->entryp)) {
3639     css_prop_list_t *style = s_xhtml_1_0_nopush_and_get_now_style(pdoc, node, attr_style);
3640     if (style) {
3641       css_property_t *display_prop           = chxj_css_get_property_value(doc, style, "display");
3642       css_property_t *text_decoration_prop   = chxj_css_get_property_value(doc, style, "text-decoration");
3643       css_property_t *color_prop             = chxj_css_get_property_value(doc, style, "color");
3644       css_property_t *text_align_prop        = chxj_css_get_property_value(doc, style, "text-align");
3645       css_property_t *font_size_prop         = chxj_css_get_property_value(doc, style, "font-size");
3646       css_property_t *background_color_prop  = chxj_css_get_property_value(doc, style, "background-color");
3647       css_property_t *background_prop        = chxj_css_get_property_value(doc, style, "background");
3648
3649       css_property_t *cur;
3650       for (cur = display_prop->next; cur != display_prop; cur = cur->next) {
3651         if (strcasecmp("-wap-marquee", cur->value) == 0) {
3652           attr_display = apr_pstrdup(doc->pool, cur->value);
3653         }
3654       }
3655       for (cur = text_decoration_prop->next; cur != text_decoration_prop; cur = cur->next) {
3656         if (STRCASEEQ('b','B',"blink", cur->value)) {
3657           attr_decoration = apr_pstrdup(doc->pool, cur->value);
3658         }
3659       }
3660       for (cur = background_color_prop->next; cur != background_color_prop; cur = cur->next) {
3661         attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
3662         attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
3663       }
3664       for (cur = background_prop->next; cur != background_prop; cur = cur->next) {
3665         char *ss = strchr(cur->value, '#');
3666         if (ss) {
3667           attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
3668           attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
3669         }
3670       }
3671       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
3672         attr_color = apr_pstrdup(doc->pool, cur->value);
3673       }
3674       for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
3675         attr_align = apr_pstrdup(doc->pool, cur->value);
3676       }
3677       for (cur = font_size_prop->next; cur != font_size_prop; cur = cur->next) {
3678         if (   STRCASEEQ('x','X',"xx-small",cur->value)
3679             || STRCASEEQ('x','X',"x-small",cur->value)
3680             || STRCASEEQ('s','S',"small",cur->value)
3681             || STRCASEEQ('m','M',"medium",cur->value)
3682             || STRCASEEQ('l','L',"large",cur->value)
3683             || STRCASEEQ('x','X',"x-large",cur->value)
3684             || STRCASEEQ('x','X',"xx-large",cur->value)) {
3685           attr_font_size = apr_pstrdup(doc->pool, cur->value);
3686         }
3687       }
3688       if (attr_display) {
3689         css_property_t *wap_marquee_style_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-style");
3690         css_property_t *wap_marquee_dir_prop   = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
3691         css_property_t *wap_marquee_loop_prop  = chxj_css_get_property_value(doc, style, "-wap-marquee-loop");
3692         for (cur = wap_marquee_style_prop->next; cur != wap_marquee_style_prop; cur = cur->next) {
3693           if (STRCASEEQ('s','S',"scroll", cur->value) || STRCASEEQ('s','S',"slide",cur->value) || STRCASEEQ('a','A',"alternate",cur->value)) {
3694             attr_wap_marquee_style = apr_pstrdup(doc->pool, cur->value);
3695           }
3696         }
3697         for (cur = wap_marquee_dir_prop->next; cur != wap_marquee_dir_prop; cur = cur->next) {
3698           if (STRCASEEQ('l','L',"ltr",cur->value)) {
3699             attr_wap_marquee_dir = apr_pstrdup(doc->pool, cur->value);
3700           }
3701           else if (STRCASEEQ('r','R',"rtl",cur->value)) {
3702             attr_wap_marquee_dir = apr_pstrdup(doc->pool, cur->value);
3703           }
3704         }
3705         for (cur = wap_marquee_loop_prop->next; cur != wap_marquee_loop_prop; cur = cur->next) {
3706           attr_wap_marquee_loop = apr_pstrdup(doc->pool, cur->value);
3707         }
3708       }
3709     }
3710   }  
3711   W_L("<div");
3712   if (attr_align
3713       || attr_display
3714       || attr_decoration
3715       || attr_wap_marquee_style
3716       || attr_wap_marquee_dir
3717       || attr_wap_marquee_loop
3718       || attr_color
3719       || attr_bgcolor
3720       || attr_font_size) {
3721     W_L(" style=\"");
3722     if (attr_align) {
3723       W_L("text-align:");
3724       W_V(attr_align);
3725       W_L(";");
3726     }
3727     if (attr_display) {
3728       W_L("display:");
3729       W_V(attr_display);
3730       W_L(";");
3731     }
3732     if (attr_decoration) {
3733       W_L("text-decoration:");
3734       W_V(attr_decoration);
3735       W_L(";");
3736     }
3737     if (attr_wap_marquee_style) {
3738       W_L("-wap-marquee-style:");
3739       W_V(attr_wap_marquee_style);
3740       W_L(";");
3741     }
3742     if (attr_wap_marquee_dir) {
3743       W_L("-wap-marquee-dir:");
3744       W_V(attr_wap_marquee_dir);
3745       W_L(";");
3746     }
3747     if (attr_wap_marquee_loop) {
3748       W_L("-wap-marquee-loop:");
3749       W_V(attr_wap_marquee_loop);
3750       W_L(";");
3751     }
3752     if (attr_color) {
3753       W_L("color:");
3754       W_V(attr_color);
3755       W_L(";");
3756     }
3757     if (attr_bgcolor) {
3758       W_L("background-color:");
3759       W_V(attr_bgcolor);
3760       W_L(";");
3761     }
3762     if (attr_font_size) {
3763       W_L("font-size:");
3764       W_V(attr_font_size);
3765       W_L(";");
3766     }
3767     W_L("\"");
3768   }
3769   W_L(">");
3770   return xhtml->out;
3771 }
3772
3773
3774 /**
3775  * It is a handler who processes the DIV tag.
3776  *
3777  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3778  *                     destination is specified.
3779  * @param node   [i]   The DIV tag node is specified.
3780  * @return The conversion result is returned.
3781  */
3782 static char *
3783 s_xhtml_1_0_end_div_tag(void *pdoc, Node *UNUSED(child))
3784 {
3785   xhtml_t *xhtml = GET_XHTML(pdoc);
3786   Doc     *doc   = xhtml->doc;
3787   W_L("</div>");
3788   if (IS_CSS_ON(xhtml->entryp)) {
3789     chxj_css_pop_prop_list(xhtml->css_prop_stack);
3790   }
3791   return xhtml->out;
3792 }
3793
3794
3795 /**
3796  * It is a handler who processes the B tag.
3797  *
3798  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3799  *                     destination is specified.
3800  * @param node   [i]   The B tag node is specified.
3801  * @return The conversion result is returned.
3802  */
3803 static char *
3804 s_xhtml_1_0_start_b_tag(void *pdoc, Node *UNUSED(child))
3805 {
3806   xhtml_t *xhtml = GET_XHTML(pdoc);
3807   Doc     *doc   = xhtml->doc;
3808
3809   W_L("<div style=\"font-weight:bold\">");
3810   return xhtml->out;
3811 }
3812
3813
3814 /**
3815  * It is a handler who processes the B tag.
3816  *
3817  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3818  *                     destination is specified.
3819  * @param node   [i]   The B tag node is specified.
3820  * @return The conversion result is returned.
3821  */
3822 static char *
3823 s_xhtml_1_0_end_b_tag(void *pdoc, Node *UNUSED(child))
3824 {
3825   xhtml_t *xhtml = GET_XHTML(pdoc);
3826   Doc     *doc   = xhtml->doc;
3827
3828   W_L("</div>");
3829   return xhtml->out;
3830 }
3831
3832
3833 /**
3834  * It is a handler who processes the CHXJ:IF tag.
3835  *
3836  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
3837  *                     destination is specified.
3838  * @param node   [i]   The CHXJ:IF tag node is specified.
3839  */
3840 static char *
3841 s_xhtml_1_0_chxjif_tag(void *pdoc, Node *node)
3842 {
3843   xhtml_t      *xhtml = GET_XHTML(pdoc);
3844   Doc          *doc   = xhtml->doc;
3845   Node         *child;
3846
3847   for (child = qs_get_child_node(doc, node);
3848        child;
3849        child = qs_get_next_node(doc, child)) {
3850     W_V(child->otext);
3851     s_xhtml_1_0_chxjif_tag(xhtml, child);
3852   }
3853
3854   return NULL;
3855 }
3856
3857
3858 /**
3859  * It is a handler who processes the TEXTARE tag.
3860  *
3861  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3862  *                     destination is specified.
3863  * @param node   [i]   The TEXTAREA tag node is specified.
3864  * @return The conversion result is returned.
3865  */
3866 static char *
3867 s_xhtml_1_0_start_textarea_tag(void *pdoc, Node *node) 
3868 {
3869   xhtml_t *xhtml = GET_XHTML(pdoc);
3870   Doc     *doc   = xhtml->doc;
3871   Attr    *attr;
3872   char    *attr_accesskey = NULL;
3873   char    *attr_name      = NULL;
3874   char    *attr_rows      = NULL;
3875   char    *attr_cols      = NULL;
3876   char    *attr_istyle    = NULL;
3877   char    *attr_style     = NULL;
3878
3879   xhtml->textarea_flag++;
3880   for (attr = qs_get_attr(doc,node);
3881        attr;
3882        attr = qs_get_next_attr(doc,attr)) {
3883     char *name  = qs_get_attr_name(doc,attr);
3884     char *value = qs_get_attr_value(doc,attr);
3885     if (STRCASEEQ('n','N',"name",name) && value && *value) {
3886       attr_name = value;
3887     }
3888     else if (STRCASEEQ('r','R',"rows",name) && value && *value) {
3889       attr_rows = value;
3890     }
3891     else if (STRCASEEQ('c','C',"cols",name) && value && *value) {
3892       attr_cols = value;
3893     }
3894     else if (STRCASEEQ('i','I',"istyle", name) && value && (*value == '1' || *value == '2' || *value == '3' || *value == '4')) {
3895       attr_istyle = value;
3896 #if 0
3897       char *fmt = qs_conv_istyle_to_format(doc->r->pool,value);
3898       W_L(" FORMAT=\"*");
3899       W_V(fmt);
3900       W_L("\"");
3901 #endif
3902     }
3903     else if (STRCASEEQ('a','A',"accesskey",name) && value && *value != 0) {
3904       attr_accesskey = value;
3905     }
3906     else if (STRCASEEQ('s','S',"style",name) && value && *value != 0) {
3907       attr_style = value;
3908     }
3909   }
3910   if (IS_CSS_ON(xhtml->entryp)) {
3911     css_prop_list_t *style = s_xhtml_1_0_nopush_and_get_now_style(pdoc, node, attr_style);
3912     if (style) {
3913       css_property_t *wap_input_format = chxj_css_get_property_value(doc, style, "-wap-input-format");
3914       css_property_t *cur;
3915       for (cur = wap_input_format->next; cur != wap_input_format; cur = cur->next) {
3916         if (strcasestr(cur->value, "<ja:n>")) {
3917           attr_istyle = "4";
3918         }
3919         else if (strcasestr(cur->value, "<ja:en>")) {
3920           attr_istyle = "3";
3921         }
3922         else if (strcasestr(cur->value, "<ja:hk>")) {
3923           attr_istyle = "2";
3924         }
3925         else if (strcasestr(cur->value, "<ja:h>")) {
3926           attr_istyle = "1";
3927         }
3928       }
3929     }
3930   }
3931   W_L("<textarea");
3932   if (attr_accesskey) {
3933     W_L(" accesskey=\"");
3934     W_V(attr_accesskey);
3935     W_L("\"");
3936   }
3937   if (attr_name) {
3938     W_L(" name=\"");
3939     W_V(attr_name);
3940     W_L("\"");
3941   }
3942   if (attr_rows) {
3943     W_L(" rows=\"");
3944     W_V(attr_rows);
3945     W_L("\"");
3946   }
3947   if (attr_cols) {
3948     W_L(" cols=\"");
3949     W_V(attr_cols);
3950     W_L("\"");
3951   }
3952   if (attr_istyle) {
3953     char *fmt = qs_conv_istyle_to_format(doc->r->pool, attr_istyle);
3954     W_L(" FORMAT=\"*");
3955     W_V(fmt);
3956     W_L("\"");
3957   }
3958   W_L(">");
3959   return xhtml->out;
3960 }
3961
3962
3963 /**
3964  * It is a handler who processes the TEXTAREA tag.
3965  *
3966  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3967  *                     destination is specified.
3968  * @param node   [i]   The TEXTAREA tag node is specified.
3969  * @return The conversion result is returned.
3970  */
3971 static char *
3972 s_xhtml_1_0_end_textarea_tag(void *pdoc, Node *UNUSED(child)) 
3973 {
3974   xhtml_t *xhtml = GET_XHTML(pdoc);
3975   Doc     *doc   = xhtml->doc;
3976
3977   W_L("</textarea>");
3978   xhtml->textarea_flag--;
3979
3980   return xhtml->out;
3981 }
3982
3983 static char *
3984 s_xhtml_1_0_text_tag(void *pdoc, Node *child)
3985 {
3986   xhtml_t     *xhtml   = GET_XHTML(pdoc);
3987   Doc         *doc     = xhtml->doc;
3988   request_rec *r       = doc->r;
3989   char        *textval;
3990   char        *tmp;
3991   char        *tdst;
3992   char        one_byte[2];
3993   int         ii;
3994   int         tdst_len;
3995   
3996   textval = qs_get_node_value(doc,child);
3997   if (strlen(textval) == 0) {
3998     return xhtml->out;
3999   }
4000   
4001   tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
4002   memset(tmp, 0, qs_get_node_size(doc,child)+1);
4003   
4004   tdst     = qs_alloc_zero_byte_string(doc->buf.pool);
4005   memset(one_byte, 0, sizeof(one_byte));
4006   tdst_len = 0;
4007   
4008   for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
4009     char *out;
4010     int rtn = s_xhtml_search_emoji(xhtml, &textval[ii], &out);
4011     if (rtn != 0) {
4012       DBG(r,"[%s][%d]", out, rtn);
4013       tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
4014       ii+=(rtn - 1);
4015       continue;
4016     }
4017     if (is_sjis_kanji(textval[ii])) {
4018       one_byte[0] = textval[ii+0];
4019       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
4020       one_byte[0] = textval[ii+1];
4021       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
4022       ii++;
4023     }
4024     else if (xhtml->pre_flag) {
4025       one_byte[0] = textval[ii+0];
4026       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
4027     }
4028     else if (xhtml->textarea_flag) {
4029       one_byte[0] = textval[ii+0];
4030       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
4031     }
4032     else if (textval[ii] != '\r' && textval[ii] != '\n') {
4033       one_byte[0] = textval[ii+0];
4034       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
4035     }
4036   }
4037   W_V(tdst);
4038   return xhtml->out;
4039 }
4040
4041
4042 /**
4043  * It is a handler who processes the BLOCKQUOTE tag.
4044  *
4045  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4046  *                     destination is specified.
4047  * @param node   [i]   The BLOCKQUOTE tag node is specified.
4048  * @return The conversion result is returned.
4049  */
4050 static char *
4051 s_xhtml_1_0_start_blockquote_tag(void *pdoc, Node *node)
4052 {
4053   xhtml_t *xhtml;
4054   Doc      *doc;
4055   Attr     *attr;
4056   char     *attr_style = NULL;
4057   char     *attr_color = NULL;
4058   char     *attr_size  = NULL;
4059
4060   xhtml  = GET_XHTML(pdoc);
4061   doc     = xhtml->doc;
4062   for (attr = qs_get_attr(doc,node);
4063        attr;
4064        attr = qs_get_next_attr(doc,attr)) {
4065     char *nm  = qs_get_attr_name(doc,attr);
4066     char *val = qs_get_attr_value(doc,attr);
4067     if (val && STRCASEEQ('s','S',"style", nm)) {
4068       attr_style = val;
4069     }
4070   }
4071   if (IS_CSS_ON(xhtml->entryp)) {
4072     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
4073     if (style) {
4074       css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4075       css_property_t *font_size_prop = chxj_css_get_property_value(doc, style, "font-size");
4076       css_property_t *cur;
4077       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4078         if (cur->value && *cur->value) {
4079           attr_color = apr_pstrdup(doc->pool, cur->value);
4080         }
4081       }
4082       for (cur = font_size_prop->next; cur != font_size_prop; cur = cur->next) {
4083         if (cur->value && *cur->value) {
4084           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
4085             attr_size = apr_pstrdup(doc->pool, cur->value);
4086           }
4087           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
4088             attr_size = apr_pstrdup(doc->pool, cur->value);
4089           }
4090           else if (STRCASEEQ('s','S',"small",cur->value)) {
4091             attr_size = apr_pstrdup(doc->pool, cur->value);
4092           }
4093           else if (STRCASEEQ('m','M',"medium",cur->value)) {
4094             attr_size = apr_pstrdup(doc->pool, cur->value);
4095           }
4096           else if (STRCASEEQ('l','L',"large",cur->value)) {
4097             attr_size = apr_pstrdup(doc->pool, cur->value);
4098           }
4099           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
4100             attr_size = apr_pstrdup(doc->pool, cur->value);
4101           }
4102           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
4103             attr_size = apr_pstrdup(doc->pool, cur->value);
4104           }
4105         }
4106       }
4107     }
4108   }
4109   W_L("<blockquote");
4110   if (attr_color || attr_size) {
4111     W_L(" style=\"");
4112     if (attr_color) {
4113       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4114       W_L("color:");
4115       W_V(attr_color);
4116       W_L(";");
4117     }
4118     if (attr_size) {
4119       W_L("font-size:");
4120       W_V(attr_size);
4121       W_L(";");
4122     }
4123     W_L("\"");
4124   }
4125   W_L(">");
4126   return xhtml->out;
4127 }
4128
4129
4130 /**
4131  * It is a handler who processes the BLOCKQUOTE tag.
4132  *
4133  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4134  *                     destination is specified.
4135  * @param node   [i]   The BLOCKQUOTE tag node is specified.
4136  * @return The conversion result is returned.
4137  */
4138 static char *
4139 s_xhtml_1_0_end_blockquote_tag(void *pdoc, Node *UNUSED(child))
4140 {
4141   xhtml_t *xhtml = GET_XHTML(pdoc);
4142   Doc     *doc   = xhtml->doc;
4143   W_L("</blockquote>");
4144   if (IS_CSS_ON(xhtml->entryp)) {
4145     chxj_css_pop_prop_list(xhtml->css_prop_stack);
4146   }
4147   return xhtml->out;
4148 }
4149
4150
4151 /**
4152  * It is a handler who processes the DIR tag.
4153  *
4154  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4155  *                     destination is specified.
4156  * @param node   [i]   The DIR tag node is specified.
4157  * @return The conversion result is returned.
4158  */
4159 static char *
4160 s_xhtml_1_0_start_dir_tag(void *pdoc, Node *node)
4161 {
4162   xhtml_t *xhtml      = GET_XHTML(pdoc);
4163   Doc       *doc        = xhtml->doc;
4164   Attr      *attr;
4165   char      *attr_style = NULL;
4166   char      *attr_color = NULL;
4167   char      *attr_type  = NULL;
4168   char      *attr_size  = NULL;
4169   for (attr = qs_get_attr(doc,node);
4170        attr;
4171        attr = qs_get_next_attr(doc,attr)) {
4172     char *name   = qs_get_attr_name(doc,attr);
4173     char *value  = qs_get_attr_value(doc,attr);
4174     if (STRCASEEQ('t','T',"type",name)) {
4175       if (value && (STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
4176         attr_type = value;
4177       }
4178     }
4179     else if (STRCASEEQ('s','S',"style", name) && value && *value) {
4180       attr_style = value;
4181     }
4182   }
4183   if (IS_CSS_ON(xhtml->entryp)) {
4184     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
4185     if (style) {
4186       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
4187       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
4188       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
4189       css_property_t *cur;
4190       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4191         if (cur->value && *cur->value) {
4192           attr_color = apr_pstrdup(doc->pool, cur->value);
4193         }
4194       }
4195       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
4196         if (cur->value && *cur->value) {
4197           attr_type = apr_pstrdup(doc->pool, cur->value);
4198         }
4199       }
4200       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
4201         if (cur->value && *cur->value) {
4202           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
4203             attr_size = apr_pstrdup(doc->pool, cur->value);
4204           }
4205           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
4206             attr_size = apr_pstrdup(doc->pool, cur->value);
4207           }
4208           else if (STRCASEEQ('s','S',"small",cur->value)) {
4209             attr_size = apr_pstrdup(doc->pool, cur->value);
4210           }
4211           else if (STRCASEEQ('m','M',"medium",cur->value)) {
4212             attr_size = apr_pstrdup(doc->pool, cur->value);
4213           }
4214           else if (STRCASEEQ('l','L',"large",cur->value)) {
4215             attr_size = apr_pstrdup(doc->pool, cur->value);
4216           }
4217           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
4218             attr_size = apr_pstrdup(doc->pool, cur->value);
4219           }
4220           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
4221             attr_size = apr_pstrdup(doc->pool, cur->value);
4222           }
4223         }
4224       }
4225     }
4226   }
4227   W_L("<dir");
4228   if (attr_type || attr_color || attr_size) {
4229     W_L(" style=\"");
4230     if (attr_type) {
4231       W_L("list-style-type:");
4232       W_V(attr_type);
4233       W_L(";");
4234     }
4235     if (attr_color) {
4236       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4237       W_L("color:");
4238       W_V(attr_color);
4239       W_L(";");
4240     }
4241     if (attr_size) {
4242       W_L("font-size:");
4243       W_V(attr_size);
4244       W_L(";");
4245     }
4246     W_L("\"");
4247   }
4248   W_L(">");
4249   return xhtml->out;
4250 }
4251
4252
4253 /**
4254  * It is a handler who processes the DIR tag.
4255  *
4256  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4257  *                     destination is specified.
4258  * @param node   [i]   The DIR tag node is specified.
4259  * @return The conversion result is returned.
4260  */
4261 static char *
4262 s_xhtml_1_0_end_dir_tag(void *pdoc, Node *UNUSED(child))
4263 {
4264   xhtml_t *xhtml = GET_XHTML(pdoc);
4265   Doc     *doc = xhtml->doc;
4266   W_L("</dir>");
4267   if (IS_CSS_ON(xhtml->entryp)) {
4268     chxj_css_pop_prop_list(xhtml->css_prop_stack);
4269   }
4270   return xhtml->out;
4271 }
4272
4273
4274 /**
4275  * It is a handler who processes the DL tag.
4276  *
4277  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4278  *                     destination is specified.
4279  * @param node   [i]   The DL tag node is specified.
4280  * @return The conversion result is returned.
4281  */
4282 static char *
4283 s_xhtml_1_0_start_dl_tag(void *pdoc, Node *node)
4284 {
4285   xhtml_t *xhtml      = GET_XHTML(pdoc);
4286   Doc     *doc        = xhtml->doc;
4287   Attr    *attr;
4288   char    *attr_style = NULL;
4289   char    *attr_color = NULL;
4290   char    *attr_size  = NULL;
4291
4292   for (attr = qs_get_attr(doc,node);
4293        attr;
4294        attr = qs_get_next_attr(doc,attr)) {
4295     char *name   = qs_get_attr_name(doc,attr);
4296     char *value  = qs_get_attr_value(doc,attr);
4297     if (STRCASEEQ('s','S',"style", name) && value && *value) {
4298       attr_style = value;
4299     }
4300   }
4301   if (IS_CSS_ON(xhtml->entryp)) {
4302     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
4303     if (style) {
4304       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
4305       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
4306       css_property_t *cur;
4307       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4308         if (cur->value && *cur->value) {
4309           attr_color = apr_pstrdup(doc->pool, cur->value);
4310         }
4311       }
4312       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
4313         if (cur->value && *cur->value) {
4314           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
4315             attr_size = apr_pstrdup(doc->pool, cur->value);
4316           }
4317           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
4318             attr_size = apr_pstrdup(doc->pool, cur->value);
4319           }
4320           else if (STRCASEEQ('s','S',"small",cur->value)) {
4321             attr_size = apr_pstrdup(doc->pool, cur->value);
4322           }
4323           else if (STRCASEEQ('m','M',"medium",cur->value)) {
4324             attr_size = apr_pstrdup(doc->pool, cur->value);
4325           }
4326           else if (STRCASEEQ('l','L',"large",cur->value)) {
4327             attr_size = apr_pstrdup(doc->pool, cur->value);
4328           }
4329           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
4330             attr_size = apr_pstrdup(doc->pool, cur->value);
4331           }
4332           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
4333             attr_size = apr_pstrdup(doc->pool, cur->value);
4334           }
4335         }
4336       }
4337     }
4338   }
4339   W_L("<dl");
4340   if (attr_color || attr_size) {
4341     W_L(" style=\"");
4342     if (attr_color) {
4343       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4344       W_L("color:");
4345       W_V(attr_color);
4346       W_L(";");
4347     }
4348     if (attr_size) {
4349       W_L("font-size:");
4350       W_V(attr_size);
4351       W_L(";");
4352     }
4353     W_L("\"");
4354   }
4355   W_L(">");
4356   return xhtml->out;
4357 }
4358
4359
4360 /**
4361  * It is a handler who processes the DL tag.
4362  *
4363  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4364  *                     destination is specified.
4365  * @param node   [i]   The DL tag node is specified.
4366  * @return The conversion result is returned.
4367  */
4368 static char *
4369 s_xhtml_1_0_end_dl_tag(void *pdoc, Node *UNUSED(child))
4370 {
4371   xhtml_t *xhtml = GET_XHTML(pdoc);
4372   Doc *doc = xhtml->doc;
4373   W_L("</dl>");
4374   if (IS_CSS_ON(xhtml->entryp)) {
4375     chxj_css_pop_prop_list(xhtml->css_prop_stack);
4376   }
4377   return xhtml->out;
4378 }
4379
4380
4381 /**
4382  * It is a handter who processes the DT tag.
4383  *
4384  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4385  *                     destination is specified.
4386  * @param node   [i]   The DT tag node is specified.
4387  * @return The conversion result is returned.
4388  */
4389 static char *
4390 s_xhtml_1_0_start_dt_tag(void *pdoc, Node *node)
4391 {
4392   xhtml_t *xhtml      = GET_XHTML(pdoc);
4393   Doc     *doc        = xhtml->doc;
4394   Attr    *attr;
4395   char    *attr_style = NULL;
4396   char    *attr_color = NULL;
4397   char    *attr_size  = NULL;
4398
4399   for (attr = qs_get_attr(doc,node);
4400        attr;
4401        attr = qs_get_next_attr(doc,attr)) {
4402     char *name   = qs_get_attr_name(doc,attr);
4403     char *value  = qs_get_attr_value(doc,attr);
4404     if (STRCASEEQ('s','S',"style", name) && value && *value) {
4405       attr_style = value;
4406     }
4407   }
4408   if (IS_CSS_ON(xhtml->entryp)) {
4409     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
4410     if (style) {
4411       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
4412       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
4413       css_property_t *cur;
4414       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4415         if (cur->value && *cur->value) {
4416           attr_color = apr_pstrdup(doc->pool, cur->value);
4417         }
4418       }
4419       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
4420         if (cur->value && *cur->value) {
4421           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
4422             attr_size = apr_pstrdup(doc->pool, cur->value);
4423           }
4424           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
4425             attr_size = apr_pstrdup(doc->pool, cur->value);
4426           }
4427           else if (STRCASEEQ('s','S',"small",cur->value)) {
4428             attr_size = apr_pstrdup(doc->pool, cur->value);
4429           }
4430           else if (STRCASEEQ('m','M',"medium",cur->value)) {
4431             attr_size = apr_pstrdup(doc->pool, cur->value);
4432           }
4433           else if (STRCASEEQ('l','L',"large",cur->value)) {
4434             attr_size = apr_pstrdup(doc->pool, cur->value);
4435           }
4436           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
4437             attr_size = apr_pstrdup(doc->pool, cur->value);
4438           }
4439           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
4440             attr_size = apr_pstrdup(doc->pool, cur->value);
4441           }
4442         }
4443       }
4444     }
4445   }
4446   W_L("<dt");
4447   if (attr_color || attr_size) {
4448     W_L(" style=\"");
4449     if (attr_color) {
4450       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4451       W_L("color:");
4452       W_V(attr_color);
4453       W_L(";");
4454     }
4455     if (attr_size) {
4456       W_L("font-size:");
4457       W_V(attr_size);
4458       W_L(";");
4459     }
4460     W_L("\"");
4461   }
4462   W_L(">");
4463   return xhtml->out;
4464 }
4465
4466
4467 /**
4468  * It is a handter who processes the DT tag.
4469  *
4470  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4471  *                     destination is specified.
4472  * @param node   [i]   The DT tag node is specified.
4473  * @return The conversion result is returned.
4474  */
4475 static char *
4476 s_xhtml_1_0_end_dt_tag(void *pdoc, Node *UNUSED(child))
4477 {
4478   xhtml_t *xhtml = GET_XHTML(pdoc);
4479   Doc     *doc   = xhtml->doc;
4480   W_L("</dt>");
4481   if (IS_CSS_ON(xhtml->entryp)) {
4482     chxj_css_pop_prop_list(xhtml->css_prop_stack);
4483   }
4484   return xhtml->out;
4485 }
4486
4487
4488 /**
4489  * It is a handder who processes the DD tag.
4490  *
4491  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4492  *                     destination is specified.
4493  * @param node   [i]   The DD tag node is specified.
4494  * @return The conversion result is returned.
4495  */
4496 static char *
4497 s_xhtml_1_0_start_dd_tag(void *pdoc, Node *node)
4498 {
4499   xhtml_t *xhtml      = GET_XHTML(pdoc);
4500   Doc     *doc        = xhtml->doc;
4501   Attr    *attr;
4502   char    *attr_style = NULL;
4503   char    *attr_color = NULL;
4504   char    *attr_size  = NULL;
4505
4506   for (attr = qs_get_attr(doc,node);
4507        attr;
4508        attr = qs_get_next_attr(doc,attr)) {
4509     char *name   = qs_get_attr_name(doc,attr);
4510     char *value  = qs_get_attr_value(doc,attr);
4511     if (STRCASEEQ('s','S',"style", name) && value && *value) {
4512       attr_style = value;
4513     }
4514   }
4515   if (IS_CSS_ON(xhtml->entryp)) {
4516     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
4517     if (style) {
4518       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
4519       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
4520       css_property_t *cur;
4521       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4522         if (cur->value && *cur->value) {
4523           attr_color = apr_pstrdup(doc->pool, cur->value);
4524         }
4525       }
4526       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
4527         if (cur->value && *cur->value) {
4528           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
4529             attr_size = apr_pstrdup(doc->pool, cur->value);
4530           }
4531           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
4532             attr_size = apr_pstrdup(doc->pool, cur->value);
4533           }
4534           else if (STRCASEEQ('s','S',"small",cur->value)) {
4535             attr_size = apr_pstrdup(doc->pool, cur->value);
4536           }
4537           else if (STRCASEEQ('m','M',"medium",cur->value)) {
4538             attr_size = apr_pstrdup(doc->pool, cur->value);
4539           }
4540           else if (STRCASEEQ('l','L',"large",cur->value)) {
4541             attr_size = apr_pstrdup(doc->pool, cur->value);
4542           }
4543           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
4544             attr_size = apr_pstrdup(doc->pool, cur->value);
4545           }
4546           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
4547             attr_size = apr_pstrdup(doc->pool, cur->value);
4548           }
4549         }
4550       }
4551     }
4552   }
4553   W_L("<dd");
4554   if (attr_color || attr_size) {
4555     W_L(" style=\"");
4556     if (attr_color) {
4557       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4558       W_L("color:");
4559       W_V(attr_color);
4560       W_L(";");
4561     }
4562     if (attr_size) {
4563       W_L("font-size:");
4564       W_V(attr_size);
4565       W_L(";");
4566     }
4567     W_L("\"");
4568   }
4569   W_L(">");
4570   return xhtml->out;
4571 }
4572
4573
4574 /**
4575  * It is a handler who processes the DD tag.
4576  *
4577  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4578  *                     destination is specified.
4579  * @param node   [i]   The DD tag node is specified.
4580  * @return The conversion result is returned.
4581  */
4582 static char *
4583 s_xhtml_1_0_end_dd_tag(void *pdoc, Node *UNUSED(child))
4584 {
4585   xhtml_t *xhtml = GET_XHTML(pdoc);
4586   Doc     *doc   = xhtml->doc;
4587   W_L("</dd>");
4588   if (IS_CSS_ON(xhtml->entryp)) {
4589     chxj_css_pop_prop_list(xhtml->css_prop_stack);
4590   }
4591   return xhtml->out;
4592 }
4593
4594
4595 /**
4596  * It is a handler who processes the MENU tag.
4597  *
4598  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4599  *                     destination is specified.
4600  * @param node   [i]   The MENU tag node is specified.
4601  * @return The conversion result is returned.
4602  */
4603 static char *
4604 s_xhtml_1_0_start_menu_tag(void *pdoc, Node *node)
4605 {
4606   xhtml_t *xhtml      = GET_XHTML(pdoc);
4607   Doc       *doc        = xhtml->doc;
4608   Attr      *attr;
4609   char      *attr_style = NULL;
4610   char      *attr_color = NULL;
4611   char      *attr_type  = NULL;
4612   char      *attr_size  = NULL;
4613   for (attr = qs_get_attr(doc,node);
4614        attr;
4615        attr = qs_get_next_attr(doc,attr)) {
4616     char *name   = qs_get_attr_name(doc,attr);
4617     char *value  = qs_get_attr_value(doc,attr);
4618     if (STRCASEEQ('t','T',"type",name)) {
4619       if (value && (STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
4620         attr_type = value;
4621       }
4622     }
4623     else if (STRCASEEQ('s','S',"style", name) && value && *value) {
4624       attr_style = value;
4625     }
4626   }
4627   if (IS_CSS_ON(xhtml->entryp)) {
4628     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
4629     if (style) {
4630       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
4631       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
4632       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
4633       css_property_t *cur;
4634       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4635         if (cur->value && *cur->value) {
4636           attr_color = apr_pstrdup(doc->pool, cur->value);
4637         }
4638       }
4639       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
4640         if (cur->value && *cur->value) {
4641           attr_type = apr_pstrdup(doc->pool, cur->value);
4642         }
4643       }
4644       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
4645         if (cur->value && *cur->value) {
4646           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
4647             attr_size = apr_pstrdup(doc->pool, cur->value);
4648           }
4649           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
4650             attr_size = apr_pstrdup(doc->pool, cur->value);
4651           }
4652           else if (STRCASEEQ('s','S',"small",cur->value)) {
4653             attr_size = apr_pstrdup(doc->pool, cur->value);
4654           }
4655           else if (STRCASEEQ('m','M',"medium",cur->value)) {
4656             attr_size = apr_pstrdup(doc->pool, cur->value);
4657           }
4658           else if (STRCASEEQ('l','L',"large",cur->value)) {
4659             attr_size = apr_pstrdup(doc->pool, cur->value);
4660           }
4661           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
4662             attr_size = apr_pstrdup(doc->pool, cur->value);
4663           }
4664           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
4665             attr_size = apr_pstrdup(doc->pool, cur->value);
4666           }
4667         }
4668       }
4669     }
4670   }
4671   W_L("<menu");
4672   if (attr_type || attr_color || attr_size) {
4673     W_L(" style=\"");
4674     if (attr_type) {
4675       W_L("list-style-type:");
4676       W_V(attr_type);
4677       W_L(";");
4678     }
4679     if (attr_color) {
4680       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4681       W_L("color:");
4682       W_V(attr_color);
4683       W_L(";");
4684     }
4685     if (attr_size) {
4686       W_L("font-size:");
4687       W_V(attr_size);
4688       W_L(";");
4689     }
4690     W_L("\"");
4691   }
4692   W_L(">");
4693   return xhtml->out;
4694 }
4695
4696
4697 /**
4698  * It is a hanmenuer who processes the MENU tag.
4699  *
4700  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4701  *                     destination is specified.
4702  * @param node   [i]   The MENU tag node is specified.
4703  * @return The conversion result is returned.
4704  */
4705 static char *
4706 s_xhtml_1_0_end_menu_tag(void *pdoc, Node *UNUSED(child))
4707 {
4708   xhtml_t *xhtml = GET_XHTML(pdoc);
4709   Doc     *doc = xhtml->doc;
4710   W_L("</menu>");
4711   if (IS_CSS_ON(xhtml->entryp)) {
4712     chxj_css_pop_prop_list(xhtml->css_prop_stack);
4713   }
4714   return xhtml->out;
4715 }
4716
4717
4718 /**
4719  * It is a handler who processes the PLAINTEXT tag.
4720  *
4721  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4722  *                     destination is specified.
4723  * @param node   [i]   The PLAINTEXT tag node is specified.
4724  * @return The conversion result is returned.
4725  */
4726 static char *
4727 s_xhtml_1_0_start_plaintext_tag(void *pdoc, Node *node)
4728 {
4729   xhtml_t *xhtml = GET_XHTML(pdoc);
4730   Doc     *doc     = xhtml->doc;
4731   W_L("<plaintext>");
4732   s_xhtml_1_0_start_plaintext_tag_inner(pdoc,node);
4733   return xhtml->out;
4734 }
4735
4736 static char *
4737 s_xhtml_1_0_start_plaintext_tag_inner(void *pdoc, Node *node)
4738 {
4739   xhtml_t *xhtml = GET_XHTML(pdoc);
4740   Doc     *doc     = xhtml->doc;
4741   Node    *child;
4742   for (child = qs_get_child_node(doc, node);
4743        child;
4744        child = qs_get_next_node(doc, child)) {
4745     W_V(child->otext);
4746     s_xhtml_1_0_start_plaintext_tag_inner(pdoc, child);
4747   }
4748   return xhtml->out;
4749 }
4750
4751
4752 /**
4753  * It is a handler who processes the PLAINTEXT tag.
4754  *
4755  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4756  *                     destination is specified.
4757  * @param node   [i]   The PLAINTEXT tag node is specified.
4758  * @return The conversion result is returned.
4759  */
4760 static char *
4761 s_xhtml_1_0_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
4762 {
4763   xhtml_t *xhtml = GET_XHTML(pdoc);
4764   Doc     *doc     = xhtml->doc;
4765   W_L("</plaintext>");
4766   return xhtml->out;
4767 }
4768
4769
4770 /**
4771  * It is a handler who processes the BLINK tag.
4772  *
4773  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4774  *                     destination is specified.
4775  * @param node   [i]   The BLINK tag node is specified.
4776  * @return The conversion result is returned.
4777  */
4778 static char *
4779 s_xhtml_1_0_start_blink_tag(void *pdoc, Node *node)
4780 {
4781   xhtml_t *xhtml      = GET_XHTML(pdoc);
4782   Doc     *doc        = xhtml->doc;
4783   Attr    *attr;
4784   char    *attr_style = NULL;
4785   char    *attr_color = NULL;
4786   char    *attr_size  = NULL;
4787
4788   for (attr = qs_get_attr(doc,node);
4789        attr;
4790        attr = qs_get_next_attr(doc,attr)) {
4791     char *name   = qs_get_attr_name(doc,attr);
4792     char *value  = qs_get_attr_value(doc,attr);
4793     if (STRCASEEQ('s','S',"style", name) && value && *value) {
4794       attr_style = value;
4795     }
4796   }
4797   if (IS_CSS_ON(xhtml->entryp)) {
4798     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
4799     if (style) {
4800       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
4801       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
4802       css_property_t *cur;
4803       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4804         if (cur->value && *cur->value) {
4805           attr_color = apr_pstrdup(doc->pool, cur->value);
4806         }
4807       }
4808       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
4809         if (cur->value && *cur->value) {
4810           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
4811             attr_size = apr_pstrdup(doc->pool, cur->value);
4812           }
4813           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
4814             attr_size = apr_pstrdup(doc->pool, cur->value);
4815           }
4816           else if (STRCASEEQ('s','S',"small",cur->value)) {
4817             attr_size = apr_pstrdup(doc->pool, cur->value);
4818           }
4819           else if (STRCASEEQ('m','M',"medium",cur->value)) {
4820             attr_size = apr_pstrdup(doc->pool, cur->value);
4821           }
4822           else if (STRCASEEQ('l','L',"large",cur->value)) {
4823             attr_size = apr_pstrdup(doc->pool, cur->value);
4824           }
4825           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
4826             attr_size = apr_pstrdup(doc->pool, cur->value);
4827           }
4828           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
4829             attr_size = apr_pstrdup(doc->pool, cur->value);
4830           }
4831         }
4832       }
4833     }
4834   }
4835   W_L("<blink");
4836   if (attr_color || attr_size) {
4837     W_L(" style=\"");
4838     if (attr_color) {
4839       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4840       W_L("color:");
4841       W_V(attr_color);
4842       W_L(";");
4843     }
4844     if (attr_size) {
4845       W_L("font-size:");
4846       W_V(attr_size);
4847       W_L(";");
4848     }
4849     W_L("\"");
4850   }
4851   W_L(">");
4852   return xhtml->out;
4853 }
4854
4855
4856 /**
4857  * It is a handler who processes the BLINK tag.
4858  *
4859  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4860  *                     destination is specified.
4861  * @param node   [i]   The BLINK tag node is specified.
4862  * @return The conversion result is returned.
4863  */
4864 static char *
4865 s_xhtml_1_0_end_blink_tag(void *pdoc, Node *UNUSED(node))
4866 {
4867   xhtml_t *xhtml = GET_XHTML(pdoc);
4868   Doc     *doc   = xhtml->doc;
4869   W_L("</blink>");
4870   if (IS_CSS_ON(xhtml->entryp)) {
4871     chxj_css_pop_prop_list(xhtml->css_prop_stack);
4872   }
4873   return xhtml->out;
4874 }
4875
4876
4877 /**
4878  * It is a handler who processes the MARQUEE tag.
4879  *
4880  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
4881  *                     destination is specified.
4882  * @param node   [i]   The MARQUEE tag node is specified.
4883  * @return The conversion result is returned.
4884  */
4885 static char *
4886 s_xhtml_1_0_start_marquee_tag(void *pdoc, Node *node)
4887 {
4888   xhtml_t   *xhtml = GET_XHTML(pdoc);
4889   Doc       *doc = xhtml->doc;
4890   Attr      *attr;
4891   char      *attr_direction = NULL;
4892   char      *attr_behavior  = NULL;
4893   char      *attr_loop      = NULL;
4894   char      *attr_style     = NULL;
4895   char      *attr_color     = NULL;
4896   char      *attr_size      = NULL;
4897   char      *attr_bgcolor   = NULL;
4898   /*--------------------------------------------------------------------------*/
4899   /* Get Attributes                                                           */
4900   /*--------------------------------------------------------------------------*/
4901   for (attr = qs_get_attr(doc,node);
4902        attr;
4903        attr = qs_get_next_attr(doc,attr)) {
4904     char *name   = qs_get_attr_name(doc,attr);
4905     char *value  = qs_get_attr_value(doc,attr);
4906     if (STRCASEEQ('d','D',"direction", name)) {
4907       if (value) {
4908         if (STRCASEEQ('l','L',"left",value)) {
4909           attr_direction = "rtl";
4910         }
4911         else if (STRCASEEQ('r','R',"right",value)) {
4912           attr_direction = "ltr";
4913         }
4914       }
4915     }
4916     else if (STRCASEEQ('b','B',"behavior",name) && value && *value) {
4917       if (STRCASEEQ('s','S',"scroll",value) || STRCASEEQ('s','S',"slide",value) || STRCASEEQ('a','A',"alternate",value)) {
4918         attr_behavior = value;
4919       }
4920     }
4921     else if (STRCASEEQ('l','L',"loop",name) && value && *value) {
4922       attr_loop = value;
4923     }
4924     else if (STRCASEEQ('b','B',"bgcolor",name)) {
4925       if (value && *value) {
4926         attr_bgcolor = value;
4927       }
4928     }
4929     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
4930       attr_style = value;
4931     }
4932   }
4933   if (IS_CSS_ON(xhtml->entryp)) {
4934     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
4935     if (style) {
4936       css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4937       css_property_t *size_prop  = chxj_css_get_property_value(doc, style, "font-size");
4938       css_property_t *bgcolor_prop  = chxj_css_get_property_value(doc, style, "background-color");
4939       css_property_t *direction_prop  = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
4940       css_property_t *behavior_prop  = chxj_css_get_property_value(doc, style, "-wap-marquee-style");
4941       css_property_t *loop_prop  = chxj_css_get_property_value(doc, style, "-wap-marquee-loop");
4942       css_property_t *cur;
4943       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4944         if (cur->value && *cur->value) {
4945           attr_color = apr_pstrdup(doc->pool, cur->value);
4946         }
4947       }
4948       for (cur = bgcolor_prop->next; cur != bgcolor_prop; cur = cur->next) {
4949         if (cur->value && *cur->value) {
4950           attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
4951         }
4952       }
4953       for (cur = direction_prop->next; cur != direction_prop; cur = cur->next) {
4954         if (cur->value && *cur->value) {
4955           attr_direction = apr_pstrdup(doc->pool, cur->value);
4956         }
4957       }
4958       for (cur = behavior_prop->next; cur != behavior_prop; cur = cur->next) {
4959         if (cur->value && *cur->value) {
4960           if (STRCASEEQ('s','S',"scroll",cur->value) || STRCASEEQ('s','S',"slide",cur->value) || STRCASEEQ('a','A',"alternate",cur->value)) {
4961             attr_behavior = apr_pstrdup(doc->pool, cur->value);
4962           }
4963         }
4964       }
4965       for (cur = loop_prop->next; cur != loop_prop; cur = cur->next) {
4966         if (cur->value && *cur->value) {
4967           attr_loop = apr_pstrdup(doc->pool, cur->value);
4968         }
4969       }
4970       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
4971         if (cur->value && *cur->value) {
4972           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
4973             attr_size = apr_pstrdup(doc->pool, cur->value);
4974           }
4975           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
4976             attr_size = apr_pstrdup(doc->pool, cur->value);
4977           }
4978           else if (STRCASEEQ('s','S',"small",cur->value)) {
4979             attr_size = apr_pstrdup(doc->pool, cur->value);
4980           }
4981           else if (STRCASEEQ('m','M',"medium",cur->value)) {
4982             attr_size = apr_pstrdup(doc->pool, cur->value);
4983           }
4984           else if (STRCASEEQ('l','L',"large",cur->value)) {
4985             attr_size = apr_pstrdup(doc->pool, cur->value);
4986           }
4987           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
4988             attr_size = apr_pstrdup(doc->pool, cur->value);
4989           }
4990           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
4991             attr_size = apr_pstrdup(doc->pool, cur->value);
4992           }
4993         }
4994       }
4995     }
4996   }
4997   W_L("<marquee");
4998   if (attr_color || attr_size || attr_direction || attr_bgcolor || attr_behavior || attr_loop) {
4999     W_L(" style=\"");
5000     if (attr_direction) {
5001       W_L("-wap-marquee-dir:");
5002       W_V(attr_direction);
5003       W_L(";");
5004     }
5005     if (attr_behavior) {
5006       W_L("-wap-marquee-style:");
5007       W_V(attr_behavior);
5008       W_L(";");
5009     }
5010     if (attr_loop) {
5011       W_L("-wap-marquee-loop:");
5012       W_V(attr_loop);
5013       W_L(";");
5014     }
5015     if (attr_bgcolor) {
5016       attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
5017       W_L("background-color:");
5018       W_V(attr_bgcolor);
5019       W_L(";");
5020     }
5021     if (attr_color) {
5022       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
5023       W_L("color:");
5024       W_V(attr_color);
5025       W_L(";");
5026     }
5027     if (attr_size) {
5028       W_L("font-size:");
5029       W_V(attr_size);
5030       W_L(";");
5031     }
5032     W_L("\"");
5033   }
5034   W_L(">");
5035
5036   return xhtml->out;
5037 }
5038
5039
5040 /**
5041  * It is a handler who processes the MARQUEE tag.
5042  *
5043  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
5044  *                     destination is specified.
5045  * @param node   [i]   The MARQUEE tag node is specified.
5046  * @return The conversion result is returned.
5047  */
5048 static char *
5049 s_xhtml_1_0_end_marquee_tag(void *pdoc, Node *UNUSED(child))
5050 {
5051   xhtml_t *xhtml = GET_XHTML(pdoc);
5052   Doc     *doc = xhtml->doc;
5053   W_L("</marquee>");
5054   if (IS_CSS_ON(xhtml->entryp)) {
5055     chxj_css_pop_prop_list(xhtml->css_prop_stack);
5056   }
5057   return xhtml->out;
5058 }
5059
5060
5061 /**
5062  * It is handler who processes the New Line Code.
5063  */
5064 static char *
5065 s_xhtml_1_0_newline_mark(void *pdoc, Node *UNUSED(node))
5066 {
5067   xhtml_t *xhtml = GET_XHTML(pdoc);
5068   Doc *doc = xhtml->doc;
5069   if (xhtml->start_html_flag) {
5070     W_NLCODE();
5071   }
5072   return xhtml->out;
5073 }
5074
5075
5076 /**
5077  * It is a handler who processes the LINK tag.
5078  *
5079  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
5080  *                     destination is specified.
5081  * @param node   [i]   The LINK tag node is specified.
5082  * @return The conversion result is returned.
5083  */
5084 static char *
5085 s_xhtml_1_0_link_tag(void *pdoc, Node *node)
5086 {
5087   xhtml_t       *xhtml;
5088   Doc           *doc;
5089   Attr          *attr;
5090   char          *rel  = NULL;
5091   char          *href = NULL;
5092   char          *type = NULL;
5093
5094   xhtml = GET_XHTML(pdoc);
5095   doc   = xhtml->doc;
5096
5097   if (! IS_CSS_ON(xhtml->entryp)) {
5098     return xhtml->out;
5099   }
5100
5101   for (attr = qs_get_attr(doc,node);
5102        attr;
5103        attr = qs_get_next_attr(doc,attr)) {
5104     char *name  = qs_get_attr_name(doc,attr);
5105     char *value = qs_get_attr_value(doc,attr);
5106     if (STRCASEEQ('r','R',"rel", name)) {
5107       if (value && *value && STRCASEEQ('s','S',"stylesheet", value)) {
5108         rel = value;
5109       }
5110     }
5111     else if (STRCASEEQ('h','H',"href", name)) {
5112       if (value && *value) {
5113         href = value;
5114       }
5115     }
5116     else if (STRCASEEQ('t','T',"type", name)) {
5117       if (value && *value && STRCASEEQ('t','T',"text/css",value)) {
5118         type = value;
5119       }
5120     }
5121   }
5122
5123   if (rel && href && type) {
5124     DBG(doc->r, "start load CSS. url:[%s]", href);
5125     xhtml->style = chxj_css_parse_from_uri(doc->r, doc->pool, xhtml->style, href);
5126     DBG(doc->r, "end load CSS. url:[%s]", href);
5127   }
5128
5129   return xhtml->out;
5130 }
5131
5132 static css_prop_list_t *
5133 s_xhtml_1_0_push_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value)
5134 {
5135   xhtml_t *xhtml = GET_XHTML(pdoc);
5136   Doc *doc = xhtml->doc;
5137   css_prop_list_t *last_css = NULL;
5138   if (IS_CSS_ON(xhtml->entryp)) {
5139     css_prop_list_t *dup_css;
5140     css_selector_t  *selector;
5141
5142     last_css = chxj_css_get_last_prop_list(xhtml->css_prop_stack);
5143     dup_css  = chxj_dup_css_prop_list(doc, last_css);
5144     selector = chxj_css_find_selector(doc, xhtml->style, node);
5145     if (selector) {
5146       chxj_css_prop_list_merge_property(doc, dup_css, selector);
5147     }
5148     chxj_css_push_prop_list(xhtml->css_prop_stack, dup_css);
5149     last_css = chxj_css_get_last_prop_list(xhtml->css_prop_stack);
5150
5151     if (style_attr_value) {
5152       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));
5153       if (ssheet) {
5154         chxj_css_prop_list_merge_property(doc, last_css, ssheet->selector_head.next);
5155       }
5156     }
5157   }
5158   return last_css;
5159 }
5160
5161
5162 static css_prop_list_t *
5163 s_xhtml_1_0_nopush_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value)
5164 {
5165   xhtml_t *xhtml = GET_XHTML(pdoc);
5166   Doc *doc = xhtml->doc;
5167   css_prop_list_t *last_css = NULL;
5168   if (IS_CSS_ON(xhtml->entryp)) {
5169     css_prop_list_t *dup_css;
5170     css_selector_t  *selector;
5171
5172     last_css = chxj_css_get_last_prop_list(xhtml->css_prop_stack);
5173     dup_css  = chxj_dup_css_prop_list(doc, last_css);
5174     selector = chxj_css_find_selector(doc, xhtml->style, node);
5175     if (selector) {
5176       chxj_css_prop_list_merge_property(doc, dup_css, selector);
5177     }
5178     last_css = dup_css;
5179
5180     if (style_attr_value) {
5181       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));
5182       if (ssheet) {
5183         chxj_css_prop_list_merge_property(doc, last_css, ssheet->selector_head.next);
5184       }
5185     }
5186   }
5187   return last_css;
5188 }
5189
5190
5191 /**
5192  * It is a handler who processes the SPAN tag.
5193  *
5194  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
5195  *                     destination is specified.
5196  * @param node   [i]   The SPAN tag node is specified.
5197  * @return The conversion result is returned.
5198  */
5199 static char *
5200 s_xhtml_1_0_start_span_tag(void *pdoc, Node *node)
5201 {
5202   xhtml_t *xhtml;
5203   Doc *doc;
5204   Attr *attr;
5205   char *attr_style = NULL;
5206   char *attr_color = NULL;
5207   char *attr_size = NULL;
5208   char *attr_align = NULL;
5209   char *attr_blink = NULL;
5210   char *attr_marquee = NULL;
5211   char *attr_marquee_dir = NULL;
5212   char *attr_marquee_style = NULL;
5213   char *attr_marquee_loop = NULL;
5214
5215   xhtml = GET_XHTML(pdoc);
5216   doc     = xhtml->doc;
5217
5218   for (attr = qs_get_attr(doc,node);
5219        attr;
5220        attr = qs_get_next_attr(doc,attr)) {
5221     char *nm  = qs_get_attr_name(doc,attr);
5222     char *val = qs_get_attr_value(doc,attr);
5223     if (val && STRCASEEQ('s','S',"style", nm)) {
5224       attr_style = val;
5225     }
5226   }
5227   if (IS_CSS_ON(xhtml->entryp)) {
5228     css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style);
5229     if (style) {
5230       css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
5231       css_property_t *size_prop = chxj_css_get_property_value(doc, style, "font-size");
5232       css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
5233       css_property_t *decoration_prop = chxj_css_get_property_value(doc, style, "text-decoration");
5234       css_property_t *display_prop = chxj_css_get_property_value(doc, style, "display");
5235       css_property_t *marquee_dir_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
5236       css_property_t *marquee_style_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-style");
5237       css_property_t *marquee_loop_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-loop");
5238       css_property_t *cur;
5239       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
5240         attr_color = apr_pstrdup(doc->pool, cur->value);
5241       }
5242       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
5243         if (cur->value && *cur->value) {
5244           if ( STRCASEEQ('x','X',"xx-small",cur->value)
5245             || STRCASEEQ('x','X',"x-small", cur->value)
5246             || STRCASEEQ('s','S',"small",   cur->value)
5247             || STRCASEEQ('m','M',"medium",  cur->value)
5248             || STRCASEEQ('l','L',"large",   cur->value)
5249             || STRCASEEQ('x','X',"x-large", cur->value)
5250             || STRCASEEQ('x','X',"xx-large",cur->value)) {
5251             attr_size = apr_pstrdup(doc->pool, cur->value);
5252           }
5253         }
5254       }
5255       for (cur = decoration_prop->next; cur != decoration_prop; cur = cur->next) {
5256         if (cur->value && STRCASEEQ('b','B',"blink",cur->value)) {
5257           attr_blink = apr_pstrdup(doc->pool, cur->value);
5258         }
5259       }
5260       for (cur = display_prop->next; cur != display_prop; cur = cur->next) {
5261         if (cur->value && strcasecmp("-wap-marquee",cur->value) == 0) {
5262           attr_marquee = apr_pstrdup(doc->pool, cur->value);
5263         }
5264       }
5265       for (cur = marquee_dir_prop->next; cur != marquee_dir_prop; cur = cur->next) {
5266         if (cur->value && *cur->value) {
5267           if ( STRCASEEQ('l','L',"ltr",cur->value)
5268             || STRCASEEQ('r','R',"rtl",cur->value)) {
5269             attr_marquee_dir = apr_pstrdup(doc->pool, cur->value);
5270           }
5271         }
5272       }
5273       for (cur = marquee_style_prop->next; cur != marquee_style_prop; cur = cur->next) {
5274         if (cur->value && *cur->value) {
5275           if ( STRCASEEQ('s','S',"scroll",cur->value)
5276             || STRCASEEQ('s','S',"slide",cur->value)
5277             || STRCASEEQ('a','A',"alternate",cur->value)) {
5278             attr_marquee_style = apr_pstrdup(doc->pool, cur->value);
5279           }
5280         }
5281       }
5282       for (cur = marquee_loop_prop->next; cur != marquee_loop_prop; cur = cur->next) {
5283         if (cur->value && *cur->value) {
5284           attr_marquee_loop = apr_pstrdup(doc->pool, cur->value);
5285         }
5286       }
5287       for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
5288         if (STRCASEEQ('l','L',"left", cur->value)) {
5289           attr_align = apr_pstrdup(doc->pool, "left");
5290         }
5291         else if (STRCASEEQ('c','C',"center",cur->value)) {
5292           attr_align = apr_pstrdup(doc->pool, "center");
5293         }
5294         else if (STRCASEEQ('r','R',"right",cur->value)) {
5295           attr_align = apr_pstrdup(doc->pool, "right");
5296         }
5297       }
5298     }
5299   }
5300
5301   W_L("<span");
5302   if (attr_color || attr_size || attr_align || attr_blink || attr_marquee) {
5303     W_L(" style=\"");
5304     if (attr_color) {
5305       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
5306       W_L("color:");
5307       W_V(attr_color);
5308       W_L(";");
5309     }
5310     if (attr_size) {
5311       W_L("font-size:");
5312       W_V(attr_size);
5313       W_L(";");
5314     }
5315     if (attr_align) {
5316       W_L("text-align:");
5317       W_V(attr_align);
5318       W_L(";");
5319     }
5320     if (attr_blink) {
5321       W_L("text-decoration:");
5322       W_V("blink");
5323       W_L(";");
5324     }
5325     if (attr_marquee) {
5326       W_L("display:-wap-marquee;");
5327       if (attr_marquee_dir) {
5328         W_L("-wap-marquee-dir:");
5329         W_V(attr_marquee_dir);
5330         W_L(";");
5331       }
5332       if (attr_marquee_style) {
5333         W_L("-wap-marquee-style:");
5334         W_V(attr_marquee_style);
5335         W_L(";");
5336       }
5337       if (attr_marquee_loop) {
5338         W_L("-wap-marquee-loop:");
5339         W_V(attr_marquee_loop);
5340         W_L(";");
5341       }
5342     }
5343     W_L("\"");
5344   }
5345   W_L(">");
5346   return xhtml->out;
5347 }
5348
5349
5350 /**
5351  * It is a handler who processes the SPAN tag.
5352  *
5353  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
5354  *                     destination is specified.
5355  * @param node   [i]   The SPAN tag node is specified.
5356  * @return The conversion result is returned.
5357  */
5358 static char *
5359 s_xhtml_1_0_end_span_tag(void *pdoc, Node *UNUSED(node))
5360 {
5361   xhtml_t *xhtml = GET_XHTML(pdoc);
5362   Doc *doc = xhtml->doc;
5363
5364   W_L("</span>");
5365   if (IS_CSS_ON(xhtml->entryp)) {
5366     chxj_css_pop_prop_list(xhtml->css_prop_stack);
5367   }
5368   return xhtml->out;
5369 }
5370
5371
5372 /**
5373  * It is a handler who processes the STYLE tag.
5374  *
5375  * @param pdoc  [i/o] The pointer to the XHTML structure at the output
5376  *                     destination is specified.
5377  * @param node   [i]   The STYLE tag node is specified.
5378  * @return The conversion result is returned.
5379  */
5380 static char *
5381 s_xhtml_1_0_style_tag(void *pdoc, Node *node)
5382 {
5383   xhtml_t     *xhtml;
5384   Doc           *doc;
5385   Attr          *attr;
5386   char          *type = NULL;
5387
5388   xhtml = GET_XHTML(pdoc);
5389   doc     = xhtml->doc;
5390
5391   if (! IS_CSS_ON(xhtml->entryp)) {
5392     return xhtml->out;
5393   }
5394
5395   for (attr = qs_get_attr(doc,node);
5396        attr;
5397        attr = qs_get_next_attr(doc,attr)) {
5398     char *name  = qs_get_attr_name(doc,attr);
5399     char *value = qs_get_attr_value(doc,attr);
5400     if (STRCASEEQ('t','T',"type", name)) {
5401       if (value && *value && STRCASEEQ('t','T',"text/css",value)) {
5402         type = value;
5403       }
5404     }
5405   }
5406
5407   Node *child = qs_get_child_node(doc, node);
5408   if (type && child) {
5409     char *name  = qs_get_node_name(doc, child);
5410     if (STRCASEEQ('t','T',"text", name)) {
5411       char *value = qs_get_node_value(doc, child);
5412       DBG(doc->r, "start load CSS. buf:[%s]", value);
5413       xhtml->style = chxj_css_parse_style_value(doc, xhtml->style, value);
5414       DBG(doc->r, "end load CSS. value:[%s]", value);
5415     }
5416   }
5417   return xhtml->out;
5418 }
5419 /*
5420  * vim:ts=2 et
5421  */