/*
- * Copyright (C) 2005-2008 QSDN,Inc. All rights reserved.
+ * Copyright (C) 2005-2009 QSDN,Inc. All rights reserved.
* Copyright (C) 2005 Atsushi Konno All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
},
{
.type = CHXJ_SPEC_Chtml_4_0,
- .handler = chtml30_handler,
+ .handler = chtml40_handler,
},
{
.type = CHXJ_SPEC_Chtml_5_0,
- .handler = chtml30_handler,
+ .handler = chtml50_handler,
},
{
.type = CHXJ_SPEC_Chtml_6_0,
- .handler = chtml30_handler,
+ .handler = ixhtml10_handler,
},
{
.type = CHXJ_SPEC_Chtml_7_0,
- .handler = chtml30_handler,
+ .handler = ixhtml10_handler,
},
{
.type = CHXJ_SPEC_XHtml_Mobile_1_0,
.handler = jhtml_handler,
},
{
+ .type = CHXJ_SPEC_Jxhtml,
+ .handler = jxhtml_handler,
+ },
+ {
.type = CHXJ_SPEC_HTML,
.handler = NULL,
},
for (child = qs_get_child_node(doc,node);
child;
child = qs_get_next_node(doc,child)) {
-
- char *name;
-
- name = qs_get_node_name(doc,child);
-
+ char *name = qs_get_node_name(doc,child);
switch(*name) {
case 'h':
case 'H':
if (handlers[tagH6].end_tag_handler)
handlers[tagH6].end_tag_handler(pdoc, child);
}
+ else {
+ chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
+ }
break;
if (handlers[tagP].end_tag_handler)
handlers[tagP].end_tag_handler(pdoc, child);
}
- else
/*----------------------------------------------------------------------*/
/* <PRE> */
/*----------------------------------------------------------------------*/
- if (strcasecmp(name, "pre") == 0) {
+ else if (strcasecmp(name, "pre") == 0) {
if (handlers[tagPRE].start_tag_handler)
handlers[tagPRE].start_tag_handler(pdoc, child);
if (handlers[tagPRE].end_tag_handler)
handlers[tagPRE].end_tag_handler(pdoc, child);
}
+ /*----------------------------------------------------------------------*/
+ /* <PLAINTEXT> */
+ /*----------------------------------------------------------------------*/
+ else if (strcasecmp(name, "plaintext") == 0) {
+ if (handlers[tagPLAINTEXT].start_tag_handler)
+ handlers[tagPLAINTEXT].start_tag_handler(pdoc, child);
+
+ if (handlers[tagPLAINTEXT].end_tag_handler)
+ handlers[tagPLAINTEXT].end_tag_handler(pdoc, child);
+ }
+ /*----------------------------------------------------------------------*/
+ /* <PARAM> */
+ /*----------------------------------------------------------------------*/
+ else if (strcasecmp(name, "param") == 0) {
+ if (handlers[tagPARAM].start_tag_handler)
+ handlers[tagPARAM].start_tag_handler(pdoc, child);
+
+ chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
+
+ if (handlers[tagPARAM].end_tag_handler)
+ handlers[tagPARAM].end_tag_handler(pdoc, child);
+ }
+ else {
+ chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
+ }
break;
case 'n':
if (handlers[tagNOBR].end_tag_handler)
handlers[tagNOBR].end_tag_handler(pdoc, child);
}
+ else {
+ chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
+ }
break;
case 'u':
if (handlers[tagUL].end_tag_handler)
handlers[tagUL].end_tag_handler(pdoc, child);
}
+ else {
+ chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
+ }
break;
case 'l':
if (handlers[tagLABEL].end_tag_handler)
handlers[tagLABEL].end_tag_handler(pdoc, child);
}
+ else
+ /*----------------------------------------------------------------------*/
+ /* <LINK> */
+ /*----------------------------------------------------------------------*/
+ if (strcasecmp(name, "link") == 0) {
+ if (handlers[tagLINK].start_tag_handler)
+ handlers[tagLINK].start_tag_handler(pdoc, child);
+
+ chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
+
+ if (handlers[tagLINK].end_tag_handler)
+ handlers[tagLINK].end_tag_handler(pdoc, child);
+ }
+ else {
+ chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
+ }
break;
if (handlers[tagOPTION].end_tag_handler)
handlers[tagOPTION].end_tag_handler(pdoc, child);
}
+ else
+ /*----------------------------------------------------------------------*/
+ /* <OBJECT> */
+ /*----------------------------------------------------------------------*/
+ if (strcasecmp(name, "object") == 0) {
+ if (handlers[tagOBJECT].start_tag_handler)
+ handlers[tagOBJECT].start_tag_handler(pdoc, child);
+
+ chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
+
+ if (handlers[tagOBJECT].end_tag_handler)
+ handlers[tagOBJECT].end_tag_handler(pdoc, child);
+ }
+ else {
+ chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
+ }
break;
if (handlers[tagMETA].end_tag_handler)
handlers[tagMETA].end_tag_handler(pdoc, child);
}
+ /*----------------------------------------------------------------------*/
+ /* <MENU> */
+ /*----------------------------------------------------------------------*/
+ else if (strcasecmp(name, "menu") == 0) {
+ if (handlers[tagMENU].start_tag_handler)
+ handlers[tagMENU].start_tag_handler(pdoc, child);
+
+ chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
+
+ if (handlers[tagMENU].end_tag_handler)
+ handlers[tagMENU].end_tag_handler(pdoc, child);
+ }
+ /*----------------------------------------------------------------------*/
+ /* <MARQUEE> */
+ /*----------------------------------------------------------------------*/
+ else if (strcasecmp(name, "marquee") == 0) {
+ if (handlers[tagMARQUEE].start_tag_handler)
+ handlers[tagMARQUEE].start_tag_handler(pdoc, child);
+
+ chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
+
+ if (handlers[tagMARQUEE].end_tag_handler)
+ handlers[tagMARQUEE].end_tag_handler(pdoc, child);
+ }
+ else {
+ chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
+ }
break;
case 'b':
/*----------------------------------------------------------------------*/
/* <BR> */
/*----------------------------------------------------------------------*/
- else
- if (strcasecmp(name, "br") == 0) {
+ else if (strcasecmp(name, "br") == 0) {
if (handlers[tagBR].start_tag_handler)
handlers[tagBR].start_tag_handler(pdoc, child);
if (handlers[tagBR].end_tag_handler)
handlers[tagBR].end_tag_handler(pdoc, child);
}
+ /*----------------------------------------------------------------------*/
+ /* <BLOCKQUOTE> */
+ /*----------------------------------------------------------------------*/
+ else if (strcasecmp(name, "blockquote") == 0) {
+ if (handlers[tagBLOCKQUOTE].start_tag_handler)
+ handlers[tagBLOCKQUOTE].start_tag_handler(pdoc, child);
+
+ chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
+
+ if (handlers[tagBLOCKQUOTE].end_tag_handler)
+ handlers[tagBLOCKQUOTE].end_tag_handler(pdoc, child);
+ }
+ /*----------------------------------------------------------------------*/
+ /* <BLINK> */
+ /*----------------------------------------------------------------------*/
+ else if (strcasecmp(name, "blink") == 0) {
+ if (handlers[tagBLINK].start_tag_handler)
+ handlers[tagBLINK].start_tag_handler(pdoc, child);
+
+ chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
+
+ if (handlers[tagBLINK].end_tag_handler)
+ handlers[tagBLINK].end_tag_handler(pdoc, child);
+ }
+ else {
+ chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
+ }
break;
case 'a':
if (handlers[tagA].end_tag_handler)
handlers[tagA].end_tag_handler(pdoc, child);
}
+ else {
+ chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
+ }
break;
case 'f':
if (handlers[tagFIELDSET].end_tag_handler)
handlers[tagFIELDSET].end_tag_handler(pdoc, child);
}
+ else {
+ chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
+ }
break;
case 'i':
if (handlers[tagIMG].end_tag_handler)
handlers[tagIMG].end_tag_handler(pdoc, child);
}
+ else {
+ chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
+ }
break;
case 's':
if (strcasecmp(name, "style") == 0) {
if (handlers[tagSTYLE].start_tag_handler)
handlers[tagSTYLE].start_tag_handler(pdoc, child);
+#if 0
+ chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
+#endif
+
if (handlers[tagSTYLE].end_tag_handler)
handlers[tagSTYLE].end_tag_handler(pdoc, child);
}
if (handlers[tagSMALL].end_tag_handler)
handlers[tagSMALL].end_tag_handler(pdoc, child);
}
+ /*----------------------------------------------------------------------*/
+ /* <SCRIPT> */
+ /*----------------------------------------------------------------------*/
+ else
+ if (strcasecmp(name, "script") == 0) {
+ /* ignore script block */
+ }
+ else {
+ chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
+ }
break;
case 'd':
handlers[tagDIV].end_tag_handler(pdoc, child);
}
/*----------------------------------------------------------------------*/
+ /* <DIR> */
+ /*----------------------------------------------------------------------*/
+ else if (strcasecmp(name, "dir") == 0) {
+ if (handlers[tagDIR].start_tag_handler)
+ handlers[tagDIR].start_tag_handler(pdoc, child);
+
+ chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
+
+ if (handlers[tagDIR].end_tag_handler)
+ handlers[tagDIR].end_tag_handler(pdoc, child);
+ }
+ /*----------------------------------------------------------------------*/
/* <DL> */
/*----------------------------------------------------------------------*/
- else
- if (strcasecmp(name, "dl") == 0) {
+ else if (strcasecmp(name, "dl") == 0) {
if (handlers[tagDL].start_tag_handler)
handlers[tagDL].start_tag_handler(pdoc, child);
/*----------------------------------------------------------------------*/
/* <DT> */
/*----------------------------------------------------------------------*/
- else
- if (strcasecmp(name, "dt") == 0) {
+ else if (strcasecmp(name, "dt") == 0) {
if (handlers[tagDT].start_tag_handler)
handlers[tagDT].start_tag_handler(pdoc, child);
/*----------------------------------------------------------------------*/
/* <DD> */
/*----------------------------------------------------------------------*/
- else
- if (strcasecmp(name, "dd") == 0) {
+ else if (strcasecmp(name, "dd") == 0) {
if (handlers[tagDD].start_tag_handler)
handlers[tagDD].start_tag_handler(pdoc, child);
if (handlers[tagDD].end_tag_handler)
handlers[tagDD].end_tag_handler(pdoc, child);
}
+ else {
+ chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
+ }
break;
case 'c':
case 'C':
/*----------------------------------------------------------------------*/
+ /* NL (CrLf) */
+ /*----------------------------------------------------------------------*/
+ if (strcasecmp(name, QS_PARSE_NL_MARK) == 0) {
+ if (handlers[tagNLMARK].start_tag_handler)
+ handlers[tagNLMARK].start_tag_handler(pdoc, child);
+ }
+ else
+ /*----------------------------------------------------------------------*/
/* <CENTER> */
/*----------------------------------------------------------------------*/
if (strcasecmp(name, "center") == 0) {
if (handlers[tagCENTER].end_tag_handler)
handlers[tagCENTER].end_tag_handler(pdoc, child);
}
+ else
+ /*----------------------------------------------------------------------*/
+ /* <CAPTION> */
+ /*----------------------------------------------------------------------*/
+ if (strcasecmp(name, "caption") == 0) {
+ if (handlers[tagCAPTION].start_tag_handler)
+ handlers[tagCAPTION].start_tag_handler(pdoc, child);
+
+ chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
+
+ if (handlers[tagCAPTION].end_tag_handler)
+ handlers[tagCAPTION].end_tag_handler(pdoc, child);
+ }
/*----------------------------------------------------------------------*/
/* <CHXJ:IF> */
/*----------------------------------------------------------------------*/
if (chxj_chxjif_is_mine(spec, doc, child)) {
char* parse_attr;
- parse_attr = qs_get_parse_attr(doc, child, r);
+ parse_attr = qs_get_parse_attr(doc, child, r->pool);
if (parse_attr && strcasecmp(parse_attr, "true") == 0) {
chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
}
}
}
+ /*----------------------------------------------------------------------*/
+ /* <CHXJ:RAW> */
+ /*----------------------------------------------------------------------*/
+ else
+ if (strcasecmp(name, "chxj:raw") == 0) {
+ if (handlers[tagCHXJRAW].start_tag_handler) {
+ handlers[tagCHXJRAW].start_tag_handler(pdoc, child);
+ }
+ }
+ else {
+ chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
+ }
break;
case 't':
if (handlers[tagTEXT].start_tag_handler)
handlers[tagTEXT].start_tag_handler(pdoc, child);
}
+ else {
+ chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
+ }
break;
default:
return NULL;
}
+
+
+char *
+chxj_node_convert_chxjif_only(
+ request_rec *r,
+ device_table *spec,
+ const char *src,
+ apr_size_t *len
+)
+{
+ Doc doc;
+ char *dst;
+ int pass = 0;
+ apr_size_t dst_pos = 0;
+ apr_size_t ii;
+
+ memset(&doc, 0, sizeof(Doc));
+
+ apr_pool_create(&doc.pool, r->pool);
+ doc.r = r;
+
+ dst = apr_palloc(doc.pool, *len + 1);
+ memset(dst, 0, *len + 1);
+
+ for (ii =0; ii<*len; ii++) {
+ if (src[ii + 0] == '<') {
+ apr_size_t endpoint = chxj_cut_tag(&src[ii + 0], *len - ii);
+ Node *node = qs_parse_tag(&doc, &src[ii], endpoint);
+ char *name = qs_get_node_name(&doc,node);
+ if (STRCASEEQ('c','C',"chxj:if", name)) {
+ if (! chxj_chxjif_is_mine(spec, &doc, node)) {
+ pass = 1;
+ }
+ ii += endpoint;
+ }
+ else if (STRCASEEQ('/','/', "/chxj:if", name)) {
+ pass = 0;
+ ii += endpoint;
+ }
+ else {
+ if (! pass) {
+#if 0
+ memcpy(&dst[dst_pos], &src[ii], endpoint + 1);
+ dst_pos += (endpoint + 1);
+#else
+ dst[dst_pos++] = src[ii];
+#endif
+ }
+#if 0
+ ii += endpoint;
+#endif
+ }
+ }
+ else {
+ if (! pass) {
+ if (is_sjis_kanji(src[ii])) {
+ dst[dst_pos++] = src[ii++];
+ dst[dst_pos++] = src[ii];
+ }
+ else {
+ dst[dst_pos++] = src[ii];
+ }
+ }
+ }
+ }
+ *len = strlen(dst);
+ return dst;
+}
/*
* vim:ts=2 et
*/