|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Comparing element values
Hi David Many thanks for the explanation. -- Kevin -----Original Message----- From: David Carlisle [mailto:davidc@xxxxxxxxx] Sent: 04 October 2004 15:58 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: Comparing element values > How do I adapt the code below to accept variables? The restriction on variables in match patterns (which was intend to make it harder to have circular definitions of variables) is fairly pointless (and removed in xslt2 draft) as you can almost always change match="fzds[jkhfjf using a variable]"> to match="fzds"> <xsl:if test="jkhfjf using a variable"> .... perhaps with some slight changes in program logic, so the restriction is really just a syntactic annoyance rather than a real restriction. so in this case: <xsl:template match="price"> <xsl:param name="n" select="3"/> <xsl:choose> <xsl:when test="position()=$n and . > following-sibling::price[1]"/> <xsl:when test="position()=($n + 1) and . >= preceding-sibling::price[1]]"/> <xsl:otherwise> <xsl:copy-of select="."/> </xsl:otherwise> </xsl:choose> </xsl:template> Note here that you need to call this via: <xsl:apply-templates select="price"/> rather than just <xsl:apply-templates/> otherwise the price elements will have postion()'s 2,4,6,8, rather than 1,2,3,4 as there are white space text nodes in the odd positions. (This isn't needed in the version I posted before as there position() was filtering the price step explictly) David ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








