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

RE: Comparing element values

Subject: RE: Comparing element values
From: "Kevin Bird (Matrix)" <kevin.bird@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 4 Oct 2004 16:30:14 +0100
comparing matrix 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 . &gt; following-sibling::price[1]"/>
  <xsl:when test="position()=($n + 1) and . &gt;=
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
________________________________________________________________________

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.