RE: [xsl] Value at position()

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 
  <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> 

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?


		<xsl:variable name="doc_cat">
		<xsl:for-each select="cat">
		<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:value-of select="//lomp/location['$doc_cat2']"/>


-----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:

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

If you are interested in finding out more about the service, please
visit our website at

 XSL-List info and archive:

Current Thread