[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

Subject: Re: mod position() tests positive all of the time
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Sat, 30 Dec 2006 14:37:04 +0100
Re:  mod position() tests positive all of the time
Hi Allen,

It is hard to answer your question without knowing the input. In a subsequent post, please add a minimum working set of your data that applies to your stylesheet. In addition, it helps a great deal if you show exactly how the unwanted and the wanted output looks like (and I wouldn't object to indentation for readability in xml and xslt). I added some notes nevertheless, see below.

Cheers,
-- Abel Braaksma
  http://www.nuntia.nl

Allen Jones wrote:
<xsl:call-template name="results"/>

Why did you choose to use call-template? Using apply-template and template matches is likely much easier.


<xsl:template name="results">
<table>
<xsl:for-each
select="insightResponse/searchResponse/collectionResultSet/object/thumbnail[position()
mod 5 = 1]">
What this does highly depends on your input. For instance, if you have a set of "object" nodes, and each has one "thumbnail" node, then this for-each will select all of them (as postion() is always for each first thumbnail node under object). Depending on your input, you may want to write this a little different for readability, but as far as I can tell, this code is not wrong per se.

<tr>
<xsl:apply-templates select=". | following-sibling::thumbnail[position()
&lt; 5]" />

This <tr> indeed will always show up, when you have at least one thumbnail in the xpath of the for-each. But I'm not certain I've understood your problem well enough. Next you apply the templates to the current thumbnail node and its first four siblings. Is this part working correctly?


</tr>
</xsl:for-each>
</table>
</xsl:template>

<xsl:template match="thumbnail">
<td align="center"><img src="{@URL}" /><br />
<xsl:for-each select="label"><xsl:value-of select="."/><br
/></xsl:for-each>
</td>
</xsl:template>

Here you appear to output a bunch of values of label nodes. Is this part correctly working?


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.