Subject: Re: [xsl] xsl:key only checks first child, need to check all From: David Carlisle <davidc@xxxxxxxxx> Date: Sun, 6 Nov 2005 00:15:05 GMT |
Avoid using // (especially since you have a key already set up so you don't need to repeat the search over the whole document. Also you usually have a better experience initially writing your code for a command line or editor based engine rather than for a browser. Browsers are not really designed to report errors. This would be easier to do in two passes, but since you want it to run in firefox which doesn't have a node-set() extension, here's I one-pass solution that probably does what you want. $ saxon a.xml a.xsl <html>culture<br> -----Deloria, Ella C.<br> -----Rice, Julian<br> texts<br> -----Deloria, Ella C.<br> -----Rice, Julian<br> </html> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:key name = "topics" match = " topic " use = " . " /> <xsl:key name = "name" match = "author/name" use = "." /> <xsl:template match = "/" > <html> <xsl:for-each select = "/sources/source/topics/topic[generate-id()=generate-id(key('topics',.))] " > <xsl:sort select = " . " /> <xsl:variable name = "currentTopic" select = " . " /> <xsl:value-of select = " $currentTopic " /> <br /><xsl:text> </xsl:text> <xsl:for-each select = "key('name',key('topics',$currentTopic)/../../authors / author / name)[generate-id()=generate-id(key('name',.))]"> <xsl:sort select = " . " /> <xsl:text>-----</xsl:text> <xsl:value-of select = "." /> <br /><xsl:text> </xsl:text> </xsl:for-each> </xsl:for-each> </html> </xsl:template> </xsl:stylesheet> ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] xsl:key only checks first, Patrick Warren | Thread | Re: [xsl] xsl:key only checks first, Patrick Warren |
Re: [xsl] Concordance with XSLT, Dimitre Novatchev | Date | Re: [xsl] Concordance with XSLT, Dimitre Novatchev |
Month |