cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Arnold <Jac...@envworld.com>
Subject RE: XSP All Nodes Even
Date Thu, 23 Jan 2003 23:42:02 GMT
Yep, that works. Thanks for your help.

Best Regards,
J


-----Original Message-----
From: Scott Warren [mailto:scottwarren@froggy.com.au]
Sent: Thursday, January 23, 2003 4:33 PM
To: cocoon-users@xml.apache.org
Subject: Re: XSP All Nodes Even


No not a second stylesheet,  Change your stylesheet to be like this


<xsl:template match="table">
 <xsl:for-each select="tr">
  <xsl:if test="position() mod 2 = 0">
   <tr class="evenrow"><xsl:apply-templates/></tr>
  </xsl:if>
  <xsl:if test="position() mod 2 = 1">
   <tr class="oddrow"><xsl:apply-templates/></tr>
  </xsl:if>
 </xsl:for-each>
</xsl:template>

Where table is assumed to be the parent node of all the tr nodes. 

Does this help ?

Scott Warren

Jacob Arnold wrote:

If my query returns 56 records (1 per row) then I get 2, 4, 6, 8, 10...
through 114. Are you suggesting adding a second stylesheet?

Thanks,
J


-----Original Message-----
From: Scott Warren [mailto:scottwarren@froggy.com.au]
Sent: Thursday, January 23, 2003 4:22 PM
To: cocoon-users@xml.apache.org
Subject: Re: XSP All Nodes Even


What is the value that position() is returning? Can you move the 
template into a another template that has a <xsl:for-each select="tr"> I 
think you may get different results then.

Hope this helps

Scott Warren

Jacob Arnold wrote:

  
Whenever I test for even nodes using XSLT on my serialized XSP, all the
nodes are even. For example, I'm trying to make every even table row a
different color:

<xsl:template match="tr">
 <xsl:if test="position() mod 2 = 0">
   <tr class="evenrow"><xsl:apply-templates/></tr>
 </xsl:if>
 <xsl:if test="position() mod 2 = 1">
   <tr class="oddrow"><xsl:apply-templates/></tr>
 </xsl:if>
</xsl:template>

But every table row is getting the evenrow class applied. When I display
    
the
  
position, every row (and every <td> for that matter) is even-numbered. Does
anyone know what might be causing this?

Here's a sitemap fragment:

<map:match pattern="**.xsp">
 <map:act type="resource-exists">
   <map:parameter name="url" value="docs/{1}.xsp"/>
   <map:generate src="docs/{../1}.xsp" type="serverpages"/>
   <map:serialize/>
 </map:act>
 <map:generate src="docs/404.xsp"/>
 <map:transform src="stylesheets/encode-html.xsl"/>
 <map:serialize/>
</map:match>

<map:match pattern="**.html">
 <map:aggregate element="document">
   <map:part src="cocoon:/menu.xsp" strip-root="true"/>
   <map:part src="cocoon:/{1}.xsp" strip-root="true"/>
 </map:aggregate>
 <map:transform src="stylesheets/encode-html.xsl"/>
 <map:serialize/>
</map:match>

I'm using Cocoon 2.0.4 on Tomcat 4.1.12.

Thanks,
J

  

---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>


Mime
View raw message