This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
for-each variable combination producing different output
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] for-each variable combination producing different output
- From: "Andrew Welch" <andrew at thebristoldirectory dot com>
- Date: Mon, 11 Jun 2001 12:15:50 +0100
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi,
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
andrew
===extract of all.xsl, this works fine==========
<xsl:for-each select="TBD/business">
<xsl:sort select="."/>
<tr>
<td width="230" style="font-weight:bold;">
<xsl:choose>
<xsl:when test="link!=''">
<a><xsl:attribute name="href"><xsl:value-of
select="link"/></xsl:attribute><xsl:value-of select="name"/></a>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="name"/>
</xsl:otherwise>
</xsl:choose>
********this code seems to be run first********
<xsl:if test="postcode!=''">
<a><xsl:attribute
name="class">little_link</xsl:attribute><xsl:attribute
name="href">http://uk.multimap.com/p/browse.cgi?pc=<xsl:value-of
select="translate(postcode,' ','')"/></xsl:attribute><xsl:attribute
name="target">new</xsl:attribute> map </a>
</xsl:if>
<xsl:if test="email!=''">
<a><xsl:attribute
name="class">little_link</xsl:attribute><xsl:attribute
name="href">mailto:<xsl:value-of select="email"/></xsl:attribute> email </a>
</xsl:if>
<xsl:if test="website!=''">
<a><xsl:attribute
name="class">little_link</xsl:attribute><xsl:attribute
name="href"><xsl:value-of select="website"/></xsl:attribute><xsl:attribute
name="target">new</xsl:attribute> webiste </a>
</xsl:if>
**************************
</td>
<td width="220" rowspan="2" style="font-size:150%;"><xsl:value-of
select="telephone"/></td>
<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