xsl-list
[Top] [All Lists]

Re: can't get xsl:sort to work

2005-09-19 04:07:41


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
content.

You have a select attribute

select="@entry"

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">
<br/>
</xsl:if>
</xsl:for-each>
</td>
</tr>
</xsl:sort>

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

</xsl:sort>


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
nested? 

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.

David

________________________________________________________________________
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
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



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