OSDN Git Service

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