xsl-list
[Top] [All Lists]

RE: using only xpath string to count list items

2004-11-18 21:32:51

Hi Deb

Hello,

I am working with a styling tool where I am only using an xpath string
to generate text. I have the following xml where I want to know the
l1items in a task. So if I am at the first l1item in the first subtask I
can get back a count of two. I have been trying to use something along
the lines of

count(./preceding::l1item[./ancestor::task])+1

but don't know how to get to the current l1item node and figure out
where it is located in the task. The tool doesn't support current() so
any help doing this with an XPath string would be great.



I am not sure whether it is going to help you or not.
But give it a go and see this what you want.

<xsl:template match="/task/topic">
<xsl:apply-templates select="subtask" />
</xsl:template>
<xsl:template match="subtask">
<xsl:text>Subtask position = </xsl:text><xsl:value-of select="position()" /><br /> <xsl:text>llitem count = </xsl:text><xsl:value-of select="count(list1/l1item)" /><br />
<xsl:for-each select="list1/l1item">
<xsl:text>llitem position in subtask = </xsl:text><xsl:value-of select="position()" /><br />
</xsl:for-each>
</xsl:template>

Cheers.

Arun

_________________________________________________________________
NRIs - Free money transfer to India. Fly to India for free! http://acm.bridgeovertw.com/hdfc/qr/landingpage/sep04/index.htm?sitecode=610|394 Apply Now.


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--