template parameters

2005-12-05 Thread Johan
Hi all...

I'm having trouble getting parameter values into my templates.
I specify the parameter like this : 

xsl:apply-templates select=profile
  xsl:with-param name=customerId  
   1234567890
   /xsl:with-param
/xsl:apply-templates

And I try to read it like this:

xsl:param name=customerIdunknown/xsl:param
  fo:block
xsl:value-of select=$customerId/
   /fo:block
/xsl:template 


But I always get 'unknown'. I've tried not specifying any value, but then the
parameter is empty.

I'm trying to loop through a nodelist and insert each element, and to do that I
need to either keep the context or pass in a parameter specifying the id. But i
havent managed to do either. I've seen lots of examples, and it all looks very
simple, but for some reason these values are not kept.

I'm using trax xsltc transformers, could that have anything to do with it?? (I'm
not getting any parser exceptions).

Does anyone have any idea??

Regards
/Johan




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: template parameters

2005-12-05 Thread Chris Bowditch

Johan wrote:

Hi all...

I'm having trouble getting parameter values into my templates.
I specify the parameter like this : 


xsl:apply-templates select=profile
  xsl:with-param name=customerId  
   1234567890

   /xsl:with-param
/xsl:apply-templates


snip/


But I always get 'unknown'. I've tried not specifying any value, but then the
parameter is empty.


The problem is you try to invoke the template using apply-templates. 
However, named templates should be invoked using call-template, e.g.


xsl:call-template
xsl:with-param name=customerId1234567890/xsl:with-param
/xsl:call-template

Chris

P.S: Since your question is purely XSLT related, its probably better to 
ask it on the XSLT mulberry list.




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: template parameters

2005-12-05 Thread Mike Trotman
xsl:param is for specifying parameter names (and default values) 
immediately following a template declaration.
Hard to tell why your example is failing as you haven't supplied a full 
working example.


Once you are inside the template you treat them as normal variables.
If your example is failing then it is probably because the element 
immediately preceding your xsl:param

is not an xsl:template...

If your xsl:param statement is 'outside' all your templates - then it 
is a global parameter

which will only get overridden by values passed to your XSLT process.

e.g.
xls:apply-template select='elements'
   xsl:with-param name='v1' select='value of v1'/
/xsl:apply-templates

...

xsl:template match='elements'
xsl:param name='v1' select='/..'/

xsl:value-of select='$v1'/

/xsl:template


Any help?

Mike
Johan wrote:


Hi all...

I'm having trouble getting parameter values into my templates.
I specify the parameter like this : 


xsl:apply-templates select=profile
 xsl:with-param name=customerId  
  1234567890

  /xsl:with-param
/xsl:apply-templates

And I try to read it like this:

xsl:param name=customerIdunknown/xsl:param
 fo:block
xsl:value-of select=$customerId/
  /fo:block
/xsl:template 



But I always get 'unknown'. I've tried not specifying any value, but then the
parameter is empty.

I'm trying to loop through a nodelist and insert each element, and to do that I
need to either keep the context or pass in a parameter specifying the id. But i
havent managed to do either. I've seen lots of examples, and it all looks very
simple, but for some reason these values are not kept.

I'm using trax xsltc transformers, could that have anything to do with it?? (I'm
not getting any parser exceptions).

Does anyone have any idea??

Regards
/Johan




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Message Scanned by ClamAV on datalucid.com

 



--
Datalucid Limited

web: http://www.datalucid.com


Message Scanned by ClamAV on datalucid.com


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]