You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Eldho George <ge...@ocwen.co.in> on 2004/09/13 13:32:46 UTC

can i assgin value to a global variable inside template


Hai all,
Thanks to all of your response.I have problem with <xsl:variable>.I have a
variable 'bordervalue' inside <xsl:stylesheet>.
I am not assign any value to this variable.But inside a template i want to
assign some value to this variable.How can i solve this problem?
I tried with lot.But the variable could not get assigned a new
value.Following is my code snippet...Please help me


<?xml version="1.0"?>
<xsl:stylesheet 
  version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:fo="http://www.w3.org/1999/XSL/Format"
  xmlns:fox="http://xml.apache.org/fop/extensions">

<!--	Global variable declaration===-->

<xsl:variable name="bordervalue"/>

	<xsl:template name="inline-style">
		<xsl:if test="$name='border'">
			<xsl:variable name="bordervalue" select='"$value'"/>
		</xsl:if>

	</xsl:template>


</xsl:stylesheet/>


Thanks and cheers
george


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


Re: can i assgin value to a global variable inside template

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Eldho George wrote:
> I have problem with <xsl:variable>.I have a
> variable 'bordervalue' inside <xsl:stylesheet>.
> I am not assign any value to this variable.But inside a template i want to
> assign some value to this variable.

FAQ. See
  http://www.dpawson.co.uk/xsl/sect2/N8090.html

> How can i solve this problem?

This depends on your original problem.
Ask on the XSL list
  http://www.mulberrytech.com/xsl/xsl-list/
with a reasonably complete description on what you actually
want to achieve.
You'll get bonus points for using a mail client which doesn't
mangle white space, punctuation, spelling, grammar and/or
semantics of your post.

J.Pietschmann

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


Re: can i assgin value to a global variable inside template

Posted by Clay Leeds <cl...@medata.com>.
On Sep 13, 2004, at 8:13 AM, Clay Leeds wrote:
> On Sep 13, 2004, at 4:32 AM, Eldho George wrote:
>> Hai all,
>> Thanks to all of your response.I have problem with <xsl:variable>.I 
>> have a
>> variable 'bordervalue' inside <xsl:stylesheet>.
>> I am not assign any value to this variable.But inside a template i 
>> want to
>> assign some value to this variable.How can i solve this problem?
>> I tried with lot.But the variable could not get assigned a new
>> value.Following is my code snippet...Please help me
>
> As I understand it, you can assign xsl:variable in any template, as 
> long as it is only *once*.

I should point out, as I understand it that only one template can 
define xsl:variable--it cannot be defined in more than one 
xsl:template, even if from another xsl:include.

> The value of a xsl:variable cannot change once it has been set (with 
> some exceptions you can find in the spec and elsewhere on the 
> internet). If you need it to 'change' then you probably want to use 
> xsl:parameter instead.

Web Maestro Clay


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


Re: can i assgin value to a global variable inside template

Posted by Clay Leeds <cl...@medata.com>.
On Sep 13, 2004, at 4:32 AM, Eldho George wrote:
> Hai all,
> Thanks to all of your response.I have problem with <xsl:variable>.I 
> have a
> variable 'bordervalue' inside <xsl:stylesheet>.
> I am not assign any value to this variable.But inside a template i 
> want to
> assign some value to this variable.How can i solve this problem?
> I tried with lot.But the variable could not get assigned a new
> value.Following is my code snippet...Please help me

As I understand it, you can assign xsl:variable in any template, as 
long as it is only *once*. The value of a xsl:variable cannot change 
once it has been set (with some exceptions you can find in the spec and 
elsewhere on the internet). If you need it to 'change' then you 
probably want to use xsl:parameter instead.

> <?xml version="1.0"?>
> <xsl:stylesheet
>   version="1.0"
>   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>   xmlns:fo="http://www.w3.org/1999/XSL/Format"
>   xmlns:fox="http://xml.apache.org/fop/extensions">
>
> <!--	Global variable declaration===-->
>
> <xsl:variable name="bordervalue"/>
>
> 	<xsl:template name="inline-style">
> 		<xsl:if test="$name='border'">
> 			<xsl:variable name="bordervalue" select='"$value'"/>

Please note, that the quotes around $value do not nest correctly. I 
believe you have a single quote, then a double, then $value, then a 
single and then a double quote.

Perhaps you are going about this the wrong way anyway. Why not create 
an $inline-bordervalue and then an $other-bordervalue (or whatever) and 
use them that way.

> 		</xsl:if>
>
> 	</xsl:template>
>
>
> </xsl:stylesheet/>
>
> Thanks and cheers
> george

Hope this helps!

Web Maestro Clay


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org