Subject: Re: [xsl] unction return value not a node? From: Bartolomeo Nicolotti <bnicolotti@xxxxxxxxx> Date: Wed, 08 Sep 2010 18:22:14 +0200 |
Hello, ok, now I remember about xsl:value-of/xsl:sequence, working ... great mailing list. many thanks! Best reagards Bartolomeo Il giorno mer, 08/09/2010 alle 16.25 +0100, David Carlisle ha scritto: > On 08/09/2010 16:16, Bartolomeo Nicolotti wrote: > > Hello, > > > > Sorry but XSLT 2.0 and XPath 2.0 book is more than 1000 pages, so I'm > > writing this: > > > > I've this xpath expression that returns a node stored in a variable: > > > > <xsl:variable name="x" select="($airTraveler/preceding-sibling::ota:AirTraveler[@PassengerTypeCode!='INF' and substring( concat( gal:normNames( ota:PersonName/ota:Surname ), concat( gal:normNames( ota:PersonName/ota:GivenName ),gal:normNames( ota:PersonName/ota:NamePrefix ))),1,16) = $srnNP16 ], $airTraveler)[1]"/> > > > > > > then if I do > > > > <xsl:value-of select="$x/preceding-sibling::ota:AirTraveler"/> > > > > I obtain the preceding-sibling nodes. > > > > but if I write this function to use the same xpath expression, quite complicated, in two places > > > > <xsl:function name="gal:func"> > > <xsl:param name="airTraveler"/> > > <xsl:param name="srnNP16"/> > > <xsl:value-of select="($airTraveler/preceding-sibling::ota:AirTraveler[@PassengerTypeCode!='INF' and substring( concat( gal:normNames( ota:PersonName/ota:Surname ), concat( gal:normNames( ota:PersonName/ota:GivenName ),gal:normNames( ota:PersonName/ota:NamePrefix ))),1,16) = $srnNP16 ], $airTraveler)[1]"/> > > </xsl:function> > > > > but when I write: > > > > <xsl:variable name="x" select="gal:func($airTraveler, $srnNP16 )"/> > > <xsl:value-of select="$x/preceding-sibling::ota:AirTraveler"/> > > > > I don't obtain any preceding sibling. > > > > Could you tell me why? > > > > Many thanks > > > > Bartolomeo > > > In the first case you are selecting a node in an input document and then > giving the string value of its preceding sibling(s) > > In the second case with the function you are returning a text node > (newly generated, not yet in any document) which is the string value of > some node, and then attempting to select a sibling of this newly > generated node which has no siblings. > > perhaps you want your gal:func function to return a node in the source > document rather than the string value of such a node, in which case use > xsl;sequence, not xsl:value-of > > david > > ________________________________________________________________________ > The Numerical Algorithms Group Ltd is a company registered in England > and Wales with company number 1249803. The registered office is: > Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom. > > This e-mail has been scanned for all viruses by Star. The service is > powered by MessageLabs. > ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] unction return value not , David Carlisle | Thread | Re: [xsl] xsl:value-of issue, Christian Roth |
Re: [xsl] unction return value not , David Carlisle | Date | [xsl] XSLT 1.0 in browsers, Max Toro |
Month |