Project

Profile

Help

Saxon 6.5 XPath Question

Added by Anonymous over 15 years ago

Legacy ID: #5361434 Legacy Poster: Toshihiko Makita (tmakita)

Hello! Sorry for beginner's question. I'm still using Saxon 6.5 because our system restriction. Today I got the following error. Ambiguous rule match for /dita-merge[1]/task[4]/prolog[1]/metadata[1]/keywords[1]/indexterm[1]/indexterm[1] Matches both "[contains(@class, ' topic/indexterm ')][not(child::[contains(@class,' topic/indexterm ')])]" on line 73 of file:/D:/DITA-OT1.421/xsl/xslfo/dita2fo_index.xsl and "[contains(@class, ' topic/indexterm ')]/[contains(@class, ' topic/indexterm ')][not(child::*[contains(@class, ' topic/indexterm ')])]" on line 129 of file:/D:/DITA-OT1.421/xsl/xslfo/dita2fo_index.xsl First matching rule is aimed at selecting "indexterm that has no indexterm as its children". The error message seems that this matching rule is not worked well. What is wrong with this XPath expression? Thanks, t.makita


Replies (2)

RE: Saxon 6.5 XPath Question - Added by Anonymous over 15 years ago

Legacy ID: #5361814 Legacy Poster: Michael Kay (mhkay)

I would recommend asking questions like this on the xsl-list at mulberrytech.com - it's not a Saxon-specific question, really, and there are plenty of people on xsl-list who are happy to answer XSLT 1.0 questions. The constructs you are referring to are not, technically speaking, XPath expressions, rather they are XSLT patterns. They deliberately use the same syntax, but they are evaluated in a different way. Let's look at your two patterns (a) [contains(@class, ' topic/indexterm ')] [not(child::[contains(@class,' topic/indexterm ')])] (b) *[contains(@class, ' topic/indexterm ')]/ [contains(@class, ' topic/indexterm ')] [not(child::[contains(@class, ' topic/indexterm ')])] It seems the second pattern matches a subset of the nodes that the first pattern matches. So you probably intended that if a node matches the second pattern, then this one should be chosen. I can tell that by examining the patterns, but the XSLT processor can't (at any rate, it isn't expected to). Instead, you have to tell it to use the second pattern by giving it a higher priority: for example set priority="1" on the first template rule and priority="2" on the second. The message from Saxon is actually a warning rather than an error, and the fallback rule if two templates match with the same priority is always to choose the second, which in this case is what you probably wanted. Michael Kay

RE: Saxon 6.5 XPath Question - Added by Anonymous over 15 years ago

Legacy ID: #5361967 Legacy Poster: Toshihiko Makita (tmakita)

Dear Michael, Thank you for your detailed explanation. I misunderstood that pattern (a) and (b) is exclusive. I will correct the stylesheets. Regards,

    (1-2/2)

    Please register to reply