Re: [xslt] Bug in import with namespaces?



On Thu, Apr 19, 2001 at 04:26:04PM -0500, Brent Hendricks wrote:
> The template for matching my:document seems to work just fine, but
> it's having problems with the select="my:item".  the current cvs
> version of libxslt spits out
> 
> Error xpath.c:6570: Undefined namespace prefix
> xmlXPathEval: evaluation failed
> 
> Looking at xpath.c it appears that the call to xmlXPathNsLookup() is
> drawing a blank here.  Poking around in gdb, it looks like the
> namespace is defined in the array ctxt->namespaces, but it doesn't
> show up in the hash table ctxt->nsHash.  I tried to dig back through
> the source code, but I got a bit lost :)

  Okay I finally fixed it.
Basically your analysis was right. The external process can define
the namespaces either though an API, they end-up in the nsHash table,
or (and taht's the method XSLT uses because it is quite faster) by
simply giving a namespace list. I modified xmlXPathNsLookup to look
in ctxt->namespace first and this works:

orchis:~/XSLT/tests/general -> xsltproc bug-8-.xsl ./../docs/bug-8-.xml
<?xml version="1.0"?>

    Big Success
orchis:~/XSLT/tests/general -> 


   Patch enclosed, thanks for the excellent bug report !

Daniel

-- 
Daniel Veillard      | Red Hat Network http://redhat.com/products/network/
veillard redhat com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
*** xpath.c	2001/04/30 17:44:45	1.109
--- xpath.c	2001/04/30 19:20:13
***************
*** 1966,1973 ****
  	return(XML_XML_NAMESPACE);
  #endif
  
!     if (ctxt->nsHash == NULL)
! 	return(NULL);
  
      return((const xmlChar *) xmlHashLookup(ctxt->nsHash, prefix));
  }
--- 1966,1980 ----
  	return(XML_XML_NAMESPACE);
  #endif
  
!     if (ctxt->namespaces != NULL) {
! 	int i;
! 
! 	for (i = 0;i < ctxt->nsNr;i++) {
! 	    if ((ctxt->namespaces[i] != NULL) &&
! 		(xmlStrEqual(ctxt->namespaces[i]->prefix, prefix)))
! 		return(ctxt->namespaces[i]->href);
! 	}
!     }
  
      return((const xmlChar *) xmlHashLookup(ctxt->nsHash, prefix));
  }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]