Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to pass a parameter and use that in my xslt

Tags:

xml

xslt

msxsl

i have a xml file and a related xslt file. I am using msxsl.exe and i need to pass a parameter as a command line argument and use that in my xslt file. how can i do that???

command:

msxsl.exe country.xml sheet.xslt -o country_sheet.html p1="india"

how to retrieve the value india in my xslt file?

like image 518
sulakshana Avatar asked Dec 01 '10 09:12

sulakshana


People also ask

How do I pass in XSLT?

You can pass parameters to XSLT, how this is done depends on your XSLT processor, but usually as additional command arguments, if it's a command-line processor. But by filtering and formatting, you are mixing two concerns in one file.

How do you pass a variable in an xsl template?

You are applying templates selecting folders , but have a template matching on folder . Either change it to folder , or if you have a folders template make sure that it passes the var1 parameter value down to the folder template. Your with-param @select uses '{var}' , which selects that literal string {var} .

How do I pass multiple parameters in XSLT?

Answer. In order to pass multiple parameters to XSLT from BP you'll need to pass '=' as a separator.

What is difference between param and variable in XSLT?

The content model of both elements is the same. The way these elements declare variables is the same. However, the value of the variable declared using <xsl:param> is only a default that can be changed with the <xsl:with-param> element, while the <xsl:variable> value cannot be changed.


1 Answers

try this

<xsl:param name="p1" select="p1"/>

this would be outside any templates, acting somewhat like a global variable

yes then to use the contents of this you could use this inside a template

<xsl:value-of select="$p1"/>
like image 185
Treemonkey Avatar answered Oct 06 '22 20:10

Treemonkey