OSDN Git Service

* changed feature.
[modchxj/mod_chxj.git] / src / chxj_jxhtml.c
old mode 100755 (executable)
new mode 100644 (file)
index 200be99..d9e793e
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2009 Atsushi Konno All rights reserved.
+ * Copyright (C) 2005-2011 Atsushi Konno All rights reserved.
  * Copyright (C) 2005 QSDN,Inc. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -137,6 +137,8 @@ static char *s_jxhtml_style_tag       (void *pdoc, Node *node);
 static char *s_jxhtml_start_object_tag     (void *pdoc, Node *node);
 static char *s_jxhtml_end_object_tag       (void *pdoc, Node *node);
 static char *s_jxhtml_start_param_tag     (void *pdoc, Node *node);
+static char *s_jxhtml_start_caption_tag     (void *pdoc, Node *node);
+static char *s_jxhtml_end_caption_tag       (void *pdoc, Node *node);
 
 static void  s_init_jxhtml(jxhtml_t *jxhtml, Doc *doc, request_rec *r, device_table *spec);
 
@@ -438,6 +440,11 @@ tag_handler jxhtml_handler[] = {
     s_jxhtml_start_param_tag,
     NULL,
   },
+  /* tagCAPTION */
+  {
+    s_jxhtml_start_caption_tag,
+    s_jxhtml_end_caption_tag,
+  },
 };
 
 
@@ -474,10 +481,9 @@ chxj_convert_jxhtml(
   *dstlen = srclen;
   dst = chxj_qr_code_blob_handler(r, src, (size_t*)dstlen);
   if (dst) {
-    DBG(r,"I found qrcode xml");
+    DBG(r,"REQ[%X] I found qrcode xml",TO_ADDR(r));
     return dst;
   }
-  DBG(r,"not found qrcode xml");
 
   /*--------------------------------------------------------------------------*/
   /* The CHTML structure is initialized.                                      */
@@ -486,7 +492,9 @@ chxj_convert_jxhtml(
 
   jxhtml.entryp = entryp;
   jxhtml.cookie = cookie;
-
+  if (strcasecmp(spec->output_encoding,"UTF-8") == 0 ){
+    apr_table_setn(r->headers_out,HTTP_X_CHXJ_SET_CONTENT_TYPE,"application/xhtml+xml; charset=UTF-8");
+  }
   chxj_set_content_type(r, chxj_header_inf_set_content_type(r, "application/xhtml+xml; charset=Windows-31J"));
 
   /*--------------------------------------------------------------------------*/
@@ -587,7 +595,7 @@ s_jxhtml_search_emoji(jxhtml_t *jxhtml, char *txt, char **rslt)
   len = strlen(txt);
   r = jxhtml->doc->r;
 
-  if (! spec) DBG(r,"spec is NULL");
+  if (! spec) DBG(r,"REQ[%X] spec is NULL",TO_ADDR(r));
 
   for (ee = jxhtml->conf->emoji;
        ee;
@@ -597,7 +605,7 @@ s_jxhtml_search_emoji(jxhtml_t *jxhtml, char *txt, char **rslt)
     unsigned char hex2byte;
 
     if (! ee->imode) { 
-      DBG(r,"emoji->imode is NULL");
+      DBG(r,"REQ[%X] emoji->imode is NULL",TO_ADDR(r));
       continue;
     }
 
@@ -646,7 +654,7 @@ chxj_jxhtml_emoji_only_converter(request_rec *r, device_table *spec, const char
   jxhtml = &__jxhtml;
   doc    = &__doc;
 
-  DBG(r, "REQ[%X] start chxj_jxhtml_emoji_eonly_converter()", (unsigned int)(apr_size_t)r);
+  DBG(r,"REQ[%X] start %s()",TO_ADDR(r),__func__);
   memset(doc,    0, sizeof(Doc));
   memset(jxhtml, 0, sizeof(jxhtml_t));
 
@@ -687,7 +695,7 @@ chxj_jxhtml_emoji_only_converter(request_rec *r, device_table *spec, const char
   }
   jxhtml->out = chxj_buffered_write_flush(jxhtml->out, &doc->buf);
 
-  DBG(r, "REQ[%X] end chxj_jxhtml_emoji_eonly_converter()", (unsigned int)(apr_size_t)r);
+  DBG(r,"REQ[%X] end %s()",TO_ADDR(r),__func__);
   return jxhtml->out;
 }
 
@@ -711,9 +719,11 @@ s_jxhtml_start_html_tag(void *pdoc, Node *UNUSED(node))
   jxhtml  = GET_JXHTML(pdoc);
   doc    = jxhtml->doc;
   r      = doc->r;
-  DBG(r, "REQ[%X] start s_jxhtml_start_html_tag()", TO_ADDR(r));
+  DBG(r,"REQ[%X] start %s()",TO_ADDR(r),__func__);
 
-  W_L("<?xml version=\"1.0\" encoding=\"Shift_JIS\" ?>");
+  W_L("<?xml version=\"1.0\" encoding=\"");
+  W_V(jxhtml->spec->output_encoding);
+  W_L("\" ?>");
   W_NLCODE();
   W_L("<!DOCTYPE html PUBLIC \"-//J-PHONE//DTD XHTML Basic 1.0 Plus//EN\" \"xhtml-basic10-plus.dtd\">");
   W_NLCODE();
@@ -725,7 +735,7 @@ s_jxhtml_start_html_tag(void *pdoc, Node *UNUSED(node))
 
   jxhtml->start_html_flag = 1;
 
-  DBG(r, "REQ[%X] end s_jxhtml_start_html_tag()", TO_ADDR(r));
+  DBG(r,"REQ[%X] end %s()",TO_ADDR(r),__func__);
 
   return jxhtml->out;
 }
@@ -1110,7 +1120,7 @@ s_jxhtml_start_body_tag(void *pdoc, Node *node)
   }
 
   if (IS_CSS_ON(jxhtml->entryp)) {
-    css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
+    css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
     if (style) {
       css_property_t *color_prop      = chxj_css_get_property_value(doc, style, "color");
       css_property_t *bgcolor_prop    = chxj_css_get_property_value(doc, style, "background-color");
@@ -1246,6 +1256,7 @@ s_jxhtml_start_a_tag(void *pdoc, Node *node)
   request_rec *r;
   Attr        *attr;
   char        *attr_style = NULL;
+  char        *attr_id    = NULL;
 
   jxhtml = GET_JXHTML(pdoc);
   doc   = jxhtml->doc;
@@ -1260,13 +1271,11 @@ s_jxhtml_start_a_tag(void *pdoc, Node *node)
        attr = qs_get_next_attr(doc,attr)) {
     char *name  = qs_get_attr_name(doc,attr);
     char *value = qs_get_attr_value(doc,attr);
-    if (STRCASEEQ('n','N',"name",name)) {
-      /*----------------------------------------------------------------------*/
-      /* CHTML1.0                                                             */
-      /*----------------------------------------------------------------------*/
-      W_L(" name=\"");
-      W_V(chxj_jreserved_to_safe_tag(r, value, jxhtml->entryp));
-      W_L("\"");
+    if (STRCASEEQ('i','I',"id",name)){
+      attr_id = chxj_jreserved_to_safe_tag(r, value, jxhtml->entryp);
+    }
+    else if (STRCASEEQ('n','N',"name",name)) {
+      attr_id = chxj_jreserved_to_safe_tag(r, value, jxhtml->entryp);
     }
     else if (STRCASEEQ('h','H',"href",name)) {
       /*----------------------------------------------------------------------*/
@@ -1358,10 +1367,15 @@ s_jxhtml_start_a_tag(void *pdoc, Node *node)
       attr_style = value;
     }
   }
+  if(attr_id){
+    W_L(" name=\"");
+    W_V(attr_id);
+    W_L("\"");
+  }
   W_L(">");
 
   if (IS_CSS_ON(jxhtml->entryp)) {
-    s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
+    s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
   }
 
   return jxhtml->out;
@@ -1438,17 +1452,19 @@ s_jxhtml_start_br_tag(void *pdoc, Node *node)
     }
   }
   if (IS_CSS_ON(jxhtml->entryp)) {
-    css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
+    css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
     if (style) {
       css_property_t *clear_prop = chxj_css_get_property_value(doc, style, "clear");
       css_property_t *cur;
       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
         if (cur->value && *cur->value) {
           if ( STRCASEEQ('l','L',"left",  cur->value)
-            || STRCASEEQ('r','R',"right", cur->value)
-            || STRCASEEQ('b','B',"both"  ,cur->value)) {
+            || STRCASEEQ('r','R',"right", cur->value)) {
             attr_clear = apr_pstrdup(doc->pool, cur->value);
           }
+          else if(STRCASEEQ('b','B',"both"  ,cur->value)) {
+            attr_clear = apr_pstrdup(doc->pool, "all");
+          }
         }
       }
     }
@@ -1610,7 +1626,7 @@ s_jxhtml_start_table_tag(void *pdoc, Node *node)
   }
   if (attr_height){
     W_L(" height=\"");
-    W_L(attr_height);
+    W_V(attr_height);
     W_L("\"");
   }
   if (attr_width){
@@ -2074,7 +2090,7 @@ s_jxhtml_start_font_tag(void *pdoc, Node *node)
     }
   }
   if (IS_CSS_ON(jxhtml->entryp)) {
-    css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
+    css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
     if (style) {
       css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
       css_property_t *size_prop  = chxj_css_get_property_value(doc, style, "font-size");
@@ -2228,6 +2244,7 @@ s_jxhtml_start_form_tag(void *pdoc, Node *node)
   char        *attr_color  = NULL;
   char        *attr_align  = NULL;
   char        *attr_name   = NULL;
+  char        *css_clear   = NULL;
   char        *new_hidden_tag = NULL;
 
   jxhtml  = GET_JXHTML(pdoc);
@@ -2285,10 +2302,11 @@ s_jxhtml_start_form_tag(void *pdoc, Node *node)
     }
   }
   if (IS_CSS_ON(jxhtml->entryp)) {
-    css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
+    css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
     if (style) {
       css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
       css_property_t *color_prop      = chxj_css_get_property_value(doc, style, "color");
+      css_property_t *clear_prop      = chxj_css_get_property_value(doc, style, "clear");
       css_property_t *cur;
       for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
         if (STRCASEEQ('l','L',"left", cur->value)) {
@@ -2304,6 +2322,9 @@ s_jxhtml_start_form_tag(void *pdoc, Node *node)
       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
         attr_color = apr_pstrdup(doc->pool, cur->value);
       }
+      for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
+        css_clear = apr_pstrdup(doc->pool, cur->value);
+      }
     }
   }
 
@@ -2340,6 +2361,12 @@ s_jxhtml_start_form_tag(void *pdoc, Node *node)
     W_V(attr_name);
     W_L("\"");
   }
+  if (css_clear) {
+    W_L(" style=\"");
+    W_L("clear:");
+    W_V(css_clear);
+    W_L("\"");
+  }
   W_L(">");
 
   jxhtml_flags_t *flg = (jxhtml_flags_t *)apr_palloc(doc->pool, sizeof(jxhtml_flags_t));
@@ -2394,6 +2421,23 @@ s_jxhtml_end_form_tag(void *pdoc, Node *node)
   return jxhtml->out;
 }
 
+static char *
+s_jxhtml_istyle_to_wap_input_format(apr_pool_t *p, const char *s)
+{
+  if (s) {
+    switch (s[0]) {
+    case '1': return apr_psprintf(p, "&quot;*&lt;ja:h&gt;&quot;");
+    case '2': return apr_psprintf(p, "&quot;*&lt;ja:hk&gt;&quot;");
+    case '3': return apr_psprintf(p, "&quot;*&lt;ja:en&gt;&quot;");
+    case '4': return apr_psprintf(p, "&quot;*&lt;ja:n&gt;&quot;");
+    default:
+      return apr_pstrdup(p, "");
+    }
+  }
+
+  return apr_pstrdup(p,"");
+}
+
 
 /**
  * It is a handler who processes the INPUT tag.
@@ -2522,9 +2566,23 @@ s_jxhtml_start_input_tag(void *pdoc, Node *node)
     W_L(" istyle=\"");
     W_V(attr_istyle);
     W_L("\"");
+
+    char *vv = s_jxhtml_istyle_to_wap_input_format(doc->buf.pool,attr_istyle);
+    W_L(" style=\"");
+    W_L("-wrap-input-format:");
+    W_V(vv);
+    W_L(";");
+    W_L("\"");
   }
   else if(attr_type && STRCASEEQ('p','P',"password",attr_type)) {
     W_L(" istyle=\"4\"");
+
+    char *vv = s_jxhtml_istyle_to_wap_input_format(doc->buf.pool,"4");
+    W_L(" style=\"");
+    W_L("-wrap-input-format:");
+    W_V(vv);
+    W_L(";");
+    W_L("\"");
   }
   /*--------------------------------------------------------------------------*/
   /* The figure is default for the password.                                  */
@@ -2702,7 +2760,7 @@ s_jxhtml_start_center_tag(void *pdoc, Node *node)
     }
   }
   if (IS_CSS_ON(jxhtml->entryp)) {
-    css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
+    css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
     if (style) {
       css_property_t *color_prop      = chxj_css_get_property_value(doc, style, "color");
       css_property_t *size_prop       = chxj_css_get_property_value(doc, style, "font-size");
@@ -2821,7 +2879,7 @@ s_jxhtml_start_li_tag(void *pdoc, Node *node)
     }
   }
   if (IS_CSS_ON(jxhtml->entryp)) {
-    css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
+    css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
     if (style) {
       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
       css_property_t *cur;
@@ -2912,6 +2970,7 @@ s_jxhtml_start_ol_tag(void *pdoc, Node *node)
   char        *attr_style = NULL;
   char        *attr_start = NULL;
   char        *attr_type  = NULL;
+  char        *css_clear  = NULL;
 
   jxhtml = GET_JXHTML(pdoc);
   doc   = jxhtml->doc;
@@ -2944,9 +3003,11 @@ s_jxhtml_start_ol_tag(void *pdoc, Node *node)
     }
   }
   if (IS_CSS_ON(jxhtml->entryp)) {
-    css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
+    css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
     if (style) {
       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
+      css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
+      
       css_property_t *cur;
       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
         if (STRCASEEQ('d','D',"decimal", cur->value)) {
@@ -2959,14 +3020,24 @@ s_jxhtml_start_ol_tag(void *pdoc, Node *node)
           attr_type = apr_pstrdup(doc->pool, "lower-alpha");
         }
       }
+      for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
+        css_clear = apr_pstrdup(doc->pool, cur->value);
+      }
     }
   }
   W_L("<ol");
-  if (attr_type) {
+  if (attr_type || css_clear) {
     W_L(" style=\"");
-    W_L("list-style-type:");
-    W_V(attr_type);
-    W_L(";");
+    if (attr_type) {
+      W_L("list-style-type:");
+      W_V(attr_type);
+      W_L(";");
+    }
+    if (css_clear){
+      W_L("clear:");
+      W_V(css_clear);
+      W_L(";");
+    }
     W_L("\"");
   }
   if (attr_start) {
@@ -3051,7 +3122,7 @@ s_jxhtml_start_p_tag(void *pdoc, Node *node)
     }
   }
   if (IS_CSS_ON(jxhtml->entryp)) {
-    css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
+    css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
     if (style) {
       css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
       css_property_t *color_prop      = chxj_css_get_property_value(doc, style, "color");
@@ -3152,6 +3223,7 @@ s_jxhtml_start_pre_tag(void *pdoc, Node *node)
   Doc       *doc   = jxhtml->doc;
   Attr      *attr;
   char      *attr_style = NULL;
+  char      *css_clear  = NULL;
 
   for (attr = qs_get_attr(doc,node);
        attr;
@@ -3164,11 +3236,27 @@ s_jxhtml_start_pre_tag(void *pdoc, Node *node)
   }
 
   if (IS_CSS_ON(jxhtml->entryp)) {
-    s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
+    css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
+    if (style) {
+      css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
+      
+      css_property_t *cur;
+      for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
+        css_clear = apr_pstrdup(doc->pool, cur->value);
+      }
+    }
   }
 
   jxhtml->pre_flag++;
-  W_L("<pre>");
+  W_L("<pre");
+  if (css_clear) {
+    W_L(" style=\"");
+    W_L("clear:");
+    W_V(css_clear);
+    W_L(";");
+    W_L("\"");
+  }
+  W_L(">");
   return jxhtml->out;
 }
 
@@ -3213,6 +3301,8 @@ s_jxhtml_start_ul_tag(void *pdoc, Node *node)
   Attr     *attr;
   char     *attr_type = NULL;
   char     *attr_style = NULL;
+  char     *css_clear  = NULL;
+  
   /*--------------------------------------------------------------------------*/
   /* Get Attributes                                                           */
   /*--------------------------------------------------------------------------*/
@@ -3231,9 +3321,11 @@ s_jxhtml_start_ul_tag(void *pdoc, Node *node)
     }
   }
   if (IS_CSS_ON(jxhtml->entryp)) {
-    css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
+    css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
     if (style) {
       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
+      css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
+      
       css_property_t *cur;
       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
         if (STRCASEEQ('d','D',"disc",cur->value)) {
@@ -3246,14 +3338,24 @@ s_jxhtml_start_ul_tag(void *pdoc, Node *node)
           attr_type = apr_pstrdup(doc->pool, "square");
         }
       }
+      for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
+        css_clear = apr_pstrdup(doc->pool, cur->value);
+      }
     }
   }
   W_L("<ul");
-  if (attr_type) {
+  if (attr_type || css_clear) {
     W_L(" style=\"");
-    W_L("list-style-type:");
-    W_V(attr_type);
-    W_L(";");
+    if (attr_type ){
+      W_L("list-style-type:");
+      W_V(attr_type);
+      W_L(";");
+    }
+    if (css_clear){
+      W_L("clear:");
+      W_V(css_clear);
+      W_L(";");
+    }
     W_L("\"");
   }
   W_L(">");
@@ -3307,6 +3409,7 @@ s_jxhtml_start_hr_tag(void *pdoc, Node *node)
   
   char        *style_float  = NULL;
   char        *style_border_color = NULL;
+  char        *css_clear          = NULL;
 
   jxhtml   = GET_JXHTML(pdoc);
   doc     = jxhtml->doc;
@@ -3393,6 +3496,7 @@ s_jxhtml_start_hr_tag(void *pdoc, Node *node)
       css_property_t *bgcolor_prop      = chxj_css_get_property_value(doc, style, "background-color");
       css_property_t *float_prop        = chxj_css_get_property_value(doc, style, "float");
       css_property_t *border_color_prop = chxj_css_get_property_value(doc, style, "border-color");
+      css_property_t *clear_prop        = chxj_css_get_property_value(doc, style, "clear");
       css_property_t *cur;
       
       for (cur = border_style_prop->next; cur != border_style_prop; cur = cur->next) {
@@ -3401,11 +3505,7 @@ s_jxhtml_start_hr_tag(void *pdoc, Node *node)
         }
       }
       for (cur = height_prop->next; cur != height_prop; cur = cur->next) {
-        char *tmp = apr_pstrdup(doc->pool, cur->value);
-        char *tmpp = strstr(tmp, "px");
-        if (tmpp) { 
-          attr_size = apr_pstrdup(doc->pool, tmp);
-        }
+        attr_size = apr_pstrdup(doc->pool, cur->value);
       }
       if(!attr_color){
           for(cur = bgcolor_prop->next; cur != bgcolor_prop; cur = cur->next){
@@ -3445,6 +3545,9 @@ s_jxhtml_start_hr_tag(void *pdoc, Node *node)
           style_border_color = apr_pstrdup(doc->pool, tmp);
         }
       }
+      for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
+        css_clear = apr_pstrdup(doc->pool, cur->value);
+      }
     }
   }
   W_L("<hr");
@@ -3460,12 +3563,12 @@ s_jxhtml_start_hr_tag(void *pdoc, Node *node)
       W_L("\"");
     }
   }
-  if (attr_size || attr_width || attr_noshade || style_border_color) {
+  if (attr_size || attr_width || attr_noshade || style_border_color || css_clear) {
     W_L(" style=\"");
     if (attr_size) {
       W_L("height:");
       W_V(attr_size);
-      if (!strstr(attr_size, "px")) {
+      if (chxj_chk_numeric(attr_size) == 0) {
         W_L("px");
       }
       W_L(";");
@@ -3486,6 +3589,11 @@ s_jxhtml_start_hr_tag(void *pdoc, Node *node)
       W_V(style_border_color);
       W_V(";");
     }
+    if (css_clear){
+      W_L("clear:");
+      W_V(css_clear);
+      W_L(";");
+    }
     W_L("\"");
   }
   if (attr_color) {
@@ -3534,7 +3642,6 @@ s_jxhtml_start_img_tag(void *pdoc, Node *node)
   char        *attr_src    = NULL;
   char        *attr_height = NULL;
   char        *attr_width  = NULL;
-  char        *attr_align  = NULL;
   char        *attr_alt    = NULL;
   char        *attr_style  = NULL;
   char        *attr_hspace = NULL;
@@ -3568,12 +3675,14 @@ s_jxhtml_start_img_tag(void *pdoc, Node *node)
       value = chxj_encoding_parameter(r, value, 1);
       value = chxj_jreserved_tag_to_safe_for_query_string(r, value, jxhtml->entryp, 1);
       value = chxj_add_cookie_no_update_parameter(r, value);
+      value = chxj_img_rewrite_parameter(r,jxhtml->conf,value);
       attr_src = value;
 #else
       value = chxj_img_conv(r, spec, value);
       value = chxj_encoding_parameter(r, value, 1);
       value = chxj_jreserved_tag_to_safe_for_query_string(r, value, jxhtml->entryp, 1);
       value = chxj_add_cookie_no_update_parameter(r, value);
+      value = chxj_img_rewrite_parameter(r,jxhtml->conf,value);
       attr_src = value;
 #endif
     }
@@ -3859,7 +3968,7 @@ s_jxhtml_start_select_tag(void *pdoc, Node *node)
   W_L(">");
 
   if (IS_CSS_ON(jxhtml->entryp)) {
-    s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
+    s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
   }
 
   return jxhtml->out;
@@ -3943,7 +4052,7 @@ s_jxhtml_start_option_tag(void *pdoc, Node *node)
   W_L(">");
 
   if (IS_CSS_ON(jxhtml->entryp)) {
-    s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
+    s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
   }
 
   return jxhtml->out;
@@ -4323,6 +4432,14 @@ s_jxhtml_start_textarea_tag(void *pdoc, Node *node)
     W_L(" istyle=\"");
     W_V(attr_istyle);
     W_L("\"");
+
+    char *vv = s_jxhtml_istyle_to_wap_input_format(doc->buf.pool,attr_istyle);
+        W_L(" style=\"");
+        W_L("-wap-input-format:");
+        W_V(vv);
+        W_L(";");
+        W_L("\"");
+
   }
   W_L(">");
   return jxhtml->out;
@@ -4485,6 +4602,7 @@ s_jxhtml_start_blockquote_tag(void *pdoc, Node *node)
   char     *attr_style = NULL;
   char     *attr_color = NULL;
   char     *attr_size  = NULL;
+  char     *css_clear  = NULL;
 
   jxhtml  = GET_JXHTML(pdoc);
   doc     = jxhtml->doc;
@@ -4498,10 +4616,12 @@ s_jxhtml_start_blockquote_tag(void *pdoc, Node *node)
     }
   }
   if (IS_CSS_ON(jxhtml->entryp)) {
-    css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
+    css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
     if (style) {
       css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
       css_property_t *font_size_prop = chxj_css_get_property_value(doc, style, "font-size");
+      css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
+      
       css_property_t *cur;
       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
         if (cur->value && *cur->value) {
@@ -4533,10 +4653,13 @@ s_jxhtml_start_blockquote_tag(void *pdoc, Node *node)
           }
         }
       }
+      for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
+        css_clear = apr_pstrdup(doc->pool, cur->value);
+      }
     }
   }
   W_L("<blockquote");
-  if (attr_color || attr_size) {
+  if (attr_color || attr_size || css_clear) {
     W_L(" style=\"");
     if (attr_color) {
       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
@@ -4549,6 +4672,11 @@ s_jxhtml_start_blockquote_tag(void *pdoc, Node *node)
       W_V(attr_size);
       W_L(";");
     }
+    if (css_clear){
+      W_L("clear:");
+      W_V(css_clear);
+      W_L(";");
+    }
     W_L("\"");
   }
   W_L(">");
@@ -4610,7 +4738,7 @@ s_jxhtml_start_dir_tag(void *pdoc, Node *node)
     }
   }
   if (IS_CSS_ON(jxhtml->entryp)) {
-    css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
+    css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
     if (style) {
       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
@@ -4717,6 +4845,8 @@ s_jxhtml_start_dl_tag(void *pdoc, Node *node)
   char      *attr_style = NULL;
   char      *attr_color = NULL;
   char      *attr_size  = NULL;
+  char      *css_clear  = NULL;
+  
   for (attr = qs_get_attr(doc,node);
        attr;
        attr = qs_get_next_attr(doc,attr)) {
@@ -4727,10 +4857,12 @@ s_jxhtml_start_dl_tag(void *pdoc, Node *node)
     }
   }
   if (IS_CSS_ON(jxhtml->entryp)) {
-    css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
+    css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
     if (style) {
       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
+      css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
+      
       css_property_t *cur;
       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
         if (cur->value && *cur->value) {
@@ -4762,10 +4894,13 @@ s_jxhtml_start_dl_tag(void *pdoc, Node *node)
           }
         }
       }
+      for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
+        css_clear = apr_pstrdup(doc->pool, cur->value);
+      }
     }
   }
   W_L("<dl");
-  if (attr_color || attr_size) {
+  if (attr_color || attr_size || css_clear) {
     W_L(" style=\"");
     if (attr_color) {
       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
@@ -4778,6 +4913,11 @@ s_jxhtml_start_dl_tag(void *pdoc, Node *node)
       W_V(attr_size);
       W_L(";");
     }
+    if (css_clear){
+      W_L("clear:");
+      W_V(css_clear);
+      W_L(";");
+    }
     W_L("\"");
   }
   W_L(">");
@@ -4833,7 +4973,7 @@ s_jxhtml_start_dt_tag(void *pdoc, Node *node)
     }
   }
   if (IS_CSS_ON(jxhtml->entryp)) {
-    css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
+    css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
     if (style) {
       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
@@ -4939,7 +5079,7 @@ s_jxhtml_start_dd_tag(void *pdoc, Node *node)
     }
   }
   if (IS_CSS_ON(jxhtml->entryp)) {
-    css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
+    css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
     if (style) {
       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
@@ -5056,7 +5196,7 @@ s_jxhtml_start_h1_tag(void *pdoc, Node *node)
     }
   }
   if (IS_CSS_ON(jxhtml->entryp)) {
-    css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
+    css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
     if (style) {
       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
@@ -5172,7 +5312,7 @@ s_jxhtml_start_h2_tag(void *pdoc, Node *node)
     }
   }
   if (IS_CSS_ON(jxhtml->entryp)) {
-    css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
+    css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
     if (style) {
       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
@@ -5287,7 +5427,7 @@ s_jxhtml_start_h3_tag(void *pdoc, Node *node)
     }
   }
   if (IS_CSS_ON(jxhtml->entryp)) {
-    css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
+    css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
     if (style) {
       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
@@ -5402,7 +5542,7 @@ s_jxhtml_start_h4_tag(void *pdoc, Node *node)
     }
   }
   if (IS_CSS_ON(jxhtml->entryp)) {
-    css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
+    css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
     if (style) {
       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
@@ -5518,7 +5658,7 @@ s_jxhtml_start_h5_tag(void *pdoc, Node *node)
     }
   }
   if (IS_CSS_ON(jxhtml->entryp)) {
-    css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
+    css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
     if (style) {
       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
@@ -5634,7 +5774,7 @@ s_jxhtml_start_h6_tag(void *pdoc, Node *node)
     }
   }
   if (IS_CSS_ON(jxhtml->entryp)) {
-    css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
+    css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
     if (style) {
       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
@@ -5745,7 +5885,7 @@ s_jxhtml_start_menu_tag(void *pdoc, Node *node)
     }
   }
   if (IS_CSS_ON(jxhtml->entryp)) {
-    css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
+    css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
     if (style) {
       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
@@ -5917,7 +6057,7 @@ s_jxhtml_start_blink_tag(void *pdoc, Node *node)
     }
   }
   if (IS_CSS_ON(jxhtml->entryp)) {
-    css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
+    css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
     if (style) {
       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
@@ -6049,7 +6189,7 @@ s_jxhtml_start_marquee_tag(void *pdoc, Node *node)
     }
   }
   if (IS_CSS_ON(jxhtml->entryp)) {
-    css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
+    css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
     if (style) {
       css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
       css_property_t *size_prop  = chxj_css_get_property_value(doc, style, "font-size");
@@ -6203,9 +6343,9 @@ s_jxhtml_link_tag(void *pdoc, Node *node)
   }
 
   if (rel && href && type) {
-    DBG(doc->r, "start load CSS. url:[%s]", href);
+    DBG(doc->r,"REQ[%X] start load CSS. url:[%s]", TO_ADDR(doc->r),href);
     jxhtml->style = chxj_css_parse_from_uri(doc->r, doc->pool, jxhtml->style, href);
-    DBG(doc->r, "end load CSS. url:[%s]", href);
+    DBG(doc->r,"REQ[%X] end load CSS. url:[%s]", TO_ADDR(doc->r),href);
   }
 
   return jxhtml->out;
@@ -6309,7 +6449,7 @@ s_jxhtml_start_span_tag(void *pdoc, Node *node)
     }
   }
   if (IS_CSS_ON(jxhtml->entryp)) {
-    css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
+    css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
     if (style) {
       css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
       css_property_t *size_prop = chxj_css_get_property_value(doc, style, "font-size");
@@ -6510,9 +6650,9 @@ s_jxhtml_style_tag(void *pdoc, Node *node)
     char *name  = qs_get_node_name(doc, child);
     if (STRCASEEQ('t','T',"text", name)) {
       char *value = qs_get_node_value(doc, child);
-      DBG(doc->r, "start load CSS. buf:[%s]", value);
+      DBG(doc->r,"REQ[%X] start load CSS. buf:[%s]", TO_ADDR(doc->r),value);
       jxhtml->style = chxj_css_parse_style_value(doc, jxhtml->style, value);
-      DBG(doc->r, "end load CSS. value:[%s]", value);
+      DBG(doc->r,"REQ[%X] end load CSS. value:[%s]", TO_ADDR(doc->r),value);
     }
   }
   return jxhtml->out;
@@ -6651,9 +6791,9 @@ s_jxhtml_start_param_tag(void *pdoc, Node *node)
   Doc *doc = jxhtml->doc;
 
   Attr *attr;
-  char *attr_style         = NULL;
   char *attr_name          = NULL;
   char *attr_value         = NULL;
+  char *attr_valuetype     = NULL;
   
   /*--------------------------------------------------------------------------*/
   /* Get Attributes                                                           */
@@ -6669,6 +6809,9 @@ s_jxhtml_start_param_tag(void *pdoc, Node *node)
     else if (STRCASEEQ('v','V',"value",name)) {
       attr_value = apr_pstrdup(doc->pool, value);
     }
+    else if (STRCASEEQ('v','V',"valuetype",name)) {
+      attr_valuetype = apr_pstrdup(doc->pool, value);
+    }
   }
   W_L("<param");
   
@@ -6682,9 +6825,88 @@ s_jxhtml_start_param_tag(void *pdoc, Node *node)
     W_V(attr_value);
     W_L("\"");
   }
-  W_L("/>");
+  if(attr_valuetype){
+    W_L(" valuetype=\"");
+    W_V(attr_valuetype);
+    W_L("\"");
+  }
+  W_L(" />");
   return jxhtml->out;
 }
+/**
+ * It is a handler who processes the CAPTION tag.
+ *
+ * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The CAPTION tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char *
+s_jxhtml_start_caption_tag(void *pdoc, Node *node)
+{
+  jxhtml_t    *jxhtml;
+  Doc         *doc;
+  request_rec *r;
+  Attr        *attr;
+  char        *attr_style = NULL;
+  char        *attr_align = NULL;
+
+  jxhtml = GET_JXHTML(pdoc);
+  doc    = jxhtml->doc;
+  r      = doc->r;
+
+  for (attr = qs_get_attr(doc,node);
+       attr;
+       attr = qs_get_next_attr(doc,attr)) {
+    char *name  = qs_get_attr_name(doc,attr);
+    char *value = qs_get_attr_value(doc,attr);
+    if (STRCASEEQ('a','A',"align", name)) {
+      if (value && 
+          (STRCASEEQ('l','L',"left",value) 
+        || STRCASEEQ('r','R',"right",value) 
+        || STRCASEEQ('t','T',"top",value)
+        || STRCASEEQ('b','B',"bottom",value) 
+        )) {
+        attr_align = value;
+      }
+    }
+    else if (STRCASEEQ('s','S',"style",name) && value && *value) {
+      attr_style = value;
+    }
+  }
+  
+  W_L("<caption");
+  if(attr_align){
+    W_L(" align=\"");
+    W_V(attr_align);
+    W_L("\"");
+  }
+  W_L(">");
+
+  return jxhtml->out;
+}
+
+
+/**
+ * It is a handler who processes the CAPTION tag.
+ *
+ * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The CAPTION tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char *
+s_jxhtml_end_caption_tag(void *pdoc, Node *UNUSED(child)) 
+{
+  jxhtml_t*    jxhtml = GET_JXHTML(pdoc);
+  Doc*          doc   = jxhtml->doc;
+  
+  W_L("</caption>");
+  
+  return jxhtml->out;
+}
+
+
 /*
  * vim:ts=2 et
  */