xsl-list
[Top] [All Lists]

RE: problem with xsl:sort

2003-02-21 08:10:20
<xsl:for-each> processes a set of nodes. The set of nodes is determined
by the select attribute. Saying select="." selects exactly one node.

The <xsl:sort> element determines the order in which the set of nodes
will be processed. For a set containing only one node, there is only one
possible order of processing, so <xsl:sort> is completely pointless.

I hope this makes it clearer.

I guess what you really wanted was for me to rewrite your code. You
picked the short straw on that - I'm not Jeni Tennison.

Michael Kay
Software AG
home: Michael(_dot_)H(_dot_)Kay(_at_)ntlworld(_dot_)com
work: Michael(_dot_)Kay(_at_)softwareag(_dot_)com 

-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com 
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of 
Lorenzo De Tomasi
Sent: 21 February 2003 09:52
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] problem with xsl:sort


Thank you very much for your answers! Now it works...
But I don't understand what you want to tell me here:

on 18-02-2003 0:35, Dion Houston at 
dionh(_at_)windows(_dot_)microsoft(_dot_)com wrote:

Also note that:

<xsl:for-each select=".">

Will always execute exactly once because "." is short for 
"self::*" -- 
the context node.

and here

on 18-02-2003 0:46, Michael Kay at 
michael(_dot_)h(_dot_)kay(_at_)ntlworld(_dot_)com wrote:

<xsl:for-each select=".">
<xsl:sort select="@type" data-type="text" order="ascending"/>

<xsl:for-each select="."> processes a node-set that always contains 
exactly one node. So there isn't very much point in sorting it.

What's the problem? Have I done something wrong? Is there a 
better way to do it? Can you try to explain me with some examples?

Thank you again :) 
______________________________________________________________
______________
XML

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="contact_temp.xsl"?> 
<xCVP xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:a="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"
xmlns:n="urn:oasis:names:tc:ciq:xsdschema:xNL:2.0" 
xsi:schemaLocation="">
    <PersonDetails lang="eng">
        <Languages>
            <Language type="other language" speak="good" 
read="excellent" write="good" code="eng">English</Language>
            <Language type="mother tongue" speak="excellent" 
read="excellent" write="excellent" code="ita">Italiano</Language>
            <Language type="other language" speak="basic" 
read="basic" write="basic" code="fr">Fran?ßais</Language>
        </Languages>
    </PersonDetails>
</xCVP> 
______________________________________________________________
______________
XSL

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:template match="xCVP/PersonDetails">
    <html>
        <body lang="eng">
            <section>
                <h>languages</h>
                <p>
                    <xsl:apply-templates select="Languages/Language"/>
                </p>
            </section>
        </body>
    </html>
</xsl:template>

<xsl:template match="PersonInfo">
    <xsl:apply-templates/>
</xsl:template>

<xsl:template match="Languages">
    <xsl:apply-templates/>
</xsl:template>

<xsl:template match="Language">
    <xsl:for-each select=".">
    <xsl:sort select="@type" data-type="text" order="ascending"/>
        <xsl:choose>
            <xsl:when test="@type='mother tongue'">
                <l><span class="label"><xsl:value-of 
select="@type"/></span><xsl:text> </xsl:text><xsl:value-of 
select="."/></l>
            </xsl:when>
            <xsl:otherwise>
                <l><span class="label"><xsl:value-of 
select="@type"/></span><xsl:text> </xsl:text><xsl:value-of 
select="."/><xsl:text> </xsl:text><span 
class="label">speak</span><xsl:text>
</xsl:text><xsl:value-of select="@speak"/><xsl:text> 
</xsl:text><span class="label">read</span><xsl:text> 
</xsl:text><xsl:value-of select="@read"/><xsl:text> 
</xsl:text><span class="label">write</span><xsl:text> 
</xsl:text><xsl:value-of select="@write"/></l>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:for-each>
</xsl:template>

</xsl:stylesheet> 
______________________________________________________________
______________


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>