GNOME Bugzilla – Bug 75813
apply-templates on a node-set doesn't find match critieria correctly
Last modified: 2009-08-15 18:40:50 UTC
original discussion from xslt mailing list: On Thu, Mar 21, 2002 at 11:11:37AM -0700, Vakoc, Mark wrote: > > The following stylesheet applys templates on identical xml, the first > instance is in a variable/node-set, the second is from the source document. > They xml is the same so the same template should be found for either. the > template match is "DIRTREE[d][f]". It finds the correct match on the xml on > the source document, and incorrectly when from a node-set > > Here's the interesting part. If you remove one set of brackets from the > match (i.e match="DIRTREE[d]") it will act correctly, so it appears that > having multiple brackets in the match when run against a variable/node- set > will not work. Yes. > Is this a bug or am I insane (or, possibly, both). Both. It's insane because initially the XSLT data model did NOT allow that kind of constructs. It get possible only via the use of the node-set extension and this create a huge amount of technical problems. a template matching DIRTREE[d][f] means it matches all the nodes //DIRTREE[d][f] in the current document. the node set has no document or if it has a document it is not reachable from the node itself. Log the bug please, but understand that the use and abuse of the node-set extension was not initially part of the XSLT model. Daniel
Created attachment 7301 [details] source document (xml)
Created attachment 7302 [details] stylesheet
I had a look at this, fairly hard, and possibly in conflict with the way I fixed another bug on similar problem. I'm not sure I will have the cycle to do this in the short term, assigned pending a more general analysis of the problem Daniel
Okay, I finally fixed it in CVS, it required changes to both libxml2 and libxslt, the handling of result value tree especially once cast using node-set() should be quite cleaner: paphio:~/XSLT/tests/general -> xsltproc bug-111.xsl ../docs/bug-111.xml <?xml version="1.0"?> <root> Test 1 DIRTREE : true : true Test 2 DIRTREE : true : true</root> paphio:~/XSLT/tests/general -> I just had to modify one thing on your example stylesheet, the top of the RVT matches '/' and hence the stylesheet was looping, so I needed to change slightly the stylesheet: Test 1 <xsl:apply-templates select="exsl:node-set($dtree)/DIRTREE"/> Test 2 instead of Test 1 <xsl:apply-templates select="exsl:node-set($dtree)"/> Test 2 thanks for the report and testcases, sorry for the delay :-) Daniel
This should be closed by release of libxml2-2.5.6 and libxslt-1.0.29, thanks, Daniel