xslt for-each and sorting issues

39 views Asked by At

Below is my XLST. My question is why is my output not being sorted correctly?? It should be sorted by ascending, I tried doing this without the secondary template and it worked, but once used within a template it will not output sorted.

XSLT CODE:

    <xsl:template match="movie">
        <xsl:for-each select ="movies/movie">
            <xsl:sort select="title" order="ascending" />
            <tr>
                <td>
                    <xsl:value-of select ="@id"/>
                    <br></br>
                </td>
                <td>
                    <xsl:value-of select ="title"/>
                    <br></br>
                </td>
                <td>
                    <xsl:value-of select ="pdirector"/>
                    <br></br>
                </td>
                <td>
                    <xsl:value-of select ="year"/>
                    <br></br>
                </td>
            </tr>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>`
1

There are 1 answers

0
Martin Honnen On BEST ANSWER

It looks like instead of

<xsl:template match="movie">
    <xsl:for-each select ="movies/movie">

you want

<xsl:template match="movies">
    <xsl:for-each select="movie">