473,398 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Programatically Read XSL Params

5
is xpath the best way to programicly read the params an xsl page requires or is there a better way?

Thanks
Dec 3 '08 #1
8 4387
Dormilich
8,658 Expert Mod 8TB
I think there's a misunderstanding. 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))
Dec 3 '08 #2
aday
5
thanks

but I am not sure I understand.......

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.
Dec 3 '08 #3
Dormilich
8,658 Expert Mod 8TB
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.

regards
Dec 3 '08 #4
aday
5
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.

I hope this explanes it .
Dec 3 '08 #5
Dormilich
8,658 Expert Mod 8TB
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
Dec 3 '08 #6
jkmyoung
2,057 Expert 2GB
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.)
Dec 3 '08 #7
aday
5
I have added a sample xsl doc.

Here is an example of me setting the param in c#

Expand|Select|Wrap|Line Numbers
  1.  
  2.                //Initialize
  3.                 string returnValue = string.Empty;
  4.                 XslCompiledTransform xslDoc = new XslCompiledTransform();           
  5.                 XmlUrlResolver xslResolver = new XmlUrlResolver();
  6.                 XsltArgumentList xslArg = new XsltArgumentList();
  7.  
  8.                 //Load XSL Template
  9.                 xslDoc.Load(FullTemplateName);
  10.  
  11.                 //Get Table Columns In XML
  12.                 XmlReader xmlColumnList = GetDatabaseTableColumnList(ddlDatabases.Text, TableName);
  13.  
  14.                 //xmlColumnList.MoveToContent();
  15.                 TextWriter swTrasformationOutput = new StringWriter();
  16.  
  17.                 //Set Required Arguments
  18.                 xslArg.AddParam("spPrefix", "", txtPrefix.Text);
  19.  
  20.                 //Do Transformation
  21.                 xslDoc.Transform(xmlColumnList, xslArg, swTrasformationOutput);
  22.                 swTrasformationOutput.Flush();
  23.  
  24.                 return swTrasformationOutput.ToString();
  25.  
  26.  
Attached Files
File Type: txt Ivey_Add.txt (1.9 KB, 598 views)
Dec 4 '08 #8
aday
5
Thanks, I will try this.... I assume you are doing this with XPath

@jkmyoung
Dec 4 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Logan McKinley | last post by:
I was wondering if there is any way for me to read the device manager in my C# program? I have a program that crashes when some third party hardware is not installed or is set to the wrong port...
0
by: CroDude | last post by:
Hi all! I have problems when writting bitmap to a byte array and after reading it back form byte to Bitmap object. What I do is this: First I throw Bitmap to a memory-stream and then I write it...
3
by: Stan Huff | last post by:
Is there any way to disable the "params" on a particular invocation so that one can pass an array containing the arguments and not have receiver get an array having you argument array stuffed into...
4
by: brent | last post by:
Currently our application is reading from the web.config, and retrieves a section, "softwareRequirements". Because the section will begin to grow dramatically, I'd like to place it in the SQL...
4
by: Kevin Vogler | last post by:
I need to read the value of a hidden field on a remote HTML page and then use that value in a form submit on my local page. How can I read the hidden field programatically? Thanks in advance....
0
by: mike | last post by:
Hi, When I programatically Bind a DataSource to DetailsView it does not fire "ModeChanged" event. This is first time i am trying to use ASP.NET DetailsView control. I have played with some of the...
1
by: Robert Burdick [eMVP] | last post by:
Hello All: I cannot seem to get a simple programmatic post to work. From one ASPX page, I want to generate HTML from another page. Thus, I programatically post to the second page and read the...
5
by: Ranginald | last post by:
Hi, I have a question about encrypting connection strings in an asp.net 2.0 app in a shared hosting environment. From what I have read, I believe I need to programatically encrypt and decrypt...
7
by: The Mad Ape | last post by:
Hi I have code to programatically create a label. It works but when I try to call a sub to create a tooltip it does not work. I do not get an error so have no idea what it wrong. Please review...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.