Logo Search packages:      
Sourcecode: rapple version File versions  Download package

static void start ( void *  data,
const char *  el,
const char **  attr 
) [static]

Resolves named entities into numeric entities. There is still some work to be done testing this function (it is not used now but has been retained as it will likely be of use later)

Parameters:
ctnt pointer to string containing named entities. Handles start of element event. Passed to XML_SetElementHandler.
data 
el 
attr 

Definition at line 476 of file parser.c.

References rpl_log_warn(), rpl_me_free(), rpl_me_malloc(), and rpl_message_get().

Referenced by rpl_parse().

                                                     {
    int         i, xhtml_ns_c=0;
    rpl_c_str_t  sp;
    rpl_str_t    atr, msg;

    /* locate the position of the first character that does not preceed a namespace separator (:) */
    if((sp = strchr(el,':')) != NULL) {
        sp++;
    } else {
        sp = el;
    }

    strcat(p_doc, "<");
    strcat(p_doc, sp);

    for(i=0; attr[i]; i += 2) {
        if(strncmp(RPL_XMLNS, attr[i], strlen(RPL_XMLNS)) != 0) {
            atr = (rpl_str_t)rpl_me_malloc(strlen(attr[i]) + strlen(attr[i+1]) + 4);
            sprintf(atr, " %s='%s' ", attr[i], attr[i+1]);
            strcat(p_doc, atr);
            rpl_me_free(atr);

            /* note the href value in <a> elements */
            if((strcmp(el, "a") == 0) && (strcmp(attr[i],"href") == 0)) {
                a_href_buf = (rpl_str_t)rpl_me_malloc(strlen(attr[i+1]) + 1);
                sprintf(a_href_buf, "%s", attr[i+1]);
            }
        }
        if(strstr(attr[i+1],RPL_XHTML_NS) != NULL)
            xhtml_ns_c++;
            /* presence of < or > not permitted in attribute values - this usually happens
               when scripting languages e.g., PHP, use constructs such as <?= to dynamically
               set attribute values. */
            if((strchr(attr[i+1], '<') != NULL) || (strchr(attr[i+1],'>') != NULL))
            {
                  msg = rpl_message_get("PARSER_ILLEGAL_ATTR_CHAR", RPL_EOM);
                  rpl_log_warn(msg);
                  rpl_me_free(msg);
            }
    }

    /* insert the XHTML namespace if not already present */
    if((strcmp(el, "html") == 0) && (xhtml_ns_c > 0))
        strcat(p_doc, RPL_XHTML_NS);

    /* if the tag is empty then close it now */
    if((strcmp(el,"br") != 0) && (strcmp(el,"hr") != 0) && (strcmp(el,"img") != 0) && (strcmp(el,"link") != 0)) {
        strcat(p_doc, ">");
    } else {
        strcat(p_doc, " />");
    }

    /* assume that the element contains no text */
    txt_flag = 0;

    depth++;
}


Generated by  Doxygen 1.6.0   Back to index