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 May 10th, 2005, 05:17 PM
Registered User
 
Join Date: May 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default retrieveing a numeric value into a "variable"

Hello, I am trying to retrieve a "Colspan" value out of my XML element and use that in my XSLT.
As you can see below i am using the Variable $vColSpan and trying to use that to set the
number-columns-spanned table-cell attribute. in this form it states i can't put any other
elements in the XSL:Number but when i try and use a straigh t variable with the select in it i get an
invalid property type for the number-columns-spanned.

I suppose the issue is retrieveing a numeric value into a "variable" and passing that somehow into a FO element attribute????

Any suggestions would be great!


<xsl:for-each select="./topSections">
    <xsl:variable name="vColSpan"><xsl:value-of select="colSpan" /></xsl:variable>
    <fo:table-cell border-width="1pt" border-style="solid" number-columns-spanned="$vColSpan">
        <fo:block text-align="center">
           <xsl:value-of select="description" />
        </fo:block>
    </fo:table-cell>
</xsl:for-each>

 
Old May 10th, 2005, 06:03 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

you want

     number-columns-spanned="{$vColSpan}"

I would also suggest

<xsl:variable name="vColSpan" select="colSpan"/>

The construct involving a child xsl:value-of element is not only more tedious to write, it's also far more expensive to execute, because it constructs a result tree fragment (two nodes and lots of overhead such as base URI, unique node identities, etc) when all you want is a number. I don't know why so many people prefer to declare variables in this inefficient way.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old May 11th, 2005, 11:08 AM
Registered User
 
Join Date: May 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks you so Much Michael. That worked like a charm! Thanks for the synatx info as well, i have applied that to all my variables now.

Grant






Similar Threads
Thread Thread Starter Forum Replies Last Post
From numeric to alfa numeric ebekir XSLT 1 August 10th, 2007 06:13 AM
How can i know it's NUMERIC deco Beginning VB 6 1 April 23rd, 2007 06:19 AM
retrieveing values from db pettrer ASP.NET 2.0 Basics 8 April 8th, 2006 03:56 AM
retrieveing value through dataset thas123 ADO.NET 2 January 17th, 2006 08:50 PM
Numeric Up Down Kunkel General .NET 0 April 16th, 2004 10:07 AM





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