Subject: Re: Rule conflict resolution From: Tyler Baker <tyler@xxxxxxxxxxx> Date: Thu, 05 Nov 1998 17:28:04 -0500 |
Aneel Nazareth wrote: > Hello all, > I'm working on an XSL processor, and I have a question about conflict > resolution for template rules. > > It seems to me that the precedence for template rules is static (independent > of context). This means that the XSL processor should be able to simply sort > the rules once and go down the list in order whenever rules are applied. This > also means that, if the stylesheet author wanted to do so, she could sort the > rules into the same order by hand ahead of time. The big stickler here is how do you sort with respect to ElementTypePatterns and AttributePatterns. If there were no AttributePatterns, then this would be simple. Also, using the element name of the last ElementTypePattern in a match pattern as a hash object would be simple, but since there are AttributePatterns, you essentially have to iterate through the entire list of templates. Nevertheless, I have found that if you internalise the names when doing pattern matching, building some sort of hashtable of templates is pretty pointless since iterating through 100 or less template match patterns and doing an identity comparison on either the element name of the last element type pattern or the attribute name of the last attribute pattern is faster than messing with a hashtable in the first place. > My question is this: why not just keep the rules in the order that they are > found (document order). (Presumably reverse document order, so you'd put > general rules first and specific rules later, but that's beside the point). > This allows the functionality of the current system, and also allows the user > more control over the order of rule application, if desired. This is the idea, but your problem here is with ElementTypePatterns and AttributePatterns. > The Drawback that I see in this scheme is that it imposes a particular > organization on the stylesheet, while the author might prefer to organize it > differently. Are there other reasons to not do this? The order of the templates is not important. In fact, the only stylesheet element that has any significance with respect to the order it comes in I believe is xsl:include. Tyler XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Rule conflict resolution, Aneel Nazareth | Thread | RE: Rule conflict resolution, Lawton, Scott |
RE: Rule conflict resolution, Lawton, Scott | Date | Advice needed on relating XSL patte, Amit Rekhi |
Month |