W3C home > Mailing lists > Public > www-talk@w3.org > November to December 2000

XSL coding problem: fetching information from a XML tree what loo k different every time.

From: Peter Landhage (QRA) <Peter.Landhage@era.ericsson.se>
Date: Mon, 20 Nov 2000 03:52:48 -0500 (EST)
Message-ID: <CD97CDC746E5D311B9340008C7E6752003DD2C8C@esekint413.ki.sw.ericsson.se>
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
Received on Tuesday, 21 November 2000 02:33:15 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 27 October 2010 18:14:24 GMT