Link to home
Start Free TrialLog in
Avatar of oxford100
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.
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

If you don't know the name of the parameter passed in, how can you then use that parameter in the XSLT. After all that is the purpose of passing a parameter. I don't see the business case for this question. Can you expand a little?

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)
Avatar of oxford100
oxford100

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!
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@value3#

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(substring-after($namval,'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
Geert,
Thanks, I have my parameter sting being passed in and it looks like yours:
name1@value1#name2@value2#name3@value3#

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
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No need to see my xml!  You solved it!  Thanks Geert!