Changeset 2188

Show
Ignore:
Timestamp:
11/03/08 21:44:48 (2 months ago)
Author:
karpet
Message:

first pass at the dom-specific property and metaname feature.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • libswish3/trunk/src/libswish3/libswish3.h

    r2187 r2188  
    600600                                         xmlBufferPtr buf,  
    601601                                         xmlChar * joiner, 
    602                                          int cleanwsp, 
     602                                         boolean cleanwsp, 
    603603                                         int autovivify); 
    604604void                swish_add_str_to_nb( swish_NamedBuffer * nb,  
     
    607607                                         unsigned int len, 
    608608                                         xmlChar * joiner, 
    609                                          int cleanwsp, 
     609                                         boolean cleanwsp, 
    610610                                         int autovivify); 
    611611void                swish_append_buffer( xmlBufferPtr buf, xmlChar * txt, int len ); 
  • libswish3/trunk/src/libswish3/namedbuffer.c

    r2178 r2188  
    149149    xmlBufferPtr buf, 
    150150    xmlChar *joiner, 
    151     int cleanwsp, 
     151    boolean cleanwsp, 
    152152    int autovivify 
    153153) 
     
    164164    unsigned int len, 
    165165    xmlChar *joiner, 
    166     int cleanwsp, 
     166    boolean cleanwsp, 
    167167    int autovivify 
    168168) 
     
    197197 
    198198    if (cleanwsp) { 
    199 /* SWISH_DEBUG_MSG("before cleanwsp: '%s'", str); */ 
     199        //SWISH_DEBUG_MSG("before cleanwsp: '%s'", str); 
    200200        nowhitesp = swish_str_skip_ws(str); 
    201201        swish_str_trim_ws(nowhitesp); 
    202 /* SWISH_DEBUG_MSG("after  cleanwsp: adding '%s' to buffer '%s'", nowhitesp, name); */ 
     202        //SWISH_DEBUG_MSG("after  cleanwsp: adding '%s' to buffer '%s'", nowhitesp, name); 
    203203        swish_append_buffer(buf, nowhitesp, xmlStrlen(nowhitesp)); 
    204204    } 
  • libswish3/trunk/src/libswish3/parser.c

    r2187 r2188  
    684684{ 
    685685    swish_ParserData *parser_data; 
     686    xmlChar *baked; 
     687     
    686688    parser_data = (swish_ParserData *)data; 
    687689     
     
    705707        push_tag_stack(parser_data->domstack, (xmlChar *)tag, parser_data->tag, SWISH_DOT); 
    706708    } 
    707  
     709     
    708710/* 
    709711* set property if this tag is configured for it  
    710712*/ 
    711     if (swish_hash_exists(parser_data->s3->config->properties, parser_data->tag)) { 
     713    if (swish_hash_exists(parser_data->s3->config->properties, parser_data->tag) 
     714        || 
     715        swish_hash_exists(parser_data->s3->config->properties, parser_data->domstack->head->context) 
     716    ) { 
    712717        if (SWISH_DEBUG & SWISH_DEBUG_PARSER) 
    713718            SWISH_DEBUG_MSG(" %s = new property", parser_data->tag); 
     
    715720        add_stack_to_prop_buf(NULL, parser_data);       /* NULL means all properties in the stack are added */ 
    716721        xmlBufferEmpty(parser_data->prop_buf); 
    717  
    718         push_tag_stack(parser_data->propstack, (xmlChar *)tag, parser_data->tag, SWISH_SPACE); 
     722         
     723        if (swish_hash_exists(parser_data->s3->config->properties, parser_data->domstack->head->context)) 
     724            baked = parser_data->domstack->head->context; 
     725        else 
     726            baked = parser_data->tag; 
     727 
     728        push_tag_stack(parser_data->propstack, (xmlChar *)tag, baked, SWISH_SPACE); 
    719729 
    720730        if (SWISH_DEBUG & SWISH_DEBUG_PARSER) 
     
    725735* likewise for metastack  
    726736*/ 
    727     if (swish_hash_exists(parser_data->s3->config->metanames, parser_data->tag)) { 
     737    if (swish_hash_exists(parser_data->s3->config->metanames, parser_data->tag) 
     738        || 
     739        swish_hash_exists(parser_data->s3->config->metanames, parser_data->domstack->head->context) 
     740    ) { 
    728741        if (SWISH_DEBUG & SWISH_DEBUG_PARSER) 
    729742            SWISH_DEBUG_MSG(" %s = new metaname", parser_data->tag); 
     
    731744        flush_buffer(parser_data, parser_data->metastack->head->baked, 
    732745                     parser_data->metastack->head->context); 
    733  
    734         push_tag_stack(parser_data->metastack, (xmlChar *)tag, parser_data->tag, SWISH_SPACE); 
     746                      
     747        if (swish_hash_exists(parser_data->s3->config->properties, parser_data->domstack->head->context)) 
     748            baked = parser_data->domstack->head->context; 
     749        else 
     750            baked = parser_data->tag; 
     751 
     752        push_tag_stack(parser_data->metastack, (xmlChar *)tag, baked, SWISH_SPACE); 
    735753    } 
    736754 
     
    10831101    ptr->domstack->temp  = NULL; 
    10841102    ptr->domstack->count = 0; 
    1085     push_tag_stack(ptr->domstack, (xmlChar *)".", (xmlChar *)".", SWISH_DOT); 
    1086  
    1087 /* 
    1088 * no such property just to seed stack  
    1089 */ 
    10901103 
    10911104/* 
     
    21552168        tmp = swish_xmalloc(size); 
    21562169                 
    2157         if (snprintf((char *)tmp, size, "%s%c%s", (char *)flat, flatten_join, (char *)stack->temp->baked) 
    2158             > 0) { 
     2170        if (snprintf((char *)tmp, size, "%s%c%s", 
     2171             (char *)stack->temp->baked, flatten_join, (char *)flat) 
     2172            > 0 
     2173        ) { 
    21592174            if (flat != NULL) 
    21602175                swish_xfree(flat); 
     
    21782193{ 
    21792194    swish_TagStack *stack; 
    2180     int cleanwsp; 
     2195    boolean cleanwsp; 
    21812196    swish_Property *prop; 
    21822197 
  • libswish3/trunk/src/t/001-wordcount.t

    r2158 r2188  
    33use strict; 
    44use warnings; 
    5 use Test::More tests => 25
     5use Test::More tests => 26
    66use SwishTestUtils; 
    77 
     
    3030    'inline.xml'       => 12, 
    3131    'inline.html'      => 9, 
     32    'dom.xml'          => 3, 
    3233 
    3334); 
  • libswish3/trunk/src/t/003-properties.t

    r2142 r2188  
    22use strict; 
    33use warnings; 
    4 use Test::More tests => 2
     4use Test::More tests => 3
    55use SwishTestUtils; 
    66 
     
    1818); 
    1919 
     20$buf = SwishTestUtils::run_lint_stderr( 'dom.xml', 'dom.conf' ); 
     21 
     22# the dot . is the TOKENPOS_BUMPER delimiter 
     23like( $buf, qr!<doc\.one\.two>green.yellow</doc\.one\.two>!, "dom" ); 
     24 
    2025#diag($buf);