[11762] in www-talk@info.cern.ch
XSL coding problem: fetching information from a XML tree what loo k different every time.
daemon@ATHENA.MIT.EDU (Peter Landhage (QRA))
Tue Nov 21 02:38:30 2000
Date: Mon, 20 Nov 2000 03:52:48 -0500 (EST)
Old-X-Envelope-From: www-talk-request@tux.w3.org Mon Nov 20 03:52:37 2000
Message-ID: <CD97CDC746E5D311B9340008C7E6752003DD2C8C@esekint413.ki.sw.ericsson.se>
From: "Peter Landhage (QRA)" <Peter.Landhage@era.ericsson.se>
To: www-talk@w3.org
MIME-Version: 1.0
Content-Type: text/plain
Old-X-Envelope-To: www-talk
Resent-From: gerald@w3.org
Resent-To: www-talk@w3.org
Hi !
I have this problem with fetching information out of a XML-tree with XSL.
The tree could look like this:
<flightinfo>
<ficomments>
<flight>Finnair - AY 792</flight>
<ficomment>
<from>Malpensa (MXP), Milan, Italy</from>
<to>-</to>
<comment>DEPARTS TERMINAL 1</comment>
</ficomment>
<ficomment>
<from>Arlanda (ARN), Stockholm, Sweden</from>
<to>Helsinki-Vantaa (HEL), Helsinki, Finland</to>
<comment>DEPARTS TERMINAL 2</comment>
</ficomment>
<ficomment>
<from>-</from>
<to>Helsinki-Vantaa (HEL), Helsinki, Finland</to>
<comment>ARRIVES TERMINAL 2</comment>
</ficomment>
<ficomment>
<from>Malpensa (MXP), Milan, Italy</from>
<to>Arlanda (ARN), Stockholm, Sweden</to>
<comment>ARRIVES TERMINAL 2</comment>
</ficomment>
<ficomment>
<from>-</from>
<to>-</to>
<comment>9/ NON-SMOKING</comment>
</ficomment>
</ficomments>
</flightinfo>
I want to fetch the first DEPARTS TERMINAL and the last ARRIVES TERMINAL in
the tree. The tree is different every time. There could be more <ficomment>
occurences before DEPARTS TERMINAL 1
and after ARRIVES TERMINAL 2, so you cannot use a postion() argument. The
code that is used today is looking like below. The problem is that it
fetching all the DEPARTS TERMINALs and all the ARRIVES TERMINALs and I only
want the first and last:
<xsl:template match="ficomments/ficomment" mode="departs">
<xsl:if test="starts-with(comment,'DEPARTS')">
<xsl:value-of select="comment"/><br/>
</xsl:if>
</xsl:template>
Is there anyone that know how to solve this ? I've tried with
following-sibling and <xsl:sort select="comment" order="descending">(and
writing a xsl:value-of select="comment[1]"/><br/>) but nothing works.
Peter Landhage, Telelogic Sverige AB
Amadeus - WTM Competence Center
Tel: +46-(0)703-401481
peter.landhage@era.ericsson.se