I think there's a misunderstandin g. XPath is the/one language to access elements in an xml document tree. and <xsl:param> is a part of the XSLT language. you can't read <xsl:param> by XPath, though you can use them inside XPath. (well, technicly it should be possible but XSLT provides easier access - you read them in XSLT by calling the parameter name with a prefixed $ sign: $param_name (like variables in PHP))
I am writing a winforms program in C# (3.5 framework) and I need to read the params from am xsl doc and present them to the user to fill in the required values.
as far as I understand XSLT, params (in the form of <xsl:param> are for the internal use in the stylesheet. usually a xsl stylesheet is used to transform one xml into another xml (or html, or text). so what the xsl contains is out of interest as long as it does its job.
out of interest, what is your xsl doc supposed to do, maybe we're talking about different things.
basicly I am building a Code and SQL Stored Procedure generation tool (vs addin) for vs.net all my templates are xsl docs that users can create and add. And my xml data is generated using the SqlXmlCommand in vs.net
Say a user has created a template (xsl doc) that accepts a param called "postfix" and "prefix" that will be used in the transformation.
I would like to be able to read the params that are defined in the xsl doc so I can then request the value from the user using the tool for the values.
you make me curious. your users can write xsl from scratch? maybe you should post some code, because I still think we're talking about different things.
you can get the parameter names via DOM, since xsl is xml. XPath is possible too, if you load the xsl into an xml reader (don't know what C# provides). It really depends on how the xsl is created... there might be more and easier ways.
regards
Last edited by Dormilich; Dec 3 '08, 09:32 PM.
Reason: got an idea
This reminds me of the old javascript way of running xsl.
In order to set parameters, you would actually have to change the values of the parameters of the elements in DOM of the xsl, then run the transformation.
Anyways, I think you can use SelectNodes("//xsl:template[@match]/xsl:param/@name", nsmgr)
where nsmgr is your namespace manager, and has the namespace xsl defined.
Assumptions:
You have a main template which uses match.
When you call your other matched templates, you don't use parameters; (Usually the case.)
Thanks, I will try this.... I assume you are doing this with XPath
Originally posted by jkmyoung
This reminds me of the old javascript way of running xsl.
In order to set parameters, you would actually have to change the values of the parameters of the elements in DOM of the xsl, then run the transformation.
Anyways, I think you can use SelectNodes("//xsl:template[@match]/xsl:param/@name", nsmgr)
where nsmgr is your namespace manager, and has the namespace xsl defined.
Assumptions:
You have a main template which uses match.
When you call your other matched templates, you don't use parameters; (Usually the case.)
Comment