Re: [xslt] xsltCompileStepPattern problem



On Tue, Jan 29, 2002 at 10:24:39PM -0600, Charles Bozeman wrote:
> I have two problems, one I have a solution for and the other I am
> stumped.
> First, libxslt doesn't handle wildcard child patterns (child::*); the
> attached patch fixes that.

  Yup, thanks a lot, applied !

> The second problem is with predicates. Given
> a templete with the match pattern:
> //b/child::*[self::aa or self::bb or self::cc][position()=last()]
> the stylesheet should get the last aa, bb, or cc element with element b
> as a parent but it doesn't. In fact I tested this with testXPath and it
> works.
> $ gnome/gnome-xml/testXPath -i abc.xml "//b/child::*[self::aa or
> self::bb or self::cc][position()=last()]"
> Object is a Node Set :
> Set contains 3 nodes:
> 1  ELEMENT cc
> 2  ELEMENT cc
> 3  ELEMENT aa
> 
> I also tested with xt and it works. I suspect the precompiled pattern
> gets missinterpreted as get the aa, bb, or cc element if it is the last
> element in the context of element b; but I don't really know.

  Yes, this one is far more complex to handle correctly. Basically 
pattern matching for templates doesn't use the XPath evaluation, that
would be far too costly. The test for the right pattern is evaluated
as nodes are processed. This mean that the concept of current nodeset
is hard to maintain. The current code works when there is no cascading
of predicates. If there is a cascading then currently the notion of
filtering of the node set is not applied. I'm afraid the only way to
get this fixed correctly is to evaluate the XPath expression and cache
it for those complex matches expressions with predicates. This mean one
need to add per document/per template informations. This is not a trivial
change. I need to think a bit more about it. Could you register the
bug in Bugzilla 

  http://bugzilla.gnome.org/buglist.cgi?product=libxslt

so I don't forget it :-)

  thanks a lot for the report and examples ! I will get it fixed.

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard@redhat.com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



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