Subject: [xsl] Comparing previous From: "Keen Tim" <Tim.Keen@xxxxxxxxxxxxxx> Date: Tue, 19 Mar 2002 14:14:28 +1000 |
Hi all, I'm hoping someone can help me. Here's my problem: I am accessing a sorted node list using apply-templates and wish to compare against the previous node in the sorted node set when accessing the current node in the matched template. Frankly the penny just hasn't dropped for me and Xpath, and if it wasn't for M. Kay's book I'd be lost. I was thinking self::node()[position()-1], but this doesn't seem to work. FWIW there are multiple wk_wks nodes and multiple wk_wks_parcel nodes as children to the wk_wks nodes. wk_wks_parcel nodes may be repeated across multiple wk_wks nodes. My goal is to display them all in a list but only once. Code snippets follow. .... <xsl:apply-templates select="wk_wks/wk_wks_parcel" mode="permit"> <xsl:sort select="t_pcl_type"/> <xsl:sort select="t_easement"/> <xsl:sort select="t_historical"/> <xsl:sort select="t_lot"/> <xsl:sort select="t_plan"/> <xsl:sort select="t_mining"/> </xsl:apply-templates> .... <xsl:template match="wk_wks_parcel" mode="permit"> <xsl:choose> <xsl:when test="position()=last()"> <xsl:text> and </xsl:text> </xsl:when> <xsl:when test="position()!=1"> <xsl:text>, </xsl:text> <xsl:text>(Prev: "</xsl:text> <!-- display here now, compare later --> <xsl:call-template name="show_works_parcel_text"> <xsl:with-param name="parcel_node" select="preceding-sibling::*"/> </xsl:call-template> <xsl:text>") </xsl:text> </xsl:when> </xsl:choose> <xsl:call-template name="show_works_parcel_text"> <xsl:with-param name="parcel_node" select="."/> </xsl:call-template> </xsl:template> Cheers Tim Keen Analyst Programmer WERD Project Dept of Natural Resources & Mines 4th Floor, Mineral House 41 George St Brisbane QLD 4000 (07) 3224 2559 (ph) (07) 3224 7963 (fax) tim.keen@xxxxxxxxxxxxxx ************************************************************************ The information in this e-mail together with any attachments is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any form of review, disclosure, modification, distribution and/or publication of this e-mail message is prohibited. If you have received this message in error, you are asked to inform the sender as quickly as possible and delete this message and any copies of this message from your computer and/or your computer system network. ************************************************************************ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] XPath filtering, Sean Russell | Thread | RE: [xsl] Comparing previous, Michael Kay |
RE: [xsl] parameters to xsl file, Bagchi Ratul | Date | RE: [xsl] filtering descendent text, Aseef Jamaluddin |
Month |