oxford100
asked on
passing dynamic parameters to xsl
I need to pass dynamic parameters to my xsl. I don't know what the parameter name is going to be, so I can't set up the xsl with the correct parameter name. Is it possible to have the xsl look for all the parameters being sent in. I'm using the xmlDom to transform my xml and then using the xsl to format my information.
ASKER
Hi again Gertone! Thanks for looking.... and you're right, I do want to pass in a selection of name/value pairs. So you said that I could pass them all in as one parameter, encoded in some sort of string (CVS like, or another encoding).
I guess the real question is how would I pass those values in and then reference them in my xsl?
thank you!
I guess the real question is how would I pass those values in and then reference them in my xsl?
thank you!
a commonly used technique for passing in name value pairs is using two seperators that are not used in the names and the values (eg. @ and #)
then use this string
name1@value1#name2@value2# name3@valu e3#
if you now need the value with a certain name,
you can do like this (passed in parameter is $namval, looking for value with name "name2")
<xsl:value-of select="substring-before(s ubstring-a fter($namv al,'name2@ '), '#')"/>
You can also recurse through the string if you need all of them,
but then you have to tell me how you want to use them
cheers
Geert
then use this string
name1@value1#name2@value2#
if you now need the value with a certain name,
you can do like this (passed in parameter is $namval, looking for value with name "name2")
<xsl:value-of select="substring-before(s
You can also recurse through the string if you need all of them,
but then you have to tell me how you want to use them
cheers
Geert
ASKER
Geert,
Thanks, I have my parameter sting being passed in and it looks like yours:
name1@value1#name2@value2# name3@valu e3#
Now if I have a value in my xml that I'm currently displaying in xsl as:
<xsl:value-of select="@name1"/>
How do I display my value1 parameter that is passed in where @name1(xml) = name1(parameter)
Thanks,
Michael
Thanks, I have my parameter sting being passed in and it looks like yours:
name1@value1#name2@value2#
Now if I have a value in my xml that I'm currently displaying in xsl as:
<xsl:value-of select="@name1"/>
How do I display my value1 parameter that is passed in where @name1(xml) = name1(parameter)
Thanks,
Michael
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
No need to see my xml! You solved it! Thanks Geert!
welcome
You can dynamically add parameters to your XSLT, using DOM. I don't recommend that and it still doesn't solve the issue of using the param. One thing you could do (I assume you want to pass in a selection of name/value pairs, is to pass them all in as one parameter, encoded in some sort of string (CVS like, or another encoding)