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

Passing parameters

Hello, I am trying to pass a parameter through C# using a
XsltArgumentList class to a xsl:param element, but I dont know if it is
possible to do. And also I am trying to get the count of this node
too, that has as name the value of the parameter.

The "DateElementName" value is the name of a selected node that I want
to know the count on the xml file.

Any ideas? Thank you.

Dago.

I have this code:

xsl document
------------

<xsl:param name="NodeName"/>
<xsl:template match="item">
<xsl:for-each select="child::$NodeName">
<xsl:copy-of select="."/><br />
</xsl:for-each>
</xsl:template>

C# code
-------

private void Page_Load(object sender, System.EventArgs e){
string myXSLTFile = ConfigurationSettings.AppSettings.Get("XSLTFile");
string myXMLFile =
ConfigurationSettings.AppSettings.Get("RssXmlFile" );
string EleName =
ConfigurationSettings.AppSettings.Get("DateElement Name");

XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath(myXMLFile));

XslTransform xslt = new XslTransform();
xslt.Load(Server.MapPath(myXSLTFile));

string DateCount = GetElementCount(EleName, doc, xslt);
this.TextBox1.Text = DateCount;
}

private string GetElementCount(string ElementName, XmlDocument XMLFile,
XslTransform XSLTFile) {
System.IO.Stream myStream = new System.IO.MemoryStream();
XPathNavigator xpathNav = XMLFile.CreateNavigator();

XsltArgumentList argsLst = new XsltArgumentList();
argsLst.AddParam("NodeName", "", ElementName);

XSLTFile.Transform(xpathNav, argsLst, myStream);

System.IO.StreamReader sr = new System.IO.StreamReader(myStream);
string output = sr.ReadToEnd();

return output;
}

Nov 12 '05 #1
1 2797
DagoFlores wrote:
<xsl:param name="NodeName"/>
<xsl:template match="item">
<xsl:for-each select="child::$NodeName">


That's XPath syntax error. What you can do is
<xsl:for-each select="child::*[name()=$NodeName]"> or
<xsl:for-each select="child::*[local-name()=$NodeName]"> or

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: zlatko | last post by:
There is a form in an Access Project (.adp, Access front end with SQL Server) for entering data into a table for temporary storing. Then, by clicking a botton, several action stored procedures...
7
by: Pavils Jurjans | last post by:
Hallo, I have been programming for restricted environments where Internet Explorer is a standard, so I haven't stumbled upon this problem until now, when I need to write a DOM-compatible code. ...
3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
12
by: Joel | last post by:
Hi all, Forgive me if I've expressed the subject line ill. What I'm trying to do is to call a c++ function given the following: a. A function name. This would be used to fetch a list of...
7
by: Harolds | last post by:
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005 the pmID is evaluated to "" instead of what the value is set to: .... xmlItems.Document = pmXML // Add the pmID...
39
by: Mike MacSween | last post by:
Just spent a happy 10 mins trying to understand a function I wrote sometime ago. Then remembered that arguments are passed by reference, by default. Does the fact that this slowed me down...
17
by: Charles Sullivan | last post by:
The library function 'qsort' is declared thus: void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)); If in my code I write: int cmp_fcn(...); int...
4
by: Mike Dinnis | last post by:
Hi, I've been working through a number of turorials to try to learn more about retrieving data from a SQL database. I think i've mastered techniques where i create a sql string in the page and...
2
by: csmith8933 | last post by:
How do I write a function where the number of parameters it takes varies? This is what I have but it doesnt work. // function prototype void functionThree(int num1=1, int num2=2, int num3=3);...
3
by: ajaymohank | last post by:
hello everyone..... i am ajay and i am new to php. in my project i have an option to invoke a bat file by passing parrameters and to diplay the result. i tried this code but my page got hung or...
0
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...
0
isladogs
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...
0
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,...
0
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$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.