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 28th, 2005, 08:14 AM
Registered User
 
Join Date: Oct 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to bluetorch
Default atomic value problem

Code:
<table:table table:name="sheet1" table:style-name="ta1">
            <table:table-column table:style-name="co1" table:number-columns-repeated="11" table:default-cell-style-name="Default"/>
            <table:table-row table:style-name="ro1" table:number-rows-repeated="13">
                <table:table-cell table:number-columns-repeated="11"/>
            </table:table-row>
            <table:table-row table:style-name="ro1">
                <table:table-cell table:number-columns-repeated="5"/>
                <table:table-cell>
                    <text:p>Dsf</text:p>
                </table:table-cell>
                <table:table-cell table:number-columns-repeated="5"/>
            </table:table-row>
this is how the xml file looks like,

<table:table-row table:style-name="ro1" table:number-rows-repeated="13">
                <table:table-cell table:number-columns-repeated="11"/>
            </table:table-row>
outputs 13 empty rows with 11 columns. this is the main prob to get right in my xsl.

this is the piece of xsl that i already have, but i cant get the value of table:table-columns-repeated.

Code:
<xsl:template match="table:table-row">
        <xsl:choose>
            <xsl:when test="@table:number-rows-repeated">
                <xsl:call-template name="emptyRows">
                    <xsl:with-param name="countRows" select="@table:number-rows-repeated"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
            <tr>


                <td class="header">
                    Y
                </td>
                <xsl:apply-templates select="table:table-cell"/>
                </tr>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

        <xsl:template name="emptyRows">
        <xsl:param name="countRows"/>
        <xsl:for-each select="1 to $countRows">
            <tr>
                <td class="header">
                    X
                </td>

                <xsl:call-template name="fillRows">


                </xsl:call-template>

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

        <xsl:template name="fillRows">
        <xsl:for-each select="1 to /@table:number-columns-repeated"> 

                <td width="70">
                    <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
                </td>
        </xsl:for-each>
    </xsl:template>
/@table:number-columns-repeated isnt right, i need to put something here that gives me the value of that attribute.
i already tried with variables and so on.. maybe XPath but i dont know how to use it

HELP !

 
Old October 28th, 2005, 08:20 AM
Registered User
 
Join Date: Oct 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to bluetorch
Default

if i put the value of that attribute manually then it works like its suposed to. like this

Code:
<xsl:for-each select="1 to 11"> 

                <td width="70">
                    <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
                </td>
        </xsl:for-each>
 
Old October 28th, 2005, 08:35 AM
Registered User
 
Join Date: Oct 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to bluetorch
Default

Code:
<xsl:template name="emptyRows">
        <xsl:param name="countRows"/>
        <xsl:for-each select="1 to $countRows">
            <tr>
                <td class="header">
                    X
                </td>

                <xsl:variable name="counterx">
                    <xsl:value-of select="table:table-cell/@table:table-columns-repeated"/>
                </xsl:variable>

                <xsl:for-each select="1 to $counterx">
                    <td>
                    <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
                    </td> 
                </xsl:for-each>

            </tr>
        </xsl:for-each>
    </xsl:template>
using this gives an errror that child::element(table-cell) cannot be used here: the context item is an atomic value

:(

 
Old October 28th, 2005, 01:25 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Outside the for-each select="1 to n", do

<xsl:variable name="node" select="."/>

Around the xsl:call-template, do

xsl:for-each select="$node"

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Atomic WizardSteps psychonet ASP.NET 2.0 Professional 2 August 26th, 2007 02:38 PM





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