TAGS :Viewed: 6 - Published at: a few seconds ago

[ use a xslt variable to define table padding ]

I would like to declare a variable in my xslt file that is styling my xml. I intend to use the variable to padd the tableview cells. depending on what data is being read will depend how far the padding is from the left of the table.

So I was woundering if its possible to then use this padding1 var on tablecell? This is currently how I am attempting this idea, with not much sucsess mind you as when i now load the xml I am getting a blank screen.

Anyway this is my code

<xsl:variable name="padding1" select="15"/>

<td style="padding-left: padding1;" colspan="2" bgcolor="#C0C0C0">

In the above code I am declaring a variable named padding1 and passing it the value 15, I would then like to use it on padding-left much like you would with a 15px type value

any help would be greatly appreciated.

Answer 1

You can use an AVT to reference your variable:

<td style="padding-left: {$padding1}px;" colspan="2" bgcolor="#C0C0C0">...</td>