Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing parameters to xsl doc 1

Status
Not open for further replies.

quinnseppo

Programmer
Aug 27, 2001
3
US
Is it possible to pass name value pairs to an xsl doc, and then access these values using <xsl:param>? I followed Thread426-147911 answered by MRTom and ended up more confused. I have the code set up to do the transform server side or client side as I've been testing both methods. Any guidance would be greatly appreciated.
 
dunno what i wrote in the other post but i may have partially been talkin out my.....

it seems that for client side processing passing params is not possible or not obvious, most of my code is server side.

on the server side, the way to pass params to the stylesheet depends very much on what is controlling the xsl, eg. java, perl, asp. usually tho, the function to call the stylesheet will allow you to pass the parameters to it. the xsl code i have posted in the part is what picks up these parameters.

at the top of the xsl you declare the params. this needs to be done as a top level element, ie. right after the opening <xsl:stylesheet> or <xsl:transform> tag.

<xsl:param name=&quot;color&quot;/>

so if you passed a parameter named color from your script it would pick this up and store it in $color - think of it like a global variable.
then if you wanted to print this value later you reference it like...

<xsl:value-of select=&quot;$color&quot;/>

to finish off with, if you wanted a default value for the param, when a value isn't given you could do something like...

<xsl:param name=&quot;color&quot;>red</xsl:param>

so if you passed color as being blue, this would overide the value of red.

hope this clears some things up.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top