473,373 Members | 1,153 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,373 software developers and data experts.

Programatically Read XSL Params

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

Dec 3 '08 #1
8 4385
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

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
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.

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

Dec 3 '08 #6
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.

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
I have added a sample xsl doc.

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

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

Dec 4 '08 #9

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

Similar topics

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...
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...
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...
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...
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....
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...
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...
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...
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...
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.