You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lenya.apache.org by Frank Hamilton <ii...@hotmail.com> on 2009/07/24 12:15:24 UTC

parameter passed to javascript in a xsl

Hi,

I am trying to passed a parameter into a javascript  variable inside a xsl
file.

in my xsl file I do that:

<xsl:param name="publication-id"/>
<xsl:param name="area"/>
	
<xsl:variable name="root" select="concat($publication-id, '/', $area)"/>

Then in  the javascript inside xsl :

 <script	type="text/javascript" charset="UTF-8"> 
		var root='<xsl:value-of select="$root"/>';
		var root2='<xsl:value-of select="$root"/>';
							
		 alert('root : '+root);
		 alert('root2 : '+root2);
   
<![CDATA[

    

     function prueba(){
         alert('root en metodo: '+root);
	 alert('root2 en metodo: '+root2);
     }


For the path /pub-id/area/CU.html, all the alert show the same:
"pub-id/area" , but for the path /pub-id/area/CU/expo/index.html all the
alert show "pub-id/area" except the alert inside javascript funcion (
alert('root en metodo: '+root)) that show  " /pub-id/area/" .

you have any idea why this happens, thanks.










							



-- 
View this message in context: http://www.nabble.com/parameter-passed-to-javascript-in-a-xsl-tp24642045p24642045.html
Sent from the Lenya - Users mailing list archive at Nabble.com.


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


Re: parameter passed to javascript in a xsl

Posted by Frank Hamilton <ii...@hotmail.com>.

Yes, I think that the best is define de var inside funtion. In this
javascript I do same ajax request and maybe this change the value of
variable.

Gracias Thor. Vamos a tomar la cervecita ya, que hace muxa calo!!!
-- 
View this message in context: http://www.nabble.com/parameter-passed-to-javascript-in-a-xsl-tp24642045p24644195.html
Sent from the Lenya - Users mailing list archive at Nabble.com.


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


Re: parameter passed to javascript in a xsl

Posted by Thorsten Scherler <th...@juntadeandalucia.es>.
On Fri, 2009-07-24 at 05:14 -0700, Frank Hamilton wrote:
> 
> 
> Thorsten Scherler-3 wrote:
> > 
> >  
> > 
> > Do the following:
> > 
> > alert('XSL:ROOT es : <xsl:value-of select="$root"/>');
> > var root2='<xsl:value-of select="$root"/>';
> > alert('root2 es :' +root2);
> > alert('XSL:ROOT es : <xsl:value-of select="$root"/>');
> > var root='<xsl:value-of select="$root"/>';
> > alert('root es :' +root);
> > 
> > SALU2
> > 
> > 
> 
> With this code always the alert show  'pub-id/area'  , even the root
> variable is  'pub-id/area' !!!, 	
> I do not understand anything :)

I do not know the code but it seems that the variable got changed
meanwhile, otherwise it does not compute.

You define the var outside the function, then use it in the function.
The only logical explanation is that it got change by something in the
js.

salu2
-- 
Thorsten Scherler <thorsten.at.apache.org>
Open Source Java <consulting, training and solutions>

Sociedad Andaluza para el Desarrollo de la Sociedad 
de la Información, S.A.U. (SADESI)





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


Re: parameter passed to javascript in a xsl

Posted by Frank Hamilton <ii...@hotmail.com>.


Thorsten Scherler-3 wrote:
> 
>  
> 
> Do the following:
> 
> alert('XSL:ROOT es : <xsl:value-of select="$root"/>');
> var root2='<xsl:value-of select="$root"/>';
> alert('root2 es :' +root2);
> alert('XSL:ROOT es : <xsl:value-of select="$root"/>');
> var root='<xsl:value-of select="$root"/>';
> alert('root es :' +root);
> 
> SALU2
> 
> 

With this code always the alert show  'pub-id/area'  , even the root
variable is  'pub-id/area' !!!, 	
I do not understand anything :)

-- 
View this message in context: http://www.nabble.com/parameter-passed-to-javascript-in-a-xsl-tp24642045p24643498.html
Sent from the Lenya - Users mailing list archive at Nabble.com.


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


Re: parameter passed to javascript in a xsl

Posted by Thorsten Scherler <th...@juntadeandalucia.es>.
On Fri, 2009-07-24 at 04:46 -0700, Frank Hamilton wrote:
> 
> 
> Thorsten Scherler-3 wrote:
> > 
> > 
> > Hmm, I have to admit I did not understand. As I understand the above
> > code the 2 alerts should be always the same, right?
> > 
> 
> Both should show the same alert, but not so. 
> 
> I try do that, and this is the result, root es : /pub-id/area/  , root2 es: 
> pub-id/area and  hack: pub-id/area 
> 
> var root2='<xsl:value-of select="$root"/>';
> var root='<xsl:value-of select="$root"/>';
> 							
> function obtener_comarcas(nomSupra){
>     alert('root es :' +root);
>     alert('root2 es :' +root2);
>     alert('hack: <xsl:value-of select="concat($publication-id, '/',
>             $area)"/>');
> }
> 							
> <![CDATA[
> 
> Perhaps there is a problem to put the same variable name of the xsl and
> javascript.
> 

Is worth a try, so instead of root use base for the jscript variable,
but actually that should not be the problem. 

Do the following:

alert('XSL:ROOT es : <xsl:value-of select="$root"/>');
var root2='<xsl:value-of select="$root"/>';
alert('root2 es :' +root2);
alert('XSL:ROOT es : <xsl:value-of select="$root"/>');
var root='<xsl:value-of select="$root"/>';
alert('root es :' +root);

SALU2

> Thank Thor.
> 
> 
> 
> 
> Meaning the expected behavior is root=root2.
> 
> So the error you see is the trailing slash on the end with alert('root
> en metodo: '+root);, right? I mean expected is '/pub-id/area' but it
> shows '/pub-id/area/'.
> 
> Hmm, weird. Try the following for debug without the surrounding CDATA:
> 
> function prueba(){
> alert('hack: <xsl:value-of select="concat($publication-id, '/',
> $area)"/>');
> alert('root en metodo: '+root);
> 
> 
> > you have any idea why this happens, thanks.
> 
> Not really, really strange, are you sure that in between the call you
> are not adding a '/' somewhere which does not explain why the second
> call does not contain it anymore. 
> 
> salu2
> -- 
> Thorsten Scherler <thorsten.at.apache.org>
> Open Source Java <consulting, training and solutions>
> 
> Sociedad Andaluza para el Desarrollo de la Sociedad 
> de la Información, S.A.U. (SADESI)
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
> For additional commands, e-mail: user-help@lenya.apache.org
> 
> 
> 
> 
-- 
Thorsten Scherler <thorsten.at.apache.org>
Open Source Java <consulting, training and solutions>

Sociedad Andaluza para el Desarrollo de la Sociedad 
de la Información, S.A.U. (SADESI)





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


Re: parameter passed to javascript in a xsl

Posted by Frank Hamilton <ii...@hotmail.com>.


Thorsten Scherler-3 wrote:
> 
> 
> Hmm, I have to admit I did not understand. As I understand the above
> code the 2 alerts should be always the same, right?
> 

Both should show the same alert, but not so. 

I try do that, and this is the result, root es : /pub-id/area/  , root2 es: 
pub-id/area and  hack: pub-id/area 

var root2='<xsl:value-of select="$root"/>';
var root='<xsl:value-of select="$root"/>';
							
function obtener_comarcas(nomSupra){
    alert('root es :' +root);
    alert('root2 es :' +root2);
    alert('hack: <xsl:value-of select="concat($publication-id, '/',
            $area)"/>');
}
							
<![CDATA[

Perhaps there is a problem to put the same variable name of the xsl and
javascript.

Thank Thor.




Meaning the expected behavior is root=root2.

So the error you see is the trailing slash on the end with alert('root
en metodo: '+root);, right? I mean expected is '/pub-id/area' but it
shows '/pub-id/area/'.

Hmm, weird. Try the following for debug without the surrounding CDATA:

function prueba(){
alert('hack: <xsl:value-of select="concat($publication-id, '/',
$area)"/>');
alert('root en metodo: '+root);


> you have any idea why this happens, thanks.

Not really, really strange, are you sure that in between the call you
are not adding a '/' somewhere which does not explain why the second
call does not contain it anymore. 

salu2
-- 
Thorsten Scherler <thorsten.at.apache.org>
Open Source Java <consulting, training and solutions>

Sociedad Andaluza para el Desarrollo de la Sociedad 
de la Información, S.A.U. (SADESI)





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




-- 
View this message in context: http://www.nabble.com/parameter-passed-to-javascript-in-a-xsl-tp24642045p24643132.html
Sent from the Lenya - Users mailing list archive at Nabble.com.


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


Re: parameter passed to javascript in a xsl

Posted by Thorsten Scherler <th...@juntadeandalucia.es>.
On Fri, 2009-07-24 at 03:15 -0700, Frank Hamilton wrote:
> Hi,
> 
> I am trying to passed a parameter into a javascript  variable inside a xsl
> file.
> 
> in my xsl file I do that:
> 
> <xsl:param name="publication-id"/>
> <xsl:param name="area"/>
> 	
> <xsl:variable name="root" select="concat($publication-id, '/', $area)"/>
> 
> Then in  the javascript inside xsl :
> 
>  <script	type="text/javascript" charset="UTF-8"> 
> 		var root='<xsl:value-of select="$root"/>';
> 		var root2='<xsl:value-of select="$root"/>';
> 							
> 		 alert('root : '+root);
> 		 alert('root2 : '+root2);
>    
> <![CDATA[
> 
>     
> 
>      function prueba(){
>          alert('root en metodo: '+root);
> 	 alert('root2 en metodo: '+root2);
>      }
> 
> 
> For the path /pub-id/area/CU.html, all the alert show the same:
> "pub-id/area" , but for the path /pub-id/area/CU/expo/index.html all the
> alert show "pub-id/area" except the alert inside javascript funcion (
> alert('root en metodo: '+root)) that show  " /pub-id/area/" .
> 

Hmm, I have to admit I did not understand. As I understand the above
code the 2 alerts should be always the same, right?

Meaning the expected behavior is root=root2.

So the error you see is the trailing slash on the end with alert('root
en metodo: '+root);, right? I mean expected is '/pub-id/area' but it
shows '/pub-id/area/'.

Hmm, weird. Try the following for debug without the surrounding CDATA:

function prueba(){
alert('hack: <xsl:value-of select="concat($publication-id, '/',
$area)"/>');
alert('root en metodo: '+root);


> you have any idea why this happens, thanks.

Not really, really strange, are you sure that in between the call you
are not adding a '/' somewhere which does not explain why the second
call does not contain it anymore. 

salu2
-- 
Thorsten Scherler <thorsten.at.apache.org>
Open Source Java <consulting, training and solutions>

Sociedad Andaluza para el Desarrollo de la Sociedad 
de la Información, S.A.U. (SADESI)





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