Re: [xsl] can't get xsl:sort to work

Subject: Re: [xsl] can't get xsl:sort to work
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 19 Sep 2005 12:07:41 +0100
> Expected select attribute or
> non empty content not both" but i have a select
> attribute. what's wrong with my xsl file.

As the error message says: you can't have both a select attribute and

You have a select attribute


and content
<tr valign="top">
<td><xsl:value-of select="@id"/></td>
<td><xsl:value-of select="@entry"/></td>
<td><xsl:variable name="x" select="count(.//xref)"/>
<xsl:for-each select=".//xref">
<xsl:value-of select="."/>
<xsl:if test="position() &lt; $x">

You don't want the body of the for-each to be content of the xsl:sort so
make that

<xsl:sort select="@entry"/>

and remove the line


Note that you have multiple uses of // which is likely to make this code
very inefficient in practice. (Unless your XSLT system does some very
extensive automatic rewrites.

select="//complexarticle |
//simplearticle | //dummyarticle">

means search the whole document to arbitrary depth to find all the
elements of that name. Are these elements really arbitrarily deeply

Also <xsl:variable name="x" select="count(.//xref)"/> You don't need to
find all the xrefs and count them, you can just use last() which is the
same number and already calculated.


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:

Current Thread