Expected end of the expression, found '%'...
when attempting this...
<xsl:variable name="column-width" select="25%"></xsl:variable>
I know it has something to do with the use of the percent sign, but I
cannot figure out how to get it to work. I want to use the variable
within other areas of the style sheet to set the width of columns.
For example...
...
<table>
<tr>
<td width="{$column-width}">SOME CONTENT</td>
</tr>
</table>
...
I appreciate any help you can provide!
Kevin
> <xsl:variable name="column-width" select="25%"></xsl:variable>
If you want the variable value to be of type string then you need
<xsl:variable name="column-width" select="'25%'"></xsl:variable>
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
<xsl:variable name="column-width">25%</xsl:variable>
This approach works fine.
So, I am assuming that the % sign causes a problem with XPath
expressions, and I still would be interested in how to utilize the %
literal character in an expression like this.
Kevin
Just so you know why this didn't work, rather than just that it doesn't
work, this is why.
In your first version:
<xsl:variable name="column-width" select="25%"></xsl:variable>
You are telling the XSL parser to make a variable called column-width
and then select using XPath the entity called 25%
25% as an XPath name doesn't work because the % character has no
relevance in XPath and nor can it be used as an element or attribute
name either.
What you did ultimately by changing your construct to:
<xsl:variable name="column-width">25%</xsl:variable>
And what Martin suggested by doing this:
<xsl:variable name="column-width" select="'25%'"></xsl:variable>
Was the define the variable as using a string - in your version you've
implicitly done this by setting the variable in the text area of the
element, Martin's one is doing it explicitly by putting '25%' in the
select statement which says select the text '25%' rather than the XPath
that equals 25%.
Cheers
AndrewF
---
XML Infinity - www.xmlinfinity.com - Content management where the
possibilities are endless