|CGI XSLT Processor |
|Extensions || |
Method for conflict resolution of templates rules
Xsltp.pl Perl XSLT parser does not support the priority attribute of template elements. Instead, the following pattern ordering algorithm is applied to resolve template rules conflicts.
The order of pattern, by definition, is the number of step operators, e. g. Order(x/*/z)=Order(x//*/z)=Order(//x/z)=Order(*//*/*)=2. Absolute paths are treated as paths, which begin with the fictitious name "root". The pattern path1 has always higher priority than pattern path2 if Order(path1)>Order(path2). Each pattern in the set of patterns with the same order is decomposed as path=...('/'|'//')p1('/'|'//')p0 where p1 and p0 have no step operators. Patterns with p0!='*'|'@*' have the highest priority. The program, then, will consider patterns with p1!='*', then it will study patterns of the form ...p1/p0 and then it will analyze patterns of the form ...p1//p0. If the conflict is not resolved the above rule is used with respect to the next left step pattern ...p2('/'|'//')p1... At each step the set of patterns with higher priority can have no suitable pattern for the current node. If it happens the set with previous priority is considered and so on. Example,
* < x < *//* < */* < a//* < b/* < *//x < */x < a//x < b/x < */*/*
A pattern can have only one predicate. Pattern with predicate has higher priority than pattern with no predicate (x[expression]>x). If more than one pattern with predicate is defined the first found pattern, predicate of which is evaluated to true, will be selected. Templates have inverse order to the document order.
Remark. Pattern of the form x[cond1][cond2] can be replaced by x[cond1 and cond2].