[xsl] for-each variable combination producing different output

Subject: [xsl] for-each variable combination producing different output
From: "Andrew Welch" <andrew@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 11 Jun 2001 12:15:50 +0100

Im using for-each mappings in my xsl files to display the contents of my xml
files.  One xsl file, called all.xsl, simply displays records.  Other xsl
files, store the 'result' tree in a variable then use a for-each mapping to
step through the results.

The problem is that when I use a $results variable I get a different output
to just accessing nodes through an xpath expression.

I test to see if certain nodes exist in the xml file, if they do some links
are output.  However, if a variable is used for the for-each mapping, all of
the links appear at the top of the output seemingly as if they have been
processed before the rest of the xml.

Ive read that using for-each misses the point of xsl, and that I should be
using templates.  Is this the case and would it solve this problem??

Many Thanks


===extract of all.xsl, this works fine==========
<xsl:for-each select="TBD/business">
    <xsl:sort select="."/>
      <td width="230" style="font-weight:bold;">

          <xsl:when test="link!=''">
            <a><xsl:attribute name="href"><xsl:value-of
select="link"/></xsl:attribute><xsl:value-of select="name"/></a>
            <xsl:value-of select="name"/>

        ********this code seems to be run first********
        <xsl:if test="postcode!=''">
select="translate(postcode,' ','')"/></xsl:attribute><xsl:attribute
name="target">new</xsl:attribute> map </a>
        <xsl:if test="email!=''">
name="href">mailto:<xsl:value-of select="email"/></xsl:attribute> email </a>
        <xsl:if test="website!=''">
name="href"><xsl:value-of select="website"/></xsl:attribute><xsl:attribute
name="target">new</xsl:attribute> webiste </a>
      <td width="220" rowspan="2" style="font-size:150%;"><xsl:value-of
      <td rowspan="2">

other files use
<xsl:for-each select="$results">
as the for-each mapping, which outputs the results of the if-tests at the
top of the xml.
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.260 / Virus Database: 131 - Release Date: 06/06/2001

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

Current Thread