Changeset 31 for trunk/fastxsl.c

Show
Ignore:
Timestamp:
08/21/07 02:50:00 (11 years ago)
Author:
jesus
Message:

make the filename passed to cached_document resolve in a similar fashion to document() before caching it by name

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/fastxsl.c

    r30 r31  
    349349/* {{{ proto void fastxsl_CachedDocumentFunction(xmlXPathParserContextPtr ctxt, int nargs) 
    350350   Emulate xsltDocumentFunction but leverage the MM shared cache for speed. */ 
    351 static void 
     351void 
    352352fastxsl_CachedDocumentFunction(xmlXPathParserContextPtr ctxt, int nargs) 
    353353{ 
    354354        xmlXPathFunction func; 
    355355        xmlXPathObjectPtr idoc, obj; 
     356        xsltTransformContextPtr tctxt; 
     357        xmlChar *base = NULL, *URI; 
    356358        int lockfd; 
    357359        char *ss_filename; 
     
    373375        } 
    374376        obj = ctxt->value; 
    375         ss_filename_len = strlen((char *)obj->stringval); 
     377 
     378        /* Translate this document as would xsltLoadDocument */ 
     379        tctxt = xsltXPathGetTransformContext(ctxt); 
     380        if ((tctxt != NULL) && (tctxt->inst != NULL)) { 
     381                base = xmlNodeGetBase(tctxt->inst->doc, tctxt->inst); 
     382        } 
     383        else { 
     384                base = xmlNodeGetBase(tctxt->style->doc, 
     385                                        (xmlNodePtr) tctxt->style->doc); 
     386        } 
     387        URI = xmlBuildURI(obj->stringval, base); 
     388        if (base != NULL)                
     389                 xmlFree(base); 
     390 
     391        ss_filename_len = strlen((char *)URI); 
    376392        ss_filename = alloca(ss_filename_len + 1); 
    377         strcpy(ss_filename, (char *)obj->stringval); 
     393        strcpy(ss_filename, (char *)URI); 
    378394 
    379395        lockfd = open(ss_filename, O_RDONLY);