XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
giancarlo rossiSubject: xsl variable problems (simple)
Author: giancarlo rossi
Date: 22 Aug 2006 10:36 AM
Originally Posted: 22 Aug 2006 10:35 AM
Hi guys,

I have this code...

<xsl:variable name="codice" select="SegmentList/Segment/Destination/Code"/>
<xsl:value-of select="/CommandList/CheckRouting/Summary/Destination/AirportList/Airport/Code[.='{$codice}']/preceding-sibling::Name[1]" />

In this way nothing is displayed

but if I put manually
<xsl:variable name="codice" select="SegmentList/Segment/Destination/Code"/>
<xsl:value-of select="/CommandList/CheckRouting/Summary/Destination/AirportList/Airport/Code[.='LGW']/preceding-sibling::Name[1]" />

I get displayed all the informations.

The variable codice is not empty if I print it it is displayed.

Could you give me some advices ?

Regards.

Postnext
Minollo I.Subject: xsl variable problems (simple)
Author: Minollo I.
Date: 22 Aug 2006 12:42 PM
Have you tried:

<xsl:value-of select="/CommandList/CheckRouting/Summary/Destination/AirportList/Airport/Code[.=$codice]/preceding-sibling::Name[1]" />

Postnext
giancarlo rossiSubject: xsl variable problems (simple)
Author: giancarlo rossi
Date: 22 Aug 2006 12:58 PM
Yes it works but the results is equal for each row.

For example, if $codice is BCN
the select give me always "BArajas"

Perhaps the variable "codice" must be clean after after print the results ?

Postnext
Minollo I.Subject: xsl variable problems (simple)
Author: Minollo I.
Date: 22 Aug 2006 01:06 PM
Not sure what behavior you are looking for... we would need more details about how that code is being used in your overall XSLT and what you are trying to do.

Postnext
giancarlo rossiSubject: xsl variable problems (simple)
Author: giancarlo rossi
Date: 22 Aug 2006 01:31 PM
is not easy btw... i try..

I have this xml

<CommandList>
<CheckRouting>
<RouterList>
<Router>
<Supplier>airberlin</Supplier>
<Complete>true</Complete>
<RequestedLocations>
<Origin>
<Type>airport</Type>
<Code>FCO</Code>
</Origin>
<Destination>
<Type>airport</Type>
<Code>CDG</Code>
</Destination>
</RequestedLocations>
<GroupList>
<Group>
<Id>1CUD5N0HSR8PNA78</Id>
<OutwardList>
<Outward>
<Id>4J6RMSAZYM7MEWII</Id>
<CacheInfo>
<CacheDataAgeSeconds>0</CacheDataAgeSeconds>
</CacheInfo>
<Price>
<Amount>197.00</Amount>
<Currency>EUR</Currency>
</Price>
<Duration>240</Duration>
<SegmentList>
<Segment>
<Origin>
<Type>airport</Type>
<Code>FCO</Code>
</Origin>
<Destination>
<Type>airport</Type>
<Code>VIE</Code>
</Destination>
<DepartDate>20/06/2006-11:55</DepartDate>
<ArriveDate>20/06/2006-13:25</ArriveDate>
<Duration>90</Duration>
<Operator>
<Name>Haiti International Airline</Name>
<Code>HG</Code>
</Operator>
<VendingOperator>
<Name>AirBerlin</Name>
<Code>AB</Code>
</VendingOperator>
<FlightId>
<Code>HG8467</Code>
<Number>8467</Number>
</FlightId>
<TravelClass>
<TfClass>Economy With Restrictions</TfClass>
<SupplierClass>Economy With Restrictions</SupplierClass>
</TravelClass>
</Segment>
<Segment>
<Origin>
<Type>airport</Type>
<Code>VIE</Code>
</Origin>
<Destination>
<Type>airport</Type>
<Code>CDG</Code>
</Destination>
<DepartDate>20/06/2006-14:05</DepartDate>
<ArriveDate>20/06/2006-15:55</ArriveDate>
<Duration>110</Duration>
<Operator>
<Name>Haiti International Airline</Name>
<Code>HG</Code>
</Operator>
<VendingOperator>
<Name>AirBerlin</Name>
<Code>AB</Code>
</VendingOperator>
<FlightId>
<Code>HG8734</Code>
<Number>8734</Number>
</FlightId>
<TravelClass>
<TfClass>Economy With Restrictions</TfClass>
<SupplierClass>Economy With Restrictions</SupplierClass>
</TravelClass>
</Segment>
</SegmentList>
<Vendor>
<Name>AirBerlin</Name>
<Url>http://www.airberlin.com/</Url>
</Vendor>
</Outward>
</OutwardList>
</Group>
</GroupList>
</Router>
<Router>

<Summary>
<Origin>
<Location>
<Id>10002737</Id>
<Name>Leonardo da Vinci/Fiumicino</Name>
<Country>
<Name>Italy</Name>
<Code>IT</Code>
</Country>
<Type>Airport</Type>
<City>
<Name>Roma</Name>
<Code>ROM</Code>
</City>
<Airport>
<Name>Leonardo da Vinci/Fiumicino</Name>
<Code>FCO</Code>
</Airport>
</Location>
<AirportList>
<Airport>
<Name>Leonardo da Vinci/Fiumicino</Name>
<Code>FCO</Code>
<City>
<Name>Roma</Name>
<Code>ROM</Code>
</City>
<Distance>0</Distance>
</Airport>
<Airport>
<Name>Ciampino</Name>
<Code>CIA</Code>
<City>
<Name>Roma</Name>
<Code>ROM</Code>
</City>
<Distance>352</Distance>
</Airport>
</AirportList>
<CityList>
<City>
<Name>Roma</Name>
<Code>ROM</Code>
<Distance>23456</Distance>
</City>
</CityList>
</Origin>
<Destination>
<Location>
<Id>10001693</Id>
<Name>Charles de Gaulle</Name>
<Country>
<Name>France</Name>
<Code>FR</Code>
</Country>
<Type>Airport</Type>
<City>
<Name>Paris</Name>
<Code>PAR</Code>
</City>
<Airport>
<Name>Charles de Gaulle</Name>
<Code>CDG</Code>
</Airport>
</Location>
<AirportList>
<Airport>
<Name>Charles de Gaulle</Name>
<Code>CDG</Code>
<City>
<Name>Paris</Name>
<Code>PAR</Code>
</City>
<Distance>0</Distance>
</Airport>
<Airport>
<Name>Orly</Name>
<Code>ORY</Code>
<City>
<Name>Paris</Name>
<Code>PAR</Code>
</City>
<Distance>35516</Distance>
</Airport>
<Airport>
<Name>Ciampino</Name>
<Code>CIA</Code>
<City>
<Name>Roma</Name>
<Code>ROM</Code>
</City>
<Distance>1100478</Distance>
</Airport>
<Airport>
<Name>Leonardo da Vinci/Fiumicino</Name>
<Code>FCO</Code>
<City>
<Name>Roma</Name>
<Code>ROM</Code>
</City>
<Distance>1100790</Distance>
</Airport>
</AirportList>
<CityList>
<City>
<Name>Paris</Name>
<Code>PAR</Code>
<Distance>22994</Distance>
</City>
<City>
<Name>Creil</Name>
<Code>CSF</Code>
<Distance>28214</Distance>
</City>
<City>
<Name>Pontoise</Name>
<Code>POX</Code>
<Distance>33013</Distance>
</City>
</CityList>
</Destination>
<Distance>1100790</Distance>
<OutwardDate>20/06/2006-10:00</OutwardDate>
</Summary>
</CheckRouting>
</CommandList>



I use this command to inizilize the list

<xsl:for-each select="/CommandList/CheckRouting/RouterList/Router/GroupList/Group/OutwardList/Outward" >

inside this cycle I Must check the
"SegmentList/Segment/Destination/Code"
for example "FCO" and get the relative Airport name from the summary area...


so I thought to use this

<xsl:variable name="codice" select="SegmentList/Segment/Destination/Code"/>
<xsl:value-of select="$codice" />
<xsl:value-of select="/CommandList/CheckRouting/Summary/Destination/AirportList/Airport/Code[.=$codice]/preceding-sibling::Name[1]" />


But it doesnt works.
Be careful becouse the router list could be more then one.
I hope you could help me...
Thanks a lot.









Postnext
Minollo I.Subject: xsl variable problems (simple)
Author: Minollo I.
Date: 22 Aug 2006 02:04 PM
I guess the problem is that each entry can have multiple segments; so, your variable defined as:
<xsl:variable name="codice" select="SegmentList/Segment/Destination/Code"/>

...ends up being a nodeset made of multiple elements. Not sure which segment you need to match, but, for example, if you want to match the first one, you can do:

<xsl:for-each select="/CommandList/CheckRouting/RouterList/Router/GroupList/Group/OutwardList/Outward" >
<xsl:variable name="codice" select="SegmentList/Segment[1]/Destination/Code/text()"/>
<xsl:value-of select="$codice" />
<xsl:value-of select="//Airport[Code=$codice]/Name"/>
</xsl:for-each>

Note that if the Summary section doesn't has an Airport entry for a Code, the last value-of will return nothing.

Postnext
giancarlo rossiSubject: xsl variable problems (simple)
Author: giancarlo rossi
Date: 22 Aug 2006 03:03 PM
Originally Posted: 22 Aug 2006 03:02 PM
You have reason , but, in this way I can see only $codice and not the
value of <xsl:value-of select="Airport[Code=$codice]/Name"/>

if I do the PREVIOUS test with

<xsl:value-of select="Airport[Code='FCO']/Name"/>
I could see displayed, the value...

I really dont understand.
This is the code that I'm using now inside the loop.

<xsl:variable name="codice" select="SegmentList/Segment[1]/Destination/Code/text()"/>
<xsl:value-of select="$codice" />
<xsl:value-of select="Airport[Code=$codice]/Name"/>

Postnext
Minollo I.Subject: xsl variable problems (simple)
Author: Minollo I.
Date: 22 Aug 2006 03:11 PM
If you see nothing out of <xsl:value-of select="//Airport[Code=$codice]/Name"/> (I am assuming you forgot // before Airport?) it means that there is no $codice equivalent in the list of Airport codes/names.

For example, in the small fragment you have posted, you have VIE as airport code that has no equivalent in the summary section, so the value-of above won't return anything.

Postnext
giancarlo rossiSubject: xsl variable problems (simple)
Author: giancarlo rossi
Date: 22 Aug 2006 03:14 PM
I'm sorry, it works.
There arent the right pair Of Iata Code in xml for comparing.

Now I need only to add a control able to write something if the code is not in the xml.

It's possible to use choose ?

Thanks a lot.




Posttop
Minollo I.Subject: xsl variable problems (simple)
Author: Minollo I.
Date: 22 Aug 2006 03:26 PM
It sure is...

<xsl:choose>
<xsl:when test="//Airport[Code=$codice]/Name">
<xsl:value-of select="//Airport[Code=$codice]/Name"/>
</xsl:when>
<xsl:otherwise>Sigh...</xsl:otherwise>
</xsl:choose>

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.