RE: [xsl] Confused by xsl:for-each

Subject: RE: [xsl] Confused by xsl:for-each
From: "Robert Soesemann" <rsoesemann@xxxxxxxxxxx>
Date: Thu, 25 Nov 2004 14:36:37 +0100
Hi,

Although you say this should work, it does not. The select="//a" seems
not to work.
When I write

<xsl:value-of select="number(.)"/> I get 1 for one td
BUT <xsl:value-of select="number(//a) I get 0, although there are two
<a..> inside <td>.

Whats wrong here.

-----Original Message-----
From: Manpreet Singh [mailto:singhm@xxxxxxxxxxx]
Sent: Donnerstag, 25. November 2004 13:57
To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
Subject: FW: [xsl] Confused by xsl:for-each
Importance: High


Hi,
  Apologies

<xsl:template match="/">
	<foo>
		<xsl:apply-templates select="//relation"/>
	</foo>
</xsl:template>

regards
Manpreet

-----Original Message-----
From: Manpreet Singh [mailto:singhm@xxxxxxxxxxx]
Sent: Thursday, November 25, 2004 6:25 PM
To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
Subject: RE: [xsl] Confused by xsl:for-each
Importance: High


Hi,

  if you want only the <a> tags in your output without its attributes
and text node then you should be using xsl:copy and not xsl:copy-of.
  Else if you want <a>'s attr's and text then what you  are doing is
correct. Just put a root tag for the target document as below.

<xsl:template match="/">
	<foo>
		<xsl:apply-templates select="relation"/>
	</foo>
</xsl:template>

<xsl:template match="relation"> <!-- match is fine-->
	<xsl:for-each select="//a">
		<xsl:copy-of select="."/>
	</xsl:for-each>
</xsl:template>

Regards
Manpreet Singh

-----Original Message-----
From: Robert Soesemann [mailto:rsoesemann@xxxxxxxxxxx]
Sent: Thursday, November 25, 2004 6:17 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] Confused by xsl:for-each


Hello,

I am a bit confused how/why I can't get for-each to work here.

Input:

...
<tr>
  <relation name="relatedAddress" type="address">
    <td>
      <a href="external/address.html">Adresse 1</a><br />
      <a href="error/code.html">Adresse 2</a>
    </td>
  </relation>
</tr>
...

Current Thread