|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Using keys in templates
Jeni Tennison wrote:
The other benefit that comes with Jeni's approach is the ability to use variables within the value of the select attribute of <xsl:apply-templates...>, something that is not legal in the match attribute of <xsl:template...>. As Jeni pointed out... "Locating which template to use to process a node takes time, so you should try to apply templates to as small a set as possible rather than trying to find a template for every node, but only doing something with some of them." ... this method ensures that only those elements which evaluate to true are sent to be matched to a template. In your original post you were using the value of a variable as the value for the key function to match against the list of elements selected using <xsl:key...>. As both Jeni and David indirectly pointed out the creation of the "dist" variable wasn't necessary in your particular case as the dist element was still the context element when you used the conditional <xsl:if...> element and as such "@name" referenced the same value that was being held in the "dist" variable. But if this wasnt the case (you had implemented a for-each loop for example) then using the value of this variable within the key function would have made sense and would have allowed you the ability to further qualify what elements should be selected and matched to a template. Hope you find this helpful! Best regards, <M:D/>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








