[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: xsl:key only checks first child, need to check all

Subject: Re: xsl:key only checks first child, need to check all
From: David Carlisle <davidc@xxxxxxxxx>
Date: Sun, 6 Nov 2005 00:15:05 GMT
xsl first child
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>&#10;</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>&#10;</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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.