[xsl] foreach, preceding-sibling::node() and following-sibling::node()

Subject: [xsl] foreach, preceding-sibling::node() and following-sibling::node()
From: "Mingqiang Yu" <myu@xxxxxxxx>
Date: Mon, 24 Oct 2005 19:21:03 -0600 (MDT)
I have a question about xsl:for-each and the usage of
preceding-sibling::node() and following-sibling::node(). Here is a piece
of my xml file:

<abs>
Experiment regarding the theory of Langevin [see Abs.
<idlink>1905A01449</idlink>].  <i>in vacuo</i> and theory of the
ferromagnetic state [see Abs. <idlink>1914A00343</idlink>,
<idlink>1914A00344</idlink>].
</abs>

I want to extract the idlink out and make it a hyperlink. So, the output
will be:
Experiment regarding the theory of Langevin [see Abs.<a
href="url1">1905A01449</a><i>in vacuo</i> and theory of the ferromagnetic
state [see Abs. <a href="url2">1914A00343</a>, <a
href="url3">1914A00344</a>.

But how can I get the text content between two idlink node? I used the
following codes but as you can imagine, the preceding-sibling::node()
keeps adding all of the content before each idlink. Do you have any
experience on this subject?

<xsl:when test="idlink">
<xsl:for-each select="idlink">
<xsl:copy-of select="preceding-sibling::node()"/>
<xsl:variable name="idlinkVal">
<xsl:copy-of select="."/>
</xsl:variable>
<a href="javascript:frLink('FRLink','all', &quot;{$idlinkVal}&quot;);">
<xsl:value-of select="$idlinkVal"/>
</a>
<xsl:copy-of select="following-sibling::node()"/>
</xsl:for-each>
</xsl:when>

Thanks in advance.

Ming

Current Thread