Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 11th, 2004, 07:53 AM
Registered User
 
Join Date: Sep 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default include param in mod evaluation

I want to set the column count I use to build a html table within my xsl at the top of the style sheet. So, I need to change the '4' in the following line of code to '$colCount'

<xsl:template match="child::node()[(position()-1) mod 4 = 0]" >

What is the proper syntax for this call? Would I create the colCount as a variable or param?

 
Old October 11th, 2004, 10:28 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi
Default

Create it as an variable..
Proper synatx is
match = match="child::node()[(position()-1) mod $colCount = 0]"

 
Old October 11th, 2004, 11:13 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Quote:
quote:Originally posted by mlaba
  Would I create the colCount as a variable or param?
You would normally use a param if you wanted to set it before running the stylesheet using the processor dependent method.
In MSXML for example you would use the addParameter method.



--

Joe (Co-author Beginning XML, 3rd edition)
 
Old October 11th, 2004, 12:14 PM
Registered User
 
Join Date: Sep 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here is a shortened version of my stlye sheet.

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:msxsl="urn:schemas-microsoft-com:xslt"
  xmlns:local="myLocal">

        <xsl:output method="html" indent="yes" />

       <xsl:param name="columnCount">4</xsl:param>

      <xsl:template match="/" >
        <html>
        <xsl:if test="count($nodes)&gt; 0">

            <table border="0" width="100%">
                <xsl:apply-templates select="nodes/*"/>
            </table>


        </xsl:if>
        </html>
    </xsl:template>

      <xsl:template match="child::node()[(position()-1) mod $columnCount = 0]" > </xsl:template>

      <xsl:template match="child::node()[(position()-1) mod 4 != 0]" /> </xsl:template>

      <xsl:template name="format">

      </xsl:template>

</xsl:stylesheet>

I can't seem to get the $columnCount param to be recognized?????

 
Old October 13th, 2004, 03:33 AM
Authorized User
 
Join Date: Jul 2004
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

You cannot use variables (or params) in a match expression.

To help you further, can you supply some example xml and explain the result you expect.

First it may be worth looking at the Faq section on the following site under grouping.

http://www.dpawson.co.uk/xsl/sect2/sect21.html

Regards
Bryan

 
Old October 20th, 2004, 09:40 AM
Registered User
 
Join Date: Sep 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Using the style sheet above I want to be able to change the value of "columnCount" at the top of the style sheet and there by set the number of columns displayed in my html table. The format of the xml is irrelevant I believe. hmmm...so changing the 4 to a variable is not possible in a match statement. Does that mean I'll need to somehow perform this calculation within a JS function and return the value to some sort of variable or sumthin. Wow, this is deep stuff. I think I like it :-)
      <xsl:template match="child::node()[(position()-1) mod 4 = 0]" > </xsl:template>

      <xsl:template match="child::node()[(position()-1) mod 4 != 0]" /> </xsl:template>






Similar Threads
Thread Thread Starter Forum Replies Last Post
Date evaluation Neal SQL Server 2000 5 May 16th, 2007 07:21 AM
GTK GUI issues and evaluation shyjumon.n Linux 0 October 12th, 2006 11:20 PM
difference between include file & include virtual crmpicco Classic ASP Basics 2 January 23rd, 2006 11:50 AM
SQLEVAL Evaluation Version Won't Install Pavesa SQL Server 2000 1 July 12th, 2005 03:15 AM
evaluation of expression in java ldb_lux Java GUI 0 March 14th, 2005 05:48 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.