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

Problem setting node-set in XsltArgumentList

Sam
I am working with .Net 2.0. I found a 2002 posting with this sample
code of how to send a node-set into a XSLT transformation:

string xml = @"<foo><bar>The Test</bar></foo>";
string xsl =
@"<xsl:stylesheet xmlns:xsl=""http://www.w3.org/1999/XSL/Transform""
version=""1.0"">
<xsl:param name=""param1""/>
<xsl:template match=""/"">
bar element from param1 value:
<xsl:copy-of select=""$param1/bar""/>
</xsl:template>
</xsl:stylesheet>";

XmlDocument doc = new XmlDocument();
doc.LoadXml(xml);
XPathNavigator nav = doc.CreateNavigator();

XslTransform xslt = new XslTransform();
xslt.Load(new XmlTextReader(new StringReader(xsl)));

XPathDocument dummy = new XPathDocument(new
StringReader("<dummy/>"));
XsltArgumentList args = new XsltArgumentList();
//Pass element foo as parameter
args.AddParam("param1", "", nav.Select("/foo"));
xslt.Transform(dummy, args, Console.Out);

The output I get is:

<?xml version="1.0" encoding="Windows-1252"?>
bar element from param1 value: <bar>The Test</bar>

If I am not mistaken, I should be getting:

<?xml version="1.0" encoding="Windows-1252"?>
bar element from param1 value: The Test

Does anyone know how to fix this sample to return the correct value?

Sam Carleton

Dec 15 '06 #1
1 1932
Sam wrote:
I am working with .Net 2.0.
Note that the preferred .NET 2.0 XSLT processor is XslCompiledTransform
and not XslTransform.
string xml = @"<foo><bar>The Test</bar></foo>";
<xsl:copy-of select=""$param1/bar""/>
<?xml version="1.0" encoding="Windows-1252"?>
bar element from param1 value: <bar>The Test</bar>

If I am not mistaken, I should be getting:

<?xml version="1.0" encoding="Windows-1252"?>
bar element from param1 value: The Test
Why, xsl:copy-of copies the selected node, in this case the bar element,
to the result tree. So you end up with a copy of the complete element in
the result tree, that is the expected behaviour.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Dec 16 '06 #2

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

Similar topics

3
by: ChrisWinterscheid | last post by:
We are running DB2 8.1 on AIX 5.2. DB2level shows: DB21085I Instance "db2inst1" uses "32" bits and DB2 code release "SQL08016" with level identifier "02070106". Informational tokens are "DB2...
57
by: Xarky | last post by:
Hi, I am writing a linked list in the following way. struct list { struct list *next; char *mybuff; };
2
by: PRadyut | last post by:
in this code the delete function does not delete the last node of the double linked list the code ---------------------------------------------------------------- #include <stdio.h>...
1
by: Joel Byrd | last post by:
I am having a problem adding a node to the page. This works on other browser (Opera, Firefox, etc.), but not in IE. The following is the function to add the node: (the id "test_div" is a...
8
by: pauldepstein | last post by:
I am writing a program which looks at nodes which have coordinates which are time-dependent. So I have a class called node which contains the private member declarations int date; int month; ...
5
by: Suresh | last post by:
Hi Guys I have Db2 server installed on remote server. i am connecting to that remote server by using VPN. I want to connect that remote DB2 server instance using my local machine DB2...
5
by: Chad | last post by:
say my input file is $ more suck ______ < gnu? > ------ \ , , \ /( )` \ \ \___ / | /- _ `-/ '
8
by: jj | last post by:
Trying to understand the manual regarding variables to solve the following. I'm working with Drupal CMS and have a loop to retrieve values that are normally fetched by using this variable:...
5
by: jbenner | last post by:
I have opened a PMR for this with IBM, and am not asking for advice from the DB2 DBA community. I am posting this as an FYI that DB2 Health Monitor, even at the latest version of DB2, still can cause...
8
by: Aftabpasha | last post by:
I have seen a simple program for handling Link List operations. The following is the part of the code that contains the problem. The code is modified but contains all necessary information regarding...
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: 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
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?
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...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.