Michael,
Many thanks. I thought too complicated and had obviously the wrong
approach regarding XSLT's way of searching (source tree vs.
document-oriented).
It works fine now. :)
Many thanks to everyone else regarding the hints,
Regards
Houman
-----Original Message-----
From: Michael Kay [mailto:mike(_at_)saxonica(_dot_)com]
Sent: 10 October 2005 16:06
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] following-sibling:: within a for-each
You can test if you're at the last item using
<xsl:if test="position()!=last()">,</xsl:if>
I would use a variable for the repeated expression
/*/*[substring(name(),8)
= 'MeterPulse'].
You could do it using following-sibling but it's tortuous:
test="following-sibling::*[substring(name(),8) = 'MeterPulse']"
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: Khorasani, Houman [mailto:houman_khorasani(_at_)csgsystems(_dot_)com]
Sent: 10 October 2005 15:34
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] following-sibling:: within a for-each
Hello everyone,
This is the first time I am experimenting with following-sibling:: and
am already stuck in here.
I have such a code here:
<xsl:if test="/*/*[substring(name(),8) = 'MeterPulse']">
<xsl:element name="MeterPulseFacility">
<xsl:for-each select="/*/*[substring(name(),8) =
'MeterPulse']"> <xsl:value-of select=" ...some
calculations... "/>
<xsl:text>,</xsl:text>
</xsl:for-each>
</xsl:element>
</xsl:if>
The "...some calculations..." outputs a plain number. Following the
comma within the <xsl:text>,</xsl:text>
The output would be something like
3,2,1,
I wish to eliminate the last comma since there is no need for
a further
separation. I thought I could check if there actually is another
incoming sibling in the for-each, if yes then set the comma
otherwise do
not set the comma.
<xsl:if test="/*/*[substring(name(),8) = 'MeterPulse']">
<xsl:element name="MeterPulseFacility">
<xsl:for-each select="/*/*[substring(name(),8) =
'MeterPulse']"> <xsl:value-of select=" ...some
calculations... "/>
<xsl:if
test="substring(following-sibling::node()/name(),8) = 'MeterPulse'">
<xsl:text>,</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:element>
</xsl:if>
However the way I wrote it seems to be wrong:
<xsl:if test="substring(following-sibling::node()/name(),8) =
'MeterPulse'">
Any comments please?
Many thanks,
Houman
--~------------------------------------------------------------------
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>
--~--
--~------------------------------------------------------------------
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>
--~--
--~------------------------------------------------------------------
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>
--~--