Subject: RE: [xsl] Value at position() From: "SHEIKH Sajjad" <Sajjad.SHEIKH@xxxxxxxxxxx> Date: Wed, 4 Feb 2004 08:40:04 +0100 |
I am testing if at position()=last()-2 is A then true and display the value which is A otherwise do nothing. I am pulling xml data using document() function..each document is structured as following <lomp> <location path="..\..\..\..\..\">040202</location> <location path="..\..\..\..\">Socio Acto</location> <location path="..\..\..\">Dossoro</location> <location path="..\..\">A</location> <location path="..\">Mentol</location> <location last="true" path="">Lentils</location> </lomp> But position of A differs in each document. So in the following style sheet, I am displaying the value A, B or C if any of those values are present at last()-2. Any suggestions? Regards, <xsl:variable name="doc_cat"> <xsl:for-each select="cat"> <xsl:choose> <xsl:when test="(position()=last()-2='A') or (position()=last()-2='B') or (position()=last()-2='C')"> <xsl:variable name="doc_cat2"> <xsl:value-of select="position()"/> </xsl:variable> <xsl:value-of select="//lomp/location['$doc_cat2']"/> </xsl:when> </xsl:choose> </xsl:for-each> </xsl:variable> -----Original Message----- From: Michael Kay [mailto:mhk@xxxxxxxxx] Sent: 03 February 2004 20:58 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: [xsl] Value at position() > <xsl:when test="(position()=last()-2='A') I don't know what you intended this expression to mean, but what it actually does is to test whether position() is equal to (last()-2), which returns true or false; it then compares true or false to the string "A", which is done by converting the string "A" to a boolean (always true) and comparing the two booleans. This means the expression is equivalent to test="position() = last()-2" Michael Kay XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list ______________________________________________________________ This message has been scanned for all viruses by BTnet VirusScreen. The service is delivered in partnership with MessageLabs. This service does not scan any password protected or encrypted attachments. If you are interested in finding out more about the service, please visit our website at http://www.btignite.com/internetservices/btnet/products_virusscreen.htm ============================================================== XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Value at position(), SHEIKH Sajjad | Thread | RE: [xsl] Value at position(), SHEIKH Sajjad |
RE: [xsl] Long string - inserting a, Jarno . Elovirta | Date | RE: [xsl] Long string - inserting a, Kenny Akridge |
Month |