[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Determine last element before applu-templates

Subject: RE: Determine last element before applu-templates
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sun, 23 Jan 2005 16:38:36 -0000
xsl last element
You can use count(onderwerpen), but in this case it's better just to use
last(), as has been suggested.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: gerritjan [mailto:gerritjankoekkoek@xxxxxxx] 
> Sent: 23 January 2005 10:41
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Determine last element before applu-templates
> 
> Hello,
> 
> Is there a 'best practise' for determine how many elements are in a 
> document.
> My schema looks like this:
> 	<xsd:element name = "onderwerpen">
> 		<xsd:complexType>
> 			<xsd:sequence>
> 				<xsd:element ref = "onderwerp"/>
> 			</xsd:sequence>
> 		</xsd:complexType>
> 	</xsd:element>
> 1 to many 'onderwerp' within 'onderwerpen'
> 
> My xslt looks like this:
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
> version="1.0">
>   <xsl:template match="onderwerpen">
>     <xsl:apply-templates select="onderwerp">
>       <xsl:with-param name="last_element">3</xsl:with-param>
>     </xsl:apply-templates>
>   </xsl:template>
> 
>   <xsl:template match="onderwerp">
>     <xsl:param name="last_element"/>
>     <xsl:if test="position()=$last_element">
>       <xsl:text>Something specific for last element</xsl:text>
>     </xsl:if>
>   </xsl:template>
> </xsl:stylesheet>
> 
> The hard-code '3' should be determined before; based on the number of 
> elements 'onderwerp'
> Any suggestions how this is best handled?
> 
> Gerritjan Koekkoek

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.