|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: mod position() tests positive all of the time
On Sat, Dec 30 2006 12:06:32 +0000, Allen Jones wrote: > I am new to the list, but I have checked the archive for this particular > problem and I haven't been able to find a solution to this. > > I am using the following stylesheet and everytime it tests for position, > the results always print the <tr> (rather than printing every 5th > element). Since I am new to XSLT, I know it is probably in the code. > Any help would be a lesson. position() returns the context position within the current node list. You don't show how many <thumbnail> are within each <object>, but the context changes with each <object>, so the first <thumbnail> in each <object> matches your predicate. If you want to group <thumbnail> across multiple <object>, the simple, brute-force, and slow way to group them is to change your xsl:for-each and xsl:apply-templates to: <xsl:for-each select="(insightResponse/searchResponse/collectionResultSet/object/thumbnail)[position() mod 5 = 1]"> <tr> <xsl:apply-templates select=". | following::thumbnail[position() < 5]" /> </tr> </xsl:for-each> or: <xsl:for-each select="insightResponse/searchResponse/collectionResultSet/object/thumbnail[count(preceding::thumbnail) mod 5 = 0]"> ... but if your data is large, you are probably better off to use keys. Regards, Tony Graham. ====================================================================== Tony Graham mailto:Tony.Graham@xxxxxxxxxxxxxxxxxxxxxx Menteith Consulting Ltd http://www.menteithconsulting.com 13 Kelly's Bay Beach Skerries, Co. Dublin, Ireland ======================================================================
|
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
|






